mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Remove explore compact URLs (#59686)
* Remove explore compact URLs * Remove two explore link builders that create compact URLs * Fix merge conflict
This commit is contained in:
parent
d3afe9e85c
commit
5a7f38053b
@ -107,7 +107,7 @@ func graphLink(rawQuery string) string {
|
||||
escapedDatasource := url.QueryEscape(q.Datasource)
|
||||
|
||||
return fmt.Sprintf(
|
||||
`/explore?left=["now-1h","now",%[1]q,{"datasource":%[1]q,"expr":%q,"instant":false,"range":true}]`, escapedDatasource, escapedExpression)
|
||||
`/explore?left={"datasource":%[1]q,"queries":[{"datasource":%[1]q,"expr":%q,"instant":false,"range":true,"refId":"A"}],"range":{"from":"now-1h","to":"now"}}`, escapedDatasource, escapedExpression)
|
||||
}
|
||||
|
||||
func tableLink(rawQuery string) string {
|
||||
@ -120,5 +120,5 @@ func tableLink(rawQuery string) string {
|
||||
escapedDatasource := url.QueryEscape(q.Datasource)
|
||||
|
||||
return fmt.Sprintf(
|
||||
`/explore?left=["now-1h","now",%[1]q,{"datasource":%[1]q,"expr":%q,"instant":true,"range":false}]`, escapedDatasource, escapedExpression)
|
||||
`/explore?left={"datasource":%[1]q,"queries":[{"datasource":%[1]q,"expr":%q,"instant":true,"range":false,"refId":"A"}],"range":{"from":"now-1h","to":"now"}}`, escapedDatasource, escapedExpression)
|
||||
}
|
||||
|
@ -359,11 +359,11 @@ func TestExpandTemplate(t *testing.T) {
|
||||
}, {
|
||||
name: "graphLink",
|
||||
text: `{{ graphLink "{\"expr\": \"up\", \"datasource\": \"gdev-prometheus\"}" }}`,
|
||||
expected: `/explore?left=["now-1h","now","gdev-prometheus",{"datasource":"gdev-prometheus","expr":"up","instant":false,"range":true}]`,
|
||||
expected: `/explore?left={"datasource":"gdev-prometheus","queries":[{"datasource":"gdev-prometheus","expr":"up","instant":false,"range":true,"refId":"A"}],"range":{"from":"now-1h","to":"now"}}`,
|
||||
}, {
|
||||
name: "graphLink should escape both the expression and the datasource",
|
||||
text: `{{ graphLink "{\"expr\": \"process_open_fds > 0\", \"datasource\": \"gdev prometheus\"}" }}`,
|
||||
expected: `/explore?left=["now-1h","now","gdev+prometheus",{"datasource":"gdev+prometheus","expr":"process_open_fds+%3E+0","instant":false,"range":true}]`,
|
||||
expected: `/explore?left={"datasource":"gdev+prometheus","queries":[{"datasource":"gdev+prometheus","expr":"process_open_fds+%3E+0","instant":false,"range":true,"refId":"A"}],"range":{"from":"now-1h","to":"now"}}`,
|
||||
}, {
|
||||
name: "check that graphLink returns an empty string when the query is not formatted correctly",
|
||||
text: "{{ graphLink \"up\" }}",
|
||||
@ -371,11 +371,11 @@ func TestExpandTemplate(t *testing.T) {
|
||||
}, {
|
||||
name: "tableLink",
|
||||
text: `{{ tableLink "{\"expr\": \"up\", \"datasource\": \"gdev-prometheus\"}" }}`,
|
||||
expected: `/explore?left=["now-1h","now","gdev-prometheus",{"datasource":"gdev-prometheus","expr":"up","instant":true,"range":false}]`,
|
||||
expected: `/explore?left={"datasource":"gdev-prometheus","queries":[{"datasource":"gdev-prometheus","expr":"up","instant":true,"range":false,"refId":"A"}],"range":{"from":"now-1h","to":"now"}}`,
|
||||
}, {
|
||||
name: "tableLink should escape both the expression and the datasource",
|
||||
text: `{{ tableLink "{\"expr\": \"process_open_fds > 0\", \"datasource\": \"gdev prometheus\"}" }}`,
|
||||
expected: `/explore?left=["now-1h","now","gdev+prometheus",{"datasource":"gdev+prometheus","expr":"process_open_fds+%3E+0","instant":true,"range":false}]`,
|
||||
expected: `/explore?left={"datasource":"gdev+prometheus","queries":[{"datasource":"gdev+prometheus","expr":"process_open_fds+%3E+0","instant":true,"range":false,"refId":"A"}],"range":{"from":"now-1h","to":"now"}}`,
|
||||
}, {
|
||||
name: "check that tableLink returns an empty string when the query is not formatted correctly",
|
||||
text: "{{ tableLink \"up\" }}",
|
||||
|
@ -136,7 +136,11 @@ function createExploreLink(settings: DataSourceInstanceSettings, query: AlertQue
|
||||
const queryParams = { ...rest, datasource: name };
|
||||
|
||||
return urlUtil.renderUrl(`${config.appSubUrl}/explore`, {
|
||||
left: JSON.stringify(['now-1h', 'now', name, queryParams]),
|
||||
left: JSON.stringify({
|
||||
datasource: name,
|
||||
queries: [{ refId: 'A', datasource: name, expr: queryParams }],
|
||||
range: { from: 'now-1h', to: 'now' },
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,11 @@ export function createViewLink(ruleSource: RulesSource, rule: CombinedRule, retu
|
||||
|
||||
export function createExploreLink(dataSourceName: string, query: string) {
|
||||
return createUrl(`/explore`, {
|
||||
left: JSON.stringify([
|
||||
'now-1h',
|
||||
'now',
|
||||
dataSourceName,
|
||||
{ datasource: dataSourceName, expr: query },
|
||||
{ ui: [true, true, true, 'none'] },
|
||||
]),
|
||||
left: JSON.stringify({
|
||||
datasource: dataSourceName,
|
||||
queries: [{ refId: 'A', datasource: dataSourceName, expr: query }],
|
||||
range: { from: 'now-1h', to: 'now' },
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user