@grafana/scenes 5.33.1--canary.996.12371059735.0 → 6.0.0--canary.979.12373078054.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/utils/utils.ts"],"sourcesContent":["import { SceneObject, SceneObjectState } from '../core/types';\nimport { locationService as locationServiceRuntime } from '@grafana/runtime';\n// @ts-ignore\n// eslint-disable-next-line no-duplicate-imports\nimport { useLocationService } from '@grafana/runtime';\n\n/**\n * This function works around the problem of Contravariance of the SceneObject.setState function\n * Contravariance is not enforce by interfaces and here we use the SceneObject interface to access the setState function\n */\nexport function setBaseClassState<T extends SceneObjectState>(sceneObject: SceneObject<T>, newState: Partial<T>) {\n sceneObject.setState(newState);\n}\n\n/**\n * Safe way to get location service that fallbacks to singleton for older runtime versions where useLocationService is\n * not available.\n */\nexport function useLocationServiceSafe() {\n // This is basically a version/feature check for grafana/runtime so this 'if' should be stable (ie for one instance\n // of grafana this will always be true or false) so it should be safe to ignore the hook rule here\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useLocationService ? useLocationService() : locationServiceRuntime;\n}\n"],"names":["locationServiceRuntime"],"mappings":";;AAUgB,SAAA,iBAAA,CAA8C,aAA6B,QAAsB,EAAA;AAC/G,EAAA,WAAA,CAAY,SAAS,QAAQ,CAAA,CAAA;AAC/B,CAAA;AAMO,SAAS,sBAAyB,GAAA;AAIvC,EAAO,OAAA,kBAAA,GAAqB,oBAAuB,GAAAA,eAAA,CAAA;AACrD;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/utils/utils.ts"],"sourcesContent":["import { SceneObject, SceneObjectState } from '../core/types';\nimport { locationService as locationServiceRuntime, useLocationService } from '@grafana/runtime';\n\n/**\n * This function works around the problem of Contravariance of the SceneObject.setState function\n * Contravariance is not enforce by interfaces and here we use the SceneObject interface to access the setState function\n */\nexport function setBaseClassState<T extends SceneObjectState>(sceneObject: SceneObject<T>, newState: Partial<T>) {\n sceneObject.setState(newState);\n}\n\n/**\n * Safe way to get location service that fallbacks to singleton for older runtime versions where useLocationService is\n * not available.\n */\nexport function useLocationServiceSafe() {\n // This is basically a version/feature check for grafana/runtime so this 'if' should be stable (ie for one instance\n // of grafana this will always be true or false) so it should be safe to ignore the hook rule here\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useLocationService ? useLocationService() : locationServiceRuntime;\n}\n"],"names":["locationServiceRuntime"],"mappings":";;AAOgB,SAAA,iBAAA,CAA8C,aAA6B,QAAsB,EAAA;AAC/G,EAAA,WAAA,CAAY,SAAS,QAAQ,CAAA,CAAA;AAC/B,CAAA;AAMO,SAAS,sBAAyB,GAAA;AAIvC,EAAO,OAAA,kBAAA,GAAqB,oBAAuB,GAAAA,eAAA,CAAA;AACrD;;;;"}
@@ -1,5 +1,4 @@
1
1
  import { getTemplateSrv, getDataSourceSrv } from '@grafana/runtime';
2
- import { interpolate } from '../../core/sceneGraph/sceneGraph.js';
3
2
 
4
3
  let originalGetAdhocFilters = void 0;
5
4
  let allActiveFilterSets = /* @__PURE__ */ new Set();
