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:
Kristina
2022-12-14 12:57:53 -06:00
committed by GitHub
parent d3afe9e85c
commit 5a7f38053b
4 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -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)
}
+4 -4
View File
@@ -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\" }}",