@grafana/scenes 5.25.0 → 5.25.1--canary.858.11930656504.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/dist/esm/behaviors/SceneQueryController.js +60 -5
  3. package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
  4. package/dist/esm/behaviors/SceneRenderProfiler.js +169 -0
  5. package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -0
  6. package/dist/esm/components/SceneRefreshPicker.js +6 -1
  7. package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
  8. package/dist/esm/components/VizPanel/VizPanel.js +9 -6
  9. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  10. package/dist/esm/components/layout/grid/SceneGridRow.js +2 -1
  11. package/dist/esm/components/layout/grid/SceneGridRow.js.map +1 -1
  12. package/dist/esm/core/SceneTimeRange.js +3 -0
  13. package/dist/esm/core/SceneTimeRange.js.map +1 -1
  14. package/dist/esm/core/sceneGraph/getQueryController.js +19 -0
  15. package/dist/esm/core/sceneGraph/getQueryController.js.map +1 -0
  16. package/dist/esm/core/sceneGraph/index.js +3 -3
  17. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  18. package/dist/esm/core/sceneGraph/sceneGraph.js +1 -26
  19. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  20. package/dist/esm/index.js.map +1 -1
  21. package/dist/esm/querying/SceneQueryRunner.js +1 -3
  22. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  23. package/dist/esm/querying/registerQueryWithController.js +18 -2
  24. package/dist/esm/querying/registerQueryWithController.js.map +1 -1
  25. package/dist/esm/utils/getDataSource.js +17 -1
  26. package/dist/esm/utils/getDataSource.js.map +1 -1
  27. package/dist/esm/variables/VariableDependencyConfig.js +29 -0
  28. package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
  29. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +12 -8
  30. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  31. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +1 -4
  32. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
  33. package/dist/esm/variables/components/VariableValueSelect.js +5 -0
  34. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  35. package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
  36. package/dist/esm/variables/utils.js.map +1 -1
  37. package/dist/esm/variables/variants/TestVariable.js.map +1 -1
  38. package/dist/index.d.ts +49 -32
  39. package/dist/index.js +788 -509
  40. package/dist/index.js.map +1 -1
  41. package/package.json +2 -2
