mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 03:42:08 +08:00
QueryLibrary: Added IsVisibility property to Query data (#104579)
* QueryLibrary: Added IsVisibility property to Query data * Added asserts for unit test * generated openapi changes
This commit is contained in:
@ -14,6 +14,9 @@ type QueryTemplate struct {
|
||||
// Longer description for why it is interesting
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// Toggle for visible/hidden queries
|
||||
IsVisible bool `json:"isVisible,omitempty"`
|
||||
|
||||
// The variables that can be used to render
|
||||
// +listType=map
|
||||
// +listMapKey=key
|
||||
|
@ -400,6 +400,13 @@ func schema_apis_query_v0alpha1_template_QueryTemplate(ref common.ReferenceCallb
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"isVisible": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Toggle for visible/hidden queries",
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"vars": {
|
||||
VendorExtensible: spec.VendorExtensible{
|
||||
Extensions: spec.Extensions{
|
||||
|
@ -33,6 +33,17 @@ export const assertQueryLibraryTemplateExists = async (datasource: string, descr
|
||||
});
|
||||
};
|
||||
|
||||
export const assertQueryLibraryTemplateDoesNotExists = async (description: string) => {
|
||||
const selector = withinQueryLibrary();
|
||||
await waitFor(() => {
|
||||
const cell = selector.queryByRole('radio', {
|
||||
name: description,
|
||||
});
|
||||
|
||||
expect(cell).not.toBeInTheDocument();
|
||||
});
|
||||
};
|
||||
|
||||
export const assertAddToQueryLibraryButtonExists = async (value = true) => {
|
||||
await waitFor(() => {
|
||||
// ensures buttons for the card have been loaded to avoid false positives
|
||||
|
@ -120,5 +120,73 @@ export const getTestQueryList = () => ({
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'QueryTemplate',
|
||||
apiVersion: 'querylibrary.grafana.app/v0alpha1',
|
||||
metadata: {
|
||||
name: 'ALoki296tj',
|
||||
generateName: 'ALoki',
|
||||
namespace: 'default',
|
||||
uid: '3e71de65-efa7-40e3-8f23-124212cca456',
|
||||
resourceVersion: '1783214217151647744',
|
||||
creationTimestamp: '2024-04-25T11:05:55Z',
|
||||
annotations: { 'grafana.app/createdBy': 'user:u000000002' },
|
||||
},
|
||||
spec: {
|
||||
title: 'Loki Query Template Hidden',
|
||||
isVisible: false,
|
||||
vars: [
|
||||
{
|
||||
key: '__value',
|
||||
defaultValues: [''],
|
||||
valueListDefinition: {
|
||||
customValues: '',
|
||||
},
|
||||
},
|
||||
],
|
||||
targets: [
|
||||
{
|
||||
variables: {
|
||||
__value: [
|
||||
{
|
||||
path: '$.datasource.jsonData.derivedFields.0.url',
|
||||
position: {
|
||||
start: 0,
|
||||
end: 14,
|
||||
},
|
||||
format: 'raw',
|
||||
},
|
||||
{
|
||||
path: '$.datasource.jsonData.derivedFields.1.url',
|
||||
position: {
|
||||
start: 0,
|
||||
end: 14,
|
||||
},
|
||||
format: 'raw',
|
||||
},
|
||||
{
|
||||
path: '$.datasource.jsonData.derivedFields.2.url',
|
||||
position: {
|
||||
start: 0,
|
||||
end: 14,
|
||||
},
|
||||
format: 'raw',
|
||||
},
|
||||
],
|
||||
},
|
||||
properties: {
|
||||
refId: 'A',
|
||||
datasource: {
|
||||
type: 'loki',
|
||||
uid: 'loki-uid',
|
||||
},
|
||||
queryType: 'range',
|
||||
editorMode: 'code',
|
||||
expr: '{test="test"}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
Reference in New Issue
Block a user