@@ -37,7 +36,7 @@ function patchGetAdhocFilters(filterVar) {
37
36
  function findActiveAdHocFilterVariableByUid(dsUid) {
38
37
  var _a;
39
38
  for (const filter of allActiveFilterSets.values()) {
40
- if (interpolate(filter, (_a = filter.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
39
+ if (((_a = filter.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
41
40
  return filter;
42
41
  }
43
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"patchGetAdhocFilters.js","sources":["../../../../src/variables/adhoc/patchGetAdhocFilters.ts"],"sourcesContent":["import { getDataSourceSrv, getTemplateSrv } from '@grafana/runtime';\nimport { AdHocVariableFilter } from '@grafana/data';\nimport { AdHocFiltersVariable } from './AdHocFiltersVariable';\nimport { interpolate } from '../../core/sceneGraph/sceneGraph';\n\nlet originalGetAdhocFilters: any = undefined;\nlet allActiveFilterSets = new Set<AdHocFiltersVariable>();\n\nexport function patchGetAdhocFilters(filterVar: AdHocFiltersVariable) {\n filterVar.addActivationHandler(() => {\n allActiveFilterSets.add(filterVar);\n return () => allActiveFilterSets.delete(filterVar);\n });\n\n if (originalGetAdhocFilters) {\n return;\n }\n\n const templateSrv: any = getTemplateSrv();\n if (!templateSrv?.getAdhocFilters) {\n console.log('Failed to patch getAdhocFilters');\n return;\n }\n\n originalGetAdhocFilters = templateSrv.getAdhocFilters;\n\n templateSrv.getAdhocFilters = function getAdhocFiltersScenePatch(dsName: string): AdHocVariableFilter[] {\n if (allActiveFilterSets.size === 0) {\n return originalGetAdhocFilters.call(templateSrv, dsName);\n }\n\n const ds = getDataSourceSrv().getInstanceSettings(dsName);\n if (!ds) {\n return [];\n }\n\n for (const filter of allActiveFilterSets.values()) {\n if (filter.state.datasource?.uid === ds.uid) {\n return filter.state.filters;\n }\n }\n\n return [];\n }.bind(templateSrv);\n}\n\nexport function findActiveAdHocFilterVariableByUid(dsUid: string | undefined): AdHocFiltersVariable | undefined {\n for (const filter of allActiveFilterSets.values()) {\n if (interpolate(filter, filter.state.datasource?.uid) === dsUid) {\n return filter;\n }\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;AAKA,IAAI,uBAA+B,GAAA,KAAA,CAAA,CAAA;AACnC,IAAI,mBAAA,uBAA0B,GAA0B,EAAA,CAAA;AAEjD,SAAS,qBAAqB,SAAiC,EAAA;AACpE,EAAA,SAAA,CAAU,qBAAqB,MAAM;AACnC,IAAA,mBAAA,CAAoB,IAAI,SAAS,CAAA,CAAA;AACjC,IAAO,OAAA,MAAM,mBAAoB,CAAA,MAAA,CAAO,SAAS,CAAA,CAAA;AAAA,GAClD,CAAA,CAAA;AAED,EAAA,IAAI,uBAAyB,EAAA;AAC3B,IAAA,OAAA;AAAA,GACF;AAEA,EAAA,MAAM,cAAmB,cAAe,EAAA,CAAA;AACxC,EAAI,IAAA,EAAC,2CAAa,eAAiB,CAAA,EAAA;AACjC,IAAA,OAAA,CAAQ,IAAI,iCAAiC,CAAA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1
+ {"version":3,"file":"patchGetAdhocFilters.js","sources":["../../../../src/variables/adhoc/patchGetAdhocFilters.ts"],"sourcesContent":["import { getDataSourceSrv, getTemplateSrv } from '@grafana/runtime';\nimport { AdHocVariableFilter } from '@grafana/data';\nimport { AdHocFiltersVariable } from './AdHocFiltersVariable';\n\nlet originalGetAdhocFilters: any = undefined;\nlet allActiveFilterSets = new Set<AdHocFiltersVariable>();\n\nexport function patchGetAdhocFilters(filterVar: AdHocFiltersVariable) {\n filterVar.addActivationHandler(() => {\n allActiveFilterSets.add(filterVar);\n return () => allActiveFilterSets.delete(filterVar);\n });\n\n if (originalGetAdhocFilters) {\n return;\n }\n\n const templateSrv: any = getTemplateSrv();\n if (!templateSrv?.getAdhocFilters) {\n console.log('Failed to patch getAdhocFilters');\n return;\n }\n\n originalGetAdhocFilters = templateSrv.getAdhocFilters;\n\n templateSrv.getAdhocFilters = function getAdhocFiltersScenePatch(dsName: string): AdHocVariableFilter[] {\n if (allActiveFilterSets.size === 0) {\n return originalGetAdhocFilters.call(templateSrv, dsName);\n }\n\n const ds = getDataSourceSrv().getInstanceSettings(dsName);\n if (!ds) {\n return [];\n }\n\n for (const filter of allActiveFilterSets.values()) {\n if (filter.state.datasource?.uid === ds.uid) {\n return filter.state.filters;\n }\n }\n\n return [];\n }.bind(templateSrv);\n}\n\nexport function findActiveAdHocFilterVariableByUid(dsUid: string | undefined): AdHocFiltersVariable | undefined {\n for (const filter of allActiveFilterSets.values()) {\n if (filter.state.datasource?.uid === dsUid) {\n return filter;\n }\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;AAIA,IAAI,uBAA+B,GAAA,KAAA,CAAA,CAAA;AACnC,IAAI,mBAAA,uBAA0B,GAA0B,EAAA,CAAA;AAEjD,SAAS,qBAAqB,SAAiC,EAAA;AACpE,EAAA,SAAA,CAAU,qBAAqB,MAAM;AACnC,IAAA,mBAAA,CAAoB,IAAI,SAAS,CAAA,CAAA;AACjC,IAAO,OAAA,MAAM,mBAAo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A,EAAU,EAAA;AACjD,IAAA,IAAA,CAAA,CAAI,EAAO,GAAA,MAAA,CAAA,KAAA,CAAM,UAAb,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAyB,SAAQ,KAAO,EAAA;AAC1C,MAAO,OAAA,MAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT;;;;"}
@@ -1,10 +1,8 @@
1
- import { interpolate } from '../../core/sceneGraph/sceneGraph.js';
2
-
3
1
  const allActiveGroupByVariables = /* @__PURE__ */ new Set();
4
2
  function findActiveGroupByVariablesByUid(dsUid) {
5
3
  var _a;
6
4
  for (const groupByVariable of allActiveGroupByVariables.values()) {
7
- if (interpolate(groupByVariable, (_a = groupByVariable.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
5
+ if (((_a = groupByVariable.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
8
6
  return groupByVariable;
9
7
  }
10
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"findActiveGroupByVariablesByUid.js","sources":["../../../../src/variables/groupby/findActiveGroupByVariablesByUid.ts"],"sourcesContent":["import { interpolate } from '../../core/sceneGraph/sceneGraph';\nimport { GroupByVariable } from './GroupByVariable';\n\nexport const allActiveGroupByVariables = new Set<GroupByVariable>();\n\nexport function findActiveGroupByVariablesByUid(dsUid: string | undefined): GroupByVariable | undefined {\n for (const groupByVariable of allActiveGroupByVariables.values()) {\n if (interpolate(groupByVariable, groupByVariable.state.datasource?.uid) === dsUid) {\n return groupByVariable;\n }\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;AAGa,MAAA,yBAAA,uBAAgC,GAAqB,GAAA;AAE3D,SAAS,gCAAgC,KAAwD,EAAA;AALxG,EAAA,IAAA,EAAA,CAAA;AAME,EAAW,KAAA,MAAA,eAAA,IAAmB,yBAA0B,CAAA,MAAA,EAAU,EAAA;AAChE,IAAI,IAAA,WAAA,CAAY,kBAAiB,EAAgB,GAAA,eAAA,CAAA,KAAA,CAAM,eAAtB,IAAkC,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,GAAG,MAAM,KAAO,EAAA;AACjF,MAAO,OAAA,eAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"findActiveGroupByVariablesByUid.js","sources":["../../../../src/variables/groupby/findActiveGroupByVariablesByUid.ts"],"sourcesContent":["import { GroupByVariable } from './GroupByVariable';\n\nexport const allActiveGroupByVariables = new Set<GroupByVariable>();\n\nexport function findActiveGroupByVariablesByUid(dsUid: string | undefined): GroupByVariable | undefined {\n for (const groupByVariable of allActiveGroupByVariables.values()) {\n if (groupByVariable.state.datasource?.uid === dsUid) {\n return groupByVariable;\n }\n }\n\n return undefined;\n}\n"],"names":[],"mappings":"AAEa,MAAA,yBAAA,uBAAgC,GAAqB,GAAA;AAE3D,SAAS,gCAAgC,KAAwD,EAAA;AAJxG,EAAA,IAAA,EAAA,CAAA;AAKE,EAAW,KAAA,MAAA,eAAA,IAAmB,yBAA0B,CAAA,MAAA,EAAU,EAAA;AAChE,IAAA,IAAA,CAAA,CAAI,EAAgB,GAAA,eAAA,CAAA,KAAA,CAAM,UAAtB,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkC,SAAQ,KAAO,EAAA;AACnD,MAAO,OAAA,eAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT;;;;"}
@@ -60,16 +60,13 @@ function escapeLokiRegexp(value) {
60
60
  return value.replace(RE2_METACHARACTERS, "\\$&");
61
61
  }
62
62
  function getQueriesForVariables(sourceObject) {
63
- var _a;
64
63
  const runners = sceneGraph.findAllObjects(
65
64
  sourceObject.getRoot(),
66
65
  (o) => o instanceof SceneQueryRunner
67
66
  );
68
- const interpolatedDsUuid = sceneGraph.interpolate(sourceObject, (_a = sourceObject.state.datasource) == null ? void 0 : _a.uid);
69
67
  const applicableRunners = filterOutInactiveRunnerDuplicates(runners).filter((r) => {
70
- var _a2;
71
- const interpolatedQueryDsUuid = sceneGraph.interpolate(sourceObject, (_a2 = r.state.datasource) == null ? void 0 : _a2.uid);
72
- return interpolatedQueryDsUuid === interpolatedDsUuid;
68
+ var _a, _b;
69
+ return ((_a = r.state.datasource) == null ? void 0 : _a.uid) === ((_b = sourceObject.state.datasource) == null ? void 0 : _b.uid);
73
70
  });
74
71
  if (applicableRunners.length === 0) {
75
72
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/variables/utils.ts"],"sourcesContent":["import { isEqual } from 'lodash';\nimport { VariableValue } from './types';\nimport { AdHocVariableFilter, DataQueryError, GetTagResponse, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneDataQuery, SceneObject, SceneObjectState } from '../core/types';\nimport { SceneQueryRunner } from '../querying/SceneQueryRunner';\nimport { DataSourceRef } from '@grafana/schema';\nimport uFuzzy from '@leeoniya/ufuzzy';\n\nexport function isVariableValueEqual(a: VariableValue | null | undefined, b: VariableValue | null | undefined) {\n if (a === b) {\n return true;\n }\n\n return isEqual(a, b);\n}\n\nexport function safeStringifyValue(value: unknown) {\n // Avoid circular references ignoring those references\n const getCircularReplacer = () => {\n const seen = new WeakSet();\n return (_: string, value: object | null) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n }\n return value;\n };\n };\n\n try {\n return JSON.stringify(value, getCircularReplacer());\n } catch (error) {\n console.error(error);\n }\n\n return '';\n}\n\nexport function renderPrometheusLabelFilters(filters: AdHocVariableFilter[]) {\n return filters.map((filter) => renderFilter(filter)).join(',');\n}\n\nfunction renderFilter(filter: AdHocVariableFilter) {\n let value = '';\n let operator = filter.operator;\n\n // map \"one of\" operator to regex\n if (operator === '=|') {\n operator = '=~';\n // TODO remove when we're on the latest version of @grafana/data\n // @ts-expect-error\n value = filter.values?.map(escapeLabelValueInRegexSelector).join('|');\n } else if (operator === '!=|') {\n operator = '!~';\n // TODO remove when we're on the latest version of @grafana/data\n // @ts-expect-error\n value = filter.values?.map(escapeLabelValueInRegexSelector).join('|');\n } else if (operator === '=~' || operator === '!~') {\n value = escapeLabelValueInRegexSelector(filter.value);\n } else {\n value = escapeLabelValueInExactSelector(filter.value);\n }\n\n return `${filter.key}${operator}\"${value}\"`;\n}\n\n// based on the openmetrics-documentation, the 3 symbols we have to handle are:\n// - \\n ... the newline character\n// - \\ ... the backslash character\n// - \" ... the double-quote character\nexport function escapeLabelValueInExactSelector(labelValue: string): string {\n return labelValue.replace(/\\\\/g, '\\\\\\\\').replace(/\\n/g, '\\\\n').replace(/\"/g, '\\\\\"');\n}\n\nexport function escapeLabelValueInRegexSelector(labelValue: string): string {\n return escapeLabelValueInExactSelector(escapeLokiRegexp(labelValue));\n}\n\nexport function isRegexSelector(selector?: string) {\n if (selector && (selector.includes('=~') || selector.includes('!~'))) {\n return true;\n }\n return false;\n}\n\n// Loki regular-expressions use the RE2 syntax (https://github.com/google/re2/wiki/Syntax),\n// so every character that matches something in that list has to be escaped.\n// the list of meta characters is: *+?()|\\.[]{}^$\n// we make a javascript regular expression that matches those characters:\nconst RE2_METACHARACTERS = /[*+?()|\\\\.\\[\\]{}^$]/g;\nfunction escapeLokiRegexp(value: string): string {\n return value.replace(RE2_METACHARACTERS, '\\\\$&');\n}\n\n/**\n * Get all queries in the scene that have the same datasource as provided source object\n */\nexport function getQueriesForVariables(\n sourceObject: SceneObject<SceneObjectState & { datasource: DataSourceRef | null }>\n) {\n const runners = sceneGraph.findAllObjects(\n sourceObject.getRoot(),\n (o) => o instanceof SceneQueryRunner\n ) as SceneQueryRunner[];\n\n const interpolatedDsUuid = sceneGraph.interpolate(sourceObject, sourceObject.state.datasource?.uid);\n\n const applicableRunners = filterOutInactiveRunnerDuplicates(runners).filter((r) => {\n const interpolatedQueryDsUuid = sceneGraph.interpolate(sourceObject, r.state.datasource?.uid);\n\n return interpolatedQueryDsUuid === interpolatedDsUuid;\n });\n\n if (applicableRunners.length === 0) {\n return [];\n }\n\n const result: SceneDataQuery[] = [];\n applicableRunners.forEach((r) => {\n result.push(...r.state.queries);\n });\n\n return result;\n}\n\n// Filters out inactive runner duplicates, keeping only the ones that are currently active.\n// This is needed for scnearios whan a query runner is cloned and the original is not removed but de-activated.\n// Can happen i.e. when editing a panel in Grafana Core dashboards.\nfunction filterOutInactiveRunnerDuplicates(runners: SceneQueryRunner[]) {\n // Group items by key\n const groupedItems: { [key: string]: SceneQueryRunner[] } = {};\n\n for (const item of runners) {\n if (item.state.key) {\n if (!(item.state.key in groupedItems)) {\n groupedItems[item.state.key] = [];\n }\n groupedItems[item.state.key].push(item);\n }\n }\n\n // Filter out inactive items and concatenate active items\n return Object.values(groupedItems).flatMap((group) => {\n const activeItems = group.filter((item) => item.isActive);\n // Keep inactive items if there's only one item with the key\n if (activeItems.length === 0 && group.length === 1) {\n return group;\n }\n return activeItems;\n });\n}\n\nexport function escapeUrlPipeDelimiters(value: string | undefined): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n // Replace the pipe due to using it as a filter separator\n return (value = /\\|/g[Symbol.replace](value, '__gfp__'));\n}\n\nexport function escapeUrlCommaDelimiters(value: string | undefined): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n // Replace the comma due to using it as a value/label separator\n return /,/g[Symbol.replace](value, '__gfc__');\n}\n\nexport function unescapeUrlDelimiters(value: string | undefined): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n value = /__gfp__/g[Symbol.replace](value, '|');\n value = /__gfc__/g[Symbol.replace](value, ',');\n\n return value;\n}\n\nexport function toUrlCommaDelimitedString(key: string, label?: string): string {\n // Omit for identical key/label or when label is not set at all\n if (!label || key === label) {\n return escapeUrlCommaDelimiters(key);\n }\n\n return [key, label].map(escapeUrlCommaDelimiters).join(',');\n}\n\nexport function dataFromResponse(response: GetTagResponse | MetricFindValue[]) {\n return Array.isArray(response) ? response : response.data;\n}\n\nexport function responseHasError(\n response: GetTagResponse | MetricFindValue[]\n): response is GetTagResponse & { error: DataQueryError } {\n return !Array.isArray(response) && Boolean(response.error);\n}\n\n// Collect a flat list of SelectableValues with a `group` property into a hierarchical list with groups\nexport function handleOptionGroups(values: SelectableValue[]): Array<SelectableValue<string>> {\n const result: Array<SelectableValue<string>> = [];\n const groupedResults = new Map<string, Array<SelectableValue<string>>>();\n\n for (const value of values) {\n const groupLabel = value.group;\n if (groupLabel) {\n let group = groupedResults.get(groupLabel);\n\n if (!group) {\n group = [];\n groupedResults.set(groupLabel, group);\n result.push({ label: groupLabel, options: group });\n }\n\n group.push(value);\n } else {\n result.push(value);\n }\n }\n\n return result;\n}\n\nexport function getFuzzySearcher(haystack: string[], limit = 10_000) {\n const ufuzzy = new uFuzzy();\n\n const FIRST = Array.from({ length: Math.min(limit, haystack.length) }, (_, i) => i);\n\n // returns matched indices by quality\n return (search: string): number[] => {\n if (search === '') {\n return FIRST;\n }\n\n const [idxs, info, order] = ufuzzy.search(haystack, search);\n\n if (idxs) {\n if (info && order) {\n const outIdxs = Array(Math.min(order.length, limit));\n\n for (let i = 0; i < outIdxs.length; i++) {\n outIdxs[i] = info.idx[order[i]];\n }\n\n return outIdxs;\n }\n\n return idxs.slice(0, limit);\n }\n\n return [];\n };\n}\n"],"names":["value","_a"],"mappings":";;;;;AASgB,SAAA,oBAAA,CAAqB,GAAqC,CAAqC,EAAA;AAC7G,EAAA,IAAI,MAAM,CAAG,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,OAAA,CAAQ,GAAG,CAAC,CAAA,CAAA;AACrB,CAAA;AAEO,SAAS,mBAAmB,KAAgB,EAAA;AAEjD,EAAA,MAAM,sBAAsB,MAAM;AAChC,IAAM,MAAA,IAAA,uBAAW,OAAQ,EAAA,CAAA;AACzB,IAAO,OAAA,CAAC,GAAWA,MAAyB,KAAA;AAC1C,MAAA,IAAI,OAAOA,MAAAA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import { AdHocVariableFilter, DataQueryError, GetTagResponse, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneDataQuery, SceneObject, SceneObjectState } from '../core/types';\nimport { SceneQueryRunner } from '../querying/SceneQueryRunner';\nimport { DataSourceRef } from '@grafana/schema';\nimport uFuzzy from '@leeoniya/ufuzzy';\n\nexport function isVariableValueEqual(a: VariableValue | null | undefined, b: VariableValue | null | undefined) {\n if (a === b) {\n return true;\n }\n\n return isEqual(a, b);\n}\n\nexport function safeStringifyValue(value: unknown) {\n // Avoid circular references ignoring those references\n const getCircularReplacer = () => {\n const seen = new WeakSet();\n return (_: string, value: object | null) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n }\n return value;\n };\n };\n\n try {\n return JSON.stringify(value, getCircularReplacer());\n } catch (error) {\n console.error(error);\n }\n\n return '';\n}\n\nexport function renderPrometheusLabelFilters(filters: AdHocVariableFilter[]) {\n return filters.map((filter) => renderFilter(filter)).join(',');\n}\n\nfunction renderFilter(filter: AdHocVariableFilter) {\n let value = '';\n let operator = filter.operator;\n\n // map \"one of\" operator to regex\n if (operator === '=|') {\n operator = '=~';\n // TODO remove when we're on the latest version of @grafana/data\n // @ts-expect-error\n value = filter.values?.map(escapeLabelValueInRegexSelector).join('|');\n } else if (operator === '!=|') {\n operator = '!~';\n // TODO remove when we're on the latest version of @grafana/data\n // @ts-expect-error\n value = filter.values?.map(escapeLabelValueInRegexSelector).join('|');\n } else if (operator === '=~' || operator === '!~') {\n value = escapeLabelValueInRegexSelector(filter.value);\n } else {\n value = escapeLabelValueInExactSelector(filter.value);\n }\n\n return `${filter.key}${operator}\"${value}\"`;\n}\n\n// based on the openmetrics-documentation, the 3 symbols we have to handle are:\n// - \\n ... the newline character\n// - \\ ... the backslash character\n// - \" ... the double-quote character\nexport function escapeLabelValueInExactSelector(labelValue: string): string {\n return labelValue.replace(/\\\\/g, '\\\\\\\\').replace(/\\n/g, '\\\\n').replace(/\"/g, '\\\\\"');\n}\n\nexport function escapeLabelValueInRegexSelector(labelValue: string): string {\n return escapeLabelValueInExactSelector(escapeLokiRegexp(labelValue));\n}\n\nexport function isRegexSelector(selector?: string) {\n if (selector && (selector.includes('=~') || selector.includes('!~'))) {\n return true;\n }\n return false;\n}\n\n// Loki regular-expressions use the RE2 syntax (https://github.com/google/re2/wiki/Syntax),\n// so every character that matches something in that list has to be escaped.\n// the list of meta characters is: *+?()|\\.[]{}^$\n// we make a javascript regular expression that matches those characters:\nconst RE2_METACHARACTERS = /[*+?()|\\\\.\\[\\]{}^$]/g;\nfunction escapeLokiRegexp(value: string): string {\n return value.replace(RE2_METACHARACTERS, '\\\\$&');\n}\n\n/**\n * Get all queries in the scene that have the same datasource as provided source object\n */\nexport function getQueriesForVariables(\n sourceObject: SceneObject<SceneObjectState & { datasource: DataSourceRef | null }>\n) {\n const runners = sceneGraph.findAllObjects(\n sourceObject.getRoot(),\n (o) => o instanceof SceneQueryRunner\n ) as SceneQueryRunner[];\n\n const applicableRunners = filterOutInactiveRunnerDuplicates(runners).filter((r) => {\n return r.state.datasource?.uid === sourceObject.state.datasource?.uid;\n });\n\n if (applicableRunners.length === 0) {\n return [];\n }\n\n const result: SceneDataQuery[] = [];\n applicableRunners.forEach((r) => {\n result.push(...r.state.queries);\n });\n\n return result;\n}\n\n// Filters out inactive runner duplicates, keeping only the ones that are currently active.\n// This is needed for scnearios whan a query runner is cloned and the original is not removed but de-activated.\n// Can happen i.e. when editing a panel in Grafana Core dashboards.\nfunction filterOutInactiveRunnerDuplicates(runners: SceneQueryRunner[]) {\n // Group items by key\n const groupedItems: { [key: string]: SceneQueryRunner[] } = {};\n\n for (const item of runners) {\n if (item.state.key) {\n if (!(item.state.key in groupedItems)) {\n groupedItems[item.state.key] = [];\n }\n groupedItems[item.state.key].push(item);\n }\n }\n\n // Filter out inactive items and concatenate active items\n return Object.values(groupedItems).flatMap((group) => {\n const activeItems = group.filter((item) => item.isActive);\n // Keep inactive items if there's only one item with the key\n if (activeItems.length === 0 && group.length === 1) {\n return group;\n }\n return activeItems;\n });\n}\n\nexport function escapeUrlPipeDelimiters(value: string | undefined): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n // Replace the pipe due to using it as a filter separator\n return (value = /\\|/g[Symbol.replace](value, '__gfp__'));\n}\n\nexport function escapeUrlCommaDelimiters(value: string | undefined): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n // Replace the comma due to using it as a value/label separator\n return /,/g[Symbol.replace](value, '__gfc__');\n}\n\nexport function unescapeUrlDelimiters(value: string | undefined): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n value = /__gfp__/g[Symbol.replace](value, '|');\n value = /__gfc__/g[Symbol.replace](value, ',');\n\n return value;\n}\n\nexport function toUrlCommaDelimitedString(key: string, label?: string): string {\n // Omit for identical key/label or when label is not set at all\n if (!label || key === label) {\n return escapeUrlCommaDelimiters(key);\n }\n\n return [key, label].map(escapeUrlCommaDelimiters).join(',');\n}\n\nexport function dataFromResponse(response: GetTagResponse | MetricFindValue[]) {\n return Array.isArray(response) ? response : response.data;\n}\n\nexport function responseHasError(\n response: GetTagResponse | MetricFindValue[]\n): response is GetTagResponse & { error: DataQueryError } {\n return !Array.isArray(response) && Boolean(response.error);\n}\n\n// Collect a flat list of SelectableValues with a `group` property into a hierarchical list with groups\nexport function handleOptionGroups(values: SelectableValue[]): Array<SelectableValue<string>> {\n const result: Array<SelectableValue<string>> = [];\n const groupedResults = new Map<string, Array<SelectableValue<string>>>();\n\n for (const value of values) {\n const groupLabel = value.group;\n if (groupLabel) {\n let group = groupedResults.get(groupLabel);\n\n if (!group) {\n group = [];\n groupedResults.set(groupLabel, group);\n result.push({ label: groupLabel, options: group });\n }\n\n group.push(value);\n } else {\n result.push(value);\n }\n }\n\n return result;\n}\n\nexport function getFuzzySearcher(haystack: string[], limit = 10_000) {\n const ufuzzy = new uFuzzy();\n\n const FIRST = Array.from({ length: Math.min(limit, haystack.length) }, (_, i) => i);\n\n // returns matched indices by quality\n return (search: string): number[] => {\n if (search === '') {\n return FIRST;\n }\n\n const [idxs, info, order] = ufuzzy.search(haystack, search);\n\n if (idxs) {\n if (info && order) {\n const outIdxs = Array(Math.min(order.length, limit));\n\n for (let i = 0; i < outIdxs.length; i++) {\n outIdxs[i] = info.idx[order[i]];\n }\n\n return outIdxs;\n }\n\n return idxs.slice(0, limit);\n }\n\n return [];\n };\n}\n"],"names":["value"],"mappings":";;;;;AASgB,SAAA,oBAAA,CAAqB,GAAqC,CAAqC,EAAA;AAC7G,EAAA,IAAI,MAAM,CAAG,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,OAAA,CAAQ,GAAG,CAAC,CAAA,CAAA;AACrB,CAAA;AAEO,SAAS,mBAAmB,KAAgB,EAAA;AAEjD,EAAA,MAAM,sBAAsB,MAAM;AAChC,IAAM,MAAA,IAAA,uBAAW,OAAQ,EAAA,CAAA;AACzB,IAAO,OAAA,CAAC,GAAWA,MAAyB,KAAA;AAC1C,MAAA,IAAI,OAAOA,MAAAA,KAAU,QAAYA,IAAAA,MAAAA,KAAU,IAAM,EAAA;AAC/C,QAAI,IAAA,IAAA,CAAK,GAAIA,CAAAA,MAAK,CAAG,EAAA;AACnB,UAAA,OAAA;AAAA,SACF;AACA,QAAA,IAAA,CAAK,IAAIA,MAAK,CAAA,CAAA;AAAA,OAChB;AACA,MAAOA,OAAAA,MAAAA,CAAAA;AAAA,KACT,CAAA;AAAA,GACF,CAAA;AAEA,EAAI,IAAA;AACF,IAAA,OAAO,IAAK,CAAA,SAAA,CAAU,KAAO,EAAA,mBAAA,EAAqB,CAAA,CAAA;AAAA,WAC3C,KAAP,EAAA;AACA,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA,CAAA;AAAA,GACrB;AAEA,EAAO,OAAA,EAAA,CAAA;AACT,CAAA;AAEO,SAAS,6BAA6B,OAAgC,EAAA;AAC3E,EAAO,OAAA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AAQ,KAAK,CAAC,CAAA,CAAA;AAEnD,QAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,OAAA,CAAQ,QAAQ,CAAK,EAAA,EAAA;AACvC,UAAQ,OAAA,CAAA,CAAA,CAAA,GAAK,IAAK,CAAA,GAAA,CAAI,KAAM,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,SAC9B;AAEA,QAAO,OAAA,OAAA,CAAA;AAAA,OACT;AAEA,MAAO,OAAA,IAAA,CAAK,KAAM,CAAA,CAAA,EAAG,KAAK,CAAA,CAAA;AAAA,KAC5B;AAEA,IAAA,OAAO,EAAC,CAAA;AAAA,GACV,CAAA;AACF;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,15 @@
1
1
  import * as _grafana_data from '@grafana/data';
2
- import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, UrlQueryMap, PanelPlugin, EventBus, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, PanelMenuItem, FieldConfigSource, PanelModel, AbsoluteTimeRange, InterpolateFunction, IconName as IconName$1, PageLayoutType, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
2
+ import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, EventBus, IconName, PageLayoutType, UrlQueryMap, PanelPlugin, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, PanelMenuItem, FieldConfigSource, PanelModel, AbsoluteTimeRange, InterpolateFunction, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
3
3
  import * as React$1 from 'react';
4
- import React__default, { CSSProperties, ComponentType } from 'react';
4
+ import React__default, { ComponentType, CSSProperties } from 'react';
5
5
  import * as rxjs from 'rxjs';
6
6
  import { Observable, Unsubscribable, MonoTypeOperatorFunction, Subscription, ReplaySubject } from 'rxjs';
7
7
  import * as _grafana_schema from '@grafana/schema';
8
8
  import { VariableType, VariableHide, TimeZone, DataTopic, DataQuery, DataSourceRef, VariableRefresh, LoadingState, DashboardCursorSync, MatcherConfig, TableFieldOptions } from '@grafana/schema';
9
9
  import { LocationService, VariableInterpolation } from '@grafana/runtime';
10
10
  import { Location } from 'history';
11
- import { PanelContext, IconName } from '@grafana/ui';
11
+ import { PanelContext, IconName as IconName$1 } from '@grafana/ui';
12
12
  import ReactGridLayout from 'react-grid-layout';
13
- import { RouteComponentProps } from 'react-router-dom';
14
13
  import { Options, FieldConfig as FieldConfig$1 } from '@grafana/schema/dist/esm/raw/composable/barchart/panelcfg/x/BarChartPanelCfg_types.gen';
15
14
  import { Options as Options$1 } from '@grafana/schema/dist/esm/raw/composable/bargauge/panelcfg/x/BarGaugePanelCfg_types.gen';
16
15
  import { Options as Options$2 } from '@grafana/schema/dist/esm/raw/composable/datagrid/panelcfg/x/DatagridPanelCfg_types.gen';
@@ -352,28 +351,6 @@ interface SceneUrlSyncOptions {
352
351
  createBrowserHistorySteps?: boolean;
353
352
  }
354
353
 
355
- /**
356
- *
357
- * @param path Url to append query params to
358
- * @param searchObject Query params of the URL
359
- * @param preserveParams Query params to preserve
360
- * @returns Url with query params
361
- */
362
- declare function getUrlWithAppState(path: string, searchObject: UrlQueryMap, preserveParams?: string[]): string;
363
-
364
- interface RuntimePanelPluginOptions {
365
- /**
366
- * Please specify a pluginId that is unlikely to collide with other plugins.
367
- */
368
- pluginId: string;
369
- plugin: PanelPlugin;
370
- }
371
- /**
372
- * Provides a way to register runtime panel plugins.
373
- * Please use a pluginId that is unlikely to collide with other plugins.
374
- */
375
- declare function registerRuntimePanelPlugin({ pluginId, plugin }: RuntimePanelPluginOptions): void;
376
-
377
354
  declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
378
355
  private _isActive;
379
356
  private _state;
@@ -470,6 +447,124 @@ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneOb
470
447
  */
471
448
  declare function useSceneObjectState<TState extends SceneObjectState>(model: SceneObject<TState>, options?: UseStateHookOptions): TState;
472
449
 
450
+ interface EmbeddedSceneState extends SceneObjectState {
451
+ /**
452
+ * The main content of the scene (usually a SceneFlexLayout)
453
+ */
454
+ body: SceneObject;
455
+ /**
456
+ * Top row of variable selectors, filters, time pickers and custom actions.
457
+ */
458
+ controls?: SceneObject[];
459
+ /**
460
+ * For interoperability (used from EmbeddedSceneWithContext)
461
+ */
462
+ context?: SceneObject;
463
+ }
464
+ declare class EmbeddedScene extends SceneObjectBase<EmbeddedSceneState> {
465
+ static Component: typeof EmbeddedSceneRenderer;
466
+ constructor(state: EmbeddedSceneState);
467
+ }
468
+ declare function EmbeddedSceneRenderer({ model }: SceneComponentProps<EmbeddedScene>): React__default.JSX.Element;
469
+
470
+ interface SceneRouteMatch<Params extends {
471
+ [K in keyof Params]?: string;
472
+ } = {}> {
473
+ params: Params;
474
+ isExact: boolean;
475
+ path: string;
476
+ url: string;
477
+ }
478
+ interface SceneAppState extends SceneObjectState {
479
+ pages: SceneAppPageLike[];
480
+ name?: string;
481
+ urlSyncOptions?: SceneUrlSyncOptions;
482
+ }
483
+ interface SceneAppRoute {
484
+ path: string;
485
+ page?: SceneAppPageLike;
486
+ drilldown?: SceneAppDrilldownView;
487
+ }
488
+ interface SceneAppPageState extends SceneObjectState {
489
+ /** Page title or tab label */
490
+ title: string;
491
+ /** Page subTitle */
492
+ subTitle?: string | React.ReactNode;
493
+ /**
494
+ * Customize title rendering.
495
+ * Please return an unstyled h1 tag here + any additional elements you need.
496
+ **/
497
+ renderTitle?: (title: string) => React.ReactNode;
498
+ /** For an image before title */
499
+ titleImg?: string;
500
+ /** For an icon before title or tab label */
501
+ titleIcon?: IconName;
502
+ /** For a tab label suffix */
503
+ tabSuffix?: ComponentType<{
504
+ className?: string;
505
+ }>;
506
+ url: string;
507
+ routePath?: string;
508
+ /** Array of scene object to be rendered at the top right of the page, inline with the page title */
509
+ controls?: SceneObject[];
510
+ hideFromBreadcrumbs?: boolean;
511
+ tabs?: SceneAppPageLike[];
512
+ getScene?: (routeMatch: SceneRouteMatch) => EmbeddedScene;
513
+ drilldowns?: SceneAppDrilldownView[];
514
+ getParentPage?: () => SceneAppPageLike;
515
+ preserveUrlKeys?: string[];
516
+ /**
517
+ * The current initialized scene, this is set by the framework after scene url initialization
518
+ **/
519
+ initializedScene?: SceneObject;
520
+ /**
521
+ * Function that returns a fallback scene app page,
522
+ * to be rendered when url does not match current page exactly or any of tabs or drilldowns.
523
+ */
524
+ getFallbackPage?: () => SceneAppPageLike;
525
+ layout?: PageLayoutType;
526
+ }
527
+ interface SceneAppPageLike extends SceneObject<SceneAppPageState>, DataRequestEnricher {
528
+ initializeScene(scene: SceneObject): void;
529
+ /**
530
+ * @internal. Please don't call this from plugin code.
531
+ * Will call the state.getScene function with the current routeMatch and will cache the resulting Scene using the routeMatch.url as key.
532
+ */
533
+ getScene(routeMatch: SceneRouteMatch): EmbeddedScene;
534
+ /**
535
+ * @internal. Please don't call this from plugin code.
536
+ * Get drilldown scene. Will call the drilldown.getPage function with the current routeMatch and will cache the resulting page using the routeMatch.url as key.
537
+ */
538
+ getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch): SceneAppPageLike;
539
+ }
540
+ interface SceneAppDrilldownView {
541
+ routePath: string;
542
+ defaultRoute?: boolean;
543
+ getPage: (routeMatch: SceneRouteMatch<any>, parent: SceneAppPageLike) => SceneAppPageLike;
544
+ }
545
+
546
+ /**
547
+ *
548
+ * @param path Url to append query params to
549
+ * @param searchObject Query params of the URL
550
+ * @param preserveParams Query params to preserve
551
+ * @returns Url with query params
552
+ */
553
+ declare function getUrlWithAppState(path: string, searchObject: UrlQueryMap, preserveParams?: string[]): string;
554
+
555
+ interface RuntimePanelPluginOptions {
556
+ /**
557
+ * Please specify a pluginId that is unlikely to collide with other plugins.
558
+ */
559
+ pluginId: string;
560
+ plugin: PanelPlugin;
561
+ }
562
+ /**
563
+ * Provides a way to register runtime panel plugins.
564
+ * Please use a pluginId that is unlikely to collide with other plugins.
565
+ */
566
+ declare function registerRuntimePanelPlugin({ pluginId, plugin }: RuntimePanelPluginOptions): void;
567
+
473
568
  declare function cloneSceneObjectState<TState extends SceneObjectState>(sceneState: TState, withState?: Partial<TState>): TState;
474
569
 
475
570
  declare abstract class RuntimeDataSource<TQuery extends DataQuery$1 = DataQuery$1> extends DataSourceApi<TQuery> {
@@ -1710,26 +1805,6 @@ interface UrlSyncContextProviderProps extends SceneUrlSyncOptions {
1710
1805
  */
1711
1806
  declare function UrlSyncContextProvider({ children, scene, updateUrlOnInit, createBrowserHistorySteps, }: UrlSyncContextProviderProps): React$1.ReactNode;
1712
1807
 
1713
- interface EmbeddedSceneState extends SceneObjectState {
1714
- /**
1715
- * The main content of the scene (usually a SceneFlexLayout)
1716
- */
1717
- body: SceneObject;
1718
- /**
1719
- * Top row of variable selectors, filters, time pickers and custom actions.
1720
- */
1721
- controls?: SceneObject[];
1722
- /**
1723
- * For interoperability (used from EmbeddedSceneWithContext)
1724
- */
1725
- context?: SceneObject;
1726
- }
1727
- declare class EmbeddedScene extends SceneObjectBase<EmbeddedSceneState> {
1728
- static Component: typeof EmbeddedSceneRenderer;
1729
- constructor(state: EmbeddedSceneState);
1730
- }
1731
- declare function EmbeddedSceneRenderer({ model }: SceneComponentProps<EmbeddedScene>): React__default.JSX.Element;
1732
-
1733
1808
  declare function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>): React__default.JSX.Element;
1734
1809
 
1735
1810
  interface VizPanelMenuState extends SceneObjectState {
@@ -1899,7 +1974,7 @@ declare class SceneCanvasText extends SceneObjectBase<SceneCanvasTextState> {
1899
1974
  }
1900
1975
 
1901
1976
  interface ToolbarButtonState extends SceneObjectState {
1902
- icon: IconName;
1977
+ icon: IconName$1;
1903
1978
  onClick: () => void;
1904
1979
  }
1905
1980
  declare class SceneToolbarButton extends SceneObjectBase<ToolbarButtonState> {
@@ -2255,82 +2330,6 @@ declare class SplitLayout extends SceneObjectBase<SplitLayoutState> {
2255
2330
  isDraggable(): boolean;
2256
2331
  }
2257
2332
 
2258
- interface SceneRouteMatch<Params extends {
2259
- [K in keyof Params]?: string;
2260
- } = {}> {
2261
- params: Params;
2262
- isExact: boolean;
2263
- path: string;
2264
- url: string;
2265
- }
2266
- interface SceneAppState extends SceneObjectState {
2267
- pages: SceneAppPageLike[];
2268
- name?: string;
2269
- urlSyncOptions?: SceneUrlSyncOptions;
2270
- }
2271
- interface SceneAppRoute {
2272
- path: string;
2273
- page?: SceneAppPageLike;
2274
- drilldown?: SceneAppDrilldownView;
2275
- }
2276
- interface SceneAppPageState extends SceneObjectState {
2277
- /** Page title or tab label */
2278
- title: string;
2279
- /** Page subTitle */
2280
- subTitle?: string | React.ReactNode;
2281
- /**
2282
- * Customize title rendering.
2283
- * Please return an unstyled h1 tag here + any additional elements you need.
2284
- **/
2285
- renderTitle?: (title: string) => React.ReactNode;
2286
- /** For an image before title */
2287
- titleImg?: string;
2288
- /** For an icon before title or tab label */
2289
- titleIcon?: IconName$1;
2290
- /** For a tab label suffix */
2291
- tabSuffix?: ComponentType<{
2292
- className?: string;
2293
- }>;
2294
- url: string;
2295
- routePath?: string;
2296
- /** Array of scene object to be rendered at the top right of the page, inline with the page title */
2297
- controls?: SceneObject[];
2298
- hideFromBreadcrumbs?: boolean;
2299
- tabs?: SceneAppPageLike[];
2300
- getScene?: (routeMatch: SceneRouteMatch) => EmbeddedScene;
2301
- drilldowns?: SceneAppDrilldownView[];
2302
- getParentPage?: () => SceneAppPageLike;
2303
- preserveUrlKeys?: string[];
2304
- /**
2305
- * The current initialized scene, this is set by the framework after scene url initialization
2306
- **/
2307
- initializedScene?: SceneObject;
2308
- /**
2309
- * Function that returns a fallback scene app page,
2310
- * to be rendered when url does not match current page exactly or any of tabs or drilldowns.
2311
- */
2312
- getFallbackPage?: () => SceneAppPageLike;
2313
- layout?: PageLayoutType;
2314
- }
2315
- interface SceneAppPageLike extends SceneObject<SceneAppPageState>, DataRequestEnricher {
2316
- initializeScene(scene: SceneObject): void;
2317
- /**
2318
- * @internal. Please don't call this from plugin code.
2319
- * Will call the state.getScene function with the current routeMatch and will cache the resulting Scene using the routeMatch.url as key.
2320
- */
2321
- getScene(routeMatch: SceneRouteMatch): EmbeddedScene;
2322
- /**
2323
- * @internal. Please don't call this from plugin code.
2324
- * Get drilldown scene. Will call the drilldown.getPage function with the current routeMatch and will cache the resulting page using the routeMatch.url as key.
2325
- */
2326
- getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch): SceneAppPageLike;
2327
- }
2328
- interface SceneAppDrilldownView {
2329
- routePath: string;
2330
- defaultRoute?: boolean;
2331
- getPage: (routeMatch: SceneRouteMatch<any>, parent: SceneAppPageLike) => SceneAppPageLike;
2332
- }
2333
-
2334
2333
  /**
2335
2334
  * Responsible for top level pages routing
2336
2335
  */
@@ -2358,10 +2357,7 @@ declare class SceneAppPage extends SceneObjectBase<SceneAppPageState> implements
2358
2357
  getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch<{}>): SceneAppPageLike;
2359
2358
  enrichDataRequest(source: SceneObject): Partial<_grafana_data.DataQueryRequest<_grafana_data.DataQuery>> | null;
2360
2359
  }
2361
- interface SceneAppPageRendererProps extends SceneComponentProps<SceneAppPage> {
2362
- routeProps: RouteComponentProps;
2363
- }
2364
- declare function SceneAppPageRenderer({ model, routeProps }: SceneAppPageRendererProps): React__default.JSX.Element;
2360
+ declare function SceneAppPageRenderer({ model }: SceneComponentProps<SceneAppPage>): React__default.JSX.Element;
2365
2361
 
2366
2362
  interface SceneReactObjectState<TProps = {}> extends SceneObjectState {
2367
2363
  /**
@@ -2381,7 +2377,7 @@ interface SceneReactObjectState<TProps = {}> extends SceneObjectState {
2381
2377
  * A utility object that can be used to render any React component or ReactNode
2382
2378
  */
2383
2379
  declare class SceneReactObject<TProps = {}> extends SceneObjectBase<SceneReactObjectState<TProps>> {
2384
- static Component: ({ model }: SceneComponentProps<SceneReactObject>) => string | number | true | Iterable<React__default.ReactNode> | React__default.JSX.Element | null;
2380
+ static Component: ({ model }: SceneComponentProps<SceneReactObject>) => string | number | true | React__default.JSX.Element | Iterable<React__default.ReactNode> | null;
2385
2381
  }
2386
2382
 
2387
2383
  type StandardFieldConfigInterface<T, C, Prefix extends string> = {
@@ -2725,7 +2721,7 @@ interface ControlsLabelProps {
2725
2721
  description?: string;
2726
2722
  isLoading?: boolean;
2727
2723
  error?: string;
2728
- icon?: IconName$1;
2724
+ icon?: IconName;
2729
2725
  layout?: ControlsLayout;
2730
2726
  onCancel?: () => void;
2731
2727
  onRemove?: () => void;