@@ -4,6 +4,7 @@ import { Select, MultiSelect, useTheme2, getSelectStyles, useStyles2, Checkbox,
4
4
  import { selectors } from '@grafana/e2e-selectors';
5
5
  import { cx, css } from '@emotion/css';
6
6
  import { getOptionSearcher } from './getOptionSearcher.js';
7
+ import { sceneGraph } from '../../core/sceneGraph/index.js';
7
8
 
8
9
  var __defProp = Object.defineProperty;
9
10
  var __defProps = Object.defineProperties;
@@ -58,6 +59,7 @@ function VariableValueSelect({ model }) {
58
59
  const [inputValue, setInputValue] = useState("");
59
60
  const [hasCustomValue, setHasCustomValue] = useState(false);
60
61
  const selectValue = toSelectableValue(value, String(text));
62
+ const queryController = sceneGraph.getQueryController(model);
61
63
  const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
62
64
  const onInputChange = (value2, { action }) => {
63
65
  if (action === "input-change") {
@@ -97,6 +99,7 @@ function VariableValueSelect({ model }) {
97
99
  "data-testid": selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
98
100
  onChange: (newValue) => {
99
101
  model.changeValueTo(newValue.value, newValue.label);
102
+ queryController == null ? void 0 : queryController.startProfile(model);
100
103
  if (hasCustomValue !== newValue.__isNew__) {
101
104
  setHasCustomValue(newValue.__isNew__);
102
105
  }
@@ -108,6 +111,7 @@ function VariableValueSelectMulti({ model }) {
108
111
  const arrayValue = useMemo(() => isArray(value) ? value : [value], [value]);
109
112
  const [uncommittedValue, setUncommittedValue] = useState(arrayValue);
110
113
  const [inputValue, setInputValue] = useState("");
114
+ const queryController = sceneGraph.getQueryController(model);
111
115
  const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
112
116
  useEffect(() => {
113
117
  setUncommittedValue(arrayValue);
@@ -153,6 +157,7 @@ function VariableValueSelectMulti({ model }) {
153
157
  onInputChange,
154
158
  onBlur: () => {
155
159
  model.changeValueTo(uncommittedValue);
160
+ queryController == null ? void 0 : queryController.startProfile(model);
156
161
  },
157
162
  filterOption: filterNoOp,
158
163
  "data-testid": selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -1 +1 @@
1
- {"version":3,"file":"VariableValueSelect.js","sources":["../../../../src/variables/components/VariableValueSelect.tsx"],"sourcesContent":["import { isArray } from 'lodash';\nimport React, { RefCallback, useEffect, useMemo, useState } from 'react';\n\n//@ts-ignore\nimport { Checkbox, InputActionMeta, MultiSelect, Select, ToggleAllState, getSelectStyles, useStyles2, useTheme2 } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { MultiValueVariable } from '../variants/MultiValueVariable';\nimport { VariableValue, VariableValueSingle } from '../types';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { getOptionSearcher } from './getOptionSearcher';\n\nconst filterNoOp = () => true;\n\nconst filterAll = (v: SelectableValue<VariableValueSingle>) => v.value !== '$__all'\n\nconst determineToggleAllState = (\n selectedValues: Array<SelectableValue<VariableValueSingle>>,\n options: Array<SelectableValue<VariableValueSingle>>\n) => {\n if (selectedValues.length === options.filter(filterAll).length) {\n return ToggleAllState.allSelected;\n } else if (\n selectedValues.length === 0 ||\n (selectedValues.length === 1 && selectedValues[0] && selectedValues[0].value === '$__all')\n ) {\n return ToggleAllState.noneSelected;\n } else {\n return ToggleAllState.indeterminate;\n }\n};\n\nexport function toSelectableValue<T>(value: T, label?: string): SelectableValue<T> {\n return {\n value,\n label: label ?? String(value),\n };\n}\n\nexport function VariableValueSelect({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const [inputValue, setInputValue] = useState('');\n const [hasCustomValue, setHasCustomValue] = useState(false);\n const selectValue = toSelectableValue(value, String(text));\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n return value;\n };\n\n const filteredOptions = optionSearcher(inputValue);\n\n const onOpenMenu = () => {\n if (hasCustomValue) {\n setInputValue(String(text));\n }\n };\n\n const onCloseMenu = () => {\n setInputValue('');\n };\n\n return (\n <Select<VariableValue>\n id={key}\n isValidNewOption={(inputValue) => inputValue.trim().length > 0}\n placeholder=\"Select value\"\n width=\"auto\"\n disabled={isReadOnly}\n value={selectValue}\n inputValue={inputValue}\n allowCustomValue={allowCustomValue}\n virtualized\n filterOption={filterNoOp}\n tabSelectsValue={false}\n onInputChange={onInputChange}\n onOpenMenu={onOpenMenu}\n onCloseMenu={onCloseMenu}\n options={filteredOptions}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`)}\n onChange={(newValue) => {\n model.changeValueTo(newValue.value!, newValue.label!);\n\n if (hasCustomValue !== newValue.__isNew__) {\n setHasCustomValue(newValue.__isNew__);\n }\n }}\n />\n );\n}\n\nexport function VariableValueSelectMulti({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const arrayValue = useMemo(() => (isArray(value) ? value : [value]), [value]);\n // To not trigger queries on every selection we store this state locally here and only update the variable onBlur\n const [uncommittedValue, setUncommittedValue] = useState(arrayValue);\n const [inputValue, setInputValue] = useState('');\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n // Detect value changes outside\n useEffect(() => {\n setUncommittedValue(arrayValue);\n }, [arrayValue]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n if (action === 'input-blur') {\n setInputValue('');\n return '';\n }\n\n return inputValue;\n };\n\n const placeholder = options.length > 0 ? 'Select value' : '';\n const filteredOptions = optionSearcher(inputValue);\n\n return (\n <MultiSelect<VariableValueSingle>\n id={key}\n placeholder={placeholder}\n width=\"auto\"\n inputValue={inputValue}\n disabled={isReadOnly}\n value={uncommittedValue}\n noMultiValueWrap={true}\n maxVisibleValues={maxVisibleValues ?? 5}\n tabSelectsValue={false}\n virtualized\n allowCustomValue={allowCustomValue}\n //@ts-ignore\n toggleAllOptions={{\n enabled: true,\n optionsFilter: filterAll,\n determineToggleAllState: determineToggleAllState,\n }}\n options={filteredOptions}\n closeMenuOnSelect={false}\n components={{ Option: OptionWithCheckbox }}\n isClearable={true}\n hideSelectedOptions={false}\n onInputChange={onInputChange}\n onBlur={() => {\n model.changeValueTo(uncommittedValue);\n }}\n filterOption={filterNoOp}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`)}\n onChange={(newValue, action) => {\n if (action.action === 'clear' && noValueOnClear) {\n model.changeValueTo([]);\n }\n setUncommittedValue(newValue.map((x) => x.value!));\n }}\n />\n );\n}\n\ninterface SelectMenuOptionProps<T> {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n innerProps: JSX.IntrinsicElements['div'];\n innerRef: RefCallback<HTMLDivElement>;\n renderOptionLabel?: (value: SelectableValue<T>) => JSX.Element;\n data: SelectableValue<T>;\n indeterminate: boolean; \n}\n\nexport const OptionWithCheckbox = ({\n children,\n data,\n innerProps,\n innerRef,\n isFocused,\n isSelected,\n indeterminate,\n renderOptionLabel,\n}: React.PropsWithChildren<SelectMenuOptionProps<unknown>>) => {\n // We are removing onMouseMove and onMouseOver from innerProps because they cause the whole\n // list to re-render everytime the user hovers over an option. This is a performance issue.\n // See https://github.com/JedWatson/react-select/issues/3128#issuecomment-451936743\n const { onMouseMove, onMouseOver, ...rest } = innerProps;\n const theme = useTheme2();\n const selectStyles = getSelectStyles(theme);\n const optionStyles = useStyles2(getOptionStyles);\n\n return (\n <div\n ref={innerRef}\n className={cx(selectStyles.option, isFocused && selectStyles.optionFocused)}\n {...rest}\n // TODO: use below selector once we update grafana dependencies to ^11.1.0\n // data-testid={selectors.components.Select.option}\n data-testid=\"data-testid Select option\"\n title={data.title}\n >\n <div className={optionStyles.checkbox}>\n <Checkbox indeterminate={indeterminate} value={isSelected} />\n </div>\n <div\n className={selectStyles.optionBody}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(\n data.label ?? String(data.value)\n )}\n >\n <span>{children}</span>\n </div>\n </div>\n );\n};\n\nOptionWithCheckbox.displayName = 'SelectMenuOptions';\n\nconst getOptionStyles = (theme: GrafanaTheme2) => ({\n checkbox: css({\n marginRight: theme.spacing(2),\n }),\n});\n\nexport function renderSelectForVariable(model: MultiValueVariable) {\n if (model.state.isMulti) {\n return <VariableValueSelectMulti model={model} />;\n } else {\n return <VariableValueSelect model={model} />;\n }\n}\n"],"names":["value","inputValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,aAAa,MAAM,IAAA,CAAA;AAEzB,MAAM,SAAY,GAAA,CAAC,CAA4C,KAAA,CAAA,CAAE,KAAU,KAAA,QAAA,CAAA;AAE3E,MAAM,uBAAA,GAA0B,CAC9B,cAAA,EACA,OACG,KAAA;AACH,EAAA,IAAI,eAAe,MAAW,KAAA,OAAA,CAAQ,MAAO,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ect.tsx"],"sourcesContent":["import { isArray } from 'lodash';\nimport React, { RefCallback, useEffect, useMemo, useState } from 'react';\nimport {\n Checkbox,\n InputActionMeta,\n MultiSelect,\n Select,\n //@ts-ignore\n ToggleAllState,\n getSelectStyles,\n useStyles2,\n useTheme2,\n} from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { MultiValueVariable } from '../variants/MultiValueVariable';\nimport { VariableValue, VariableValueSingle } from '../types';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { getOptionSearcher } from './getOptionSearcher';\nimport { sceneGraph } from '../../core/sceneGraph';\n\nconst filterNoOp = () => true;\n\nconst filterAll = (v: SelectableValue<VariableValueSingle>) => v.value !== '$__all';\n\nconst determineToggleAllState = (\n selectedValues: Array<SelectableValue<VariableValueSingle>>,\n options: Array<SelectableValue<VariableValueSingle>>\n) => {\n if (selectedValues.length === options.filter(filterAll).length) {\n return ToggleAllState.allSelected;\n } else if (\n selectedValues.length === 0 ||\n (selectedValues.length === 1 && selectedValues[0] && selectedValues[0].value === '$__all')\n ) {\n return ToggleAllState.noneSelected;\n } else {\n return ToggleAllState.indeterminate;\n }\n};\n\nexport function toSelectableValue<T>(value: T, label?: string): SelectableValue<T> {\n return {\n value,\n label: label ?? String(value),\n };\n}\n\nexport function VariableValueSelect({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const [inputValue, setInputValue] = useState('');\n const [hasCustomValue, setHasCustomValue] = useState(false);\n const selectValue = toSelectableValue(value, String(text));\n const queryController = sceneGraph.getQueryController(model);\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n return value;\n };\n\n const filteredOptions = optionSearcher(inputValue);\n\n const onOpenMenu = () => {\n if (hasCustomValue) {\n setInputValue(String(text));\n }\n };\n\n const onCloseMenu = () => {\n setInputValue('');\n };\n\n return (\n <Select<VariableValue>\n id={key}\n isValidNewOption={(inputValue) => inputValue.trim().length > 0}\n placeholder=\"Select value\"\n width=\"auto\"\n disabled={isReadOnly}\n value={selectValue}\n inputValue={inputValue}\n allowCustomValue={allowCustomValue}\n virtualized\n filterOption={filterNoOp}\n tabSelectsValue={false}\n onInputChange={onInputChange}\n onOpenMenu={onOpenMenu}\n onCloseMenu={onCloseMenu}\n options={filteredOptions}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`)}\n onChange={(newValue) => {\n model.changeValueTo(newValue.value!, newValue.label!);\n queryController?.startProfile(model);\n\n if (hasCustomValue !== newValue.__isNew__) {\n setHasCustomValue(newValue.__isNew__);\n }\n }}\n />\n );\n}\n\nexport function VariableValueSelectMulti({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const arrayValue = useMemo(() => (isArray(value) ? value : [value]), [value]);\n // To not trigger queries on every selection we store this state locally here and only update the variable onBlur\n const [uncommittedValue, setUncommittedValue] = useState(arrayValue);\n const [inputValue, setInputValue] = useState('');\n const queryController = sceneGraph.getQueryController(model);\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n // Detect value changes outside\n useEffect(() => {\n setUncommittedValue(arrayValue);\n }, [arrayValue]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n if (action === 'input-blur') {\n setInputValue('');\n return '';\n }\n\n return inputValue;\n };\n\n const placeholder = options.length > 0 ? 'Select value' : '';\n const filteredOptions = optionSearcher(inputValue);\n\n return (\n <MultiSelect<VariableValueSingle>\n id={key}\n placeholder={placeholder}\n width=\"auto\"\n inputValue={inputValue}\n disabled={isReadOnly}\n value={uncommittedValue}\n noMultiValueWrap={true}\n maxVisibleValues={maxVisibleValues ?? 5}\n tabSelectsValue={false}\n virtualized\n allowCustomValue={allowCustomValue}\n //@ts-ignore\n toggleAllOptions={{\n enabled: true,\n optionsFilter: filterAll,\n determineToggleAllState: determineToggleAllState,\n }}\n options={filteredOptions}\n closeMenuOnSelect={false}\n components={{ Option: OptionWithCheckbox }}\n isClearable={true}\n hideSelectedOptions={false}\n onInputChange={onInputChange}\n onBlur={() => {\n model.changeValueTo(uncommittedValue);\n queryController?.startProfile(model);\n }}\n filterOption={filterNoOp}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`)}\n onChange={(newValue, action) => {\n if (action.action === 'clear' && noValueOnClear) {\n model.changeValueTo([]);\n }\n setUncommittedValue(newValue.map((x) => x.value!));\n }}\n />\n );\n}\n\ninterface SelectMenuOptionProps<T> {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n innerProps: JSX.IntrinsicElements['div'];\n innerRef: RefCallback<HTMLDivElement>;\n renderOptionLabel?: (value: SelectableValue<T>) => JSX.Element;\n data: SelectableValue<T>;\n indeterminate: boolean;\n}\n\nexport const OptionWithCheckbox = ({\n children,\n data,\n innerProps,\n innerRef,\n isFocused,\n isSelected,\n indeterminate,\n renderOptionLabel,\n}: React.PropsWithChildren<SelectMenuOptionProps<unknown>>) => {\n // We are removing onMouseMove and onMouseOver from innerProps because they cause the whole\n // list to re-render everytime the user hovers over an option. This is a performance issue.\n // See https://github.com/JedWatson/react-select/issues/3128#issuecomment-451936743\n const { onMouseMove, onMouseOver, ...rest } = innerProps;\n const theme = useTheme2();\n const selectStyles = getSelectStyles(theme);\n const optionStyles = useStyles2(getOptionStyles);\n\n return (\n <div\n ref={innerRef}\n className={cx(selectStyles.option, isFocused && selectStyles.optionFocused)}\n {...rest}\n // TODO: use below selector once we update grafana dependencies to ^11.1.0\n // data-testid={selectors.components.Select.option}\n data-testid=\"data-testid Select option\"\n title={data.title}\n >\n <div className={optionStyles.checkbox}>\n <Checkbox indeterminate={indeterminate} value={isSelected} />\n </div>\n <div\n className={selectStyles.optionBody}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(\n data.label ?? String(data.value)\n )}\n >\n <span>{children}</span>\n </div>\n </div>\n );\n};\n\nOptionWithCheckbox.displayName = 'SelectMenuOptions';\n\nconst getOptionStyles = (theme: GrafanaTheme2) => ({\n checkbox: css({\n marginRight: theme.spacing(2),\n }),\n});\n\nexport function renderSelectForVariable(model: MultiValueVariable) {\n if (model.state.isMulti) {\n return <VariableValueSelectMulti model={model} />;\n } else {\n return <VariableValueSelect model={model} />;\n }\n}\n"],"names":["value","inputValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,aAAa,MAAM,IAAA,CAAA;AAEzB,MAAM,SAAY,GAAA,CAAC,CAA4C,KAAA,CAAA,CAAE,KAAU,KAAA,QAAA,CAAA;AAE3E,MAAM,uBAAA,GAA0B,CAC9B,cAAA,EACA,OACG,KAAA;AACH,EAAA,IAAI,eAAe,MAAW,KAAA,OAAA,CAAQ,MAAO,CAAA,SAAS,EAAE,MAAQ,EAAA;AAC9D,IAAA,OAAO,cAAe,CAAA,WAAA,CAAA;AAAA,GAEtB,MAAA,IAAA,cAAA,CAAe,MAAW,KAAA,CAAA,IACzB,cAAe,CAAA,MAAA,KAAW,CAAK,IAAA,cAAA,CAAe,CAAM,CAAA,IAAA,cAAA,CAAe,CAAG,CAAA,CAAA,KAAA,KAAU,QACjF,EAAA;AACA,IAAA,OAAO,cAAe,CAAA,YAAA,CAAA;AAAA,GACjB,MAAA;AACL,IAAA,OAAO,cAAe,CAAA,aAAA,CAAA;AAAA,GACxB;AACF,CAAA,CAAA;AAEgB,SAAA,iBAAA,CAAqB,OA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A,EAAA;AAAA,IAAI,WAAW,YAAa,CAAA,QAAA;AAAA,GAAA,kBAC1B,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,IAAS,aAAA;AAAA,IAA8B,KAAO,EAAA,UAAA;AAAA,GAAY,CAC7D,mBACC,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IACC,WAAW,YAAa,CAAA,UAAA;AAAA,IACxB,aAAa,EAAA,SAAA,CAAU,KAAM,CAAA,SAAA,CAAU,OAAQ,CAAA,mCAAA;AAAA,MAAA,CAC7C,EAAK,GAAA,IAAA,CAAA,KAAA,KAAL,IAAc,GAAA,EAAA,GAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,KACjC;AAAA,GAAA,kBAEC,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAM,QAAS,CAClB,CACF,CAAA,CAAA;AAEJ,EAAA;AAEA,kBAAA,CAAmB,WAAc,GAAA,mBAAA,CAAA;AAEjC,MAAM,eAAA,GAAkB,CAAC,KAA0B,MAAA;AAAA,EACjD,UAAU,GAAI,CAAA;AAAA,IACZ,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GAC7B,CAAA;AACH,CAAA,CAAA,CAAA;AAEO,SAAS,wBAAwB,KAA2B,EAAA;AACjE,EAAI,IAAA,KAAA,CAAM,MAAM,OAAS,EAAA;AACvB,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,wBAAA,EAAA;AAAA,MAAyB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC1C,MAAA;AACL,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA;AAAA,MAAoB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SceneVariableSet.js","sources":["../../../../src/variables/sets/SceneVariableSet.ts"],"sourcesContent":["import { VariableRefresh } from '@grafana/data';\nimport { Unsubscribable } from 'rxjs';\nimport { sceneGraph } from '../../core/sceneGraph';\n\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneObject } from '../../core/types';\nimport { writeSceneLog } from '../../utils/writeSceneLog';\nimport {\n SceneVariable,\n SceneVariableDependencyConfigLike,\n SceneVariables,\n SceneVariableSetState,\n SceneVariableValueChangedEvent,\n} from '../types';\nimport { VariableValueRecorder } from '../VariableValueRecorder';\n\nexport class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> implements SceneVariables {\n /** Variables that have changed in since the activation or since the first manual value change */\n private _variablesThatHaveChanged = new Set<SceneVariable>();\n\n /** Variables that are scheduled to be validated and updated */\n private _variablesToUpdate = new Set<SceneVariable>();\n\n /** Variables currently updating */\n private _updating = new Map<SceneVariable, VariableUpdateInProgress>();\n\n private _variableValueRecorder = new VariableValueRecorder();\n\n /**\n * This makes sure SceneVariableSet's higher up in the chain notify us when parent level variables complete update batches.\n **/\n protected _variableDependency = new SceneVariableSetVariableDependencyHandler(\n this._handleParentVariableUpdatesCompleted.bind(this)\n );\n\n public getByName(name: string): SceneVariable | undefined {\n // TODO: Replace with index\n return this.state.variables.find((x) => x.state.name === name);\n }\n\n public constructor(state: SceneVariableSetState) {\n super(state);\n\n this.addActivationHandler(this._onActivate);\n }\n\n /**\n * Subscribes to child variable value changes, and starts the variable value validation process\n */\n private _onActivate = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n // Subscribe to changes to child variables\n this._subs.add(\n this.subscribeToEvent(SceneVariableValueChangedEvent, (event) => this._handleVariableValueChanged(event.payload))\n );\n\n this._subs.add(\n timeRange.subscribeToState(() => {\n this._refreshTimeRangeBasedVariables();\n })\n );\n\n // Subscribe to state changes\n this._subs.add(this.subscribeToState(this._onStateChanged));\n\n this._checkForVariablesThatChangedWhileInactive();\n\n // Add all variables that need updating to queue\n for (const variable of this.state.variables) {\n if (this._variableNeedsUpdate(variable)) {\n this._variablesToUpdate.add(variable);\n }\n }\n\n this._updateNextBatch();\n\n // Return deactivation handler;\n return this._onDeactivate;\n };\n\n /**\n * Add all variables that depend on the changed variable to the update queue\n */\n private _refreshTimeRangeBasedVariables() {\n for (const variable of this.state.variables) {\n if ('refresh' in variable.state && variable.state.refresh === VariableRefresh.onTimeRangeChanged) {\n this._variablesToUpdate.add(variable);\n }\n }\n\n this._updateNextBatch();\n }\n\n /**\n * Cancel all currently running updates\n */\n private _onDeactivate = () => {\n for (const update of this._updating.values()) {\n update.subscription?.unsubscribe();\n }\n\n // Remember current variable values\n for (const variable of this.state.variables) {\n // if the current variable is not in queue to update and validate and not being actively updated then the value is ok\n if (!this._variablesToUpdate.has(variable) && !this._updating.has(variable)) {\n this._variableValueRecorder.recordCurrentValue(variable);\n }\n }\n\n this._variablesToUpdate.clear();\n this._updating.clear();\n };\n\n /**\n * Look for new variables that need to be initialized\n */\n private _onStateChanged = (newState: SceneVariableSetState, oldState: SceneVariableSetState) => {\n const variablesToUpdateCountStart = this._variablesToUpdate.size;\n\n // Check for removed variables\n for (const variable of oldState.variables) {\n if (!newState.variables.includes(variable)) {\n const updating = this._updating.get(variable);\n if (updating?.subscription) {\n updating.subscription.unsubscribe();\n }\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n }\n }\n\n // Check for new variables\n for (const variable of newState.variables) {\n if (!oldState.variables.includes(variable)) {\n if (this._variableNeedsUpdate(variable)) {\n this._variablesToUpdate.add(variable);\n }\n }\n }\n\n // Only start a new batch if there was no batch already running\n if (variablesToUpdateCountStart === 0 && this._variablesToUpdate.size > 0) {\n this._updateNextBatch();\n }\n };\n\n /**\n * If variables changed while in in-active state we don't get any change events, so we need to check for that here.\n */\n private _checkForVariablesThatChangedWhileInactive() {\n if (!this._variableValueRecorder.hasValues()) {\n return;\n }\n\n for (const variable of this.state.variables) {\n if (this._variableValueRecorder.hasValueChanged(variable)) {\n writeVariableTraceLog(variable, 'Changed while in-active');\n this._addDependentVariablesToUpdateQueue(variable);\n }\n }\n }\n\n private _variableNeedsUpdate(variable: SceneVariable): boolean {\n if (variable.isLazy) {\n return false;\n }\n\n if (!variable.validateAndUpdate) {\n return false;\n }\n\n // If we have recorded valid value (even if it has changed since we do not need to re-validate this variable)\n if (this._variableValueRecorder.hasRecordedValue(variable)) {\n writeVariableTraceLog(variable, 'Skipping updateAndValidate current value valid');\n return false;\n }\n\n return true;\n }\n\n /**\n * This loops through variablesToUpdate and update all that can.\n * If one has a dependency that is currently in variablesToUpdate it will be skipped for now.\n */\n private _updateNextBatch() {\n for (const variable of this._variablesToUpdate) {\n if (!variable.validateAndUpdate) {\n throw new Error('Variable added to variablesToUpdate but does not have validateAndUpdate');\n }\n\n // Ignore it if it's already started\n if (this._updating.has(variable)) {\n continue;\n }\n\n // Wait for variables that has dependencies that also needs updates\n if (sceneGraph.hasVariableDependencyInLoadingState(variable)) {\n continue;\n }\n\n const variableToUpdate: VariableUpdateInProgress = {\n variable,\n };\n\n this._updating.set(variable, variableToUpdate);\n writeVariableTraceLog(variable, 'updateAndValidate started');\n\n variableToUpdate.subscription = variable.validateAndUpdate().subscribe({\n next: () => this._validateAndUpdateCompleted(variable),\n complete: () => this._validateAndUpdateCompleted(variable),\n error: (err) => this._handleVariableError(variable, err),\n });\n }\n }\n\n /**\n * A variable has completed its update process. This could mean that variables that depend on it can now be updated in turn.\n */\n private _validateAndUpdateCompleted(variable: SceneVariable) {\n if (!this._updating.has(variable)) {\n return;\n }\n\n const update = this._updating.get(variable);\n update?.subscription?.unsubscribe();\n\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n\n writeVariableTraceLog(variable, 'updateAndValidate completed');\n\n this._notifyDependentSceneObjects(variable);\n this._updateNextBatch();\n }\n\n public cancel(variable: SceneVariable) {\n const update = this._updating.get(variable);\n update?.subscription?.unsubscribe();\n\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n }\n\n private _handleVariableError(variable: SceneVariable, err: Error) {\n const update = this._updating.get(variable);\n update?.subscription?.unsubscribe();\n\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n\n variable.setState({ loading: false, error: err.message });\n\n console.error('SceneVariableSet updateAndValidate error', err);\n\n writeVariableTraceLog(variable, 'updateAndValidate error', err);\n\n this._notifyDependentSceneObjects(variable);\n this._updateNextBatch();\n }\n\n private _handleVariableValueChanged(variableThatChanged: SceneVariable) {\n this._variablesThatHaveChanged.add(variableThatChanged);\n this._addDependentVariablesToUpdateQueue(variableThatChanged);\n\n // Ignore this change if it is currently updating\n if (!this._updating.has(variableThatChanged)) {\n this._updateNextBatch();\n this._notifyDependentSceneObjects(variableThatChanged);\n }\n }\n\n /**\n * This is called by any parent level variable set to notify scene that an update batch is completed.\n * This is the main mechanism lower level variable set's react to changes on higher levels.\n */\n private _handleParentVariableUpdatesCompleted(variable: SceneVariable, hasChanged: boolean) {\n // First loop through changed variables and add any of our variables that depend on the higher level variable to the update queue\n if (hasChanged) {\n this._addDependentVariablesToUpdateQueue(variable);\n }\n\n // If we have variables to update but none are currently updating kick of a new update batch\n if (this._variablesToUpdate.size > 0 && this._updating.size === 0) {\n this._updateNextBatch();\n }\n }\n\n private _addDependentVariablesToUpdateQueue(variableThatChanged: SceneVariable) {\n for (const otherVariable of this.state.variables) {\n if (otherVariable.variableDependency) {\n if (otherVariable.variableDependency.hasDependencyOn(variableThatChanged.state.name)) {\n writeVariableTraceLog(otherVariable, 'Added to update queue, dependant variable value changed');\n\n if (this._updating.has(otherVariable) && otherVariable.onCancel) {\n otherVariable.onCancel();\n }\n\n this._variablesToUpdate.add(otherVariable);\n }\n }\n }\n }\n\n /**\n * Walk scene object graph and update all objects that depend on variables that have changed\n */\n private _notifyDependentSceneObjects(variable: SceneVariable) {\n if (!this.parent) {\n return;\n }\n\n this._traverseSceneAndNotify(this.parent, variable, this._variablesThatHaveChanged.has(variable));\n this._variablesThatHaveChanged.delete(variable);\n }\n\n /**\n * Recursivly walk the full scene object graph and notify all objects with dependencies that include any of changed variables\n */\n private _traverseSceneAndNotify(sceneObject: SceneObject, variable: SceneVariable, hasChanged: boolean) {\n // No need to notify variables under this SceneVariableSet\n if (this === sceneObject) {\n return;\n }\n\n // Skip non active scene objects\n if (!sceneObject.isActive) {\n return;\n }\n\n // If we find a nested SceneVariableSet that has a variable with the same name we stop the traversal\n if (sceneObject.state.$variables && sceneObject.state.$variables !== this) {\n const localVar = sceneObject.state.$variables.getByName(variable.state.name);\n if (localVar) {\n return;\n }\n }\n\n if (sceneObject.variableDependency) {\n sceneObject.variableDependency.variableUpdateCompleted(variable, hasChanged);\n }\n\n sceneObject.forEachChild((child) => this._traverseSceneAndNotify(child, variable, hasChanged));\n }\n\n /**\n * Return true if variable is waiting to update or currently updating.\n * It also returns true if a dependency of the variable is loading.\n *\n * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.\n */\n public isVariableLoadingOrWaitingToUpdate(variable: SceneVariable) {\n if (variable.isAncestorLoading && variable.isAncestorLoading()) {\n return true;\n }\n\n if (this._variablesToUpdate.has(variable) || this._updating.has(variable)) {\n return true;\n }\n\n // Last scenario is to check the variable's own dependencies as well\n return sceneGraph.hasVariableDependencyInLoadingState(variable);\n }\n}\n\nexport interface VariableUpdateInProgress {\n variable: SceneVariable;\n subscription?: Unsubscribable;\n}\n\nfunction writeVariableTraceLog(variable: SceneVariable, message: string, err?: Error) {\n if (err) {\n writeSceneLog('SceneVariableSet', `Variable[${variable.state.name}]: ${message}`, err);\n } else {\n writeSceneLog('SceneVariableSet', `Variable[${variable.state.name}]: ${message}`);\n }\n}\n\nclass SceneVariableSetVariableDependencyHandler implements SceneVariableDependencyConfigLike {\n public constructor(private _variableUpdatesCompleted: (variable: SceneVariable, hasChanged: boolean) => void) {}\n\n private _emptySet = new Set<string>();\n\n public getNames(): Set<string> {\n return this._emptySet;\n }\n\n public hasDependencyOn(name: string): boolean {\n return false;\n }\n\n public variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void {\n this._variableUpdatesCompleted(variable, hasChanged);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAgBO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afana/data';\nimport { Unsubscribable } from 'rxjs';\nimport { sceneGraph } from '../../core/sceneGraph';\n\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneObject } from '../../core/types';\nimport { writeSceneLog } from '../../utils/writeSceneLog';\nimport {\n SceneVariable,\n SceneVariableDependencyConfigLike,\n SceneVariables,\n SceneVariableSetState,\n SceneVariableValueChangedEvent,\n} from '../types';\nimport { VariableValueRecorder } from '../VariableValueRecorder';\n\nexport class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> implements SceneVariables {\n /** Variables that have changed in since the activation or since the first manual value change */\n private _variablesThatHaveChanged = new Set<SceneVariable>();\n\n /** Variables that are scheduled to be validated and updated */\n private _variablesToUpdate = new Set<SceneVariable>();\n\n /** Variables currently updating */\n private _updating = new Map<SceneVariable, VariableUpdateInProgress>();\n\n private _variableValueRecorder = new VariableValueRecorder();\n\n /**\n * This makes sure SceneVariableSet's higher up in the chain notify us when parent level variables complete update batches.\n **/\n protected _variableDependency = new SceneVariableSetVariableDependencyHandler(\n this._handleParentVariableUpdatesCompleted.bind(this)\n );\n\n public getByName(name: string): SceneVariable | undefined {\n // TODO: Replace with index\n return this.state.variables.find((x) => x.state.name === name);\n }\n\n public constructor(state: SceneVariableSetState) {\n super(state);\n\n this.addActivationHandler(this._onActivate);\n }\n\n /**\n * Subscribes to child variable value changes, and starts the variable value validation process\n */\n private _onActivate = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n // Subscribe to changes to child variables\n this._subs.add(\n this.subscribeToEvent(SceneVariableValueChangedEvent, (event) => this._handleVariableValueChanged(event.payload))\n );\n\n this._subs.add(\n timeRange.subscribeToState(() => {\n this._refreshTimeRangeBasedVariables();\n })\n );\n\n // Subscribe to state changes\n this._subs.add(this.subscribeToState(this._onStateChanged));\n\n this._checkForVariablesThatChangedWhileInactive();\n\n // Add all variables that need updating to queue\n for (const variable of this.state.variables) {\n if (this._variableNeedsUpdate(variable)) {\n this._variablesToUpdate.add(variable);\n }\n }\n\n this._updateNextBatch();\n\n // Return deactivation handler;\n return this._onDeactivate;\n };\n\n /**\n * Add all variables that depend on the changed variable to the update queue\n */\n private _refreshTimeRangeBasedVariables() {\n for (const variable of this.state.variables) {\n if ('refresh' in variable.state && variable.state.refresh === VariableRefresh.onTimeRangeChanged) {\n this._variablesToUpdate.add(variable);\n }\n }\n this._updateNextBatch();\n }\n\n /**\n * Cancel all currently running updates\n */\n private _onDeactivate = () => {\n for (const update of this._updating.values()) {\n update.subscription?.unsubscribe();\n }\n\n // Remember current variable values\n for (const variable of this.state.variables) {\n // if the current variable is not in queue to update and validate and not being actively updated then the value is ok\n if (!this._variablesToUpdate.has(variable) && !this._updating.has(variable)) {\n this._variableValueRecorder.recordCurrentValue(variable);\n }\n }\n\n this._variablesToUpdate.clear();\n this._updating.clear();\n };\n\n /**\n * Look for new variables that need to be initialized\n */\n private _onStateChanged = (newState: SceneVariableSetState, oldState: SceneVariableSetState) => {\n const variablesToUpdateCountStart = this._variablesToUpdate.size;\n\n // Check for removed variables\n for (const variable of oldState.variables) {\n if (!newState.variables.includes(variable)) {\n const updating = this._updating.get(variable);\n if (updating?.subscription) {\n updating.subscription.unsubscribe();\n }\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n }\n }\n\n // Check for new variables\n for (const variable of newState.variables) {\n if (!oldState.variables.includes(variable)) {\n if (this._variableNeedsUpdate(variable)) {\n this._variablesToUpdate.add(variable);\n }\n }\n }\n\n // Only start a new batch if there was no batch already running\n if (variablesToUpdateCountStart === 0 && this._variablesToUpdate.size > 0) {\n this._updateNextBatch();\n }\n };\n\n /**\n * If variables changed while in in-active state we don't get any change events, so we need to check for that here.\n */\n private _checkForVariablesThatChangedWhileInactive() {\n if (!this._variableValueRecorder.hasValues()) {\n return;\n }\n\n for (const variable of this.state.variables) {\n if (this._variableValueRecorder.hasValueChanged(variable)) {\n writeVariableTraceLog(variable, 'Changed while in-active');\n this._addDependentVariablesToUpdateQueue(variable);\n }\n }\n }\n\n private _variableNeedsUpdate(variable: SceneVariable): boolean {\n if (variable.isLazy) {\n return false;\n }\n\n if (!variable.validateAndUpdate) {\n return false;\n }\n\n // If we have recorded valid value (even if it has changed since we do not need to re-validate this variable)\n if (this._variableValueRecorder.hasRecordedValue(variable)) {\n writeVariableTraceLog(variable, 'Skipping updateAndValidate current value valid');\n return false;\n }\n\n return true;\n }\n\n /**\n * This loops through variablesToUpdate and update all that can.\n * If one has a dependency that is currently in variablesToUpdate it will be skipped for now.\n */\n private _updateNextBatch() {\n for (const variable of this._variablesToUpdate) {\n if (!variable.validateAndUpdate) {\n throw new Error('Variable added to variablesToUpdate but does not have validateAndUpdate');\n }\n\n // Ignore it if it's already started\n if (this._updating.has(variable)) {\n continue;\n }\n\n // Wait for variables that has dependencies that also needs updates\n if (sceneGraph.hasVariableDependencyInLoadingState(variable)) {\n continue;\n }\n\n const variableToUpdate: VariableUpdateInProgress = {\n variable,\n };\n\n this._updating.set(variable, variableToUpdate);\n writeVariableTraceLog(variable, 'updateAndValidate started');\n\n variableToUpdate.subscription = variable.validateAndUpdate().subscribe({\n next: () => this._validateAndUpdateCompleted(variable),\n complete: () => this._validateAndUpdateCompleted(variable),\n error: (err) => this._handleVariableError(variable, err),\n });\n }\n }\n\n /**\n * A variable has completed its update process. This could mean that variables that depend on it can now be updated in turn.\n */\n private _validateAndUpdateCompleted(variable: SceneVariable) {\n if (!this._updating.has(variable)) {\n return;\n }\n\n const update = this._updating.get(variable);\n update?.subscription?.unsubscribe();\n\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n\n writeVariableTraceLog(variable, 'updateAndValidate completed');\n\n this._notifyDependentSceneObjects(variable);\n this._updateNextBatch();\n }\n\n public cancel(variable: SceneVariable) {\n const update = this._updating.get(variable);\n update?.subscription?.unsubscribe();\n\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n }\n\n private _handleVariableError(variable: SceneVariable, err: Error) {\n const update = this._updating.get(variable);\n update?.subscription?.unsubscribe();\n\n this._updating.delete(variable);\n this._variablesToUpdate.delete(variable);\n\n variable.setState({ loading: false, error: err.message });\n\n console.error('SceneVariableSet updateAndValidate error', err);\n\n writeVariableTraceLog(variable, 'updateAndValidate error', err);\n\n this._notifyDependentSceneObjects(variable);\n this._updateNextBatch();\n }\n\n private _handleVariableValueChanged(variableThatChanged: SceneVariable) {\n this._variablesThatHaveChanged.add(variableThatChanged);\n this._addDependentVariablesToUpdateQueue(variableThatChanged);\n\n // Ignore this change if it is currently updating\n if (!this._updating.has(variableThatChanged)) {\n this._updateNextBatch();\n this._notifyDependentSceneObjects(variableThatChanged);\n }\n }\n\n /**\n * This is called by any parent level variable set to notify scene that an update batch is completed.\n * This is the main mechanism lower level variable set's react to changes on higher levels.\n */\n private _handleParentVariableUpdatesCompleted(variable: SceneVariable, hasChanged: boolean) {\n // First loop through changed variables and add any of our variables that depend on the higher level variable to the update queue\n if (hasChanged) {\n this._addDependentVariablesToUpdateQueue(variable);\n }\n\n // If we have variables to update but none are currently updating kick of a new update batch\n if (this._variablesToUpdate.size > 0 && this._updating.size === 0) {\n this._updateNextBatch();\n }\n }\n\n private _addDependentVariablesToUpdateQueue(variableThatChanged: SceneVariable) {\n for (const otherVariable of this.state.variables) {\n if (otherVariable.variableDependency) {\n if (otherVariable.variableDependency.hasDependencyOn(variableThatChanged.state.name)) {\n writeVariableTraceLog(otherVariable, 'Added to update queue, dependant variable value changed');\n\n if (this._updating.has(otherVariable) && otherVariable.onCancel) {\n otherVariable.onCancel();\n }\n\n this._variablesToUpdate.add(otherVariable);\n }\n }\n }\n }\n\n /**\n * Walk scene object graph and update all objects that depend on variables that have changed\n */\n private _notifyDependentSceneObjects(variable: SceneVariable) {\n if (!this.parent) {\n return;\n }\n\n this._traverseSceneAndNotify(this.parent, variable, this._variablesThatHaveChanged.has(variable));\n this._variablesThatHaveChanged.delete(variable);\n }\n\n /**\n * Recursivly walk the full scene object graph and notify all objects with dependencies that include any of changed variables\n */\n private _traverseSceneAndNotify(sceneObject: SceneObject, variable: SceneVariable, hasChanged: boolean) {\n // No need to notify variables under this SceneVariableSet\n if (this === sceneObject) {\n return;\n }\n\n // Skip non active scene objects\n if (!sceneObject.isActive) {\n return;\n }\n\n // If we find a nested SceneVariableSet that has a variable with the same name we stop the traversal\n if (sceneObject.state.$variables && sceneObject.state.$variables !== this) {\n const localVar = sceneObject.state.$variables.getByName(variable.state.name);\n if (localVar) {\n return;\n }\n }\n\n if (sceneObject.variableDependency) {\n sceneObject.variableDependency.variableUpdateCompleted(variable, hasChanged);\n }\n\n sceneObject.forEachChild((child) => this._traverseSceneAndNotify(child, variable, hasChanged));\n }\n\n /**\n * Return true if variable is waiting to update or currently updating.\n * It also returns true if a dependency of the variable is loading.\n *\n * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.\n */\n public isVariableLoadingOrWaitingToUpdate(variable: SceneVariable) {\n if (variable.isAncestorLoading && variable.isAncestorLoading()) {\n return true;\n }\n\n if (this._variablesToUpdate.has(variable) || this._updating.has(variable)) {\n return true;\n }\n\n // Last scenario is to check the variable's own dependencies as well\n return sceneGraph.hasVariableDependencyInLoadingState(variable);\n }\n}\n\nexport interface VariableUpdateInProgress {\n variable: SceneVariable;\n subscription?: Unsubscribable;\n}\n\nfunction writeVariableTraceLog(variable: SceneVariable, message: string, err?: Error) {\n if (err) {\n writeSceneLog('SceneVariableSet', `Variable[${variable.state.name}]: ${message}`, err);\n } else {\n writeSceneLog('SceneVariableSet', `Variable[${variable.state.name}]: ${message}`);\n }\n}\n\nclass SceneVariableSetVariableDependencyHandler implements SceneVariableDependencyConfigLike {\n public constructor(private _variableUpdatesCompleted: (variable: SceneVariable, hasChanged: boolean) => void) {}\n\n private _emptySet = new Set<string>();\n\n public getNames(): Set<string> {\n return this._emptySet;\n }\n\n public hasDependencyOn(name: string): boolean {\n return false;\n }\n\n public variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void {\n this._variableUpdatesCompleted(variable, hasChanged);\n }\n}\n"],"names":[],"mappings":";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'lodash';\nimport { VariableValue } from './types';\n// @ts-expect-error Remove when 11.1.x is released\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';\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(response: GetTagResponse | MetricFindValue[]): 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"],"names":["value"],"mappings":";;;;AASgB,SAAA,oBAAA,CAAqB,GAAqC,CAAqC,EAAA;AAC7G,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A,EAAS,OAAO,CAAA,CAAA;AAAA,OACnD;AAEA,MAAA,KAAA,CAAM,KAAK,KAAK,CAAA,CAAA;AAAA,KACX,MAAA;AACL,MAAA,MAAA,CAAO,KAAK,KAAK,CAAA,CAAA;AAAA,KACnB;AAAA,GACF;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/variables/utils.ts"],"sourcesContent":["import { isEqual } from 'lodash';\nimport { VariableValue } from './types';\n// @ts-expect-error Remove when 11.1.x is released\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';\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"],"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,OAAA,CAAQ,IAAI,CAAC,MAAA,KAAW,aAAa,MAAM,CAAC,CAAE,CAAA,I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AI,UAAY,EAAA;AACd,MAAI,IAAA,KAAA,GAAQ,cAAe,CAAA,GAAA,CAAI,UAAU,CAAA,CAAA;AAEzC,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAA,KAAA,GAAQ,EAAC,CAAA;AACT,QAAe,cAAA,CAAA,GAAA,CAAI,YAAY,KAAK,CAAA,CAAA;AACpC,QAAA,MAAA,CAAO,KAAK,EAAE,KAAA,EAAO,UAAY,EAAA,OAAA,EAAS,OAAO,CAAA,CAAA;AAAA,OACnD;AAEA,MAAA,KAAA,CAAM,KAAK,KAAK,CAAA,CAAA;AAAA,KACX,MAAA;AACL,MAAA,MAAA,CAAO,KAAK,KAAK,CAAA,CAAA;AAAA,KACnB;AAAA,GACF;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TestVariable.js","sources":["../../../../src/variables/variants/TestVariable.tsx"],"sourcesContent":["import { Observable, Subject } from 'rxjs';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { SceneComponentProps } from '../../core/types';\nimport { queryMetricTree } from '../../utils/metricTree';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../components/VariableValueSelect';\nimport { VariableValueOption } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { VariableRefresh } from '@grafana/data';\nimport { getClosest } from '../../core/sceneGraph/utils';\nimport { SceneVariableSet } from '../sets/SceneVariableSet';\nimport { SceneQueryControllerEntry } from '../../behaviors/SceneQueryController';\n\nexport interface TestVariableState extends MultiValueVariableState {\n query: string;\n delayMs?: number;\n issuedQuery?: string;\n refresh?: VariableRefresh;\n throwError?: string;\n optionsToReturn?: VariableValueOption[];\n updateOptions?: boolean;\n}\n\n/**\n * This variable is only designed for unit tests and potentially e2e tests.\n */\nexport class TestVariable extends MultiValueVariable<TestVariableState> {\n private completeUpdate = new Subject<number>();\n public isGettingValues = true;\n public getValueOptionsCount = 0;\n isLazy = false;\n\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<TestVariableState>, isLazy = false) {\n super({\n type: 'custom',\n name: 'Test',\n value: 'Value',\n text: 'Text',\n query: 'Query',\n options: [],\n refresh: VariableRefresh.onDashboardLoad,\n updateOptions: true,\n ...initialState,\n });\n this.isLazy = isLazy;\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n const { delayMs } = this.state;\n\n this.getValueOptionsCount += 1;\n\n const queryController = sceneGraph.getQueryController(this);\n\n return new Observable<VariableValueOption[]>((observer) => {\n const queryEntry: SceneQueryControllerEntry = {\n type: 'variable',\n origin: this,\n cancel: () => observer.complete(),\n };\n\n if (queryController) {\n queryController.queryStarted(queryEntry);\n }\n\n this.setState({ loading: true });\n\n if (this.state.throwError) {\n throw new Error(this.state.throwError);\n }\n\n const interpolatedQuery = sceneGraph.interpolate(this, this.state.query);\n const options = this.getOptions(interpolatedQuery);\n\n const sub = this.completeUpdate.subscribe({\n next: () => {\n const newState: Partial<TestVariableState> = { issuedQuery: interpolatedQuery, loading: false };\n\n if (this.state.updateOptions) {\n newState.options = options;\n }\n\n this.setState(newState);\n observer.next(options);\n observer.complete();\n },\n });\n\n let timeout: number | undefined;\n if (delayMs) {\n timeout = window.setTimeout(() => this.signalUpdateCompleted(), delayMs);\n } else if (delayMs === 0) {\n this.signalUpdateCompleted();\n }\n\n this.isGettingValues = true;\n\n return () => {\n sub.unsubscribe();\n window.clearTimeout(timeout);\n this.isGettingValues = false;\n\n if (this.state.loading) {\n this.setState({ loading: false });\n }\n\n if (queryController) {\n queryController.queryCompleted(queryEntry);\n }\n };\n });\n }\n\n public cancel() {\n const sceneVarSet = getClosest(this, (s) => (s instanceof SceneVariableSet ? s : undefined));\n sceneVarSet?.cancel(this);\n }\n\n private getOptions(interpolatedQuery: string) {\n if (this.state.optionsToReturn) {\n return this.state.optionsToReturn;\n }\n\n return queryMetricTree(interpolatedQuery).map((x) => ({ label: x.name, value: x.name }));\n }\n\n /** Useful from tests */\n public signalUpdateCompleted() {\n this.completeUpdate.next(1);\n }\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return renderSelectForVariable(model);\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,qBAAqB,kBAAsC,CAAA;AAAA,EAU/D,WAAA,CAAY,YAA0C,EAAA,MAAA,GAAS,KAAO,EAAA;AAC3E,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,QAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,OAAA;AAAA,MACP,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,OAAA;AAAA,MACP,SAAS,EAAC;AAAA,MACV,SAAS,eAAgB,CAAA,eAAA;AAAA,MACzB,aAAe,EAAA,IAAA;AAAA,KAAA,EACZ,YACJ,CAAA,CAAA,CAAA;AApBH,IAAQ,IAAA,CAAA,cAAA,GAAiB,IAAI,OAAgB,EAAA,CAAA;AAC7C,IAAA,IAAA,CAAO,eAAkB,GAAA,IAAA,CAAA;AACzB,IAAA,IAAA,CAAO,oBAAuB,GAAA,CAAA,CAAA;AAC9B,IAAS,IAAA,CAAA,MAAA,GAAA,KAAA,CAAA;AAET,IAAU,IAAA,CAAA,mBAAA,GAAsB,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MACjE,UAAA,EAAY,CAAC,OAAO,CAAA;AAAA,KACrB,CAAA,CAAA;AAcC,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AAAA,GAChB;AAAA,EAEO,gBAAgB,IAAiE,EAAA;AACtF,IAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,IAAK,CAAA,KAAA,CAAA;AAEzB,IAAA,IAAA,CAAK,oBAAwB,IAAA,CAAA,CAAA;AAE7B,IAAM,MAAA,eAAA,GA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E,CAAA,IAAA,EAAM,KAAO,EAAA,CAAA,CAAE,MAAO,CAAA,CAAA,CAAA;AAAA,GACzF;AAAA,EAGO,qBAAwB,GAAA;AAC7B,IAAK,IAAA,CAAA,cAAA,CAAe,KAAK,CAAC,CAAA,CAAA;AAAA,GAC5B;AAKF,CAAA;AAhHa,YAAA,CA6GG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAqD,KAAA;AAChF,EAAA,OAAO,wBAAwB,KAAK,CAAA,CAAA;AACtC,CAAA;;;;"}
1
+ {"version":3,"file":"TestVariable.js","sources":["../../../../src/variables/variants/TestVariable.tsx"],"sourcesContent":["import { Observable, Subject } from 'rxjs';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { SceneComponentProps } from '../../core/types';\nimport { queryMetricTree } from '../../utils/metricTree';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../components/VariableValueSelect';\nimport { VariableValueOption } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { VariableRefresh } from '@grafana/data';\nimport { getClosest } from '../../core/sceneGraph/utils';\nimport { SceneVariableSet } from '../sets/SceneVariableSet';\nimport { SceneQueryControllerEntry } from '../../behaviors/types';\n\nexport interface TestVariableState extends MultiValueVariableState {\n query: string;\n delayMs?: number;\n issuedQuery?: string;\n refresh?: VariableRefresh;\n throwError?: string;\n optionsToReturn?: VariableValueOption[];\n updateOptions?: boolean;\n}\n\n/**\n * This variable is only designed for unit tests and potentially e2e tests.\n */\nexport class TestVariable extends MultiValueVariable<TestVariableState> {\n private completeUpdate = new Subject<number>();\n public isGettingValues = true;\n public getValueOptionsCount = 0;\n isLazy = false;\n\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<TestVariableState>, isLazy = false) {\n super({\n type: 'custom',\n name: 'Test',\n value: 'Value',\n text: 'Text',\n query: 'Query',\n options: [],\n refresh: VariableRefresh.onDashboardLoad,\n updateOptions: true,\n ...initialState,\n });\n this.isLazy = isLazy;\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n const { delayMs } = this.state;\n\n this.getValueOptionsCount += 1;\n\n const queryController = sceneGraph.getQueryController(this);\n\n return new Observable<VariableValueOption[]>((observer) => {\n const queryEntry: SceneQueryControllerEntry = {\n type: 'variable',\n origin: this,\n cancel: () => observer.complete(),\n };\n\n if (queryController) {\n queryController.queryStarted(queryEntry);\n }\n\n this.setState({ loading: true });\n\n if (this.state.throwError) {\n throw new Error(this.state.throwError);\n }\n\n const interpolatedQuery = sceneGraph.interpolate(this, this.state.query);\n const options = this.getOptions(interpolatedQuery);\n\n const sub = this.completeUpdate.subscribe({\n next: () => {\n const newState: Partial<TestVariableState> = { issuedQuery: interpolatedQuery, loading: false };\n\n if (this.state.updateOptions) {\n newState.options = options;\n }\n\n this.setState(newState);\n observer.next(options);\n observer.complete();\n },\n });\n\n let timeout: number | undefined;\n if (delayMs) {\n timeout = window.setTimeout(() => this.signalUpdateCompleted(), delayMs);\n } else if (delayMs === 0) {\n this.signalUpdateCompleted();\n }\n\n this.isGettingValues = true;\n\n return () => {\n sub.unsubscribe();\n window.clearTimeout(timeout);\n this.isGettingValues = false;\n\n if (this.state.loading) {\n this.setState({ loading: false });\n }\n\n if (queryController) {\n queryController.queryCompleted(queryEntry);\n }\n };\n });\n }\n\n public cancel() {\n const sceneVarSet = getClosest(this, (s) => (s instanceof SceneVariableSet ? s : undefined));\n sceneVarSet?.cancel(this);\n }\n\n private getOptions(interpolatedQuery: string) {\n if (this.state.optionsToReturn) {\n return this.state.optionsToReturn;\n }\n\n return queryMetricTree(interpolatedQuery).map((x) => ({ label: x.name, value: x.name }));\n }\n\n /** Useful from tests */\n public signalUpdateCompleted() {\n this.completeUpdate.next(1);\n }\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return renderSelectForVariable(model);\n };\n}\n"],"names":[],"mappings":";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a,YAAA,CA6GG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAqD,KAAA;AAChF,EAAA,OAAO,wBAAwB,KAAK,CAAA,CAAA;AACtC,CAAA;;;;"}
package/dist/index.d.ts CHANGED
@@ -679,6 +679,10 @@ interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
679
679
  * Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
680
680
  */
681
681
  onAnyVariableChanged?: (variable: SceneVariable) => void;
682
+ /**
683
+ * Handle time macros.
684
+ */
685
+ handleTimeMacros?: boolean;
682
686
  }
683
687
  declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
684
688
  private _sceneObject;
@@ -706,6 +710,7 @@ declare class VariableDependencyConfig<TState extends SceneObjectState> implemen
706
710
  setPaths(paths: Array<keyof TState | '*'>): void;
707
711
  private scanStateForDependencies;
708
712
  private extractVariablesFrom;
713
+ private handleTimeMacros;
709
714
  }
710
715
 
711
716
  interface MultiValueVariableState extends SceneVariableState {
@@ -958,20 +963,6 @@ declare class UserActionEvent extends BusEventWithPayload<UserActionEventPayload
958
963
  */
959
964
  declare function lookupVariable(name: string, sceneObject: SceneObject): SceneVariable | null;
960
965
 
961
- /**
962
- * Will walk up the scene object graph to the closest $timeRange scene object
963
- */
964
- declare function getTimeRange(sceneObject: SceneObject): SceneTimeRangeLike;
965
-
966
- interface SceneQueryStateControllerState extends SceneObjectState {
967
- isRunning: boolean;
968
- }
969
- interface SceneQueryControllerLike extends SceneObject<SceneQueryStateControllerState> {
970
- isQueryController: true;
971
- cancelAll(): void;
972
- queryStarted(entry: SceneQueryControllerEntry): void;
973
- queryCompleted(entry: SceneQueryControllerEntry): void;
974
- }
975
966
  interface QueryResultWithState {
976
967
  state: LoadingState;
977
968
  }
@@ -981,17 +972,40 @@ interface SceneQueryControllerEntry {
981
972
  origin: SceneObject;
982
973
  cancel?: () => void;
983
974
  }
984
- type SceneQueryControllerEntryType = 'data' | 'annotations' | 'variable' | 'alerts';
985
- declare class SceneQueryController extends SceneObjectBase<SceneQueryStateControllerState> implements SceneQueryControllerLike {
986
- #private;
975
+ type SceneQueryControllerEntryType = 'data' | 'annotations' | 'variable' | 'alerts' | 'plugin';
976
+ interface SceneInteractionProfileEvent {
977
+ origin: string;
978
+ duration: number;
979
+ networkDuration: number;
980
+ jsHeapSizeLimit: number;
981
+ usedJSHeapSize: number;
982
+ totalJSHeapSize: number;
983
+ crumbs: string[];
984
+ }
985
+ interface SceneQueryStateControllerState extends SceneObjectState {
986
+ isRunning: boolean;
987
+ enableProfiling?: boolean;
988
+ onProfileComplete?(event: SceneInteractionProfileEvent): void;
989
+ }
990
+ interface SceneQueryControllerLike extends SceneObject<SceneQueryStateControllerState> {
987
991
  isQueryController: true;
988
- constructor();
992
+ cancelAll(): void;
989
993
  queryStarted(entry: SceneQueryControllerEntry): void;
990
994
  queryCompleted(entry: SceneQueryControllerEntry): void;
991
- private changeRunningQueryCount;
992
- cancelAll(): void;
995
+ startProfile(source: SceneObject): void;
996
+ runningQueriesCount(): number;
993
997
  }
994
998
 
999
+ /**
1000
+ * Returns the closest query controller undefined if none found
1001
+ */
1002
+ declare function getQueryController(sceneObject: SceneObject): SceneQueryControllerLike | undefined;
1003
+
1004
+ /**
1005
+ * Will walk up the scene object graph to the closest $timeRange scene object
1006
+ */
1007
+ declare function getTimeRange(sceneObject: SceneObject): SceneTimeRangeLike;
1008
+
995
1009
  interface UrlSyncManagerLike {
996
1010
  initSync(root: SceneObject): void;
997
1011
  cleanUp(root: SceneObject): void;
@@ -1094,15 +1108,6 @@ declare function getAncestor<ParentType>(sceneObject: SceneObject, ancestorType:
1094
1108
  * This will search down the full scene graph, looking for objects that match the provided descendentType type.
1095
1109
  */
1096
1110
  declare function findDescendents<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>): T[];
1097
- /**
1098
- * Returns the closest query controller undefined if none found
1099
- */
1100
- declare function getQueryController(sceneObject: SceneObject): SceneQueryControllerLike | undefined;
1101
- /**
1102
- * Returns the closest SceneObject that has a state property with the
1103
- * name urlSyncManager that is of type UrlSyncManager
1104
- */
1105
- declare function getUrlSyncManager(sceneObject: SceneObject): UrlSyncManagerLike | undefined;
1106
1111
 
1107
1112
  declare const sceneGraph: {
1108
1113
  getVariables: typeof getVariables;
@@ -1118,9 +1123,8 @@ declare const sceneGraph: {
1118
1123
  findObject: typeof findObject;
1119
1124
  findAllObjects: typeof findAllObjects;
1120
1125
  getAncestor: typeof getAncestor;
1121
- findDescendents: typeof findDescendents;
1122
1126
  getQueryController: typeof getQueryController;
1123
- getUrlSyncManager: typeof getUrlSyncManager;
1127
+ findDescendents: typeof findDescendents;
1124
1128
  };
1125
1129
 
1126
1130
  interface ActWhenVariableChangedState extends SceneObjectState {
@@ -1166,6 +1170,19 @@ declare class PanelContextEventBus implements EventBus {
1166
1170
  newScopedBus(key: string, filter: EventFilterOptions): EventBus;
1167
1171
  }
1168
1172
 
1173
+ declare class SceneQueryController extends SceneObjectBase<SceneQueryStateControllerState> implements SceneQueryControllerLike {
1174
+ #private;
1175
+ isQueryController: true;
1176
+ private profiler;
1177
+ constructor(state?: Partial<SceneQueryStateControllerState>);
1178
+ runningQueriesCount: () => number;
1179
+ startProfile(source: SceneObject): void;
1180
+ queryStarted(entry: SceneQueryControllerEntry): void;
1181
+ queryCompleted(entry: SceneQueryControllerEntry): void;
1182
+ private changeRunningQueryCount;
1183
+ cancelAll(): void;
1184
+ }
1185
+
1169
1186
  interface LiveNowTimerState extends SceneObjectState {
1170
1187
  enabled: boolean;
1171
1188
  }
@@ -2822,4 +2839,4 @@ declare const sceneUtils: {
2822
2839
  isGroupByVariable: typeof isGroupByVariable;
2823
2840
  };
2824
2841
 
2825
- export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLabel, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataProviderProxy, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
2842
+ export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLabel, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataProviderProxy, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneInteractionProfileEvent, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };