@grafana/scenes 5.20.4 → 5.20.5--canary.942.11520639649.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +11 -4
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +31 -11
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js +5 -5
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +28 -0
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +117 -62
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AdHocFiltersVariable.js","sources":["../../../../src/variables/adhoc/AdHocFiltersVariable.tsx"],"sourcesContent":["import React from 'react';\n// @ts-expect-error Remove when 11.1.x is released\nimport { AdHocVariableFilter, GetTagResponse, GrafanaTheme2, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { ControlsLayout, SceneComponentProps } from '../../core/types';\nimport { DataSourceRef } from '@grafana/schema';\nimport { dataFromResponse, getQueriesForVariables, renderPrometheusLabelFilters, responseHasError } from '../utils';\nimport { patchGetAdhocFilters } from './patchGetAdhocFilters';\nimport { useStyles2 } from '@grafana/ui';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { AdHocFilterBuilder } from './AdHocFilterBuilder';\nimport { AdHocFilterRenderer } from './AdHocFilterRenderer';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler';\nimport { css } from '@emotion/css';\nimport { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest';\nimport { AdHocFiltersComboboxRenderer } from './AdHocFiltersCombobox/AdHocFiltersComboboxRenderer';\nimport { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject';\n\nexport interface AdHocFilterWithLabels extends AdHocVariableFilter {\n keyLabel?: string;\n valueLabels?: string[];\n}\n\nexport type AdHocControlsLayout = ControlsLayout | 'combobox';\n\nexport interface AdHocFiltersVariableState extends SceneVariableState {\n /** Optional text to display on the 'add filter' button */\n addFilterButtonText?: string;\n /** The visible filters */\n filters: AdHocFilterWithLabels[];\n /** Base filters to always apply when looking up keys*/\n baseFilters?: AdHocFilterWithLabels[];\n /** Datasource to use for getTagKeys and getTagValues and also controls which scene queries the filters should apply to */\n datasource: DataSourceRef | null;\n /** Controls if the filters can be changed */\n readOnly?: boolean;\n /**\n * @experimental\n * Controls the layout and design of the label.\n */\n layout?: AdHocControlsLayout;\n /**\n * Defaults to automatic which means filters will automatically be applied to all queries with the same data source as this AdHocFilterSet.\n * In manual mode you either have to use the filters programmatically or as a variable inside query expressions.\n */\n applyMode: 'auto' | 'manual';\n /**\n * Filter out the keys that do not match the regex.\n */\n tagKeyRegexFilter?: RegExp;\n /**\n * Extension hook for customizing the key lookup.\n * Return replace: true if you want to override the default lookup\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagKeysProvider?: getTagKeysProvider;\n /**\n * Extension hook for customizing the value lookup.\n * Return replace: true if you want to override the default lookup.\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagValuesProvider?: getTagValuesProvider;\n\n /**\n * Optionally provide an array of static keys that override getTagKeys\n */\n defaultKeys?: MetricFindValue[];\n\n /**\n * This is the expression that the filters resulted in. Defaults to\n * Prometheus / Loki compatible label filter expression\n */\n filterExpression?: string;\n\n /**\n * The default builder creates a Prometheus/Loki compatible filter expression,\n * this can be overridden to create a different expression based on the current filters.\n */\n expressionBuilder?: AdHocVariableExpressionBuilderFn;\n\n /**\n * Whether the filter supports new multi-value operators like =| and !=|\n */\n supportsMultiValueOperators?: boolean;\n\n /**\n * When querying the datasource for label names and values to determine keys and values\n * for this ad hoc filter, consider the queries in the scene and use them as a filter.\n * This queries filter can be used to ensure that only ad hoc filter options that would\n * impact the current queries are presented to the user.\n */\n useQueriesAsFilterForOptions?: boolean;\n\n /**\n * @internal state of the new filter being added\n */\n _wip?: AdHocFilterWithLabels;\n}\n\nexport type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;\n\nexport type getTagKeysProvider = (\n variable: AdHocFiltersVariable,\n currentKey: string | null\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type getTagValuesProvider = (\n variable: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type AdHocFiltersVariableCreateHelperArgs = AdHocFiltersVariableState;\n\nexport type OperatorDefinition = {\n value: string;\n description?: string;\n isMulti?: Boolean;\n};\n\nexport const OPERATORS: OperatorDefinition[] = [\n {\n value: '=',\n description: 'Equals',\n },\n {\n value: '!=',\n description: 'Not equal',\n },\n {\n value: '=|',\n description: 'One of. Use to filter on multiple values.',\n isMulti: true,\n },\n {\n value: '!=|',\n description: 'Not one of. Use to exclude multiple values.',\n isMulti: true,\n },\n {\n value: '=~',\n description: 'Matches regex',\n },\n {\n value: '!~',\n description: 'Does not match regex',\n },\n {\n value: '<',\n description: 'Less than',\n },\n {\n value: '>',\n description: 'Greater than',\n },\n];\n\nexport class AdHocFiltersVariable\n extends SceneObjectBase<AdHocFiltersVariableState>\n implements SceneVariable<AdHocFiltersVariableState>\n{\n static Component = AdHocFiltersVariableRenderer;\n\n private _scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };\n private _dataSourceSrv = getDataSourceSrv();\n\n protected _urlSync = new AdHocFiltersVariableUrlSyncHandler(this);\n\n public constructor(state: Partial<AdHocFiltersVariableState>) {\n super({\n type: 'adhoc',\n name: state.name ?? 'Filters',\n filters: [],\n datasource: null,\n applyMode: 'auto',\n filterExpression: state.filterExpression ?? renderExpression(state.expressionBuilder, state.filters),\n ...state,\n });\n\n if (this.state.applyMode === 'auto') {\n patchGetAdhocFilters(this);\n }\n }\n\n public setState(update: Partial<AdHocFiltersVariableState>): void {\n let filterExpressionChanged = false;\n\n if (update.filters && update.filters !== this.state.filters && !update.filterExpression) {\n update.filterExpression = renderExpression(this.state.expressionBuilder, update.filters);\n filterExpressionChanged = update.filterExpression !== this.state.filterExpression;\n }\n\n super.setState(update);\n\n if (filterExpressionChanged) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n public getValue(): VariableValue | undefined {\n return this.state.filterExpression;\n }\n\n public _updateFilter(filter: AdHocFilterWithLabels, update: Partial<AdHocFilterWithLabels>) {\n const { filters, _wip } = this.state;\n\n if (filter === _wip) {\n // If we set value we are done with this \"work in progress\" filter and we can add it\n if ('value' in update && update['value'] !== '') {\n this.setState({ filters: [...filters, { ..._wip, ...update }], _wip: undefined });\n } else {\n this.setState({ _wip: { ...filter, ...update } });\n }\n return;\n }\n\n const updatedFilters = this.state.filters.map((f) => {\n return f === filter ? { ...f, ...update } : f;\n });\n\n this.setState({ filters: updatedFilters });\n }\n\n public _removeFilter(filter: AdHocFilterWithLabels) {\n if (filter === this.state._wip) {\n this.setState({ _wip: undefined });\n return;\n }\n\n this.setState({ filters: this.state.filters.filter((f) => f !== filter) });\n }\n\n public _removeLastFilter() {\n const filterToRemove = this.state.filters.at(-1);\n\n if (filterToRemove) {\n this._removeFilter(filterToRemove);\n }\n }\n\n /**\n * Get possible keys given current filters. Do not call from plugins directly\n */\n public async _getKeys(currentKey: string | null): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagKeysProvider?.(this, currentKey);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n if (this.state.defaultKeys) {\n return this.state.defaultKeys.map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n if (!ds || !ds.getTagKeys) {\n return [];\n }\n\n const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat(this.state.baseFilters ?? []);\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n const response = await ds.getTagKeys({\n filters: otherFilters,\n queries,\n timeRange,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let keys = dataFromResponse(response);\n if (override) {\n keys = keys.concat(dataFromResponse(override.values));\n }\n\n const tagKeyRegexFilter = this.state.tagKeyRegexFilter;\n if (tagKeyRegexFilter) {\n // @ts-expect-error Remove when 11.1.x is released\n keys = keys.filter((f) => f.text.match(tagKeyRegexFilter));\n }\n\n return keys.map(toSelectableValue);\n }\n\n /**\n * Get possible key values for a specific key given current filters. Do not call from plugins directly\n */\n public async _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagValuesProvider?.(this, filter);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n\n if (!ds || !ds.getTagValues) {\n return [];\n }\n\n // Filter out the current filter key from the list of all filters\n const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(this.state.baseFilters ?? []);\n\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n\n const response = await ds.getTagValues({\n key: filter.key,\n filters: otherFilters,\n timeRange, // @ts-expect-error TODO: remove this once 11.1.x is released\n queries,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let values = dataFromResponse(response);\n if (override) {\n values = values.concat(dataFromResponse(override.values));\n }\n\n return values.map(toSelectableValue);\n }\n\n public _addWip() {\n this.setState({\n _wip: { key: '', value: '', operator: '=', condition: '' },\n });\n }\n\n public _getOperators() {\n const filteredOperators = this.state.supportsMultiValueOperators\n ? OPERATORS\n : OPERATORS.filter((operator) => !operator.isMulti);\n return filteredOperators.map<SelectableValue<string>>(({ value, description }) => ({\n label: value,\n value,\n description,\n }));\n }\n}\n\nfunction renderExpression(\n builder: AdHocVariableExpressionBuilderFn | undefined,\n filters: AdHocFilterWithLabels[] | undefined\n) {\n return (builder ?? renderPrometheusLabelFilters)(filters ?? []);\n}\n\nexport function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>) {\n const { filters, readOnly, addFilterButtonText } = model.useState();\n const styles = useStyles2(getStyles);\n\n if (model.state.layout === 'combobox') {\n return <AdHocFiltersComboboxRenderer model={model} />;\n }\n\n return (\n <div className={styles.wrapper}>\n {filters.map((filter, index) => (\n <React.Fragment key={index}>\n <AdHocFilterRenderer filter={filter} model={model} />\n </React.Fragment>\n ))}\n\n {!readOnly && <AdHocFilterBuilder model={model} key=\"'builder\" addFilterButtonText={addFilterButtonText} />}\n </div>\n );\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'flex-end',\n columnGap: theme.spacing(2),\n rowGap: theme.spacing(1),\n }),\n});\n\nexport function toSelectableValue(input: MetricFindValue): SelectableValue<string> {\n const { text, value } = input;\n const result: SelectableValue<string> = {\n label: text,\n value: String(value ?? text),\n };\n\n if ('group' in input) {\n result.group = input.group;\n }\n\n return result;\n}\n\nexport function isFilterComplete(filter: AdHocFilterWithLabels): boolean {\n return filter.key !== '' && filter.operator !== '' && filter.value !== '';\n}\n\nexport function isMultiValueOperator(operatorValue: string): boolean {\n const operator = OPERATORS.find((o) => o.value === operatorValue);\n if (!operator) {\n // default to false if operator is not found\n return false;\n }\n return Boolean(operator.isMulti);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHO,MAAM,SAAkC,GAAA;AAAA,EAC7C;AAAA,IACE,KAAO,EAAA,GAAA;AAAA,IACP,WAAa,EAAA,QAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,IACP,WAAa,EAAA,WAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,IACP,WAAa,EAAA,2CAAA;AAAA,IACb,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EACA;AAAA,IACE,KAAO,EAAA,KAAA;AAAA,IACP,WAAa,EAAA,6CAAA;AAAA,IACb,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,IACP,WAAa,EAAA,eAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,IACP,WAAa,EAAA,sBAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,GAAA;AAAA,IACP,WAAa,EAAA,WAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,GAAA;AAAA,IACP,WAAa,EAAA,cAAA;AAAA,GACf;AACF,EAAA;AAEO,MAAM,6BACH,eAEV,CAAA;AAAA,EAQS,YAAY,KAA2C,EAAA;AAzKhE,IAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA0KI,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,OAAA;AAAA,MACN,IAAA,EAAA,CAAM,EAAM,GAAA,KAAA,CAAA,IAAA,KAAN,IAAc,GAAA,EAAA,GAAA,SAAA;AAAA,MACpB,SAAS,EAAC;AAAA,MACV,UAAY,EAAA,IAAA;AAAA,MACZ,SAAW,EA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AA;AACH,CAAA,CAAA,CAAA;AAEO,SAAS,kBAAkB,KAAiD,EAAA;AACjF,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AACxB,EAAA,MAAM,MAAkC,GAAA;AAAA,IACtC,KAAO,EAAA,IAAA;AAAA,IACP,KAAA,EAAO,MAAO,CAAA,KAAA,IAAA,IAAA,GAAA,KAAA,GAAS,IAAI,CAAA;AAAA,GAC7B,CAAA;AAEA,EAAA,IAAI,WAAW,KAAO,EAAA;AACpB,IAAA,MAAA,CAAO,QAAQ,KAAM,CAAA,KAAA,CAAA;AAAA,GACvB;AAEA,EAAO,OAAA,MAAA,CAAA;AACT,CAAA;AAEO,SAAS,iBAAiB,MAAwC,EAAA;AACvE,EAAA,OAAO,OAAO,GAAQ,KAAA,EAAA,IAAM,OAAO,QAAa,KAAA,EAAA,IAAM,OAAO,KAAU,KAAA,EAAA,CAAA;AACzE,CAAA;AAEO,SAAS,qBAAqB,aAAgC,EAAA;AACnE,EAAA,MAAM,WAAW,SAAU,CAAA,IAAA,CAAK,CAAC,CAAM,KAAA,CAAA,CAAE,UAAU,aAAa,CAAA,CAAA;AAChE,EAAA,IAAI,CAAC,QAAU,EAAA;AAEb,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,OAAA,CAAQ,SAAS,OAAO,CAAA,CAAA;AACjC;;;;"}
|
1
|
+
{"version":3,"file":"AdHocFiltersVariable.js","sources":["../../../../src/variables/adhoc/AdHocFiltersVariable.tsx"],"sourcesContent":["import React from 'react';\n// @ts-expect-error Remove when 11.1.x is released\nimport { AdHocVariableFilter, GetTagResponse, GrafanaTheme2, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { ControlsLayout, SceneComponentProps } from '../../core/types';\nimport { DataSourceRef } from '@grafana/schema';\nimport { dataFromResponse, getQueriesForVariables, renderPrometheusLabelFilters, responseHasError } from '../utils';\nimport { patchGetAdhocFilters } from './patchGetAdhocFilters';\nimport { useStyles2 } from '@grafana/ui';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { AdHocFilterBuilder } from './AdHocFilterBuilder';\nimport { AdHocFilterRenderer } from './AdHocFilterRenderer';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler';\nimport { css } from '@emotion/css';\nimport { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest';\nimport { AdHocFiltersComboboxRenderer } from './AdHocFiltersCombobox/AdHocFiltersComboboxRenderer';\nimport { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject';\n\nexport interface AdHocFilterWithLabels extends AdHocVariableFilter {\n keyLabel?: string;\n valueLabels?: string[];\n // this is used to externally trigger edit mode in combobox filter UI\n forceEdit?: boolean;\n}\n\nexport type AdHocControlsLayout = ControlsLayout | 'combobox';\n\nexport interface AdHocFiltersVariableState extends SceneVariableState {\n /** Optional text to display on the 'add filter' button */\n addFilterButtonText?: string;\n /** The visible filters */\n filters: AdHocFilterWithLabels[];\n /** Base filters to always apply when looking up keys*/\n baseFilters?: AdHocFilterWithLabels[];\n /** Datasource to use for getTagKeys and getTagValues and also controls which scene queries the filters should apply to */\n datasource: DataSourceRef | null;\n /** Controls if the filters can be changed */\n readOnly?: boolean;\n /**\n * @experimental\n * Controls the layout and design of the label.\n */\n layout?: AdHocControlsLayout;\n /**\n * Defaults to automatic which means filters will automatically be applied to all queries with the same data source as this AdHocFilterSet.\n * In manual mode you either have to use the filters programmatically or as a variable inside query expressions.\n */\n applyMode: 'auto' | 'manual';\n /**\n * Filter out the keys that do not match the regex.\n */\n tagKeyRegexFilter?: RegExp;\n /**\n * Extension hook for customizing the key lookup.\n * Return replace: true if you want to override the default lookup\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagKeysProvider?: getTagKeysProvider;\n /**\n * Extension hook for customizing the value lookup.\n * Return replace: true if you want to override the default lookup.\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagValuesProvider?: getTagValuesProvider;\n\n /**\n * Optionally provide an array of static keys that override getTagKeys\n */\n defaultKeys?: MetricFindValue[];\n\n /**\n * This is the expression that the filters resulted in. Defaults to\n * Prometheus / Loki compatible label filter expression\n */\n filterExpression?: string;\n\n /**\n * The default builder creates a Prometheus/Loki compatible filter expression,\n * this can be overridden to create a different expression based on the current filters.\n */\n expressionBuilder?: AdHocVariableExpressionBuilderFn;\n\n /**\n * Whether the filter supports new multi-value operators like =| and !=|\n */\n supportsMultiValueOperators?: boolean;\n\n /**\n * When querying the datasource for label names and values to determine keys and values\n * for this ad hoc filter, consider the queries in the scene and use them as a filter.\n * This queries filter can be used to ensure that only ad hoc filter options that would\n * impact the current queries are presented to the user.\n */\n useQueriesAsFilterForOptions?: boolean;\n\n /**\n * @internal state of the new filter being added\n */\n _wip?: AdHocFilterWithLabels;\n}\n\nexport type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;\n\nexport type getTagKeysProvider = (\n variable: AdHocFiltersVariable,\n currentKey: string | null\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type getTagValuesProvider = (\n variable: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type AdHocFiltersVariableCreateHelperArgs = AdHocFiltersVariableState;\n\nexport type OperatorDefinition = {\n value: string;\n description?: string;\n isMulti?: Boolean;\n};\n\nexport const OPERATORS: OperatorDefinition[] = [\n {\n value: '=',\n description: 'Equals',\n },\n {\n value: '!=',\n description: 'Not equal',\n },\n {\n value: '=|',\n description: 'One of. Use to filter on multiple values.',\n isMulti: true,\n },\n {\n value: '!=|',\n description: 'Not one of. Use to exclude multiple values.',\n isMulti: true,\n },\n {\n value: '=~',\n description: 'Matches regex',\n },\n {\n value: '!~',\n description: 'Does not match regex',\n },\n {\n value: '<',\n description: 'Less than',\n },\n {\n value: '>',\n description: 'Greater than',\n },\n];\n\nexport class AdHocFiltersVariable\n extends SceneObjectBase<AdHocFiltersVariableState>\n implements SceneVariable<AdHocFiltersVariableState>\n{\n static Component = AdHocFiltersVariableRenderer;\n\n private _scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };\n private _dataSourceSrv = getDataSourceSrv();\n\n protected _urlSync = new AdHocFiltersVariableUrlSyncHandler(this);\n\n public constructor(state: Partial<AdHocFiltersVariableState>) {\n super({\n type: 'adhoc',\n name: state.name ?? 'Filters',\n filters: [],\n datasource: null,\n applyMode: 'auto',\n filterExpression: state.filterExpression ?? renderExpression(state.expressionBuilder, state.filters),\n ...state,\n });\n\n if (this.state.applyMode === 'auto') {\n patchGetAdhocFilters(this);\n }\n }\n\n public setState(update: Partial<AdHocFiltersVariableState>): void {\n let filterExpressionChanged = false;\n\n if (update.filters && update.filters !== this.state.filters && !update.filterExpression) {\n update.filterExpression = renderExpression(this.state.expressionBuilder, update.filters);\n filterExpressionChanged = update.filterExpression !== this.state.filterExpression;\n }\n\n super.setState(update);\n\n if (filterExpressionChanged) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n public getValue(): VariableValue | undefined {\n return this.state.filterExpression;\n }\n\n public _updateFilter(filter: AdHocFilterWithLabels, update: Partial<AdHocFilterWithLabels>) {\n const { filters, _wip } = this.state;\n\n if (filter === _wip) {\n // If we set value we are done with this \"work in progress\" filter and we can add it\n if ('value' in update && update['value'] !== '') {\n this.setState({ filters: [...filters, { ..._wip, ...update }], _wip: undefined });\n } else {\n this.setState({ _wip: { ...filter, ...update } });\n }\n return;\n }\n\n const updatedFilters = this.state.filters.map((f) => {\n return f === filter ? { ...f, ...update } : f;\n });\n\n this.setState({ filters: updatedFilters });\n }\n\n public _removeFilter(filter: AdHocFilterWithLabels) {\n if (filter === this.state._wip) {\n this.setState({ _wip: undefined });\n return;\n }\n\n this.setState({ filters: this.state.filters.filter((f) => f !== filter) });\n }\n\n public _removeLastFilter() {\n const filterToRemove = this.state.filters.at(-1);\n\n if (filterToRemove) {\n this._removeFilter(filterToRemove);\n }\n }\n\n public _handleComboboxBackspace(filter: AdHocFilterWithLabels) {\n if (this.state.filters.length) {\n // default filter to forceEdit to last filter (when triggering from wip filter)\n let filterToForceIndex = this.state.filters.length - 1;\n\n // adjust index if backspace triggered from non wip filter\n if (filter !== this.state._wip) {\n const filterIndex = this.state.filters.findIndex((f) => f === filter);\n filterToForceIndex = filterIndex - 1;\n }\n\n // const filterToForceEditExists = !!this.state.filters[filterToForceIndex];\n this.setState({\n filters: this.state.filters.reduce<AdHocFilterWithLabels[]>((acc, f, index) => {\n // adjust forceEdit of preceding filter\n if (index === filterToForceIndex) {\n return [\n ...acc,\n {\n ...f,\n forceEdit: true,\n },\n ];\n }\n // remove current filter\n if (f === filter) {\n return acc;\n }\n\n return [...acc, f];\n }, []),\n });\n }\n }\n\n /**\n * Get possible keys given current filters. Do not call from plugins directly\n */\n public async _getKeys(currentKey: string | null): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagKeysProvider?.(this, currentKey);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n if (this.state.defaultKeys) {\n return this.state.defaultKeys.map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n if (!ds || !ds.getTagKeys) {\n return [];\n }\n\n const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat(this.state.baseFilters ?? []);\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n const response = await ds.getTagKeys({\n filters: otherFilters,\n queries,\n timeRange,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let keys = dataFromResponse(response);\n if (override) {\n keys = keys.concat(dataFromResponse(override.values));\n }\n\n const tagKeyRegexFilter = this.state.tagKeyRegexFilter;\n if (tagKeyRegexFilter) {\n // @ts-expect-error Remove when 11.1.x is released\n keys = keys.filter((f) => f.text.match(tagKeyRegexFilter));\n }\n\n return keys.map(toSelectableValue);\n }\n\n /**\n * Get possible key values for a specific key given current filters. Do not call from plugins directly\n */\n public async _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagValuesProvider?.(this, filter);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n\n if (!ds || !ds.getTagValues) {\n return [];\n }\n\n // Filter out the current filter key from the list of all filters\n const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(this.state.baseFilters ?? []);\n\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n\n const response = await ds.getTagValues({\n key: filter.key,\n filters: otherFilters,\n timeRange, // @ts-expect-error TODO: remove this once 11.1.x is released\n queries,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let values = dataFromResponse(response);\n if (override) {\n values = values.concat(dataFromResponse(override.values));\n }\n\n return values.map(toSelectableValue);\n }\n\n public _addWip() {\n this.setState({\n _wip: { key: '', value: '', operator: '=', condition: '' },\n });\n }\n\n public _getOperators() {\n const filteredOperators = this.state.supportsMultiValueOperators\n ? OPERATORS\n : OPERATORS.filter((operator) => !operator.isMulti);\n return filteredOperators.map<SelectableValue<string>>(({ value, description }) => ({\n label: value,\n value,\n description,\n }));\n }\n}\n\nfunction renderExpression(\n builder: AdHocVariableExpressionBuilderFn | undefined,\n filters: AdHocFilterWithLabels[] | undefined\n) {\n return (builder ?? renderPrometheusLabelFilters)(filters ?? []);\n}\n\nexport function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>) {\n const { filters, readOnly, addFilterButtonText } = model.useState();\n const styles = useStyles2(getStyles);\n\n if (model.state.layout === 'combobox') {\n return <AdHocFiltersComboboxRenderer model={model} />;\n }\n\n return (\n <div className={styles.wrapper}>\n {filters.map((filter, index) => (\n <React.Fragment key={index}>\n <AdHocFilterRenderer filter={filter} model={model} />\n </React.Fragment>\n ))}\n\n {!readOnly && <AdHocFilterBuilder model={model} key=\"'builder\" addFilterButtonText={addFilterButtonText} />}\n </div>\n );\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'flex-end',\n columnGap: theme.spacing(2),\n rowGap: theme.spacing(1),\n }),\n});\n\nexport function toSelectableValue(input: MetricFindValue): SelectableValue<string> {\n const { text, value } = input;\n const result: SelectableValue<string> = {\n label: text,\n value: String(value ?? text),\n };\n\n if ('group' in input) {\n result.group = input.group;\n }\n\n return result;\n}\n\nexport function isFilterComplete(filter: AdHocFilterWithLabels): boolean {\n return filter.key !== '' && filter.operator !== '' && filter.value !== '';\n}\n\nexport function isMultiValueOperator(operatorValue: string): boolean {\n const operator = OPERATORS.find((o) => o.value === operatorValue);\n if (!operator) {\n // default to false if operator is not found\n return false;\n }\n return Boolean(operator.isMulti);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HO,MAAM,SAAkC,GAAA;AAAA,EAC7C;AAAA,IACE,KAAO,EAAA,GAAA;AAAA,IACP,WAAa,EAAA,QAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,IACP,WAAa,EAAA,WAAA;AAAA,GACf;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,IACP,WAAa,EAAA,2CAAA;AAAA,IACb,OAAS,EAAA,IAAA;AAAA,GACX;AAAA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aAAa,CAAA,CAAA;AAChE,EAAA,IAAI,CAAC,QAAU,EAAA;AAEb,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,OAAA,CAAQ,SAAS,OAAO,CAAA,CAAA;AACjC;;;;"}
|
package/dist/index.d.ts
CHANGED
@@ -534,6 +534,7 @@ declare class AdHocFiltersVariableUrlSyncHandler implements SceneObjectUrlSyncHa
|
|
534
534
|
interface AdHocFilterWithLabels extends AdHocVariableFilter {
|
535
535
|
keyLabel?: string;
|
536
536
|
valueLabels?: string[];
|
537
|
+
forceEdit?: boolean;
|
537
538
|
}
|
538
539
|
type AdHocControlsLayout = ControlsLayout | 'combobox';
|
539
540
|
interface AdHocFiltersVariableState extends SceneVariableState {
|
@@ -623,6 +624,7 @@ declare class AdHocFiltersVariable extends SceneObjectBase<AdHocFiltersVariableS
|
|
623
624
|
_updateFilter(filter: AdHocFilterWithLabels, update: Partial<AdHocFilterWithLabels>): void;
|
624
625
|
_removeFilter(filter: AdHocFilterWithLabels): void;
|
625
626
|
_removeLastFilter(): void;
|
627
|
+
_handleComboboxBackspace(filter: AdHocFilterWithLabels): void;
|
626
628
|
/**
|
627
629
|
* Get possible keys given current filters. Do not call from plugins directly
|
628
630
|
*/
|
package/dist/index.js
CHANGED
@@ -77,8 +77,8 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
|
|
77
77
|
}
|
78
78
|
|
79
79
|
var __defProp$N = Object.defineProperty;
|
80
|
-
var __defProps$
|
81
|
-
var __getOwnPropDescs$
|
80
|
+
var __defProps$v = Object.defineProperties;
|
81
|
+
var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
|
82
82
|
var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
|
83
83
|
var __hasOwnProp$N = Object.prototype.hasOwnProperty;
|
84
84
|
var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
|
@@ -94,13 +94,13 @@ var __spreadValues$N = (a, b) => {
|
|
94
94
|
}
|
95
95
|
return a;
|
96
96
|
};
|
97
|
-
var __spreadProps$
|
97
|
+
var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
|
98
98
|
const runtimePanelPlugins = /* @__PURE__ */ new Map();
|
99
99
|
function registerRuntimePanelPlugin({ pluginId, plugin }) {
|
100
100
|
if (runtimePanelPlugins.has(pluginId)) {
|
101
101
|
throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
|
102
102
|
}
|
103
|
-
plugin.meta = __spreadProps$
|
103
|
+
plugin.meta = __spreadProps$v(__spreadValues$N({}, plugin.meta), {
|
104
104
|
id: pluginId,
|
105
105
|
name: pluginId,
|
106
106
|
module: "runtime plugin",
|
@@ -129,8 +129,8 @@ function loadPanelPluginSync(pluginId) {
|
|
129
129
|
}
|
130
130
|
|
131
131
|
var __defProp$M = Object.defineProperty;
|
132
|
-
var __defProps$
|
133
|
-
var __getOwnPropDescs$
|
132
|
+
var __defProps$u = Object.defineProperties;
|
133
|
+
var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
|
134
134
|
var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
|
135
135
|
var __hasOwnProp$M = Object.prototype.hasOwnProperty;
|
136
136
|
var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
|
@@ -146,7 +146,7 @@ var __spreadValues$M = (a, b) => {
|
|
146
146
|
}
|
147
147
|
return a;
|
148
148
|
};
|
149
|
-
var __spreadProps$
|
149
|
+
var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
|
150
150
|
var __objRest$5 = (source, exclude) => {
|
151
151
|
var target = {};
|
152
152
|
for (var prop in source)
|
@@ -172,7 +172,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
|
|
172
172
|
if (!model.isActive) {
|
173
173
|
return null;
|
174
174
|
}
|
175
|
-
return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$
|
175
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$u(__spreadValues$M({}, otherProps), {
|
176
176
|
model
|
177
177
|
}));
|
178
178
|
}
|
@@ -1746,8 +1746,8 @@ function collectAllVariables(sceneObject, record = {}) {
|
|
1746
1746
|
}
|
1747
1747
|
|
1748
1748
|
var __defProp$H = Object.defineProperty;
|
1749
|
-
var __defProps$
|
1750
|
-
var __getOwnPropDescs$
|
1749
|
+
var __defProps$t = Object.defineProperties;
|
1750
|
+
var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
|
1751
1751
|
var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
|
1752
1752
|
var __hasOwnProp$H = Object.prototype.hasOwnProperty;
|
1753
1753
|
var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
|
@@ -1763,7 +1763,7 @@ var __spreadValues$H = (a, b) => {
|
|
1763
1763
|
}
|
1764
1764
|
return a;
|
1765
1765
|
};
|
1766
|
-
var __spreadProps$
|
1766
|
+
var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
|
1767
1767
|
function getTemplateProxyForField(field, frame, frames) {
|
1768
1768
|
return new Proxy(
|
1769
1769
|
{},
|
@@ -1779,7 +1779,7 @@ function getTemplateProxyForField(field, frame, frames) {
|
|
1779
1779
|
if (!field.labels) {
|
1780
1780
|
return "";
|
1781
1781
|
}
|
1782
|
-
return __spreadProps$
|
1782
|
+
return __spreadProps$t(__spreadValues$H({}, field.labels), {
|
1783
1783
|
__values: Object.values(field.labels).sort().join(", "),
|
1784
1784
|
toString: () => {
|
1785
1785
|
return data.formatLabels(field.labels, "", true);
|
@@ -2277,8 +2277,8 @@ function isExtraQueryProvider(obj) {
|
|
2277
2277
|
}
|
2278
2278
|
|
2279
2279
|
var __defProp$G = Object.defineProperty;
|
2280
|
-
var __defProps$
|
2281
|
-
var __getOwnPropDescs$
|
2280
|
+
var __defProps$s = Object.defineProperties;
|
2281
|
+
var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
|
2282
2282
|
var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
|
2283
2283
|
var __hasOwnProp$G = Object.prototype.hasOwnProperty;
|
2284
2284
|
var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
|
@@ -2294,7 +2294,7 @@ var __spreadValues$G = (a, b) => {
|
|
2294
2294
|
}
|
2295
2295
|
return a;
|
2296
2296
|
};
|
2297
|
-
var __spreadProps$
|
2297
|
+
var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
|
2298
2298
|
const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
|
2299
2299
|
const extraQueryProcessingOperator = (processors) => (data) => {
|
2300
2300
|
return data.pipe(
|
@@ -2307,7 +2307,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
|
|
2307
2307
|
}),
|
2308
2308
|
rxjs.map(([primary, ...processedSecondaries]) => {
|
2309
2309
|
var _a;
|
2310
|
-
return __spreadProps$
|
2310
|
+
return __spreadProps$s(__spreadValues$G({}, primary), {
|
2311
2311
|
series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
|
2312
2312
|
annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
|
2313
2313
|
var _a2;
|
@@ -2319,8 +2319,8 @@ const extraQueryProcessingOperator = (processors) => (data) => {
|
|
2319
2319
|
};
|
2320
2320
|
|
2321
2321
|
var __defProp$F = Object.defineProperty;
|
2322
|
-
var __defProps$
|
2323
|
-
var __getOwnPropDescs$
|
2322
|
+
var __defProps$r = Object.defineProperties;
|
2323
|
+
var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
|
2324
2324
|
var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
|
2325
2325
|
var __hasOwnProp$F = Object.prototype.hasOwnProperty;
|
2326
2326
|
var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
|
@@ -2336,7 +2336,7 @@ var __spreadValues$F = (a, b) => {
|
|
2336
2336
|
}
|
2337
2337
|
return a;
|
2338
2338
|
};
|
2339
|
-
var __spreadProps$
|
2339
|
+
var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
|
2340
2340
|
function filterAnnotations(data, filters) {
|
2341
2341
|
var _a;
|
2342
2342
|
if (!Array.isArray(data) || data.length === 0) {
|
@@ -2387,11 +2387,11 @@ function filterAnnotations(data, filters) {
|
|
2387
2387
|
continue;
|
2388
2388
|
}
|
2389
2389
|
}
|
2390
|
-
fields.push(__spreadProps$
|
2390
|
+
fields.push(__spreadProps$r(__spreadValues$F({}, field), {
|
2391
2391
|
values: buffer
|
2392
2392
|
}));
|
2393
2393
|
}
|
2394
|
-
processed.push(__spreadProps$
|
2394
|
+
processed.push(__spreadProps$r(__spreadValues$F({}, frame), {
|
2395
2395
|
fields,
|
2396
2396
|
length: frameLength
|
2397
2397
|
}));
|
@@ -2542,8 +2542,8 @@ function getOptionSearcher(options, includeAll) {
|
|
2542
2542
|
}
|
2543
2543
|
|
2544
2544
|
var __defProp$E = Object.defineProperty;
|
2545
|
-
var __defProps$
|
2546
|
-
var __getOwnPropDescs$
|
2545
|
+
var __defProps$q = Object.defineProperties;
|
2546
|
+
var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
|
2547
2547
|
var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
|
2548
2548
|
var __hasOwnProp$E = Object.prototype.hasOwnProperty;
|
2549
2549
|
var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
|
@@ -2559,7 +2559,7 @@ var __spreadValues$E = (a, b) => {
|
|
2559
2559
|
}
|
2560
2560
|
return a;
|
2561
2561
|
};
|
2562
|
-
var __spreadProps$
|
2562
|
+
var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
|
2563
2563
|
var __objRest$4 = (source, exclude) => {
|
2564
2564
|
var target = {};
|
2565
2565
|
for (var prop in source)
|
@@ -2715,7 +2715,7 @@ const OptionWithCheckbox = ({
|
|
2715
2715
|
const theme = ui.useTheme2();
|
2716
2716
|
const selectStyles = ui.getSelectStyles(theme);
|
2717
2717
|
const optionStyles = ui.useStyles2(getOptionStyles);
|
2718
|
-
return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$
|
2718
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$q(__spreadValues$E({
|
2719
2719
|
ref: innerRef,
|
2720
2720
|
className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
|
2721
2721
|
}, rest), {
|
@@ -2881,8 +2881,8 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
|
|
2881
2881
|
}
|
2882
2882
|
|
2883
2883
|
var __defProp$D = Object.defineProperty;
|
2884
|
-
var __defProps$
|
2885
|
-
var __getOwnPropDescs$
|
2884
|
+
var __defProps$p = Object.defineProperties;
|
2885
|
+
var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
|
2886
2886
|
var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
|
2887
2887
|
var __hasOwnProp$D = Object.prototype.hasOwnProperty;
|
2888
2888
|
var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
|
@@ -2898,10 +2898,10 @@ var __spreadValues$D = (a, b) => {
|
|
2898
2898
|
}
|
2899
2899
|
return a;
|
2900
2900
|
};
|
2901
|
-
var __spreadProps$
|
2901
|
+
var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
|
2902
2902
|
class GroupByVariable extends MultiValueVariable {
|
2903
2903
|
constructor(initialState) {
|
2904
|
-
super(__spreadProps$
|
2904
|
+
super(__spreadProps$p(__spreadValues$D({
|
2905
2905
|
isMulti: true,
|
2906
2906
|
name: "",
|
2907
2907
|
value: [],
|
@@ -4012,8 +4012,8 @@ const useFloatingInteractions = ({
|
|
4012
4012
|
};
|
4013
4013
|
|
4014
4014
|
var __defProp$A = Object.defineProperty;
|
4015
|
-
var __defProps$
|
4016
|
-
var __getOwnPropDescs$
|
4015
|
+
var __defProps$o = Object.defineProperties;
|
4016
|
+
var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
|
4017
4017
|
var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
|
4018
4018
|
var __hasOwnProp$A = Object.prototype.hasOwnProperty;
|
4019
4019
|
var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
|
@@ -4029,8 +4029,8 @@ var __spreadValues$A = (a, b) => {
|
|
4029
4029
|
}
|
4030
4030
|
return a;
|
4031
4031
|
};
|
4032
|
-
var __spreadProps$
|
4033
|
-
const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
|
4032
|
+
var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
|
4033
|
+
const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef }, parentRef) {
|
4034
4034
|
var _a, _b, _c;
|
4035
4035
|
const [open, setOpen] = React.useState(false);
|
4036
4036
|
const [options, setOptions] = React.useState([]);
|
@@ -4182,19 +4182,39 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4182
4182
|
const handleBackspaceInput = React.useCallback(
|
4183
4183
|
(event, multiValueEdit) => {
|
4184
4184
|
if (event.key === "Backspace" && !inputValue) {
|
4185
|
-
if (
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4191
|
-
|
4192
|
-
|
4193
|
-
|
4185
|
+
if (filterInputType === "value") {
|
4186
|
+
if (multiValueEdit) {
|
4187
|
+
if (filterMultiValues.length) {
|
4188
|
+
setFilterMultiValues((items) => {
|
4189
|
+
const updated = [...items];
|
4190
|
+
updated.splice(-1, 1);
|
4191
|
+
return updated;
|
4192
|
+
});
|
4193
|
+
return;
|
4194
|
+
}
|
4195
|
+
}
|
4196
|
+
setInputType("operator");
|
4197
|
+
return;
|
4198
|
+
}
|
4199
|
+
if (model.state.filters[0] === filter) {
|
4200
|
+
focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
|
4201
|
+
}
|
4202
|
+
model._handleComboboxBackspace(filter);
|
4203
|
+
if (isAlwaysWip) {
|
4204
|
+
handleResetWip();
|
4194
4205
|
}
|
4195
4206
|
}
|
4196
4207
|
},
|
4197
|
-
[
|
4208
|
+
[
|
4209
|
+
inputValue,
|
4210
|
+
filterInputType,
|
4211
|
+
model,
|
4212
|
+
filter,
|
4213
|
+
isAlwaysWip,
|
4214
|
+
filterMultiValues.length,
|
4215
|
+
handleResetWip,
|
4216
|
+
focusOnWipInputRef
|
4217
|
+
]
|
4198
4218
|
);
|
4199
4219
|
const handleTabInput = React.useCallback(
|
4200
4220
|
(event, multiValueEdit) => {
|
@@ -4338,7 +4358,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4338
4358
|
item,
|
4339
4359
|
index: i,
|
4340
4360
|
handleRemoveMultiValue
|
4341
|
-
})) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$
|
4361
|
+
})) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
|
4342
4362
|
ref: refs.setReference,
|
4343
4363
|
onChange,
|
4344
4364
|
value: inputValue,
|
@@ -4375,14 +4395,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4375
4395
|
visuallyHiddenDismiss: true,
|
4376
4396
|
modal: false
|
4377
4397
|
}, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
4378
|
-
style: __spreadProps$
|
4398
|
+
style: __spreadProps$o(__spreadValues$A({}, floatingStyles), {
|
4379
4399
|
width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,
|
4380
4400
|
transform: isMultiValueEdit ? `translate(${((_b = multiValuePillWrapperRef.current) == null ? void 0 : _b.getBoundingClientRect().left) || 0}px, ${(((_c = refs.domReference.current) == null ? void 0 : _c.getBoundingClientRect().bottom) || 0) + 10}px )` : floatingStyles.transform
|
4381
4401
|
}),
|
4382
4402
|
ref: refs.setFloating,
|
4383
4403
|
className: styles.dropdownWrapper,
|
4384
4404
|
tabIndex: -1
|
4385
|
-
}, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$
|
4405
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({
|
4386
4406
|
style: {
|
4387
4407
|
height: `${rowVirtualizer.getTotalSize() || VIRTUAL_LIST_ITEM_HEIGHT}px`
|
4388
4408
|
}
|
@@ -4410,7 +4430,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
4410
4430
|
}
|
4411
4431
|
const nextItem = filteredDropDownItems[virtualItem.index + 1];
|
4412
4432
|
const shouldAddBottomBorder = nextItem && !nextItem.group && !nextItem.options && item.group;
|
4413
|
-
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$
|
4433
|
+
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$o(__spreadValues$A({}, getItemProps({
|
4414
4434
|
key: `${item.value}-${index}`,
|
4415
4435
|
ref(node) {
|
4416
4436
|
listRef.current[index] = node;
|
@@ -4506,7 +4526,7 @@ const getStyles$b = (theme) => ({
|
|
4506
4526
|
alignItems: "center",
|
4507
4527
|
flexWrap: "wrap"
|
4508
4528
|
}),
|
4509
|
-
basePill: css.css(__spreadProps$
|
4529
|
+
basePill: css.css(__spreadProps$o(__spreadValues$A({
|
4510
4530
|
display: "flex",
|
4511
4531
|
alignItems: "center",
|
4512
4532
|
background: theme.colors.action.disabledBackground,
|
@@ -4573,7 +4593,7 @@ const getStyles$b = (theme) => ({
|
|
4573
4593
|
color: theme.colors.text.primary
|
4574
4594
|
}
|
4575
4595
|
}),
|
4576
|
-
descriptionText: css.css(__spreadProps$
|
4596
|
+
descriptionText: css.css(__spreadProps$o(__spreadValues$A({}, theme.typography.bodySmall), {
|
4577
4597
|
color: theme.colors.text.secondary,
|
4578
4598
|
paddingTop: theme.spacing(0.5)
|
4579
4599
|
})),
|
@@ -4586,8 +4606,8 @@ const getStyles$b = (theme) => ({
|
|
4586
4606
|
});
|
4587
4607
|
|
4588
4608
|
var __defProp$z = Object.defineProperty;
|
4589
|
-
var __defProps$
|
4590
|
-
var __getOwnPropDescs$
|
4609
|
+
var __defProps$n = Object.defineProperties;
|
4610
|
+
var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
|
4591
4611
|
var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
|
4592
4612
|
var __hasOwnProp$z = Object.prototype.hasOwnProperty;
|
4593
4613
|
var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
|
@@ -4603,8 +4623,8 @@ var __spreadValues$z = (a, b) => {
|
|
4603
4623
|
}
|
4604
4624
|
return a;
|
4605
4625
|
};
|
4606
|
-
var __spreadProps$
|
4607
|
-
function AdHocFilterPill({ filter, model, readOnly,
|
4626
|
+
var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
|
4627
|
+
function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
4608
4628
|
var _a, _b, _c;
|
4609
4629
|
const styles = ui.useStyles2(getStyles$a);
|
4610
4630
|
const [viewMode, setViewMode] = React.useState(true);
|
@@ -4630,6 +4650,12 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
|
|
4630
4650
|
setShouldFocus(false);
|
4631
4651
|
}
|
4632
4652
|
}, [shouldFocus]);
|
4653
|
+
React.useEffect(() => {
|
4654
|
+
if (filter.forceEdit && viewMode) {
|
4655
|
+
setViewMode(false);
|
4656
|
+
model._updateFilter(filter, { forceEdit: void 0 });
|
4657
|
+
}
|
4658
|
+
}, [filter, model, viewMode]);
|
4633
4659
|
if (viewMode) {
|
4634
4660
|
const pillText = /* @__PURE__ */ React__default["default"].createElement("span", {
|
4635
4661
|
className: styles.pillText
|
@@ -4655,14 +4681,14 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
|
|
4655
4681
|
onClick: (e) => {
|
4656
4682
|
e.stopPropagation();
|
4657
4683
|
model._removeFilter(filter);
|
4658
|
-
setTimeout(() =>
|
4684
|
+
setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
|
4659
4685
|
},
|
4660
4686
|
onKeyDownCapture: (e) => {
|
4661
4687
|
if (e.key === "Enter") {
|
4662
4688
|
e.preventDefault();
|
4663
4689
|
e.stopPropagation();
|
4664
4690
|
model._removeFilter(filter);
|
4665
|
-
setTimeout(() =>
|
4691
|
+
setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
|
4666
4692
|
}
|
4667
4693
|
},
|
4668
4694
|
name: "times",
|
@@ -4674,11 +4700,12 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
|
|
4674
4700
|
return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
|
4675
4701
|
filter,
|
4676
4702
|
model,
|
4677
|
-
handleChangeViewMode
|
4703
|
+
handleChangeViewMode,
|
4704
|
+
focusOnWipInputRef
|
4678
4705
|
});
|
4679
4706
|
}
|
4680
4707
|
const getStyles$a = (theme) => ({
|
4681
|
-
combinedFilterPill: css.css(__spreadProps$
|
4708
|
+
combinedFilterPill: css.css(__spreadProps$n(__spreadValues$z({
|
4682
4709
|
display: "flex",
|
4683
4710
|
alignItems: "center",
|
4684
4711
|
background: theme.colors.action.selected,
|
@@ -4739,26 +4766,26 @@ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwa
|
|
4739
4766
|
const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
|
4740
4767
|
const { filters, readOnly } = model.useState();
|
4741
4768
|
const styles = ui.useStyles2(getStyles$9);
|
4742
|
-
const
|
4769
|
+
const focusOnWipInputRef = React.useRef();
|
4743
4770
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
4744
4771
|
className: css.cx(styles.comboboxWrapper, { [styles.comboboxFocusOutline]: !readOnly }),
|
4745
4772
|
onClick: () => {
|
4746
4773
|
var _a;
|
4747
|
-
(_a =
|
4774
|
+
(_a = focusOnWipInputRef.current) == null ? void 0 : _a.call(focusOnWipInputRef);
|
4748
4775
|
}
|
4749
4776
|
}, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
|
4750
4777
|
name: "filter",
|
4751
4778
|
className: styles.filterIcon,
|
4752
4779
|
size: "lg"
|
4753
4780
|
}), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
|
4754
|
-
key: index
|
4781
|
+
key: `${index}-${filter.key}`,
|
4755
4782
|
filter,
|
4756
4783
|
model,
|
4757
4784
|
readOnly,
|
4758
|
-
|
4785
|
+
focusOnWipInputRef: focusOnWipInputRef.current
|
4759
4786
|
})), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersAlwaysWipCombobox, {
|
4760
4787
|
model,
|
4761
|
-
ref:
|
4788
|
+
ref: focusOnWipInputRef
|
4762
4789
|
}) : null);
|
4763
4790
|
});
|
4764
4791
|
const getStyles$9 = (theme) => ({
|
@@ -4794,6 +4821,8 @@ const getStyles$9 = (theme) => ({
|
|
4794
4821
|
});
|
4795
4822
|
|
4796
4823
|
var __defProp$y = Object.defineProperty;
|
4824
|
+
var __defProps$m = Object.defineProperties;
|
4825
|
+
var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
|
4797
4826
|
var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
|
4798
4827
|
var __hasOwnProp$y = Object.prototype.hasOwnProperty;
|
4799
4828
|
var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
|
@@ -4809,6 +4838,7 @@ var __spreadValues$y = (a, b) => {
|
|
4809
4838
|
}
|
4810
4839
|
return a;
|
4811
4840
|
};
|
4841
|
+
var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
|
4812
4842
|
const OPERATORS = [
|
4813
4843
|
{
|
4814
4844
|
value: "=",
|
@@ -4905,6 +4935,31 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
4905
4935
|
this._removeFilter(filterToRemove);
|
4906
4936
|
}
|
4907
4937
|
}
|
4938
|
+
_handleComboboxBackspace(filter) {
|
4939
|
+
if (this.state.filters.length) {
|
4940
|
+
let filterToForceIndex = this.state.filters.length - 1;
|
4941
|
+
if (filter !== this.state._wip) {
|
4942
|
+
const filterIndex = this.state.filters.findIndex((f) => f === filter);
|
4943
|
+
filterToForceIndex = filterIndex - 1;
|
4944
|
+
}
|
4945
|
+
this.setState({
|
4946
|
+
filters: this.state.filters.reduce((acc, f, index) => {
|
4947
|
+
if (index === filterToForceIndex) {
|
4948
|
+
return [
|
4949
|
+
...acc,
|
4950
|
+
__spreadProps$m(__spreadValues$y({}, f), {
|
4951
|
+
forceEdit: true
|
4952
|
+
})
|
4953
|
+
];
|
4954
|
+
}
|
4955
|
+
if (f === filter) {
|
4956
|
+
return acc;
|
4957
|
+
}
|
4958
|
+
return [...acc, f];
|
4959
|
+
}, [])
|
4960
|
+
});
|
4961
|
+
}
|
4962
|
+
}
|
4908
4963
|
async _getKeys(currentKey) {
|
4909
4964
|
var _a, _b, _c;
|
4910
4965
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
|