@grafana/scenes 5.5.0--canary.836.9987320115.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
# v5.5.0 (Thu Jul 18 2024)
|
2
|
+
|
3
|
+
#### 🚀 Enhancement
|
4
|
+
|
5
|
+
- Scenes: Move change panel plugin logic in VizPanel [#836](https://github.com/grafana/scenes/pull/836) ([@mdvictor](https://github.com/mdvictor))
|
6
|
+
|
7
|
+
#### Authors: 1
|
8
|
+
|
9
|
+
- Victor Marin ([@mdvictor](https://github.com/mdvictor))
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
# v5.4.1 (Thu Jul 18 2024)
|
14
|
+
|
15
|
+
#### 🐛 Bug Fix
|
16
|
+
|
17
|
+
- QueryVariable: Query is empty string by default [#837](https://github.com/grafana/scenes/pull/837) ([@ivanortegaalba](https://github.com/ivanortegaalba))
|
18
|
+
- fix(lazyloader): fix trying to run inexistent callbacks [#833](https://github.com/grafana/scenes/pull/833) ([@svennergr](https://github.com/svennergr))
|
19
|
+
|
20
|
+
#### Authors: 2
|
21
|
+
|
22
|
+
- Ivan Ortega Alba ([@ivanortegaalba](https://github.com/ivanortegaalba))
|
23
|
+
- Sven Grossmann ([@svennergr](https://github.com/svennergr))
|
24
|
+
|
25
|
+
---
|
26
|
+
|
1
27
|
# v5.4.0 (Tue Jul 16 2024)
|
2
28
|
|
3
29
|
#### 🚀 Enhancement
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryVariable.js","sources":["../../../../../src/variables/variants/query/QueryVariable.tsx"],"sourcesContent":["import { Observable, of, filter, take, mergeMap, catchError, throwError, from, lastValueFrom } from 'rxjs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n CoreApp,\n DataQueryRequest,\n LoadingState,\n PanelData,\n ScopedVars,\n VariableRefresh,\n VariableSort,\n} from '@grafana/data';\n\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport { SceneComponentProps, SceneDataQuery } from '../../../core/types';\nimport { VariableDependencyConfig } from '../../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../../components/VariableValueSelect';\nimport { VariableValueOption } from '../../types';\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from '../MultiValueVariable';\n\nimport { createQueryVariableRunner } from './createQueryVariableRunner';\nimport { metricNamesToVariableValues } from './utils';\nimport { toMetricFindValues } from './toMetricFindValues';\nimport { getDataSource } from '../../../utils/getDataSource';\nimport { safeStringifyValue } from '../../utils';\nimport { DataQuery, DataSourceRef } from '@grafana/schema';\nimport { SEARCH_FILTER_VARIABLE } from '../../constants';\nimport { debounce } from 'lodash';\nimport { registerQueryWithController } from '../../../querying/registerQueryWithController';\n\nexport interface QueryVariableState extends MultiValueVariableState {\n type: 'query';\n datasource: DataSourceRef | null;\n query: string | SceneDataQuery;\n regex: string;\n refresh: VariableRefresh;\n sort: VariableSort;\n /** @internal Only for use inside core dashboards */\n definition?: string;\n}\n\nexport class QueryVariable extends MultiValueVariable<QueryVariableState> {\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['regex', 'query', 'datasource'],\n });\n\n public constructor(initialState: Partial<QueryVariableState>) {\n super({\n type: 'query',\n name: '',\n value: '',\n text: '',\n options: [],\n datasource: null,\n regex: '',\n query:
|
1
|
+
{"version":3,"file":"QueryVariable.js","sources":["../../../../../src/variables/variants/query/QueryVariable.tsx"],"sourcesContent":["import { Observable, of, filter, take, mergeMap, catchError, throwError, from, lastValueFrom } from 'rxjs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n CoreApp,\n DataQueryRequest,\n LoadingState,\n PanelData,\n ScopedVars,\n VariableRefresh,\n VariableSort,\n} from '@grafana/data';\n\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport { SceneComponentProps, SceneDataQuery } from '../../../core/types';\nimport { VariableDependencyConfig } from '../../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../../components/VariableValueSelect';\nimport { VariableValueOption } from '../../types';\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from '../MultiValueVariable';\n\nimport { createQueryVariableRunner } from './createQueryVariableRunner';\nimport { metricNamesToVariableValues } from './utils';\nimport { toMetricFindValues } from './toMetricFindValues';\nimport { getDataSource } from '../../../utils/getDataSource';\nimport { safeStringifyValue } from '../../utils';\nimport { DataQuery, DataSourceRef } from '@grafana/schema';\nimport { SEARCH_FILTER_VARIABLE } from '../../constants';\nimport { debounce } from 'lodash';\nimport { registerQueryWithController } from '../../../querying/registerQueryWithController';\n\nexport interface QueryVariableState extends MultiValueVariableState {\n type: 'query';\n datasource: DataSourceRef | null;\n query: string | SceneDataQuery;\n regex: string;\n refresh: VariableRefresh;\n sort: VariableSort;\n /** @internal Only for use inside core dashboards */\n definition?: string;\n}\n\nexport class QueryVariable extends MultiValueVariable<QueryVariableState> {\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['regex', 'query', 'datasource'],\n });\n\n public constructor(initialState: Partial<QueryVariableState>) {\n super({\n type: 'query',\n name: '',\n value: '',\n text: '',\n options: [],\n datasource: null,\n regex: '',\n query: '',\n refresh: VariableRefresh.onDashboardLoad,\n sort: VariableSort.disabled,\n ...initialState,\n });\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n if (!this.state.query) {\n return of([]);\n }\n\n this.setState({ loading: true, error: null });\n\n return from(\n getDataSource(this.state.datasource, {\n __sceneObject: { text: '__sceneObject', value: this },\n })\n ).pipe(\n mergeMap((ds) => {\n const runner = createQueryVariableRunner(ds);\n const target = runner.getTarget(this);\n const request = this.getRequest(target, args.searchFilter);\n\n return runner.runRequest({ variable: this, searchFilter: args.searchFilter }, request).pipe(\n registerQueryWithController({\n type: 'variable',\n request: request,\n origin: this,\n }),\n filter((data) => data.state === LoadingState.Done || data.state === LoadingState.Error), // we only care about done or error for now\n take(1), // take the first result, using first caused a bug where it in some situations throw an uncaught error because of no results had been received yet\n mergeMap((data: PanelData) => {\n if (data.state === LoadingState.Error) {\n return throwError(() => data.error);\n }\n return of(data);\n }),\n toMetricFindValues(),\n mergeMap((values) => {\n let regex = '';\n if (this.state.regex) {\n regex = sceneGraph.interpolate(this, this.state.regex, undefined, 'regex');\n }\n return of(metricNamesToVariableValues(regex, this.state.sort, values));\n }),\n catchError((error) => {\n if (error.cancelled) {\n return of([]);\n }\n return throwError(() => error);\n })\n );\n })\n );\n }\n\n private getRequest(target: DataQuery | string, searchFilter?: string) {\n const scopedVars: ScopedVars = {\n __sceneObject: { text: '__sceneObject', value: this },\n };\n\n if (searchFilter) {\n scopedVars.__searchFilter = { value: searchFilter, text: searchFilter };\n }\n\n const range = sceneGraph.getTimeRange(this).state.value;\n\n const request: DataQueryRequest = {\n app: CoreApp.Dashboard,\n requestId: uuidv4(),\n timezone: '',\n range,\n interval: '',\n intervalMs: 0,\n // @ts-ignore\n targets: [target],\n scopedVars,\n startTime: Date.now(),\n };\n\n return request;\n }\n\n onSearchChange = (searchFilter: string) => {\n if (!containsSearchFilter(this.state.query)) {\n return;\n }\n\n this._updateOptionsBasedOnSearchFilter(searchFilter);\n };\n\n private _updateOptionsBasedOnSearchFilter = debounce(async (searchFilter: string) => {\n const result = await lastValueFrom(this.getValueOptions({ searchFilter }));\n this.setState({ options: result, loading: false });\n }, 400);\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return renderSelectForVariable(model);\n };\n}\n\nfunction containsSearchFilter(query: string | DataQuery) {\n const str = safeStringifyValue(query);\n return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;\n}\n"],"names":["uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCO,MAAM,sBAAsB,kBAAuC,CAAA;AAAA,EAKjE,YAAY,YAA2C,EAAA;AAC5D,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,OAAA;AAAA,MACN,IAAM,EAAA,EAAA;AAAA,MACN,KAAO,EAAA,EAAA;A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,EAAA;AAAA,KACtB,CAAA;AAEA,IAAO,OAAA,OAAA,CAAA;AAAA,GACT;AAkBF,CAAA;AAlHa,aAAA,CA+GG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAqD,KAAA;AAChF,EAAA,OAAO,wBAAwB,KAAK,CAAA,CAAA;AACtC,CAAA,CAAA;AAGF,SAAS,qBAAqB,KAA2B,EAAA;AACvD,EAAM,MAAA,GAAA,GAAM,mBAAmB,KAAK,CAAA,CAAA;AACpC,EAAO,OAAA,GAAA,CAAI,OAAQ,CAAA,sBAAsB,CAAI,GAAA,CAAA,CAAA,CAAA;AAC/C;;;;"}
|
package/dist/index.js
CHANGED
@@ -7419,7 +7419,7 @@ class QueryVariable extends MultiValueVariable {
|
|
7419
7419
|
options: [],
|
7420
7420
|
datasource: null,
|
7421
7421
|
regex: "",
|
7422
|
-
query:
|
7422
|
+
query: "",
|
7423
7423
|
refresh: data.VariableRefresh.onDashboardLoad,
|
7424
7424
|
sort: data.VariableSort.disabled
|
7425
7425
|
}, initialState));
|