Merge pull request #17365 from akshatsinha0/fix/old-ui-createExpressionLink
Some checks failed
buf.build / lint and publish (push) Has been cancelled
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled

fix(react-app): correct createExpressionLink query for /graph links
This commit is contained in:
Julius Volz 2025-10-19 13:14:19 +02:00 committed by GitHub
commit 4c1355e14b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -270,7 +270,7 @@ export const getQueryParam = (key: string): string => {
export const createExpressionLink = (expr: string): string => {
return `../graph?g0.expr=${encodeURIComponent(expr)}&g0.tab=1&g0.display_mode=${
GraphDisplayMode.Lines
}&g0.show_exemplars=0.g0.range_input=1h.`;
}&g0.show_exemplars=0&g0.range_input=1h`;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any,

View file

@ -15,6 +15,7 @@ import {
parseOption,
decodePanelOptionsFromQueryString,
parsePrometheusFloat,
createExpressionLink,
} from '.';
import { GraphDisplayMode, PanelType } from '../pages/graph/Panel';
@ -332,5 +333,17 @@ describe('Utils', () => {
expect(parsePrometheusFloat('-1.7e+01')).toEqual(-17);
});
});
describe('createExpressionLink',()=>{
it('<....>builds link',()=>{
expect(createExpressionLink('up')).toEqual(
`../graph?g0.expr=up&g0.tab=1&g0.display_mode=${GraphDisplayMode.Lines}&g0.show_exemplars=0&g0.range_input=1h`
);
});
it('url-encodes PromQL',() =>{
expect(createExpressionLink('ALERTS{alertname="HighCPU"}')).toEqual(
`../graph?g0.expr=ALERTS%7Balertname%3D%22High%20CPU%22%7D&g0.tab=1&g0.display_mode=${GraphDisplayMode.Lines}&g0.show_exemplars=0&g0.range_input=1h`
);
});
});
});
});