From f85470d6523a6d086176686cd47ef0a2177ff9e7 Mon Sep 17 00:00:00 2001 From: Brendan O'Handley Date: Mon, 15 Apr 2024 16:45:23 -0500 Subject: [PATCH] Prometheus: Use the frontend package in Prometheus and remove feature toggle (#86080) * add history links for monaco completion provider folder * add history links for monaco query field folder * add history links for components folder * add history links for configuration folder * add history links for dashboard json folder * add history links for gcopypaste folder * add history link for variableMigration * add history link for querybuilder/components/metrics-modal folder * add history link for querybuilder/components/promqail folder * add history links for querybuilder/components folder * add history links for querybuilder/hooks folder * add history links for querybuilder/shared folder * add history links for querybuilder folder * add history links for querycache folder * add history links for src folder * use frontend package and custom auth in module.ts * remove files and fix import issues * remove usePrometheusFrontendPackage * remove extra files * update betterer * remove extra files after rebase * fix betterer for rebase * fix e2e flakiness --- .betterer.results | 247 ---- .../feature-toggles/index.md | 1 - e2e/various-suite/query-editor.spec.ts | 2 +- .../src/types/featureToggles.gen.ts | 1 - .../src/add_label_to_query.test.ts | 1 + .../src/add_label_to_query.ts | 1 + .../src/components/AnnotationQueryEditor.tsx | 1 + .../src/components/PromCheatSheet.tsx | 1 + .../src/components/PromExemplarField.tsx | 1 + .../components/PromExploreExtraField.test.tsx | 1 + .../src/components/PromExploreExtraField.tsx | 1 + .../components/PromQueryEditorByApp.test.tsx | 1 + .../src/components/PromQueryEditorByApp.tsx | 1 + .../components/PromQueryEditorForAlerting.tsx | 1 + .../src/components/PromQueryField.test.tsx | 1 + .../src/components/PromQueryField.tsx | 1 + .../PrometheusMetricsBrowser.test.tsx | 1 + .../components/PrometheusMetricsBrowser.tsx | 1 + .../components/VariableQueryEditor.test.tsx | 1 + .../src/components/VariableQueryEditor.tsx | 1 + .../monaco-query-field/MonacoQueryField.tsx | 1 + .../MonacoQueryFieldLazy.tsx | 1 + .../MonacoQueryFieldProps.ts | 1 + .../MonacoQueryFieldWrapper.tsx | 1 + .../monaco-query-field/getOverrideServices.ts | 1 + .../monaco-completion-provider/completions.ts | 1 + .../monaco-completion-provider/index.ts | 1 + .../situation.test.ts | 1 + .../monaco-completion-provider/situation.ts | 1 + .../monaco-completion-provider/util.ts | 2 + .../validation.test.ts | 1 + .../monaco-completion-provider/validation.ts | 1 + .../src/components/types.ts | 1 + .../AlertingSettingsOverhaul.tsx | 1 + .../src/configuration/ConfigEditor.test.tsx | 1 + .../src/configuration/ConfigEditor.tsx | 1 + .../DataSourceHttpSettingsOverhaul.tsx | 1 + .../src/configuration/ExemplarSetting.tsx | 1 + .../src/configuration/ExemplarsSettings.tsx | 1 + .../src/configuration/PromFlavorVersions.ts | 1 + .../src/configuration/PromSettings.test.tsx | 1 + .../src/configuration/PromSettings.tsx | 1 + .../src/configuration/mocks.ts | 1 + .../src/dashboards/grafana_stats.json | 1 + .../src/dashboards/prometheus_2_stats.json | 1 + .../src/dashboards/prometheus_stats.json | 1 + packages/grafana-prometheus/src/dataquery.ts | 1 + .../grafana-prometheus/src/datasource.test.ts | 1 + packages/grafana-prometheus/src/datasource.ts | 1 + .../LocalStorageValueProvider.tsx | 1 + .../LocalStorageValueProvider/index.tsx | 1 + .../src/gcopypaste/app/core/store.ts | 1 + .../app/core/utils/CancelablePromise.ts | 1 + .../src/gcopypaste/app/core/utils/query.ts | 1 + .../datasources/__mocks__/dataSourcesMocks.ts | 1 + .../app/features/live/data/amendTimeSeries.ts | 1 + .../src/components/Select/SelectBase.tsx | 1 + .../gcopypaste/public/test/matchers/index.ts | 1 + .../public/test/matchers/toEmitValues.test.ts | 1 + .../public/test/matchers/toEmitValues.ts | 1 + .../test/matchers/toEmitValuesWith.test.ts | 1 + .../public/test/matchers/toEmitValuesWith.ts | 1 + .../gcopypaste/public/test/matchers/types.ts | 1 + .../gcopypaste/public/test/matchers/utils.ts | 1 + .../test/helpers/selectOptionInTest.ts | 1 + packages/grafana-prometheus/src/index.ts | 4 +- .../src/language_provider.mock.ts | 1 + .../src/language_provider.test.ts | 1 + .../src/language_provider.ts | 1 + .../src/language_utils.test.ts | 1 + .../grafana-prometheus/src/language_utils.ts | 1 + .../src/metric_find_query.test.ts | 1 + .../src/metric_find_query.ts | 1 + .../src/migrations/variableMigration.ts | 1 + .../grafana-prometheus/src/module.test.ts | 1 + packages/grafana-prometheus/src/module.ts | 1 + .../grafana-prometheus/src/promql.test.ts | 1 + packages/grafana-prometheus/src/promql.ts | 1 + .../src/query_hints.test.ts | 1 + .../grafana-prometheus/src/query_hints.ts | 1 + .../querybuilder/PromQueryModeller.test.ts | 1 + .../src/querybuilder/PromQueryModeller.ts | 1 + .../src/querybuilder/QueryPattern.tsx | 1 + .../querybuilder/QueryPatternsModal.test.tsx | 1 + .../src/querybuilder/QueryPatternsModal.tsx | 1 + .../src/querybuilder/aggregations.ts | 1 + .../querybuilder/binaryScalarOperations.ts | 1 + .../components/LabelFilterItem.tsx | 1 + .../components/LabelFilters.test.tsx | 1 + .../querybuilder/components/LabelFilters.tsx | 1 + .../components/LabelParamEditor.tsx | 1 + .../components/MetricSelect.test.tsx | 1 + .../querybuilder/components/MetricSelect.tsx | 1 + .../components/MetricsLabelsSection.tsx | 1 + .../querybuilder/components/NestedQuery.tsx | 1 + .../components/NestedQueryList.tsx | 1 + .../components/PromQueryBuilder.test.tsx | 1 + .../components/PromQueryBuilder.tsx | 1 + .../PromQueryBuilderContainer.test.tsx | 1 + .../components/PromQueryBuilderContainer.tsx | 1 + .../components/PromQueryBuilderExplained.tsx | 1 + .../PromQueryBuilderOptions.test.tsx | 1 + .../components/PromQueryBuilderOptions.tsx | 1 + .../components/PromQueryCodeEditor.test.tsx | 1 + .../components/PromQueryCodeEditor.tsx | 1 + .../PromQueryEditorSelector.test.tsx | 1 + .../components/PromQueryEditorSelector.tsx | 1 + .../components/PromQueryLegendEditor.tsx | 1 + .../querybuilder/components/QueryPreview.tsx | 1 + .../metrics-modal/AdditionalSettings.tsx | 1 + .../components/metrics-modal/FeedbackLink.tsx | 1 + .../metrics-modal/MetricsModal.test.tsx | 1 + .../components/metrics-modal/MetricsModal.tsx | 1 + .../components/metrics-modal/ResultsTable.tsx | 1 + .../components/metrics-modal/state/helpers.ts | 1 + .../components/metrics-modal/state/state.ts | 1 + .../components/metrics-modal/styles.ts | 1 + .../components/metrics-modal/types.ts | 1 + .../components/metrics-modal/uFuzzy.ts | 1 + .../components/promQail/PromQail.test.tsx | 1 + .../components/promQail/PromQail.tsx | 1 + .../promQail/QueryAssistantButton.test.tsx | 1 + .../promQail/QueryAssistantButton.tsx | 1 + .../promQail/QuerySuggestionContainer.tsx | 1 + .../promQail/QuerySuggestionItem.tsx | 1 + .../components/promQail/prompts.ts | 1 + .../components/promQail/state/helpers.test.ts | 1 + .../components/promQail/state/helpers.ts | 1 + .../components/promQail/state/state.ts | 1 + .../components/promQail/state/templates.ts | 1 + .../querybuilder/components/promQail/types.ts | 1 + .../src/querybuilder/hooks/useFlag.test.ts | 1 + .../src/querybuilder/hooks/useFlag.ts | 1 + .../src/querybuilder/operationUtils.test.ts | 1 + .../src/querybuilder/operationUtils.ts | 1 + .../src/querybuilder/operations.ts | 1 + .../src/querybuilder/parsing.test.ts | 1 + .../src/querybuilder/parsing.ts | 1 + .../src/querybuilder/parsingUtils.test.ts | 1 + .../src/querybuilder/parsingUtils.ts | 1 + .../shared/LokiAndPromQueryModellerBase.ts | 1 + .../querybuilder/shared/OperationEditor.tsx | 1 + .../shared/OperationExplainedBox.tsx | 1 + .../querybuilder/shared/OperationHeader.tsx | 1 + .../shared/OperationInfoButton.tsx | 1 + .../shared/OperationList.test.tsx | 1 + .../src/querybuilder/shared/OperationList.tsx | 1 + .../shared/OperationListExplained.tsx | 1 + .../shared/OperationParamEditor.tsx | 1 + .../shared/OperationsEditorRow.tsx | 1 + .../querybuilder/shared/QueryBuilderHints.tsx | 1 + .../shared/QueryEditorModeToggle.tsx | 1 + .../querybuilder/shared/QueryHeaderSwitch.tsx | 1 + .../querybuilder/shared/QueryOptionGroup.tsx | 1 + .../src/querybuilder/shared/RawQuery.tsx | 1 + .../src/querybuilder/shared/types.ts | 1 + .../src/querybuilder/state.test.ts | 1 + .../src/querybuilder/state.ts | 1 + .../src/querybuilder/testUtils.ts | 1 + .../src/querybuilder/types.ts | 1 + .../src/querycache/QueryCache.test.ts | 1 + .../src/querycache/QueryCache.ts | 1 + .../src/querycache/QueryCacheTestData.ts | 1 + .../src/result_transformer.test.ts | 1 + .../src/result_transformer.ts | 1 + packages/grafana-prometheus/src/tracking.ts | 1 + packages/grafana-prometheus/src/types.ts | 1 + packages/grafana-prometheus/src/variables.ts | 1 + pkg/services/featuremgmt/registry.go | 7 - pkg/services/featuremgmt/toggles_gen.csv | 1 - pkg/services/featuremgmt/toggles_gen.go | 4 - pkg/services/featuremgmt/toggles_gen.json | 1 + .../unified/PanelAlertTabContent.test.tsx | 3 +- .../unified/components/Expression.tsx | 4 +- .../rule-editor/ExpressionEditor.tsx | 2 +- .../features/alerting/unified/utils/query.ts | 2 +- .../alerting/unified/utils/rule-form.test.ts | 2 +- .../alerting/unified/utils/rule-form.ts | 2 +- .../PanelDataAlertingTab.test.tsx | 3 +- .../dashboard/state/DashboardModel.ts | 2 +- .../explore/PrometheusListView/ItemLabels.tsx | 3 +- .../explore/TraceView/createSpanLink.tsx | 2 +- .../trails/ActionTabs/MetricOverviewScene.tsx | 2 +- .../AutomaticMetricQueries/previewPanel.ts | 2 +- .../query-generators/histogram.ts | 2 +- .../trails/AutomaticMetricQueries/types.ts | 2 +- .../trails/helpers/MetricDatasourceHelper.ts | 4 +- .../dashboard/DashboardQueryEditor.tsx | 3 +- .../prometheus/add_label_to_query.test.ts | 114 -- .../prometheus/add_label_to_query.ts | 100 -- .../components/AnnotationQueryEditor.tsx | 139 -- .../prometheus/components/PromCheatSheet.tsx | 52 - .../components/PromExemplarField.tsx | 79 - .../components/PromExploreExtraField.test.tsx | 37 - .../components/PromExploreExtraField.tsx | 141 -- .../components/PromQueryEditorByApp.test.tsx | 83 -- .../components/PromQueryEditorByApp.tsx | 21 - .../components/PromQueryEditorForAlerting.tsx | 25 - .../components/PromQueryField.test.tsx | 183 --- .../prometheus/components/PromQueryField.tsx | 290 ---- .../PrometheusMetricsBrowser.test.tsx | 324 ---- .../components/PrometheusMetricsBrowser.tsx | 684 --------- .../components/VariableQueryEditor.test.tsx | 392 ----- .../components/VariableQueryEditor.tsx | 437 ------ .../monaco-query-field/MonacoQueryField.tsx | 296 ---- .../MonacoQueryFieldLazy.tsx | 13 - .../MonacoQueryFieldProps.ts | 21 - .../MonacoQueryFieldWrapper.tsx | 34 - .../monaco-query-field/getOverrideServices.ts | 116 -- .../completions.test.ts | 118 -- .../monaco-completion-provider/completions.ts | 217 --- .../data_provider.ts | 116 -- .../monaco-completion-provider/index.ts | 116 -- .../situation.test.ts | 185 --- .../monaco-completion-provider/situation.ts | 567 ------- .../monaco-completion-provider/util.ts | 25 - .../validation.test.ts | 85 -- .../datasource/prometheus/components/types.ts | 6 - .../AlertingSettingsOverhaul.tsx | 65 - .../configuration/ConfigEditor.test.tsx | 93 -- .../prometheus/configuration/ConfigEditor.tsx | 195 --- .../DataSourceHttpSettingsOverhaul.tsx | 168 --- .../configuration/ExemplarSetting.tsx | 150 -- .../configuration/ExemplarsSettings.tsx | 67 - .../configuration/PromFlavorVersions.ts | 99 -- .../configuration/PromSettings.test.tsx | 142 -- .../prometheus/configuration/PromSettings.tsx | 638 -------- .../prometheus/configuration/mocks.ts | 14 - .../overhaul/AdvancedHttpSettings.tsx | 93 -- .../overhaul/ConnectionSettings.tsx | 90 -- .../configuration/overhaul/types.ts | 11 - .../datasource/prometheus/dataquery.ts | 49 - .../datasource/prometheus/datasource.test.ts | 1297 ----------------- .../datasource/prometheus/datasource.ts | 1023 ------------- .../prometheus/language_provider.mock.ts | 18 - .../prometheus/language_provider.test.ts | 393 ----- .../prometheus/language_provider.ts | 378 ----- .../prometheus/language_utils.test.ts | 515 ------- .../datasource/prometheus/language_utils.ts | 533 ------- .../prometheus/metric_find_query.test.ts | 413 ------ .../prometheus/metric_find_query.ts | 203 --- .../migrations/variableMigration.ts | 137 -- .../plugins/datasource/prometheus/module.ts | 30 +- .../datasource/prometheus/promql.test.ts | 23 - .../plugins/datasource/prometheus/promql.ts | 607 -------- .../datasource/prometheus/query_hints.test.ts | 192 --- .../datasource/prometheus/query_hints.ts | 151 -- .../querybuilder/PromQueryModeller.test.ts | 335 ----- .../querybuilder/PromQueryModeller.ts | 93 -- .../prometheus/querybuilder/QueryPattern.tsx | 118 -- .../querybuilder/QueryPatternsModal.test.tsx | 143 -- .../querybuilder/QueryPatternsModal.tsx | 132 -- .../prometheus/querybuilder/aggregations.ts | 62 - .../querybuilder/binaryScalarOperations.ts | 120 -- .../components/LabelFilterItem.tsx | 195 --- .../components/LabelFilters.test.tsx | 162 -- .../querybuilder/components/LabelFilters.tsx | 114 -- .../components/LabelParamEditor.tsx | 60 - .../components/MetricSelect.test.tsx | 191 --- .../querybuilder/components/MetricSelect.tsx | 423 ------ .../components/MetricsLabelsSection.tsx | 252 ---- .../querybuilder/components/NestedQuery.tsx | 129 -- .../components/NestedQueryList.tsx | 49 - .../components/PromQueryBuilder.test.tsx | 392 ----- .../components/PromQueryBuilder.tsx | 149 -- .../PromQueryBuilderContainer.test.tsx | 64 - .../components/PromQueryBuilderContainer.tsx | 120 -- .../components/PromQueryBuilderExplained.tsx | 41 - .../PromQueryBuilderOptions.test.tsx | 134 -- .../components/PromQueryBuilderOptions.tsx | 162 -- .../components/PromQueryCodeEditor.test.tsx | 64 - .../components/PromQueryCodeEditor.tsx | 52 - ...omQueryCodeEditorAutocompleteInfo.test.tsx | 161 -- .../PromQueryCodeEditorAutocompleteInfo.tsx | 69 - .../PromQueryEditorSelector.test.tsx | 255 ---- .../components/PromQueryEditorSelector.tsx | 168 --- .../components/PromQueryLegendEditor.tsx | 119 -- .../querybuilder/components/QueryPreview.tsx | 24 - .../metrics-modal/AdditionalSettings.tsx | 81 - .../components/metrics-modal/FeedbackLink.tsx | 40 - .../metrics-modal/MetricsModal.test.tsx | 261 ---- .../components/metrics-modal/MetricsModal.tsx | 337 ----- .../components/metrics-modal/ResultsTable.tsx | 252 ---- .../components/metrics-modal/state/helpers.ts | 259 ---- .../components/metrics-modal/state/state.ts | 193 --- .../components/metrics-modal/styles.ts | 101 -- .../components/metrics-modal/types.ts | 30 - .../components/metrics-modal/uFuzzy.ts | 45 - .../components/promQail/PromQail.test.tsx | 148 -- .../components/promQail/PromQail.tsx | 567 ------- .../promQail/QueryAssistantButton.test.tsx | 51 - .../promQail/QueryAssistantButton.tsx | 87 -- .../promQail/QuerySuggestionContainer.tsx | 101 -- .../promQail/QuerySuggestionItem.tsx | 321 ---- .../components/promQail/prompts.ts | 114 -- .../promQail/resources/AI_Logo_bw.svg | 4 - .../promQail/resources/AI_Logo_color.svg | 11 - .../components/promQail/state/helpers.test.ts | 74 - .../components/promQail/state/helpers.ts | 419 ------ .../components/promQail/state/state.ts | 93 -- .../components/promQail/state/templates.ts | 337 ----- .../querybuilder/components/promQail/types.ts | 17 - .../querybuilder/hooks/useFlag.test.ts | 23 - .../prometheus/querybuilder/hooks/useFlag.ts | 36 - .../querybuilder/operationUtils.test.ts | 208 --- .../prometheus/querybuilder/operationUtils.ts | 353 ----- .../prometheus/querybuilder/operations.ts | 376 ----- .../prometheus/querybuilder/parsing.test.ts | 720 --------- .../prometheus/querybuilder/parsing.ts | 468 ------ .../querybuilder/parsingUtils.test.ts | 42 - .../prometheus/querybuilder/parsingUtils.ts | 140 -- .../querybuilder/shared/LabelFilterItem.tsx | 184 --- .../querybuilder/shared/LabelFilters.test.tsx | 121 -- .../querybuilder/shared/LabelFilters.tsx | 79 - .../shared/LokiAndPromQueryModellerBase.ts | 122 -- .../querybuilder/shared/OperationEditor.tsx | 332 ----- .../shared/OperationExplainedBox.tsx | 77 - .../querybuilder/shared/OperationHeader.tsx | 121 -- .../shared/OperationInfoButton.tsx | 120 -- .../shared/OperationList.test.tsx | 85 -- .../querybuilder/shared/OperationList.tsx | 204 --- .../shared/OperationListExplained.tsx | 55 - .../shared/OperationParamEditor.tsx | 129 -- .../shared/OperationsEditorRow.tsx | 29 - .../querybuilder/shared/QueryBuilderHints.tsx | 88 -- .../shared/QueryEditorModeToggle.tsx | 23 - .../querybuilder/shared/QueryHeaderSwitch.tsx | 39 - .../shared/QueryOptionGroup.test.tsx | 48 - .../querybuilder/shared/QueryOptionGroup.tsx | 114 -- .../querybuilder/shared/RawQuery.tsx | 37 - .../prometheus/querybuilder/shared/types.ts | 110 -- .../prometheus/querybuilder/state.test.ts | 64 - .../prometheus/querybuilder/state.ts | 72 - .../prometheus/querybuilder/testUtils.ts | 27 - .../prometheus/querybuilder/types.ts | 139 -- .../prometheus/querycache/QueryCache.test.ts | 521 ------- .../prometheus/querycache/QueryCache.ts | 441 ------ .../querycache/QueryCacheTestData.ts | 862 ----------- .../prometheus/result_transformer.test.ts | 1159 --------------- .../prometheus/result_transformer.ts | 422 ------ .../plugins/datasource/prometheus/tracking.ts | 46 - .../plugins/datasource/prometheus/types.ts | 142 -- .../datasource/prometheus/variables.ts | 58 - public/app/plugins/panel/heatmap/fields.ts | 2 +- 344 files changed, 193 insertions(+), 30015 deletions(-) delete mode 100644 public/app/plugins/datasource/prometheus/add_label_to_query.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/add_label_to_query.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/AnnotationQueryEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromExemplarField.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromExploreExtraField.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromQueryEditorForAlerting.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromQueryField.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PromQueryField.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/VariableQueryEditor.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryField.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryFieldLazy.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryFieldProps.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryFieldWrapper.tsx delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/getOverrideServices.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/completions.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/completions.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/data_provider.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/index.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/situation.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/situation.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/util.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/validation.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/components/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/configuration/AlertingSettingsOverhaul.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/ConfigEditor.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/ConfigEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/DataSourceHttpSettingsOverhaul.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/ExemplarSetting.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/ExemplarsSettings.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/PromFlavorVersions.ts delete mode 100644 public/app/plugins/datasource/prometheus/configuration/PromSettings.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/mocks.ts delete mode 100644 public/app/plugins/datasource/prometheus/configuration/overhaul/AdvancedHttpSettings.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/overhaul/ConnectionSettings.tsx delete mode 100644 public/app/plugins/datasource/prometheus/configuration/overhaul/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/dataquery.ts delete mode 100644 public/app/plugins/datasource/prometheus/datasource.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/datasource.ts delete mode 100644 public/app/plugins/datasource/prometheus/language_provider.mock.ts delete mode 100644 public/app/plugins/datasource/prometheus/language_provider.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/language_provider.ts delete mode 100644 public/app/plugins/datasource/prometheus/language_utils.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/language_utils.ts delete mode 100644 public/app/plugins/datasource/prometheus/metric_find_query.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/metric_find_query.ts delete mode 100644 public/app/plugins/datasource/prometheus/migrations/variableMigration.ts delete mode 100644 public/app/plugins/datasource/prometheus/promql.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/promql.ts delete mode 100644 public/app/plugins/datasource/prometheus/query_hints.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/query_hints.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/PromQueryModeller.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/PromQueryModeller.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/QueryPattern.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/QueryPatternsModal.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/QueryPatternsModal.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/aggregations.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/binaryScalarOperations.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilterItem.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/LabelParamEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/MetricSelect.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/MetricSelect.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/MetricsLabelsSection.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/NestedQuery.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/NestedQueryList.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilder.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilder.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderContainer.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderContainer.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderExplained.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderOptions.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderOptions.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditorAutocompleteInfo.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditorAutocompleteInfo.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryEditorSelector.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryEditorSelector.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryLegendEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/QueryPreview.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/AdditionalSettings.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/FeedbackLink.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/MetricsModal.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/MetricsModal.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/ResultsTable.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/state/helpers.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/state/state.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/styles.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/uFuzzy.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/PromQail.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/PromQail.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QueryAssistantButton.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QueryAssistantButton.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QuerySuggestionContainer.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QuerySuggestionItem.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/prompts.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/resources/AI_Logo_bw.svg delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/resources/AI_Logo_color.svg delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/helpers.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/helpers.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/state.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/templates.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/components/promQail/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/hooks/useFlag.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/hooks/useFlag.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/operationUtils.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/operationUtils.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/operations.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/parsing.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/parsing.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/parsingUtils.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/parsingUtils.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilters.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilters.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/LokiAndPromQueryModellerBase.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationExplainedBox.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationHeader.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationInfoButton.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationList.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationList.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationListExplained.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/OperationsEditorRow.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/QueryBuilderHints.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/QueryEditorModeToggle.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/QueryHeaderSwitch.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/QueryOptionGroup.test.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/QueryOptionGroup.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/RawQuery.tsx delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/shared/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/state.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/state.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/testUtils.ts delete mode 100644 public/app/plugins/datasource/prometheus/querybuilder/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/querycache/QueryCache.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/querycache/QueryCache.ts delete mode 100644 public/app/plugins/datasource/prometheus/querycache/QueryCacheTestData.ts delete mode 100644 public/app/plugins/datasource/prometheus/result_transformer.test.ts delete mode 100644 public/app/plugins/datasource/prometheus/result_transformer.ts delete mode 100644 public/app/plugins/datasource/prometheus/tracking.ts delete mode 100644 public/app/plugins/datasource/prometheus/types.ts delete mode 100644 public/app/plugins/datasource/prometheus/variables.ts diff --git a/.betterer.results b/.betterer.results index b39049d9b2d..d9cef880441 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5681,40 +5681,6 @@ exports[`better eslint`] = { "public/app/plugins/datasource/parca/webpack.config.ts:5381": [ [0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"] ], - "public/app/plugins/datasource/prometheus/components/PromExemplarField.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"] - ], - "public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"] - ], - "public/app/plugins/datasource/prometheus/components/PromQueryField.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/plugins/datasource/prometheus/components/PromQueryField.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx:5381": [ - [0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"], - [0, 0, 0, "Styles should be written using objects.", "5"], - [0, 0, 0, "Styles should be written using objects.", "6"], - [0, 0, 0, "Styles should be written using objects.", "7"], - [0, 0, 0, "Styles should be written using objects.", "8"], - [0, 0, 0, "Styles should be written using objects.", "9"], - [0, 0, 0, "Styles should be written using objects.", "10"], - [0, 0, 0, "Styles should be written using objects.", "11"], - [0, 0, 0, "Styles should be written using objects.", "12"] - ], - "public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryField.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"] - ], "public/app/plugins/datasource/prometheus/configuration/AzureCredentialsConfig.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -5736,165 +5702,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "17"], [0, 0, 0, "Unexpected any. Specify a different type.", "18"] ], - "public/app/plugins/datasource/prometheus/configuration/ConfigEditor.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"], - [0, 0, 0, "Styles should be written using objects.", "5"], - [0, 0, 0, "Styles should be written using objects.", "6"], - [0, 0, 0, "Styles should be written using objects.", "7"], - [0, 0, 0, "Styles should be written using objects.", "8"], - [0, 0, 0, "Styles should be written using objects.", "9"], - [0, 0, 0, "Styles should be written using objects.", "10"], - [0, 0, 0, "Styles should be written using objects.", "11"], - [0, 0, 0, "Styles should be written using objects.", "12"], - [0, 0, 0, "Styles should be written using objects.", "13"], - [0, 0, 0, "Styles should be written using objects.", "14"], - [0, 0, 0, "Styles should be written using objects.", "15"] - ], - "public/app/plugins/datasource/prometheus/configuration/ExemplarsSettings.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"] - ], - "public/app/plugins/datasource/prometheus/datasource.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"], - [0, 0, 0, "Unexpected any. Specify a different type.", "8"] - ], - "public/app/plugins/datasource/prometheus/language_provider.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], - "public/app/plugins/datasource/prometheus/language_utils.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/QueryPattern.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/QueryPatternsModal.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/binaryScalarOperations.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilterItem.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/LabelParamEditor.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/MetricSelect.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"], - [0, 0, 0, "Styles should be written using objects.", "5"], - [0, 0, 0, "Styles should be written using objects.", "6"], - [0, 0, 0, "Styles should be written using objects.", "7"], - [0, 0, 0, "Styles should be written using objects.", "8"], - [0, 0, 0, "Styles should be written using objects.", "9"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilder.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/AdditionalSettings.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/ResultsTable.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"], - [0, 0, 0, "Styles should be written using objects.", "5"], - [0, 0, 0, "Styles should be written using objects.", "6"], - [0, 0, 0, "Styles should be written using objects.", "7"], - [0, 0, 0, "Styles should be written using objects.", "8"], - [0, 0, 0, "Styles should be written using objects.", "9"], - [0, 0, 0, "Styles should be written using objects.", "10"], - [0, 0, 0, "Styles should be written using objects.", "11"], - [0, 0, 0, "Styles should be written using objects.", "12"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/styles.ts:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"], - [0, 0, 0, "Styles should be written using objects.", "5"], - [0, 0, 0, "Styles should be written using objects.", "6"], - [0, 0, 0, "Styles should be written using objects.", "7"], - [0, 0, 0, "Styles should be written using objects.", "8"], - [0, 0, 0, "Styles should be written using objects.", "9"], - [0, 0, 0, "Styles should be written using objects.", "10"], - [0, 0, 0, "Styles should be written using objects.", "11"], - [0, 0, 0, "Styles should be written using objects.", "12"], - [0, 0, 0, "Styles should be written using objects.", "13"], - [0, 0, 0, "Styles should be written using objects.", "14"], - [0, 0, 0, "Styles should be written using objects.", "15"], - [0, 0, 0, "Styles should be written using objects.", "16"], - [0, 0, 0, "Styles should be written using objects.", "17"], - [0, 0, 0, "Styles should be written using objects.", "18"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilterItem.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Do not use any type assertions.", "7"], - [0, 0, 0, "Do not use any type assertions.", "8"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/shared/LabelFilters.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/shared/QueryBuilderHints.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/shared/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], - "public/app/plugins/datasource/prometheus/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], "public/app/plugins/datasource/tempo/QueryField.tsx:5381": [ [0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"] ], @@ -7163,25 +6970,6 @@ exports[`no gf-form usage`] = { [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] ], - "public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx:5381": [ - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] - ], - "public/app/plugins/datasource/prometheus/components/PromQueryField.tsx:5381": [ - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] - ], - "public/app/plugins/datasource/prometheus/configuration/AlertingSettingsOverhaul.tsx:5381": [ - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] - ], "public/app/plugins/datasource/prometheus/configuration/AzureAuthSettings.tsx:5381": [ [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] ], @@ -7208,41 +6996,6 @@ exports[`no gf-form usage`] = { [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] ], - "public/app/plugins/datasource/prometheus/configuration/ExemplarSetting.tsx:5381": [ - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] - ], - "public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx:5381": [ - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] - ], - "public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.tsx:5381": [ - [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] - ], "public/app/plugins/datasource/tempo/_importedDependencies/components/AdHocFilter/AdHocFilter.tsx:5381": [ [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] ], diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 0d755b205e1..c17980df319 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -59,7 +59,6 @@ Some features are enabled by default. You can disable these feature by setting t | `lokiQueryHints` | Enables query hints for Loki | Yes | | `alertingQueryOptimization` | Optimizes eligible queries in order to reduce load on datasources | | | `betterPageScrolling` | Removes CustomScrollbar from the UI, relying on native browser scrollbars | Yes | -| `usePrometheusFrontendPackage` | Use the @grafana/prometheus frontend package in core Prometheus. | | | `cloudWatchNewLabelParsing` | Updates CloudWatch label parsing to be more accurate | Yes | ## Preview feature toggles diff --git a/e2e/various-suite/query-editor.spec.ts b/e2e/various-suite/query-editor.spec.ts index 3441f2b4c0d..4a4b8b249c5 100644 --- a/e2e/various-suite/query-editor.spec.ts +++ b/e2e/various-suite/query-editor.spec.ts @@ -13,7 +13,7 @@ describe('Query editor', () => { cy.contains('gdev-prometheus').scrollIntoView().should('be.visible').click(); const queryText = `rate(http_requests_total{job="grafana"}[5m])`; - e2e.components.RadioButton.container().filter(':contains("Code")').click(); + e2e.components.RadioButton.container().filter(':contains("Code")').should('be.visible').click(); waitForMonacoToLoad(); diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index a751590217f..a070155a704 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -174,7 +174,6 @@ export interface FeatureToggles { authAPIAccessTokenAuth?: boolean; scopeFilters?: boolean; ssoSettingsSAML?: boolean; - usePrometheusFrontendPackage?: boolean; oauthRequireSubClaim?: boolean; newDashboardWithFiltersAndGroupBy?: boolean; cloudWatchNewLabelParsing?: boolean; diff --git a/packages/grafana-prometheus/src/add_label_to_query.test.ts b/packages/grafana-prometheus/src/add_label_to_query.test.ts index 08c32e3c398..0936da9f726 100644 --- a/packages/grafana-prometheus/src/add_label_to_query.test.ts +++ b/packages/grafana-prometheus/src/add_label_to_query.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/add_label_to_query.test.ts import { addLabelToQuery } from './add_label_to_query'; describe('addLabelToQuery()', () => { diff --git a/packages/grafana-prometheus/src/add_label_to_query.ts b/packages/grafana-prometheus/src/add_label_to_query.ts index 696e0cbb8dc..690a5c3aaff 100644 --- a/packages/grafana-prometheus/src/add_label_to_query.ts +++ b/packages/grafana-prometheus/src/add_label_to_query.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/add_label_to_query.ts import { parser, VectorSelector } from '@prometheus-io/lezer-promql'; import { PromQueryModeller } from './querybuilder/PromQueryModeller'; diff --git a/packages/grafana-prometheus/src/components/AnnotationQueryEditor.tsx b/packages/grafana-prometheus/src/components/AnnotationQueryEditor.tsx index 0cbaf5978cd..2c22905e99e 100644 --- a/packages/grafana-prometheus/src/components/AnnotationQueryEditor.tsx +++ b/packages/grafana-prometheus/src/components/AnnotationQueryEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/AnnotationQueryEditor.tsx import React from 'react'; import { AnnotationQuery } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/components/PromCheatSheet.tsx b/packages/grafana-prometheus/src/components/PromCheatSheet.tsx index 347d6547301..7eaee0b0782 100644 --- a/packages/grafana-prometheus/src/components/PromCheatSheet.tsx +++ b/packages/grafana-prometheus/src/components/PromCheatSheet.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx import React from 'react'; import { QueryEditorHelpProps } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/components/PromExemplarField.tsx b/packages/grafana-prometheus/src/components/PromExemplarField.tsx index e09a6260c98..8b300687dad 100644 --- a/packages/grafana-prometheus/src/components/PromExemplarField.tsx +++ b/packages/grafana-prometheus/src/components/PromExemplarField.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromExemplarField.tsx import { css, cx } from '@emotion/css'; import React, { useEffect, useState } from 'react'; import { usePrevious } from 'react-use'; diff --git a/packages/grafana-prometheus/src/components/PromExploreExtraField.test.tsx b/packages/grafana-prometheus/src/components/PromExploreExtraField.test.tsx index 4c22e2f16f2..75cc778f7f0 100644 --- a/packages/grafana-prometheus/src/components/PromExploreExtraField.test.tsx +++ b/packages/grafana-prometheus/src/components/PromExploreExtraField.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.test.tsx import { render, screen } from '@testing-library/react'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/components/PromExploreExtraField.tsx b/packages/grafana-prometheus/src/components/PromExploreExtraField.tsx index c9ad0a79e36..0d3fa86a1b4 100644 --- a/packages/grafana-prometheus/src/components/PromExploreExtraField.tsx +++ b/packages/grafana-prometheus/src/components/PromExploreExtraField.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx import { css, cx } from '@emotion/css'; import { isEqual } from 'lodash'; import React, { memo, useCallback } from 'react'; diff --git a/packages/grafana-prometheus/src/components/PromQueryEditorByApp.test.tsx b/packages/grafana-prometheus/src/components/PromQueryEditorByApp.test.tsx index 832cc37355f..6909409f810 100644 --- a/packages/grafana-prometheus/src/components/PromQueryEditorByApp.test.tsx +++ b/packages/grafana-prometheus/src/components/PromQueryEditorByApp.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.test.tsx import { render, screen } from '@testing-library/react'; import { noop } from 'lodash'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/components/PromQueryEditorByApp.tsx b/packages/grafana-prometheus/src/components/PromQueryEditorByApp.tsx index 843bb30284a..82b095322bf 100644 --- a/packages/grafana-prometheus/src/components/PromQueryEditorByApp.tsx +++ b/packages/grafana-prometheus/src/components/PromQueryEditorByApp.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.tsx import React, { memo } from 'react'; import { CoreApp } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/components/PromQueryEditorForAlerting.tsx b/packages/grafana-prometheus/src/components/PromQueryEditorForAlerting.tsx index 5adac3afeb5..5f5f2da7bfc 100644 --- a/packages/grafana-prometheus/src/components/PromQueryEditorForAlerting.tsx +++ b/packages/grafana-prometheus/src/components/PromQueryEditorForAlerting.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromQueryEditorForAlerting.tsx import React from 'react'; import { PromQueryField } from './PromQueryField'; diff --git a/packages/grafana-prometheus/src/components/PromQueryField.test.tsx b/packages/grafana-prometheus/src/components/PromQueryField.test.tsx index 700f73574d5..46c56efc381 100644 --- a/packages/grafana-prometheus/src/components/PromQueryField.test.tsx +++ b/packages/grafana-prometheus/src/components/PromQueryField.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromQueryField.test.tsx import { getByTestId, render, screen, waitFor } from '@testing-library/react'; // @ts-ignore import userEvent from '@testing-library/user-event'; diff --git a/packages/grafana-prometheus/src/components/PromQueryField.tsx b/packages/grafana-prometheus/src/components/PromQueryField.tsx index 3ceab631609..623092b648c 100644 --- a/packages/grafana-prometheus/src/components/PromQueryField.tsx +++ b/packages/grafana-prometheus/src/components/PromQueryField.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx import { cx } from '@emotion/css'; import React, { ReactNode } from 'react'; diff --git a/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.test.tsx b/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.test.tsx index e3ba496356b..393a15b3d00 100644 --- a/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.test.tsx +++ b/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx b/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx index 79ae235574e..e58a57c9323 100644 --- a/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx +++ b/packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx import { css, cx } from '@emotion/css'; import React, { ChangeEvent } from 'react'; import { FixedSizeList } from 'react-window'; diff --git a/packages/grafana-prometheus/src/components/VariableQueryEditor.test.tsx b/packages/grafana-prometheus/src/components/VariableQueryEditor.test.tsx index 0d3a877069d..427066e9c41 100644 --- a/packages/grafana-prometheus/src/components/VariableQueryEditor.test.tsx +++ b/packages/grafana-prometheus/src/components/VariableQueryEditor.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/components/VariableQueryEditor.tsx b/packages/grafana-prometheus/src/components/VariableQueryEditor.tsx index fce9bf1e1df..cd81e5fc6c8 100644 --- a/packages/grafana-prometheus/src/components/VariableQueryEditor.tsx +++ b/packages/grafana-prometheus/src/components/VariableQueryEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx import React, { FormEvent, useCallback, useEffect, useState } from 'react'; import { QueryEditorProps, SelectableValue } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryField.tsx b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryField.tsx index 2e5dbb1f52e..9b554db003b 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryField.tsx +++ b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryField.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryField.tsx import { css } from '@emotion/css'; import { parser } from '@prometheus-io/lezer-promql'; import { debounce } from 'lodash'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldLazy.tsx b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldLazy.tsx index 797d48b6c2b..ea2fb3576e9 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldLazy.tsx +++ b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldLazy.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryFieldLazy.tsx import React, { Suspense } from 'react'; import MonacoQueryField from './MonacoQueryField'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldProps.ts b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldProps.ts index 1383b565828..a0d21761f2c 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldProps.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldProps.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryFieldProps.ts import { HistoryItem } from '@grafana/data'; import { PrometheusDatasource } from '../../datasource'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldWrapper.tsx b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldWrapper.tsx index 7f69ce54758..2fafe41a1cc 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldWrapper.tsx +++ b/packages/grafana-prometheus/src/components/monaco-query-field/MonacoQueryFieldWrapper.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryFieldWrapper.tsx import React, { useRef } from 'react'; import { MonacoQueryFieldLazy } from './MonacoQueryFieldLazy'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/getOverrideServices.ts b/packages/grafana-prometheus/src/components/monaco-query-field/getOverrideServices.ts index b3bc45a3f57..c7a3192ddb6 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/getOverrideServices.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/getOverrideServices.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/getOverrideServices.ts import { monacoTypes } from '@grafana/ui'; // this thing here is a workaround in a way. diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/completions.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/completions.ts index a092beac588..d93338c5ea5 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/completions.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/completions.ts @@ -1,3 +1,4 @@ +// Core grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/completions.ts import UFuzzy from '@leeoniya/ufuzzy'; import { config } from '@grafana/runtime'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/index.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/index.ts index 6c1037df321..abc97de27ce 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/index.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/index.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/index.ts import type { Monaco, monacoTypes } from '@grafana/ui'; import { CompletionType, getCompletions } from './completions'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.test.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.test.ts index 8c7be6b592b..605d9658174 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.test.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/situation.test.ts import { getSituation, Situation } from './situation'; // we use the `^` character as the cursor-marker in the string. diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.ts index e6f569fe806..f633922d298 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/situation.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/situation.ts import type { SyntaxNode, Tree } from '@lezer/common'; import { AggregateExpr, diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/util.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/util.ts index 35babca0d09..84ee27c8e94 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/util.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/util.ts @@ -1,3 +1,5 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/util.ts + // this helper class is used to make typescript warn you when you forget // a case-block in a switch statement. // example code that triggers the typescript-error: diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.test.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.test.ts index c51c764e8fa..e467257e23d 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.test.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/validation.test.ts import { parser } from '@prometheus-io/lezer-promql'; import { validateQuery } from './validation'; diff --git a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.ts b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.ts index 8b9cb8e6766..34ce38c060b 100644 --- a/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.ts +++ b/packages/grafana-prometheus/src/components/monaco-query-field/monaco-completion-provider/validation.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/validation.ts import { SyntaxNode } from '@lezer/common'; import { LRParser } from '@lezer/lr'; diff --git a/packages/grafana-prometheus/src/components/types.ts b/packages/grafana-prometheus/src/components/types.ts index 419b86ea5bd..4f453b0a947 100644 --- a/packages/grafana-prometheus/src/components/types.ts +++ b/packages/grafana-prometheus/src/components/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/types.ts import { QueryEditorProps } from '@grafana/data'; import { PrometheusDatasource } from '../datasource'; diff --git a/packages/grafana-prometheus/src/configuration/AlertingSettingsOverhaul.tsx b/packages/grafana-prometheus/src/configuration/AlertingSettingsOverhaul.tsx index 11bbe3d2361..4cd5a13b85a 100644 --- a/packages/grafana-prometheus/src/configuration/AlertingSettingsOverhaul.tsx +++ b/packages/grafana-prometheus/src/configuration/AlertingSettingsOverhaul.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/AlertingSettingsOverhaul.tsx import { cx } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/configuration/ConfigEditor.test.tsx b/packages/grafana-prometheus/src/configuration/ConfigEditor.test.tsx index 9ce9e66c563..12878c69435 100644 --- a/packages/grafana-prometheus/src/configuration/ConfigEditor.test.tsx +++ b/packages/grafana-prometheus/src/configuration/ConfigEditor.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/ConfigEditor.test.tsx import React from 'react'; import { FieldValidationMessage } from '@grafana/ui'; diff --git a/packages/grafana-prometheus/src/configuration/ConfigEditor.tsx b/packages/grafana-prometheus/src/configuration/ConfigEditor.tsx index 86a6f687253..28355af85be 100644 --- a/packages/grafana-prometheus/src/configuration/ConfigEditor.tsx +++ b/packages/grafana-prometheus/src/configuration/ConfigEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/ConfigEditor.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/configuration/DataSourceHttpSettingsOverhaul.tsx b/packages/grafana-prometheus/src/configuration/DataSourceHttpSettingsOverhaul.tsx index 86af4461740..035e513c6a3 100644 --- a/packages/grafana-prometheus/src/configuration/DataSourceHttpSettingsOverhaul.tsx +++ b/packages/grafana-prometheus/src/configuration/DataSourceHttpSettingsOverhaul.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/DataSourceHttpSettingsOverhaul.tsx import React from 'react'; import { DataSourceSettings } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/configuration/ExemplarSetting.tsx b/packages/grafana-prometheus/src/configuration/ExemplarSetting.tsx index 75614934cf5..acb9c35cbe6 100644 --- a/packages/grafana-prometheus/src/configuration/ExemplarSetting.tsx +++ b/packages/grafana-prometheus/src/configuration/ExemplarSetting.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/ExemplarSetting.tsx import React, { useState } from 'react'; import { DataSourceInstanceSettings } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/configuration/ExemplarsSettings.tsx b/packages/grafana-prometheus/src/configuration/ExemplarsSettings.tsx index 6ffece606a0..24ad9a5d1ad 100644 --- a/packages/grafana-prometheus/src/configuration/ExemplarsSettings.tsx +++ b/packages/grafana-prometheus/src/configuration/ExemplarsSettings.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/ExemplarsSettings.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/configuration/PromFlavorVersions.ts b/packages/grafana-prometheus/src/configuration/PromFlavorVersions.ts index bce2dd88a87..71381bd73c0 100644 --- a/packages/grafana-prometheus/src/configuration/PromFlavorVersions.ts +++ b/packages/grafana-prometheus/src/configuration/PromFlavorVersions.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/PromFlavorVersions.ts export const PromFlavorVersions: { [index: string]: Array<{ value?: string; label: string }> } = { Prometheus: [ { value: undefined, label: 'Please select' }, diff --git a/packages/grafana-prometheus/src/configuration/PromSettings.test.tsx b/packages/grafana-prometheus/src/configuration/PromSettings.test.tsx index af9b99bd4da..2deae5f94dd 100644 --- a/packages/grafana-prometheus/src/configuration/PromSettings.test.tsx +++ b/packages/grafana-prometheus/src/configuration/PromSettings.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/PromSettings.test.tsx import { render, screen, fireEvent } from '@testing-library/react'; import React, { SyntheticEvent } from 'react'; diff --git a/packages/grafana-prometheus/src/configuration/PromSettings.tsx b/packages/grafana-prometheus/src/configuration/PromSettings.tsx index d9a0b7abc64..5e41aaac5e9 100644 --- a/packages/grafana-prometheus/src/configuration/PromSettings.tsx +++ b/packages/grafana-prometheus/src/configuration/PromSettings.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx import React, { SyntheticEvent, useState } from 'react'; import { diff --git a/packages/grafana-prometheus/src/configuration/mocks.ts b/packages/grafana-prometheus/src/configuration/mocks.ts index dc52090298b..3c1d7e29762 100644 --- a/packages/grafana-prometheus/src/configuration/mocks.ts +++ b/packages/grafana-prometheus/src/configuration/mocks.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/mocks.ts import { DataSourceSettings } from '@grafana/data'; import { getMockDataSource } from '../gcopypaste/app/features/datasources/__mocks__/dataSourcesMocks'; diff --git a/packages/grafana-prometheus/src/dashboards/grafana_stats.json b/packages/grafana-prometheus/src/dashboards/grafana_stats.json index a121de7fe5a..0131aa9bc40 100644 --- a/packages/grafana-prometheus/src/dashboards/grafana_stats.json +++ b/packages/grafana-prometheus/src/dashboards/grafana_stats.json @@ -1,4 +1,5 @@ { + "_comment": "Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/dashboards/grafana_stats.json", "__inputs": [ { "name": "DS_PROMETHEUS", diff --git a/packages/grafana-prometheus/src/dashboards/prometheus_2_stats.json b/packages/grafana-prometheus/src/dashboards/prometheus_2_stats.json index 3d4cea64f05..034663fe6f4 100644 --- a/packages/grafana-prometheus/src/dashboards/prometheus_2_stats.json +++ b/packages/grafana-prometheus/src/dashboards/prometheus_2_stats.json @@ -1,4 +1,5 @@ { + "_comment": "Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/dashboards/prometheus_2_stats.json", "__inputs": [ { "name": "DS_GDEV-PROMETHEUS", diff --git a/packages/grafana-prometheus/src/dashboards/prometheus_stats.json b/packages/grafana-prometheus/src/dashboards/prometheus_stats.json index 9169006b895..8a2764c5cb7 100644 --- a/packages/grafana-prometheus/src/dashboards/prometheus_stats.json +++ b/packages/grafana-prometheus/src/dashboards/prometheus_stats.json @@ -1,4 +1,5 @@ { + "_comment": "Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/dashboards/prometheus_stats.json", "__inputs": [ { "name": "DS_GDEV-PROMETHEUS", diff --git a/packages/grafana-prometheus/src/dataquery.ts b/packages/grafana-prometheus/src/dataquery.ts index 999a969c99e..6601b7ac8ab 100644 --- a/packages/grafana-prometheus/src/dataquery.ts +++ b/packages/grafana-prometheus/src/dataquery.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/dataquery.ts import { ScopeSpec } from '@grafana/data'; import * as common from '@grafana/schema'; diff --git a/packages/grafana-prometheus/src/datasource.test.ts b/packages/grafana-prometheus/src/datasource.test.ts index 72f9c4572d8..a8ae4298ef1 100644 --- a/packages/grafana-prometheus/src/datasource.test.ts +++ b/packages/grafana-prometheus/src/datasource.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/datasource.test.ts import { cloneDeep } from 'lodash'; import { lastValueFrom, of } from 'rxjs'; diff --git a/packages/grafana-prometheus/src/datasource.ts b/packages/grafana-prometheus/src/datasource.ts index b809452bede..ea36501aea5 100644 --- a/packages/grafana-prometheus/src/datasource.ts +++ b/packages/grafana-prometheus/src/datasource.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/datasource.ts import { defaults } from 'lodash'; import { lastValueFrom, Observable, throwError } from 'rxjs'; import { map, tap } from 'rxjs/operators'; diff --git a/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/LocalStorageValueProvider.tsx b/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/LocalStorageValueProvider.tsx index d0558fe43ee..c71e11ec749 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/LocalStorageValueProvider.tsx +++ b/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/LocalStorageValueProvider.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/core/components/LocalStorageValueProvider/LocalStorageValueProvider.tsx import React, { useEffect, useState } from 'react'; import store from '../../store'; diff --git a/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/index.tsx b/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/index.tsx index e4bde7ccaea..e3df7a01194 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/index.tsx +++ b/packages/grafana-prometheus/src/gcopypaste/app/core/components/LocalStorageValueProvider/index.tsx @@ -1 +1,2 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/core/components/LocalStorageValueProvider/index.tsx export { LocalStorageValueProvider } from './LocalStorageValueProvider'; diff --git a/packages/grafana-prometheus/src/gcopypaste/app/core/store.ts b/packages/grafana-prometheus/src/gcopypaste/app/core/store.ts index 28587a7d428..a23d14c93cc 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/core/store.ts +++ b/packages/grafana-prometheus/src/gcopypaste/app/core/store.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/core/store.ts type StoreValue = string | number | boolean | null; export class Store { diff --git a/packages/grafana-prometheus/src/gcopypaste/app/core/utils/CancelablePromise.ts b/packages/grafana-prometheus/src/gcopypaste/app/core/utils/CancelablePromise.ts index 221e5ef2bb6..0256922cbbb 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/core/utils/CancelablePromise.ts +++ b/packages/grafana-prometheus/src/gcopypaste/app/core/utils/CancelablePromise.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/core/utils/CancelablePromise.ts // https://github.com/facebook/react/issues/5465 export interface CancelablePromise { diff --git a/packages/grafana-prometheus/src/gcopypaste/app/core/utils/query.ts b/packages/grafana-prometheus/src/gcopypaste/app/core/utils/query.ts index 4084e418f18..28b4af48c0b 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/core/utils/query.ts +++ b/packages/grafana-prometheus/src/gcopypaste/app/core/utils/query.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/core/utils/query.ts import { DataQuery } from '@grafana/data'; export const getNextRefIdChar = (queries: DataQuery[]): string => { diff --git a/packages/grafana-prometheus/src/gcopypaste/app/features/datasources/__mocks__/dataSourcesMocks.ts b/packages/grafana-prometheus/src/gcopypaste/app/features/datasources/__mocks__/dataSourcesMocks.ts index db78a03b289..15ebe4229a9 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/features/datasources/__mocks__/dataSourcesMocks.ts +++ b/packages/grafana-prometheus/src/gcopypaste/app/features/datasources/__mocks__/dataSourcesMocks.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/features/datasources/__mocks__/dataSourcesMocks.ts import { merge } from 'lodash'; import { DataSourceJsonData, DataSourceSettings } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/gcopypaste/app/features/live/data/amendTimeSeries.ts b/packages/grafana-prometheus/src/gcopypaste/app/features/live/data/amendTimeSeries.ts index 39b01600d46..a2d00ad34f4 100644 --- a/packages/grafana-prometheus/src/gcopypaste/app/features/live/data/amendTimeSeries.ts +++ b/packages/grafana-prometheus/src/gcopypaste/app/features/live/data/amendTimeSeries.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/features/live/data/amendTimeSeries.ts import { closestIdx } from '@grafana/data'; export type Table = [times: number[], ...values: any[][]]; diff --git a/packages/grafana-prometheus/src/gcopypaste/packages/grafana-ui/src/components/Select/SelectBase.tsx b/packages/grafana-prometheus/src/gcopypaste/packages/grafana-ui/src/components/Select/SelectBase.tsx index 9c6e81eec9f..f252ee11767 100644 --- a/packages/grafana-prometheus/src/gcopypaste/packages/grafana-ui/src/components/Select/SelectBase.tsx +++ b/packages/grafana-prometheus/src/gcopypaste/packages/grafana-ui/src/components/Select/SelectBase.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/packages/grafana-ui/src/components/Select/SelectBase.tsx import { cx } from '@emotion/css'; import { max } from 'lodash'; import React, { RefCallback } from 'react'; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/index.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/index.ts index b6f8a091aaa..ea1578a7482 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/index.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/index.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/test/matchers/index.ts import { Observable } from 'rxjs'; import { toEmitValues } from './toEmitValues'; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.test.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.test.ts index 71edff27e8d..bb0d9aa3c63 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.test.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/test/matchers/toEmitValues.test.ts import { interval, Observable, of, throwError } from 'rxjs'; import { map, mergeMap, take } from 'rxjs/operators'; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.ts index d2987471a38..5d87c1f342d 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValues.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/test/matchers/toEmitValues.ts import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils'; import { isEqual } from 'lodash'; import { Observable, Subscription } from 'rxjs'; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.test.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.test.ts index 7ca3eed1c57..352c8237665 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.test.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/test/matchers/toEmitValuesWith.test.ts import { interval, Observable, of, throwError } from 'rxjs'; import { map, mergeMap, take } from 'rxjs/operators'; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.ts index d9a53e965a0..2c647baea5b 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/toEmitValuesWith.ts @@ -1,3 +1,4 @@ +// Core Grafana history import { matcherHint, printReceived } from 'jest-matcher-utils'; import { Observable, Subscription } from 'rxjs'; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/types.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/types.ts index c67b32897f5..953b5ff86da 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/types.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/test/matchers/toEmitValuesWith.ts import { Observable } from 'rxjs'; export const OBSERVABLE_TEST_TIMEOUT_IN_MS = 1000; diff --git a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/utils.ts b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/utils.ts index e7758bb9177..3915cc13a4f 100644 --- a/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/utils.ts +++ b/packages/grafana-prometheus/src/gcopypaste/public/test/matchers/utils.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/test/matchers/utils.ts import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils'; import { asapScheduler, Subscription, timer, isObservable } from 'rxjs'; diff --git a/packages/grafana-prometheus/src/gcopypaste/test/helpers/selectOptionInTest.ts b/packages/grafana-prometheus/src/gcopypaste/test/helpers/selectOptionInTest.ts index c1ff432dacc..f8d333d2c2e 100644 --- a/packages/grafana-prometheus/src/gcopypaste/test/helpers/selectOptionInTest.ts +++ b/packages/grafana-prometheus/src/gcopypaste/test/helpers/selectOptionInTest.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/packages/grafana-ui/src/components/Select/SelectBase.tsx import { Matcher, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { select } from 'react-select-event'; diff --git a/packages/grafana-prometheus/src/index.ts b/packages/grafana-prometheus/src/index.ts index 76302ec9570..acf324f7e92 100644 --- a/packages/grafana-prometheus/src/index.ts +++ b/packages/grafana-prometheus/src/index.ts @@ -59,14 +59,14 @@ export { PromQail } from './querybuilder/components/promQail/PromQail'; // SRC/ // Main export -export { PrometheusDatasource } from './datasource'; +export { PrometheusDatasource, InstantQueryRefIdIndex } from './datasource'; // The parts export { addLabelToQuery } from './add_label_to_query'; export { type QueryEditorMode, type PromQueryFormat, type Prometheus } from './dataquery'; export { PrometheusMetricFindQuery } from './metric_find_query'; export { promqlGrammar } from './promql'; export { getQueryHints, getInitHints } from './query_hints'; -export { transformV2, transformDFToTable } from './result_transformer'; +export { transformV2, transformDFToTable, parseSampleValue, sortSeriesByLabel } from './result_transformer'; export { type PromQuery, type PrometheusCacheLevel, diff --git a/packages/grafana-prometheus/src/language_provider.mock.ts b/packages/grafana-prometheus/src/language_provider.mock.ts index 731a1977ca9..e10c2844b19 100644 --- a/packages/grafana-prometheus/src/language_provider.mock.ts +++ b/packages/grafana-prometheus/src/language_provider.mock.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/language_provider.mock.ts export class EmptyLanguageProviderMock { metrics = []; constructor() {} diff --git a/packages/grafana-prometheus/src/language_provider.test.ts b/packages/grafana-prometheus/src/language_provider.test.ts index 91576162dd1..dd7dec7ce71 100644 --- a/packages/grafana-prometheus/src/language_provider.test.ts +++ b/packages/grafana-prometheus/src/language_provider.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/language_provider.test.ts import { AbstractLabelOperator, dateTime, TimeRange } from '@grafana/data'; import { Label } from './components/monaco-query-field/monaco-completion-provider/situation'; diff --git a/packages/grafana-prometheus/src/language_provider.ts b/packages/grafana-prometheus/src/language_provider.ts index 7794c2d9339..e5c85a9316f 100644 --- a/packages/grafana-prometheus/src/language_provider.ts +++ b/packages/grafana-prometheus/src/language_provider.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/language_provider.ts import { once } from 'lodash'; import Prism from 'prismjs'; diff --git a/packages/grafana-prometheus/src/language_utils.test.ts b/packages/grafana-prometheus/src/language_utils.test.ts index fe6d1dd02c9..949e6489af1 100644 --- a/packages/grafana-prometheus/src/language_utils.test.ts +++ b/packages/grafana-prometheus/src/language_utils.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/language_utils.test.ts import { Moment } from 'moment'; import { AbstractLabelOperator, AbstractQuery, DateTime, dateTime, TimeRange } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/language_utils.ts b/packages/grafana-prometheus/src/language_utils.ts index eeb699f6739..ed96e929702 100644 --- a/packages/grafana-prometheus/src/language_utils.ts +++ b/packages/grafana-prometheus/src/language_utils.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/language_utils.ts import { invert } from 'lodash'; import { Token } from 'prismjs'; diff --git a/packages/grafana-prometheus/src/metric_find_query.test.ts b/packages/grafana-prometheus/src/metric_find_query.test.ts index a410189fc42..c21fd8f8353 100644 --- a/packages/grafana-prometheus/src/metric_find_query.test.ts +++ b/packages/grafana-prometheus/src/metric_find_query.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/metric_find_query.test.ts import { Observable, of } from 'rxjs'; import 'whatwg-fetch'; // fetch polyfill needed backendSrv diff --git a/packages/grafana-prometheus/src/metric_find_query.ts b/packages/grafana-prometheus/src/metric_find_query.ts index 9390f32373c..8be41c06364 100644 --- a/packages/grafana-prometheus/src/metric_find_query.ts +++ b/packages/grafana-prometheus/src/metric_find_query.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/metric_find_query.ts import { chain, map as _map, uniq } from 'lodash'; import { getDefaultTimeRange, MetricFindValue, TimeRange } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/migrations/variableMigration.ts b/packages/grafana-prometheus/src/migrations/variableMigration.ts index 302191f98fb..08476c2f4b6 100644 --- a/packages/grafana-prometheus/src/migrations/variableMigration.ts +++ b/packages/grafana-prometheus/src/migrations/variableMigration.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/migrations/variableMigration.ts import { promQueryModeller } from '../querybuilder/PromQueryModeller'; import { buildVisualQueryFromString } from '../querybuilder/parsing'; import { PromVariableQuery, PromVariableQueryType as QueryType } from '../types'; diff --git a/packages/grafana-prometheus/src/module.test.ts b/packages/grafana-prometheus/src/module.test.ts index 171fd491637..0fb7bb592a8 100644 --- a/packages/grafana-prometheus/src/module.test.ts +++ b/packages/grafana-prometheus/src/module.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/module.test.ts import { plugin as PrometheusDatasourcePlugin } from './module'; describe('module', () => { diff --git a/packages/grafana-prometheus/src/module.ts b/packages/grafana-prometheus/src/module.ts index 8fdb90c8bd9..0bbabf50383 100644 --- a/packages/grafana-prometheus/src/module.ts +++ b/packages/grafana-prometheus/src/module.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/module.ts // DONT NEED THIS BUT MAYBE EXPORT THIS TO CORE PROM import { DataSourcePlugin } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/promql.test.ts b/packages/grafana-prometheus/src/promql.test.ts index ff78a805ef2..8ce99e175fc 100644 --- a/packages/grafana-prometheus/src/promql.test.ts +++ b/packages/grafana-prometheus/src/promql.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/promql.test.ts import Prism from 'prismjs'; import promql from './promql'; diff --git a/packages/grafana-prometheus/src/promql.ts b/packages/grafana-prometheus/src/promql.ts index a9e89ee5f67..58893206b09 100644 --- a/packages/grafana-prometheus/src/promql.ts +++ b/packages/grafana-prometheus/src/promql.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/promql.ts import { Grammar } from 'prismjs'; import { CompletionItem } from '@grafana/ui'; diff --git a/packages/grafana-prometheus/src/query_hints.test.ts b/packages/grafana-prometheus/src/query_hints.test.ts index 7089ea3e2e1..aa425a22f28 100644 --- a/packages/grafana-prometheus/src/query_hints.test.ts +++ b/packages/grafana-prometheus/src/query_hints.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/query_hints.test.ts import { PrometheusDatasource } from './datasource'; import { getQueryHints, SUM_HINT_THRESHOLD_COUNT } from './query_hints'; diff --git a/packages/grafana-prometheus/src/query_hints.ts b/packages/grafana-prometheus/src/query_hints.ts index 12c8bdfbbaf..10ec829f364 100644 --- a/packages/grafana-prometheus/src/query_hints.ts +++ b/packages/grafana-prometheus/src/query_hints.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/query_hints.ts import { size } from 'lodash'; import { QueryFix, QueryHint } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.test.ts b/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.test.ts index f81ab15cbc9..432adeb59d4 100644 --- a/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/PromQueryModeller.test.ts import { PromQueryModeller } from './PromQueryModeller'; import { PromOperationId } from './types'; diff --git a/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.ts b/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.ts index 894ba907ed1..cef7b53e6d6 100644 --- a/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.ts +++ b/packages/grafana-prometheus/src/querybuilder/PromQueryModeller.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/PromQueryModeller.ts import { FUNCTIONS } from '../promql'; import { getAggregationOperations } from './aggregations'; diff --git a/packages/grafana-prometheus/src/querybuilder/QueryPattern.tsx b/packages/grafana-prometheus/src/querybuilder/QueryPattern.tsx index 083396cda39..a332a7f2da4 100644 --- a/packages/grafana-prometheus/src/querybuilder/QueryPattern.tsx +++ b/packages/grafana-prometheus/src/querybuilder/QueryPattern.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/QueryPattern.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.test.tsx b/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.test.tsx index a8a2b3c9e02..8cc19b9cbe9 100644 --- a/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/QueryPatternsModal.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.tsx b/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.tsx index f98a778e778..404b0b7a502 100644 --- a/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.tsx +++ b/packages/grafana-prometheus/src/querybuilder/QueryPatternsModal.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/QueryPatternsModal.tsx import { css } from '@emotion/css'; import { capitalize } from 'lodash'; import React, { useMemo, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/aggregations.ts b/packages/grafana-prometheus/src/querybuilder/aggregations.ts index 18a2f72b687..d4129c3665e 100644 --- a/packages/grafana-prometheus/src/querybuilder/aggregations.ts +++ b/packages/grafana-prometheus/src/querybuilder/aggregations.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/aggregations.ts import { createAggregationOperation, createAggregationOperationWithParam, diff --git a/packages/grafana-prometheus/src/querybuilder/binaryScalarOperations.ts b/packages/grafana-prometheus/src/querybuilder/binaryScalarOperations.ts index 523f85e99a7..b1fc45e849a 100644 --- a/packages/grafana-prometheus/src/querybuilder/binaryScalarOperations.ts +++ b/packages/grafana-prometheus/src/querybuilder/binaryScalarOperations.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/binaryScalarOperations.ts import { defaultAddOperationHandler } from './operationUtils'; import { QueryBuilderOperation, QueryBuilderOperationDef, QueryBuilderOperationParamDef } from './shared/types'; import { PromOperationId, PromVisualQueryOperationCategory } from './types'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/LabelFilterItem.tsx b/packages/grafana-prometheus/src/querybuilder/components/LabelFilterItem.tsx index c1a28d8f96f..c8075933f3b 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/LabelFilterItem.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/LabelFilterItem.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilterItem.tsx import debounce from 'debounce-promise'; import React, { useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.test.tsx index fcd1b06b72a..b1e21da0096 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.test.tsx import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { ComponentProps } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.tsx b/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.tsx index 09f5fd1d822..9364dd83f28 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/LabelFilters.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx import { css, cx } from '@emotion/css'; import { isEqual } from 'lodash'; import React, { useEffect, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/LabelParamEditor.tsx b/packages/grafana-prometheus/src/querybuilder/components/LabelParamEditor.tsx index 6cf4e9a9b74..0c1c4a8e35c 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/LabelParamEditor.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/LabelParamEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/LabelParamEditor.tsx import React, { useState } from 'react'; import { DataSourceApi, SelectableValue, toOption } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.test.tsx index a0561768837..cb115f389c0 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/MetricSelect.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.tsx b/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.tsx index 3e0ab156c2e..35a10f7064c 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/MetricSelect.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/MetricSelect.tsx import { css } from '@emotion/css'; import debounce from 'debounce-promise'; import React, { RefCallback, useCallback, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/MetricsLabelsSection.tsx b/packages/grafana-prometheus/src/querybuilder/components/MetricsLabelsSection.tsx index b27af15c168..60d0f4fbcca 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/MetricsLabelsSection.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/MetricsLabelsSection.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/MetricsLabelsSection.tsx import React, { useCallback } from 'react'; import { SelectableValue } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/NestedQuery.tsx b/packages/grafana-prometheus/src/querybuilder/components/NestedQuery.tsx index ecba5898454..efdffc73023 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/NestedQuery.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/NestedQuery.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/NestedQuery.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/NestedQueryList.tsx b/packages/grafana-prometheus/src/querybuilder/components/NestedQueryList.tsx index fb9e60229fe..7d36bec9919 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/NestedQueryList.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/NestedQueryList.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/NestedQueryList.tsx import React from 'react'; import { Stack } from '@grafana/ui'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.test.tsx index 54f44c46f13..fdbb2779a4f 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilder.test.tsx import { getByText, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.tsx index e05b1c2caa2..90e4d46f8c7 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilder.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilder.tsx import { css } from '@emotion/css'; import React, { useEffect, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.test.tsx index 5172172fd32..e55b4f2d3f4 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderContainer.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.tsx index 46d3dc05625..a960fc3a58e 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderContainer.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderContainer.tsx import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import React, { useEffect, useReducer } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderExplained.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderExplained.tsx index 38389fbc6e4..c3de6c3808e 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderExplained.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderExplained.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderExplained.tsx import React from 'react'; import { Stack } from '@grafana/ui'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.test.tsx index 331092c1962..9b9531a28ed 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderOptions.test.tsx import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.tsx index 79f93db2fe7..7a554d9be45 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryBuilderOptions.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderOptions.tsx import React, { SyntheticEvent } from 'react'; import { CoreApp, SelectableValue } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.test.tsx index 5554f33997d..c907e604576 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.test.tsx import { render, screen } from '@testing-library/react'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.tsx index 75bc63055e6..84e5805a4f3 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryCodeEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.test.tsx index 9e9079188f3..2dbc49535a7 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryEditorSelector.test.tsx import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { cloneDeep, defaultsDeep } from 'lodash'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.tsx index b46ef45c6f0..30c5502bacb 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryEditorSelector.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryEditorSelector.tsx import { isEqual, map } from 'lodash'; import React, { SyntheticEvent, useCallback, useEffect, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/PromQueryLegendEditor.tsx b/packages/grafana-prometheus/src/querybuilder/components/PromQueryLegendEditor.tsx index 440278b4c50..5be07dee6be 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/PromQueryLegendEditor.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/PromQueryLegendEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryLegendEditor.tsx import React, { useRef } from 'react'; import { SelectableValue } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/QueryPreview.tsx b/packages/grafana-prometheus/src/querybuilder/components/QueryPreview.tsx index 0f731ec0b3d..2bd0e252672 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/QueryPreview.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/QueryPreview.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/QueryPreview.tsx import React from 'react'; import { EditorFieldGroup, EditorRow } from '@grafana/experimental'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/AdditionalSettings.tsx b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/AdditionalSettings.tsx index c5a7d104849..38caa6e6f49 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/AdditionalSettings.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/AdditionalSettings.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/AdditionalSettings.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/FeedbackLink.tsx b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/FeedbackLink.tsx index 4ba1d881147..954efbd61e1 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/FeedbackLink.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/FeedbackLink.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/FeedbackLink.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.test.tsx index f12d7c67080..ca0c28916c3 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/MetricsModal.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.tsx b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.tsx index 6e02715a804..4d6aab8dc0d 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/MetricsModal.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/MetricsModal.tsx import { cx } from '@emotion/css'; import { PayloadAction, createSlice } from '@reduxjs/toolkit'; import debounce from 'debounce-promise'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/ResultsTable.tsx b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/ResultsTable.tsx index a474098bbc0..ef396c58e21 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/ResultsTable.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/ResultsTable.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/ResultsTable.tsx import { css } from '@emotion/css'; import React, { ReactElement } from 'react'; import Highlighter from 'react-highlight-words'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/helpers.ts b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/helpers.ts index e8a40d02b0c..19d016eafd0 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/helpers.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/helpers.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/state/helpers.ts import { AnyAction } from '@reduxjs/toolkit'; import { reportInteraction } from '@grafana/runtime'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/state.ts b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/state.ts index f22bd73ea4b..fa29ba2450e 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/state.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/state/state.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/state/state.ts import { SelectableValue } from '@grafana/data'; import { PromVisualQuery } from '../../../types'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/styles.ts b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/styles.ts index e8eb2fe86dd..e105530602c 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/styles.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/styles.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/styles.ts import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/types.ts b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/types.ts index d4be9a48638..233f3765e8a 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/types.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/types.ts export type MetricsData = MetricData[]; export type MetricData = { diff --git a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/uFuzzy.ts b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/uFuzzy.ts index 7c7e5eb44ea..7b070b9ab58 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/uFuzzy.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/metrics-modal/uFuzzy.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/metrics-modal/uFuzzy.ts import uFuzzy from '@leeoniya/ufuzzy'; import { debounce as debounceLodash } from 'lodash'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.test.tsx index b4056fb8bca..0874258cc87 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/PromQail.test.tsx import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.tsx b/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.tsx index 8777f8c48ab..638d3f53b93 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/PromQail.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/PromQail.tsx import { css, cx } from '@emotion/css'; import { PayloadAction, createSlice } from '@reduxjs/toolkit'; import React, { useEffect, useReducer, useRef, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.test.tsx b/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.test.tsx index 2b64277c22c..3bfabc4bf60 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QueryAssistantButton.test.tsx import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.tsx b/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.tsx index 5445134b64b..577d330691e 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/QueryAssistantButton.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QueryAssistantButton.tsx import React from 'react'; import { selectors } from '@grafana/e2e-selectors'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionContainer.tsx b/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionContainer.tsx index 1a52194b9cb..469811e72e2 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionContainer.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionContainer.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QuerySuggestionContainer.tsx import { cx } from '@emotion/css'; import React, { useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionItem.tsx b/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionItem.tsx index 9076faae6bc..09a5b1c3fce 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionItem.tsx +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/QuerySuggestionItem.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/QuerySuggestionItem.tsx import { cx } from '@emotion/css'; import React, { FormEvent, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/prompts.ts b/packages/grafana-prometheus/src/querybuilder/components/promQail/prompts.ts index b92bd2d2f14..3a62b1c7b72 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/prompts.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/prompts.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/prompts.ts export const ExplainSystemPrompt = `You are an expert in Prometheus, the event monitoring and alerting application. You are given relevant PromQL documentation, a type and description for a Prometheus metric, and a PromQL query on that metric. Using the provided information for reference, please explain what the output of a given query is in 1 sentences. Do not walk through what the functions do separately, make your answer concise. diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.test.ts b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.test.ts index 323848bebdc..90da7dbadd5 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/helpers.test.ts import { llms } from '@grafana/experimental'; import { guessMetricType, isLLMPluginEnabled } from './helpers'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.ts b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.ts index 8bf207da75e..ea94d6da2a7 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/helpers.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/helpers.ts import { AnyAction } from 'redux'; import { llms } from '@grafana/experimental'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/state.ts b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/state.ts index 2c00053f1dc..a33d0a227ee 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/state.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/state.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/state.ts import { PromVisualQuery } from '../../../types'; import { Interaction, SuggestionType } from '../types'; diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/templates.ts b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/templates.ts index 2a56e9f4fbb..330de01da2f 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/state/templates.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/state/templates.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/state/templates.ts import { QuerySuggestion } from '../types'; interface TemplateData { diff --git a/packages/grafana-prometheus/src/querybuilder/components/promQail/types.ts b/packages/grafana-prometheus/src/querybuilder/components/promQail/types.ts index e8c5005cfac..09f4a3988f5 100644 --- a/packages/grafana-prometheus/src/querybuilder/components/promQail/types.ts +++ b/packages/grafana-prometheus/src/querybuilder/components/promQail/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/components/promQail/types.ts export type QuerySuggestion = { query: string; explanation: string; diff --git a/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.test.ts b/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.test.ts index 4c7ca4e6393..a3c95b17a52 100644 --- a/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/hooks/useFlag.test.ts import { act, renderHook } from '@testing-library/react'; import { promQueryEditorExplainKey, useFlag } from './useFlag'; diff --git a/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.ts b/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.ts index 183a956d45a..7dfc732b025 100644 --- a/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.ts +++ b/packages/grafana-prometheus/src/querybuilder/hooks/useFlag.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/hooks/useFlag.ts import { useCallback, useState } from 'react'; import store from '../../gcopypaste/app/core/store'; diff --git a/packages/grafana-prometheus/src/querybuilder/operationUtils.test.ts b/packages/grafana-prometheus/src/querybuilder/operationUtils.test.ts index da1aabe924e..d1e690bc807 100644 --- a/packages/grafana-prometheus/src/querybuilder/operationUtils.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/operationUtils.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/operationUtils.test.ts import { createAggregationOperation, createAggregationOperationWithParam, diff --git a/packages/grafana-prometheus/src/querybuilder/operationUtils.ts b/packages/grafana-prometheus/src/querybuilder/operationUtils.ts index 9be994d73da..a0bda0d598f 100644 --- a/packages/grafana-prometheus/src/querybuilder/operationUtils.ts +++ b/packages/grafana-prometheus/src/querybuilder/operationUtils.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/operationUtils.ts import { capitalize } from 'lodash'; import pluralize from 'pluralize'; diff --git a/packages/grafana-prometheus/src/querybuilder/operations.ts b/packages/grafana-prometheus/src/querybuilder/operations.ts index e4a3dffacbd..afecda0ab31 100644 --- a/packages/grafana-prometheus/src/querybuilder/operations.ts +++ b/packages/grafana-prometheus/src/querybuilder/operations.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/operations.ts import { binaryScalarOperations } from './binaryScalarOperations'; import { LabelParamEditor } from './components/LabelParamEditor'; import { diff --git a/packages/grafana-prometheus/src/querybuilder/parsing.test.ts b/packages/grafana-prometheus/src/querybuilder/parsing.test.ts index fbd094bb5ff..1522aff295f 100644 --- a/packages/grafana-prometheus/src/querybuilder/parsing.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/parsing.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/parsing.test.ts import { buildVisualQueryFromString } from './parsing'; import { PromOperationId, PromVisualQuery } from './types'; diff --git a/packages/grafana-prometheus/src/querybuilder/parsing.ts b/packages/grafana-prometheus/src/querybuilder/parsing.ts index de1486efc2a..af31365c564 100644 --- a/packages/grafana-prometheus/src/querybuilder/parsing.ts +++ b/packages/grafana-prometheus/src/querybuilder/parsing.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/parsing.ts import { SyntaxNode } from '@lezer/common'; import { AggregateExpr, diff --git a/packages/grafana-prometheus/src/querybuilder/parsingUtils.test.ts b/packages/grafana-prometheus/src/querybuilder/parsingUtils.test.ts index 81c8d255ca6..3bef72e1fd0 100644 --- a/packages/grafana-prometheus/src/querybuilder/parsingUtils.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/parsingUtils.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/parsingUtils.test.ts import { parser } from '@prometheus-io/lezer-promql'; import { getLeftMostChild, getString, replaceVariables } from './parsingUtils'; diff --git a/packages/grafana-prometheus/src/querybuilder/parsingUtils.ts b/packages/grafana-prometheus/src/querybuilder/parsingUtils.ts index 10be8692ebc..bc19084122f 100644 --- a/packages/grafana-prometheus/src/querybuilder/parsingUtils.ts +++ b/packages/grafana-prometheus/src/querybuilder/parsingUtils.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/parsingUtils.ts import { SyntaxNode, TreeCursor } from '@lezer/common'; import { QueryBuilderOperation, QueryBuilderOperationParamValue } from './shared/types'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/LokiAndPromQueryModellerBase.ts b/packages/grafana-prometheus/src/querybuilder/shared/LokiAndPromQueryModellerBase.ts index 81afc5a2762..872973b4887 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/LokiAndPromQueryModellerBase.ts +++ b/packages/grafana-prometheus/src/querybuilder/shared/LokiAndPromQueryModellerBase.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/LokiAndPromQueryModellerBase.ts import { Registry } from '@grafana/data'; import { PromVisualQueryOperationCategory } from '../types'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationEditor.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationEditor.tsx index cd4dd77ff72..405b40b7cd2 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationEditor.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationEditor.tsx import { css, cx } from '@emotion/css'; import React, { useEffect, useId, useState } from 'react'; import { Draggable } from 'react-beautiful-dnd'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationExplainedBox.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationExplainedBox.tsx index f38597c3c10..d5e5f753997 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationExplainedBox.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationExplainedBox.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationExplainedBox.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationHeader.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationHeader.tsx index a47c747c9d5..757befe40ec 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationHeader.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationHeader.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationHeader.tsx import { css } from '@emotion/css'; import React, { useState } from 'react'; import { DraggableProvided } from 'react-beautiful-dnd'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationInfoButton.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationInfoButton.tsx index 56f12509390..c5149c16ef9 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationInfoButton.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationInfoButton.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationInfoButton.tsx import { css } from '@emotion/css'; import { autoUpdate, diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationList.test.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationList.test.tsx index 02d95b87236..912bc4e4952 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationList.test.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationList.test.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationList.test.tsx import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationList.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationList.tsx index 6e104e2675f..875eb166730 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationList.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationList.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationList.tsx import { css } from '@emotion/css'; import React, { useState } from 'react'; import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationListExplained.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationListExplained.tsx index bfc7fba3808..bde7203584c 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationListExplained.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationListExplained.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationListExplained.tsx import { Grammar } from 'prismjs'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationParamEditor.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationParamEditor.tsx index e9bbbff644b..d4f8694c4a6 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationParamEditor.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationParamEditor.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationParamEditor.tsx import { css } from '@emotion/css'; import React, { ComponentType } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/OperationsEditorRow.tsx b/packages/grafana-prometheus/src/querybuilder/shared/OperationsEditorRow.tsx index 00ebc654f06..696d034b5a9 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/OperationsEditorRow.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/OperationsEditorRow.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/OperationsEditorRow.tsx import { css } from '@emotion/css'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/QueryBuilderHints.tsx b/packages/grafana-prometheus/src/querybuilder/shared/QueryBuilderHints.tsx index 91389eb495b..25ed6b8e271 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/QueryBuilderHints.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/QueryBuilderHints.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/QueryBuilderHints.tsx import { css } from '@emotion/css'; import React, { useEffect, useState } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/QueryEditorModeToggle.tsx b/packages/grafana-prometheus/src/querybuilder/shared/QueryEditorModeToggle.tsx index b47d89b6301..f5541dde1c8 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/QueryEditorModeToggle.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/QueryEditorModeToggle.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/QueryEditorModeToggle.tsx import React from 'react'; import { RadioButtonGroup } from '@grafana/ui'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/QueryHeaderSwitch.tsx b/packages/grafana-prometheus/src/querybuilder/shared/QueryHeaderSwitch.tsx index b7088bb3f8b..f92f2accd44 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/QueryHeaderSwitch.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/QueryHeaderSwitch.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/QueryHeaderSwitch.tsx import { css } from '@emotion/css'; import { uniqueId } from 'lodash'; import React, { HTMLProps, useRef } from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/QueryOptionGroup.tsx b/packages/grafana-prometheus/src/querybuilder/shared/QueryOptionGroup.tsx index b0c6951b092..7d8df70545b 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/QueryOptionGroup.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/QueryOptionGroup.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/QueryOptionGroup.tsx import { css } from '@emotion/css'; import React from 'react'; import { useToggle } from 'react-use'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/RawQuery.tsx b/packages/grafana-prometheus/src/querybuilder/shared/RawQuery.tsx index b2cc3d8a372..da7ec8c0f79 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/RawQuery.tsx +++ b/packages/grafana-prometheus/src/querybuilder/shared/RawQuery.tsx @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/RawQuery.tsx import { css, cx } from '@emotion/css'; import Prism, { Grammar } from 'prismjs'; import React from 'react'; diff --git a/packages/grafana-prometheus/src/querybuilder/shared/types.ts b/packages/grafana-prometheus/src/querybuilder/shared/types.ts index 73d46de0a74..e8764866c43 100644 --- a/packages/grafana-prometheus/src/querybuilder/shared/types.ts +++ b/packages/grafana-prometheus/src/querybuilder/shared/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/shared/types.ts /** * Shared types that can be reused by Loki and other data sources */ diff --git a/packages/grafana-prometheus/src/querybuilder/state.test.ts b/packages/grafana-prometheus/src/querybuilder/state.test.ts index a96f876ada1..04293ec686c 100644 --- a/packages/grafana-prometheus/src/querybuilder/state.test.ts +++ b/packages/grafana-prometheus/src/querybuilder/state.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/state.test.ts import { CoreApp } from '@grafana/data'; import { PromQuery } from '../types'; diff --git a/packages/grafana-prometheus/src/querybuilder/state.ts b/packages/grafana-prometheus/src/querybuilder/state.ts index 06ef89c33fc..fddda52c406 100644 --- a/packages/grafana-prometheus/src/querybuilder/state.ts +++ b/packages/grafana-prometheus/src/querybuilder/state.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/state.ts import { CoreApp } from '@grafana/data'; import store from '../gcopypaste/app/core/store'; diff --git a/packages/grafana-prometheus/src/querybuilder/testUtils.ts b/packages/grafana-prometheus/src/querybuilder/testUtils.ts index 818d05756b4..04ef4c911e7 100644 --- a/packages/grafana-prometheus/src/querybuilder/testUtils.ts +++ b/packages/grafana-prometheus/src/querybuilder/testUtils.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/testUtils.ts import { getAllByRole, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; diff --git a/packages/grafana-prometheus/src/querybuilder/types.ts b/packages/grafana-prometheus/src/querybuilder/types.ts index 773b22373a4..c846adff8a5 100644 --- a/packages/grafana-prometheus/src/querybuilder/types.ts +++ b/packages/grafana-prometheus/src/querybuilder/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querybuilder/types.ts import { VisualQueryBinary } from './shared/LokiAndPromQueryModellerBase'; import { QueryBuilderLabelFilter, QueryBuilderOperation } from './shared/types'; diff --git a/packages/grafana-prometheus/src/querycache/QueryCache.test.ts b/packages/grafana-prometheus/src/querycache/QueryCache.test.ts index d0f385a7516..78ff585ec20 100644 --- a/packages/grafana-prometheus/src/querycache/QueryCache.test.ts +++ b/packages/grafana-prometheus/src/querycache/QueryCache.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querycache/QueryCache.test.ts import moment from 'moment'; import { DataFrame, DataQueryRequest, DateTime, dateTime, TimeRange } from '@grafana/data'; diff --git a/packages/grafana-prometheus/src/querycache/QueryCache.ts b/packages/grafana-prometheus/src/querycache/QueryCache.ts index 0cf5f84c2f5..05ad2c3f1d3 100644 --- a/packages/grafana-prometheus/src/querycache/QueryCache.ts +++ b/packages/grafana-prometheus/src/querycache/QueryCache.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querycache/QueryCache.ts import { DataFrame, DataQueryRequest, diff --git a/packages/grafana-prometheus/src/querycache/QueryCacheTestData.ts b/packages/grafana-prometheus/src/querycache/QueryCacheTestData.ts index ec4d5154bf2..a066f3107e4 100644 --- a/packages/grafana-prometheus/src/querycache/QueryCacheTestData.ts +++ b/packages/grafana-prometheus/src/querycache/QueryCacheTestData.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/querycache/QueryCacheTestData.ts import { clone } from 'lodash'; /** diff --git a/packages/grafana-prometheus/src/result_transformer.test.ts b/packages/grafana-prometheus/src/result_transformer.test.ts index bc2f251767f..b530babd4f5 100644 --- a/packages/grafana-prometheus/src/result_transformer.test.ts +++ b/packages/grafana-prometheus/src/result_transformer.test.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/result_transformer.test.ts import { cacheFieldDisplayNames, createDataFrame, diff --git a/packages/grafana-prometheus/src/result_transformer.ts b/packages/grafana-prometheus/src/result_transformer.ts index ac93f7955a8..a3f11c39087 100644 --- a/packages/grafana-prometheus/src/result_transformer.ts +++ b/packages/grafana-prometheus/src/result_transformer.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/result_transformer.ts import { flatten, forOwn, groupBy, partition } from 'lodash'; import { diff --git a/packages/grafana-prometheus/src/tracking.ts b/packages/grafana-prometheus/src/tracking.ts index 76706984df3..a39c02882f5 100644 --- a/packages/grafana-prometheus/src/tracking.ts +++ b/packages/grafana-prometheus/src/tracking.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/tracking.ts import { CoreApp, DataQueryRequest, DataQueryResponse } from '@grafana/data'; import { config, reportInteraction } from '@grafana/runtime'; diff --git a/packages/grafana-prometheus/src/types.ts b/packages/grafana-prometheus/src/types.ts index f6837388e05..beb9fb07a63 100644 --- a/packages/grafana-prometheus/src/types.ts +++ b/packages/grafana-prometheus/src/types.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/types.ts import { DataSourceJsonData } from '@grafana/data'; import { DataQuery } from '@grafana/schema'; diff --git a/packages/grafana-prometheus/src/variables.ts b/packages/grafana-prometheus/src/variables.ts index fcf545e0d1c..cf3ac7c5f63 100644 --- a/packages/grafana-prometheus/src/variables.ts +++ b/packages/grafana-prometheus/src/variables.ts @@ -1,3 +1,4 @@ +// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/variables.ts import { from, Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index daef6b36959..16327d02e5a 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -1164,13 +1164,6 @@ var ( HideFromDocs: true, HideFromAdminPage: true, }, - { - Name: "usePrometheusFrontendPackage", - Description: "Use the @grafana/prometheus frontend package in core Prometheus.", - Stage: FeatureStageGeneralAvailability, - FrontendOnly: true, - Owner: grafanaObservabilityMetricsSquad, - }, { Name: "oauthRequireSubClaim", Description: "Require that sub claims is present in oauth tokens.", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index bc4043f1f78..9c99387368a 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -155,7 +155,6 @@ betterPageScrolling,GA,@grafana/grafana-frontend-platform,false,false,true authAPIAccessTokenAuth,experimental,@grafana/identity-access-team,false,false,false scopeFilters,experimental,@grafana/dashboards-squad,false,false,false ssoSettingsSAML,experimental,@grafana/identity-access-team,false,false,false -usePrometheusFrontendPackage,GA,@grafana/observability-metrics,false,false,true oauthRequireSubClaim,experimental,@grafana/identity-access-team,false,false,false newDashboardWithFiltersAndGroupBy,experimental,@grafana/dashboards-squad,false,false,false cloudWatchNewLabelParsing,GA,@grafana/aws-datasources,false,false,false diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 753ab0885a4..80c0dc9dc0c 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -631,10 +631,6 @@ const ( // Use the new SSO Settings API to configure the SAML connector FlagSsoSettingsSAML = "ssoSettingsSAML" - // FlagUsePrometheusFrontendPackage - // Use the @grafana/prometheus frontend package in core Prometheus. - FlagUsePrometheusFrontendPackage = "usePrometheusFrontendPackage" - // FlagOauthRequireSubClaim // Require that sub claims is present in oauth tokens. FlagOauthRequireSubClaim = "oauthRequireSubClaim" diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index 78ab30dc6e6..3479f58e6d1 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -1468,6 +1468,7 @@ "name": "usePrometheusFrontendPackage", "resourceVersion": "1712841379965", "creationTimestamp": "2024-04-09T05:07:41Z", + "deletionTimestamp": "2024-04-12T23:12:45Z", "annotations": { "grafana.app/updatedTimestamp": "2024-04-11 13:16:19.965312 +0000 UTC" } diff --git a/public/app/features/alerting/unified/PanelAlertTabContent.test.tsx b/public/app/features/alerting/unified/PanelAlertTabContent.test.tsx index a1df6a1be3e..9c70f018da8 100644 --- a/public/app/features/alerting/unified/PanelAlertTabContent.test.tsx +++ b/public/app/features/alerting/unified/PanelAlertTabContent.test.tsx @@ -4,14 +4,13 @@ import { TestProvider } from 'test/helpers/TestProvider'; import { byTestId } from 'testing-library-selector'; import { DataSourceApi } from '@grafana/data'; +import { PromOptions, PrometheusDatasource } from '@grafana/prometheus'; import { setDataSourceSrv } from '@grafana/runtime'; import * as ruleActionButtons from 'app/features/alerting/unified/components/rules/RuleActionsButtons'; import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; import { toggleOption } from 'app/features/variables/pickers/OptionsPicker/reducer'; import { toKeyedAction } from 'app/features/variables/state/keyedVariablesReducer'; -import { PrometheusDatasource } from 'app/plugins/datasource/prometheus/datasource'; -import { PromOptions } from 'app/plugins/datasource/prometheus/types'; import { configureStore } from 'app/store/configureStore'; import { AccessControlAction } from 'app/types'; import { AlertQuery } from 'app/types/unified-alerting-dto'; diff --git a/public/app/features/alerting/unified/components/Expression.tsx b/public/app/features/alerting/unified/components/Expression.tsx index dce352a0f92..ec11e41a58f 100644 --- a/public/app/features/alerting/unified/components/Expression.tsx +++ b/public/app/features/alerting/unified/components/Expression.tsx @@ -4,9 +4,9 @@ import React, { FC, useMemo } from 'react'; import { Editor } from 'slate-react'; import { GrafanaTheme2 } from '@grafana/data'; +import { promqlGrammar } from '@grafana/prometheus'; import { makeValue, SlatePrism, useStyles2 } from '@grafana/ui'; import LogqlSyntax from 'app/plugins/datasource/loki/syntax'; -import PromqlSyntax from 'app/plugins/datasource/prometheus/promql'; import { RulesSource } from 'app/types/unified-alerting'; import { DataSourceType, isCloudRulesSource } from '../utils/datasource'; @@ -26,7 +26,7 @@ export const HighlightedQuery: FC<{ language: 'promql' | 'logql'; expr: string } onlyIn: (node) => 'type' in node && node.type === 'code_block', getSyntax: () => language, }, - { ...prismLanguages, [language]: language === 'logql' ? LogqlSyntax : PromqlSyntax } + { ...prismLanguages, [language]: language === 'logql' ? LogqlSyntax : promqlGrammar } ), ], [language] diff --git a/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx b/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx index 4c2f5892908..58caf640fe4 100644 --- a/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/ExpressionEditor.tsx @@ -4,10 +4,10 @@ import React, { useCallback, useMemo } from 'react'; import { useAsync } from 'react-use'; import { CoreApp, DataQuery, DataSourcePluginContextProvider, GrafanaTheme2, LoadingState } from '@grafana/data'; +import { PromQuery } from '@grafana/prometheus'; import { getDataSourceSrv } from '@grafana/runtime'; import { Alert, Button, useStyles2 } from '@grafana/ui'; import { LokiQuery } from 'app/plugins/datasource/loki/types'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { CloudAlertPreview } from './CloudAlertPreview'; import { usePreview } from './PreviewRule'; diff --git a/public/app/features/alerting/unified/utils/query.ts b/public/app/features/alerting/unified/utils/query.ts index 950c7340956..49ec1464a93 100644 --- a/public/app/features/alerting/unified/utils/query.ts +++ b/public/app/features/alerting/unified/utils/query.ts @@ -1,9 +1,9 @@ import { produce } from 'immer'; import { DataSourceInstanceSettings } from '@grafana/data'; +import { PromQuery } from '@grafana/prometheus'; import { DataQuery } from '@grafana/schema'; import { LokiQuery } from 'app/plugins/datasource/loki/types'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { CombinedRule } from 'app/types/unified-alerting'; import { AlertQuery } from 'app/types/unified-alerting-dto'; diff --git a/public/app/features/alerting/unified/utils/rule-form.test.ts b/public/app/features/alerting/unified/utils/rule-form.test.ts index 735a8f7087b..164720b2f4a 100644 --- a/public/app/features/alerting/unified/utils/rule-form.test.ts +++ b/public/app/features/alerting/unified/utils/rule-form.test.ts @@ -1,5 +1,5 @@ +import { PromQuery } from '@grafana/prometheus'; import { config } from '@grafana/runtime'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { GrafanaAlertStateDecision, GrafanaRuleDefinition, RulerAlertingRuleDTO } from 'app/types/unified-alerting-dto'; import { AlertManagerManualRouting, RuleFormType, RuleFormValues } from '../types/rule-form'; diff --git a/public/app/features/alerting/unified/utils/rule-form.ts b/public/app/features/alerting/unified/utils/rule-form.ts index 1b664dfbfb4..8efbb441727 100644 --- a/public/app/features/alerting/unified/utils/rule-form.ts +++ b/public/app/features/alerting/unified/utils/rule-form.ts @@ -11,6 +11,7 @@ import { ScopedVars, TimeRange, } from '@grafana/data'; +import { PromQuery } from '@grafana/prometheus'; import { config, getDataSourceSrv } from '@grafana/runtime'; import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend'; import { sceneGraph, VizPanel } from '@grafana/scenes'; @@ -24,7 +25,6 @@ import { } from 'app/features/dashboard-scene/utils/utils'; import { ExpressionDatasourceUID, ExpressionQuery, ExpressionQueryType } from 'app/features/expressions/types'; import { LokiQuery } from 'app/plugins/datasource/loki/types'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { RuleWithLocation } from 'app/types/unified-alerting'; import { AlertDataQuery, diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx index a261687ea1c..7a3ccdd4f4c 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx @@ -5,6 +5,7 @@ import { TestProvider } from 'test/helpers/TestProvider'; import { byTestId } from 'testing-library-selector'; import { DataSourceApi } from '@grafana/data'; +import { PromOptions, PrometheusDatasource } from '@grafana/prometheus'; import { locationService, setDataSourceSrv } from '@grafana/runtime'; import { fetchRules } from 'app/features/alerting/unified/api/prometheus'; import { fetchRulerRules } from 'app/features/alerting/unified/api/ruler'; @@ -24,8 +25,6 @@ import { Annotation } from 'app/features/alerting/unified/utils/constants'; import { DataSourceType, GRAFANA_RULES_SOURCE_NAME } from 'app/features/alerting/unified/utils/datasource'; import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; -import { PrometheusDatasource } from 'app/plugins/datasource/prometheus/datasource'; -import { PromOptions } from 'app/plugins/datasource/prometheus/types'; import { configureStore } from 'app/store/configureStore'; import { AccessControlAction } from 'app/types'; import { AlertQuery } from 'app/types/unified-alerting-dto'; diff --git a/public/app/features/dashboard/state/DashboardModel.ts b/public/app/features/dashboard/state/DashboardModel.ts index a4b2600dc5f..e8f75cd8262 100644 --- a/public/app/features/dashboard/state/DashboardModel.ts +++ b/public/app/features/dashboard/state/DashboardModel.ts @@ -17,6 +17,7 @@ import { TypedVariableModel, UrlQueryValue, } from '@grafana/data'; +import { PromQuery } from '@grafana/prometheus'; import { RefreshEvent, TimeRangeUpdatedEvent, config } from '@grafana/runtime'; import { Dashboard, DashboardLink } from '@grafana/schema'; import { DEFAULT_ANNOTATION_COLOR } from '@grafana/ui'; @@ -27,7 +28,6 @@ import { isAngularDatasourcePluginAndNotHidden } from 'app/features/plugins/angu import { variableAdapters } from 'app/features/variables/adapters'; import { onTimeRangeUpdated } from 'app/features/variables/state/actions'; import { GetVariables, getVariablesByKey } from 'app/features/variables/state/selectors'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { CoreEvents, DashboardMeta, KioskMode } from 'app/types'; import { DashboardMetaChangedEvent, DashboardPanelsChangedEvent, RenderEvent } from 'app/types/events'; diff --git a/public/app/features/explore/PrometheusListView/ItemLabels.tsx b/public/app/features/explore/PrometheusListView/ItemLabels.tsx index a3630f2e650..453edc18e4c 100644 --- a/public/app/features/explore/PrometheusListView/ItemLabels.tsx +++ b/public/app/features/explore/PrometheusListView/ItemLabels.tsx @@ -2,10 +2,9 @@ import { css } from '@emotion/css'; import React from 'react'; import { Field, GrafanaTheme2 } from '@grafana/data/'; +import { InstantQueryRefIdIndex } from '@grafana/prometheus'; import { useStyles2 } from '@grafana/ui/'; -import { InstantQueryRefIdIndex } from '../../../plugins/datasource/prometheus/datasource'; - import { rawListItemColumnWidth } from './RawListItem'; const getItemLabelsStyles = (theme: GrafanaTheme2, expanded: boolean) => { diff --git a/public/app/features/explore/TraceView/createSpanLink.tsx b/public/app/features/explore/TraceView/createSpanLink.tsx index 7b9cdd06c76..c7b840d683a 100644 --- a/public/app/features/explore/TraceView/createSpanLink.tsx +++ b/public/app/features/explore/TraceView/createSpanLink.tsx @@ -20,11 +20,11 @@ import { TraceToLogsOptionsV2, TraceToLogsTag, } from '@grafana/o11y-ds-frontend'; +import { PromQuery } from '@grafana/prometheus'; import { getTemplateSrv } from '@grafana/runtime'; import { DataQuery } from '@grafana/schema'; import { Icon } from '@grafana/ui'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { LokiQuery } from '../../../plugins/datasource/loki/types'; import { ExploreFieldLinkModel, getFieldLinksForExplore, getVariableUsageInfo } from '../utils/links'; diff --git a/public/app/features/trails/ActionTabs/MetricOverviewScene.tsx b/public/app/features/trails/ActionTabs/MetricOverviewScene.tsx index 799ee2c2b13..8803de661a6 100644 --- a/public/app/features/trails/ActionTabs/MetricOverviewScene.tsx +++ b/public/app/features/trails/ActionTabs/MetricOverviewScene.tsx @@ -1,5 +1,6 @@ import React from 'react'; +import { PromMetricsMetadataItem } from '@grafana/prometheus'; import { QueryVariable, SceneComponentProps, @@ -10,7 +11,6 @@ import { } from '@grafana/scenes'; import { Stack, Text, TextLink } from '@grafana/ui'; -import { PromMetricsMetadataItem } from '../../../plugins/datasource/prometheus/types'; import { ALL_VARIABLE_VALUE } from '../../variables/constants'; import { MetricScene } from '../MetricScene'; import { StatusWrapper } from '../StatusWrapper'; diff --git a/public/app/features/trails/AutomaticMetricQueries/previewPanel.ts b/public/app/features/trails/AutomaticMetricQueries/previewPanel.ts index 7b77811f2c5..e6561ba26aa 100644 --- a/public/app/features/trails/AutomaticMetricQueries/previewPanel.ts +++ b/public/app/features/trails/AutomaticMetricQueries/previewPanel.ts @@ -1,5 +1,5 @@ +import { PromQuery } from '@grafana/prometheus'; import { SceneCSSGridItem, SceneQueryRunner, SceneVariableSet } from '@grafana/scenes'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; import { SelectMetricAction } from '../SelectMetricAction'; import { hideEmptyPreviews } from '../hideEmptyPreviews'; diff --git a/public/app/features/trails/AutomaticMetricQueries/query-generators/histogram.ts b/public/app/features/trails/AutomaticMetricQueries/query-generators/histogram.ts index 6f51f6270e2..b6fc3903c1f 100644 --- a/public/app/features/trails/AutomaticMetricQueries/query-generators/histogram.ts +++ b/public/app/features/trails/AutomaticMetricQueries/query-generators/histogram.ts @@ -1,4 +1,4 @@ -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; +import { PromQuery } from '@grafana/prometheus'; import { VAR_FILTERS_EXPR, VAR_GROUP_BY_EXP, VAR_METRIC_EXPR } from '../../shared'; import { heatmapGraphBuilder } from '../graph-builders/heatmap'; diff --git a/public/app/features/trails/AutomaticMetricQueries/types.ts b/public/app/features/trails/AutomaticMetricQueries/types.ts index 0737f3bcbe0..e104dd6dab2 100644 --- a/public/app/features/trails/AutomaticMetricQueries/types.ts +++ b/public/app/features/trails/AutomaticMetricQueries/types.ts @@ -1,5 +1,5 @@ +import { PromQuery } from '@grafana/prometheus'; import { VizPanelBuilder } from '@grafana/scenes'; -import { PromQuery } from 'app/plugins/datasource/prometheus/types'; export interface AutoQueryDef { variant: string; diff --git a/public/app/features/trails/helpers/MetricDatasourceHelper.ts b/public/app/features/trails/helpers/MetricDatasourceHelper.ts index 48aa4f9c3d1..c89b4ab990d 100644 --- a/public/app/features/trails/helpers/MetricDatasourceHelper.ts +++ b/public/app/features/trails/helpers/MetricDatasourceHelper.ts @@ -1,8 +1,8 @@ import { DataSourceApi } from '@grafana/data'; import { PromMetricsMetadata, PromMetricsMetadataItem } from '@grafana/prometheus'; +import PromQlLanguageProvider from '@grafana/prometheus/src/language_provider'; import { getDataSourceSrv } from '@grafana/runtime'; -import PrometheusLanguageProvider from '../../../plugins/datasource/prometheus/language_provider'; import { DataTrail } from '../DataTrail'; import { VAR_DATASOURCE_EXPR } from '../shared'; @@ -34,7 +34,7 @@ export class MetricDatasourceHelper { private async _getMetricsMetadata() { const ds = await this.getDatasource(); - if (ds.languageProvider instanceof PrometheusLanguageProvider) { + if (ds.languageProvider instanceof PromQlLanguageProvider) { if (!ds.languageProvider.metricsMetadata) { await ds.languageProvider.start(); } diff --git a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx index b43d0363169..589a532f349 100644 --- a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx +++ b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx @@ -5,6 +5,7 @@ import React, { useCallback, useMemo } from 'react'; import { useAsync } from 'react-use'; import { DataQuery, GrafanaTheme2, SelectableValue, DataTopic, QueryEditorProps } from '@grafana/data'; +import { OperationsEditorRow } from '@grafana/experimental'; import { Field, Select, useStyles2, Spinner, RadioButtonGroup, Stack, InlineSwitch } from '@grafana/ui'; import config from 'app/core/config'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; @@ -12,8 +13,6 @@ import { PanelModel } from 'app/features/dashboard/state'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; import { filterPanelDataToQuery } from 'app/features/query/components/QueryEditorRow'; -import { OperationsEditorRow } from '../prometheus/querybuilder/shared/OperationsEditorRow'; - import { DashboardDatasource } from './datasource'; import { DashboardQuery, ResultInfo, SHARED_DASHBOARD_QUERY } from './types'; diff --git a/public/app/plugins/datasource/prometheus/add_label_to_query.test.ts b/public/app/plugins/datasource/prometheus/add_label_to_query.test.ts deleted file mode 100644 index 08c32e3c398..00000000000 --- a/public/app/plugins/datasource/prometheus/add_label_to_query.test.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { addLabelToQuery } from './add_label_to_query'; - -describe('addLabelToQuery()', () => { - it('should add label to simple query', () => { - expect(() => { - addLabelToQuery('foo', '', ''); - }).toThrow(); - expect(addLabelToQuery('foo', 'bar', 'baz')).toBe('foo{bar="baz"}'); - expect(addLabelToQuery('foo{}', 'bar', 'baz')).toBe('foo{bar="baz"}'); - expect(addLabelToQuery('foo{x="yy"}', 'bar', 'baz')).toBe('foo{x="yy", bar="baz"}'); - expect(addLabelToQuery('metric > 0.001', 'foo', 'bar')).toBe('metric{foo="bar"} > 0.001'); - }); - - it('should add custom operator', () => { - expect(addLabelToQuery('foo{}', 'bar', 'baz', '!=')).toBe('foo{bar!="baz"}'); - expect(addLabelToQuery('foo{x="yy"}', 'bar', 'baz', '!=')).toBe('foo{x="yy", bar!="baz"}'); - }); - - it('should not modify ranges', () => { - expect(addLabelToQuery('rate(metric[1m])', 'foo', 'bar')).toBe('rate(metric{foo="bar"}[1m])'); - }); - - it('should detect in-order function use', () => { - expect(addLabelToQuery('sum by (xx) (foo)', 'bar', 'baz')).toBe('sum by (xx) (foo{bar="baz"})'); - }); - - it('should convert number Infinity to +Inf', () => { - expect( - addLabelToQuery('sum(rate(prometheus_tsdb_compaction_chunk_size_bytes_bucket[5m])) by (le)', 'le', Infinity) - ).toBe('sum(rate(prometheus_tsdb_compaction_chunk_size_bytes_bucket{le="+Inf"}[5m])) by (le)'); - }); - - it('should handle selectors with punctuation', () => { - expect(addLabelToQuery('foo{instance="my-host.com:9100"}', 'bar', 'baz')).toBe( - 'foo{instance="my-host.com:9100", bar="baz"}' - ); - expect(addLabelToQuery('foo:metric:rate1m', 'bar', 'baz')).toBe('foo:metric:rate1m{bar="baz"}'); - expect(addLabelToQuery('avg(foo:metric:rate1m{a="b"})', 'bar', 'baz')).toBe( - 'avg(foo:metric:rate1m{a="b", bar="baz"})' - ); - expect(addLabelToQuery('foo{list="a,b,c"}', 'bar', 'baz')).toBe('foo{list="a,b,c", bar="baz"}'); - }); - - it('should work on arithmetical expressions', () => { - expect(addLabelToQuery('foo + foo', 'bar', 'baz')).toBe('foo{bar="baz"} + foo{bar="baz"}'); - expect(addLabelToQuery('foo{x="yy"} + metric', 'bar', 'baz')).toBe('foo{x="yy", bar="baz"} + metric{bar="baz"}'); - expect(addLabelToQuery('avg(foo) + sum(xx_yy)', 'bar', 'baz')).toBe('avg(foo{bar="baz"}) + sum(xx_yy{bar="baz"})'); - expect(addLabelToQuery('foo{x="yy"} * metric{y="zz",a="bb"} * metric2', 'bar', 'baz')).toBe( - 'foo{x="yy", bar="baz"} * metric{y="zz", a="bb", bar="baz"} * metric2{bar="baz"}' - ); - }); - - it('should not add duplicate labels to a query', () => { - expect(addLabelToQuery(addLabelToQuery('foo{x="yy"}', 'bar', 'baz', '!='), 'bar', 'baz', '!=')).toBe( - 'foo{x="yy", bar!="baz"}' - ); - expect(addLabelToQuery(addLabelToQuery('rate(metric[1m])', 'foo', 'bar'), 'foo', 'bar')).toBe( - 'rate(metric{foo="bar"}[1m])' - ); - expect(addLabelToQuery(addLabelToQuery('foo{list="a,b,c"}', 'bar', 'baz'), 'bar', 'baz')).toBe( - 'foo{list="a,b,c", bar="baz"}' - ); - expect(addLabelToQuery(addLabelToQuery('avg(foo) + sum(xx_yy)', 'bar', 'baz'), 'bar', 'baz')).toBe( - 'avg(foo{bar="baz"}) + sum(xx_yy{bar="baz"})' - ); - }); - - it('should not remove filters', () => { - expect(addLabelToQuery('{x="y"} |="yy"', 'bar', 'baz')).toBe('{x="y", bar="baz"} |="yy"'); - expect(addLabelToQuery('{x="y"} |="yy" !~"xx"', 'bar', 'baz')).toBe('{x="y", bar="baz"} |="yy" !~"xx"'); - }); - - it('should add labels to metrics with logical operators', () => { - expect(addLabelToQuery('foo_info or bar_info', 'bar', 'baz')).toBe('foo_info{bar="baz"} or bar_info{bar="baz"}'); - expect(addLabelToQuery('foo_info and bar_info', 'bar', 'baz')).toBe('foo_info{bar="baz"} and bar_info{bar="baz"}'); - }); - - it('should not add ad-hoc filter to template variables', () => { - expect(addLabelToQuery('sum(rate({job="foo"}[2m])) by (value $variable)', 'bar', 'baz')).toBe( - 'sum(rate({job="foo", bar="baz"}[2m])) by (value $variable)' - ); - }); - - it('should not add ad-hoc filter to range', () => { - expect(addLabelToQuery('avg(rate((my_metric{job="foo"} > 0)[3h:])) by (label)', 'bar', 'baz')).toBe( - 'avg(rate((my_metric{job="foo", bar="baz"} > 0)[3h:])) by (label)' - ); - }); - it('should not add ad-hoc filter to labels in label list provided with the group modifier', () => { - expect( - addLabelToQuery( - 'max by (id, name, type) (my_metric{type=~"foo|bar|baz-test"}) * on(id) group_right(id, type, name) sum by (id) (my_metric) * 1000', - 'bar', - 'baz' - ) - ).toBe( - 'max by (id, name, type) (my_metric{type=~"foo|bar|baz-test", bar="baz"}) * on(id) group_right(id, type, name) sum by (id) (my_metric{bar="baz"}) * 1000' - ); - }); - it('should not add ad-hoc filter to labels in label list provided with the group modifier', () => { - expect(addLabelToQuery('rate(my_metric[${__range_s}s])', 'bar', 'baz')).toBe( - 'rate(my_metric{bar="baz"}[${__range_s}s])' - ); - }); - it('should not add ad-hoc filter to labels to math operations', () => { - expect(addLabelToQuery('count(my_metric{job!="foo"} < (5*1024*1024*1024) or vector(0)) - 1', 'bar', 'baz')).toBe( - 'count(my_metric{job!="foo", bar="baz"} < (5*1024*1024*1024) or vector(0)) - 1' - ); - }); - - it('should not add ad-hoc filter bool operator', () => { - expect(addLabelToQuery('ALERTS < bool 1', 'bar', 'baz')).toBe('ALERTS{bar="baz"} < bool 1'); - }); -}); diff --git a/public/app/plugins/datasource/prometheus/add_label_to_query.ts b/public/app/plugins/datasource/prometheus/add_label_to_query.ts deleted file mode 100644 index 696e0cbb8dc..00000000000 --- a/public/app/plugins/datasource/prometheus/add_label_to_query.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { parser, VectorSelector } from '@prometheus-io/lezer-promql'; - -import { PromQueryModeller } from './querybuilder/PromQueryModeller'; -import { buildVisualQueryFromString } from './querybuilder/parsing'; -import { QueryBuilderLabelFilter } from './querybuilder/shared/types'; -import { PromVisualQuery } from './querybuilder/types'; - -/** - * Adds label filter to existing query. Useful for query modification for example for ad hoc filters. - * - * It uses PromQL parser to find instances of metric and labels, alters them and then splices them back into the query. - * Ideally we could use the parse -> change -> render is a simple 3 steps but right now building the visual query - * object does not support all possible queries. - * - * So instead this just operates on substrings of the query with labels and operates just on those. This makes this - * more robust and can alter even invalid queries, and preserves in general the query structure and whitespace. - * @param query - * @param key - * @param value - * @param operator - */ -export function addLabelToQuery(query: string, key: string, value: string | number, operator = '='): string { - if (!key || !value) { - throw new Error('Need label to add to query.'); - } - - const vectorSelectorPositions = getVectorSelectorPositions(query); - if (!vectorSelectorPositions.length) { - return query; - } - - const filter = toLabelFilter(key, value, operator); - return addFilter(query, vectorSelectorPositions, filter); -} - -type VectorSelectorPosition = { from: number; to: number; query: PromVisualQuery }; - -/** - * Parse the string and get all VectorSelector positions in the query together with parsed representation of the vector - * selector. - * @param query - */ -function getVectorSelectorPositions(query: string): VectorSelectorPosition[] { - const tree = parser.parse(query); - const positions: VectorSelectorPosition[] = []; - tree.iterate({ - enter: ({ to, from, type }): false | void => { - if (type.id === VectorSelector) { - const visQuery = buildVisualQueryFromString(query.substring(from, to)); - positions.push({ query: visQuery.query, from, to }); - return false; - } - }, - }); - return positions; -} - -function toLabelFilter(key: string, value: string | number, operator: string): QueryBuilderLabelFilter { - // We need to make sure that we convert the value back to string because it may be a number - const transformedValue = value === Infinity ? '+Inf' : value.toString(); - return { label: key, op: operator, value: transformedValue }; -} - -function addFilter( - query: string, - vectorSelectorPositions: VectorSelectorPosition[], - filter: QueryBuilderLabelFilter -): string { - const modeller = new PromQueryModeller(); - let newQuery = ''; - let prev = 0; - - for (let i = 0; i < vectorSelectorPositions.length; i++) { - // This is basically just doing splice on a string for each matched vector selector. - - const match = vectorSelectorPositions[i]; - const isLast = i === vectorSelectorPositions.length - 1; - - const start = query.substring(prev, match.from); - const end = isLast ? query.substring(match.to) : ''; - - if (!labelExists(match.query.labels, filter)) { - // We don't want to add duplicate labels. - match.query.labels.push(filter); - } - const newLabels = modeller.renderQuery(match.query); - newQuery += start + newLabels + end; - prev = match.to; - } - return newQuery; -} - -/** - * Check if label exists in the list of labels but ignore the operator. - * @param labels - * @param filter - */ -function labelExists(labels: QueryBuilderLabelFilter[], filter: QueryBuilderLabelFilter) { - return labels.find((label) => label.label === filter.label && label.value === filter.value); -} diff --git a/public/app/plugins/datasource/prometheus/components/AnnotationQueryEditor.tsx b/public/app/plugins/datasource/prometheus/components/AnnotationQueryEditor.tsx deleted file mode 100644 index 0cbaf5978cd..00000000000 --- a/public/app/plugins/datasource/prometheus/components/AnnotationQueryEditor.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import React from 'react'; - -import { AnnotationQuery } from '@grafana/data'; -import { selectors } from '@grafana/e2e-selectors'; -import { EditorField, EditorRow, EditorRows, EditorSwitch } from '@grafana/experimental'; -import { AutoSizeInput, Input, Space } from '@grafana/ui'; - -import { PromQueryCodeEditor } from '../querybuilder/components/PromQueryCodeEditor'; -import { PromQuery } from '../types'; - -import { PromQueryEditorProps } from './types'; - -type Props = PromQueryEditorProps & { - annotation?: AnnotationQuery; - onAnnotationChange?: (annotation: AnnotationQuery) => void; -}; - -export function AnnotationQueryEditor(props: Props) { - // This is because of problematic typing. See AnnotationQueryEditorProps in grafana-data/annotations.ts. - const annotation = props.annotation!; - const onAnnotationChange = props.onAnnotationChange!; - const query = { expr: annotation.expr, refId: annotation.name, interval: annotation.step }; - - return ( - <> - - { - onAnnotationChange({ - ...annotation, - expr: query.expr, - }); - }} - /> - - - An additional lower limit for the step parameter of the Prometheus query and for the{' '} - $__interval and $__rate_interval variables. - - } - > - { - onAnnotationChange({ - ...annotation, - step: ev.currentTarget.value, - }); - }} - defaultValue={query.interval} - id={selectors.components.DataSource.Prometheus.annotations.minStep} - /> - - - - - - - { - onAnnotationChange({ - ...annotation, - titleFormat: event.currentTarget.value, - }); - }} - data-testid={selectors.components.DataSource.Prometheus.annotations.title} - /> - - - { - onAnnotationChange({ - ...annotation, - tagKeys: event.currentTarget.value, - }); - }} - data-testid={selectors.components.DataSource.Prometheus.annotations.tags} - /> - - - { - onAnnotationChange({ - ...annotation, - textFormat: event.currentTarget.value, - }); - }} - data-testid={selectors.components.DataSource.Prometheus.annotations.text} - /> - - - { - onAnnotationChange({ - ...annotation, - useValueForTime: event.currentTarget.value, - }); - }} - data-testid={selectors.components.DataSource.Prometheus.annotations.seriesValueAsTimestamp} - /> - - - - ); -} diff --git a/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx b/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx deleted file mode 100644 index 9142be3e1f7..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; - -import { QueryEditorHelpProps } from '@grafana/data'; - -import { PromQuery } from '../types'; - -const CHEAT_SHEET_ITEMS = [ - { - title: 'Request Rate', - expression: 'rate(http_request_total[5m])', - label: - 'Given an HTTP request counter, this query calculates the per-second average request rate over the last 5 minutes.', - }, - { - title: '95th Percentile of Request Latencies', - expression: 'histogram_quantile(0.95, sum(rate(prometheus_http_request_duration_seconds_bucket[5m])) by (le))', - label: 'Calculates the 95th percentile of HTTP request rate over 5 minute windows.', - }, - { - title: 'Alerts Firing', - expression: 'sort_desc(sum(sum_over_time(ALERTS{alertstate="firing"}[24h])) by (alertname))', - label: 'Sums up the alerts that have been firing over the last 24 hours.', - }, - { - title: 'Step', - label: - 'Defines the graph resolution using a duration format (15s, 1m, 3h, ...). Small steps create high-resolution graphs but can be slow over larger time ranges. Using a longer step lowers the resolution and smooths the graph by producing fewer datapoints. If no step is given the resolution is calculated automatically.', - }, -]; - -const PromCheatSheet = (props: QueryEditorHelpProps) => ( -
-

PromQL Cheat Sheet

- {CHEAT_SHEET_ITEMS.map((item, index) => ( -
-
{item.title}
- {item.expression ? ( - - ) : null} -
{item.label}
-
- ))} -
-); - -export default PromCheatSheet; diff --git a/public/app/plugins/datasource/prometheus/components/PromExemplarField.tsx b/public/app/plugins/datasource/prometheus/components/PromExemplarField.tsx deleted file mode 100644 index e09a6260c98..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromExemplarField.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { css, cx } from '@emotion/css'; -import React, { useEffect, useState } from 'react'; -import { usePrevious } from 'react-use'; - -import { GrafanaTheme2 } from '@grafana/data'; -import { IconButton, InlineLabel, Tooltip, useStyles2 } from '@grafana/ui'; - -import { PrometheusDatasource } from '../datasource'; -import { PromQuery } from '../types'; - -interface Props { - onChange: (exemplar: boolean) => void; - datasource: PrometheusDatasource; - query: PromQuery; - 'data-testid'?: string; -} - -export function PromExemplarField({ datasource, onChange, query, ...rest }: Props) { - const [error, setError] = useState(null); - const styles = useStyles2(getStyles); - const prevError = usePrevious(error); - - useEffect(() => { - if (!datasource.exemplarsAvailable) { - setError('Exemplars for this query are not available'); - onChange(false); - } else if (query.instant && !query.range) { - setError('Exemplars are not available for instant queries'); - onChange(false); - } else { - setError(null); - // If error is cleared, we want to change exemplar to true - if (prevError && !error) { - onChange(true); - } - } - }, [datasource.exemplarsAvailable, query.instant, query.range, onChange, prevError, error]); - - const iconButtonStyles = cx( - { - [styles.activeIcon]: !!query.exemplar, - }, - styles.eyeIcon - ); - - return ( - - -
- Exemplars - { - onChange(!query.exemplar); - }} - /> -
-
-
- ); -} - -function getStyles(theme: GrafanaTheme2) { - return { - eyeIcon: css` - margin-left: ${theme.spacing(2)}; - `, - activeIcon: css` - color: ${theme.colors.primary.main}; - `, - iconWrapper: css` - display: flex; - align-items: center; - `, - }; -} diff --git a/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.test.tsx b/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.test.tsx deleted file mode 100644 index 44fcd65b7a8..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.test.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import React from 'react'; - -import { PrometheusDatasource } from '../datasource'; -import { PromQuery } from '../types'; - -import { PromExploreExtraFieldProps, PromExploreExtraField, testIds } from './PromExploreExtraField'; - -const setup = (propOverrides?: PromExploreExtraFieldProps) => { - const query = { exemplar: false } as PromQuery; - const datasource = {} as PrometheusDatasource; - const onChange = jest.fn(); - const onRunQuery = jest.fn(); - - const props: PromExploreExtraFieldProps = { - onChange, - onRunQuery, - query, - datasource, - }; - - Object.assign(props, propOverrides); - - return render(); -}; - -describe('PromExploreExtraField', () => { - it('should render step field', () => { - setup(); - expect(screen.getByTestId(testIds.stepField)).toBeInTheDocument(); - }); - - it('should render query type field', () => { - setup(); - expect(screen.getByTestId(testIds.queryTypeField)).toBeInTheDocument(); - }); -}); diff --git a/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx b/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx deleted file mode 100644 index f4bc23d0e4d..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromExploreExtraField.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import { css, cx } from '@emotion/css'; -import { isEqual } from 'lodash'; -import React, { memo, useCallback } from 'react'; -import { usePrevious } from 'react-use'; - -import { InlineFormLabel, RadioButtonGroup } from '@grafana/ui'; - -import { PrometheusDatasource } from '../datasource'; -import { PromQuery } from '../types'; - -import { PromExemplarField } from './PromExemplarField'; - -export interface PromExploreExtraFieldProps { - query: PromQuery; - onChange: (value: PromQuery) => void; - onRunQuery: () => void; - datasource: PrometheusDatasource; -} - -export const PromExploreExtraField = memo(({ query, datasource, onChange, onRunQuery }: PromExploreExtraFieldProps) => { - const rangeOptions = getQueryTypeOptions(true); - const prevQuery = usePrevious(query); - - const onExemplarChange = useCallback( - (exemplar: boolean) => { - if (!isEqual(query, prevQuery) || exemplar !== query.exemplar) { - onChange({ ...query, exemplar }); - } - }, - [prevQuery, query, onChange] - ); - - function onChangeQueryStep(interval: string) { - onChange({ ...query, interval }); - } - - function onStepChange(e: React.SyntheticEvent) { - if (e.currentTarget.value !== query.interval) { - onChangeQueryStep(e.currentTarget.value); - } - } - - function onReturnKeyDown(e: React.KeyboardEvent) { - if (e.key === 'Enter' && e.shiftKey) { - onRunQuery(); - } - } - - const onQueryTypeChange = getQueryTypeChangeHandler(query, onChange); - - return ( -
- {/*Query type field*/} -
- Query type - - -
- {/*Step field*/} -
- - Min step - - -
- - -
- ); -}); - -PromExploreExtraField.displayName = 'PromExploreExtraField'; - -export function getQueryTypeOptions(includeBoth: boolean) { - const rangeOptions = [ - { value: 'range', label: 'Range', description: 'Run query over a range of time' }, - { - value: 'instant', - label: 'Instant', - description: 'Run query against a single point in time. For this query, the "To" time is used', - }, - ]; - - if (includeBoth) { - rangeOptions.push({ value: 'both', label: 'Both', description: 'Run an Instant query and a Range query' }); - } - - return rangeOptions; -} - -export function getQueryTypeChangeHandler(query: PromQuery, onChange: (update: PromQuery) => void) { - return (queryType: string) => { - if (queryType === 'instant') { - onChange({ ...query, instant: true, range: false, exemplar: false }); - } else if (queryType === 'range') { - onChange({ ...query, instant: false, range: true }); - } else { - onChange({ ...query, instant: true, range: true }); - } - }; -} - -export const testIds = { - extraFieldEditor: 'prom-editor-extra-field', - stepField: 'prom-editor-extra-field-step', - queryTypeField: 'prom-editor-extra-field-query-type', -}; diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.test.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.test.tsx deleted file mode 100644 index e8da197c087..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.test.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import { noop } from 'lodash'; -import React from 'react'; - -import { CoreApp } from '@grafana/data'; - -import { PrometheusDatasource } from '../datasource'; - -import { PromQueryEditorByApp } from './PromQueryEditorByApp'; -import { testIds as alertingTestIds } from './PromQueryEditorForAlerting'; -import { Props } from './monaco-query-field/MonacoQueryFieldProps'; - -// the monaco-based editor uses lazy-loading and that does not work -// well with this test, and we do not need the monaco-related -// functionality in this test anyway, so we mock it out. -jest.mock('./monaco-query-field/MonacoQueryFieldLazy', () => { - const fakeQueryField = (props: Props) => { - return props.onBlur(e.currentTarget.value)} data-testid={'dummy-code-input'} type={'text'} />; - }; - return { - MonacoQueryFieldLazy: fakeQueryField, - }; -}); - -function setup(app: CoreApp): { onRunQuery: jest.Mock } { - const dataSource = { - createQuery: jest.fn((q) => q), - getInitHints: () => [], - getPrometheusTime: jest.fn((date, roundup) => 123), - getQueryHints: jest.fn(() => []), - getDebounceTimeInMilliseconds: jest.fn(() => 300), - languageProvider: { - start: () => Promise.resolve([]), - syntax: () => {}, - getLabelKeys: () => [], - metrics: [], - }, - } as unknown as PrometheusDatasource; - const onRunQuery = jest.fn(); - - render( - - ); - - return { - onRunQuery, - }; -} - -describe('PromQueryEditorByApp', () => { - it('should render simplified query editor for cloud alerting', async () => { - setup(CoreApp.CloudAlerting); - - expect(await screen.findByTestId(alertingTestIds.editor)).toBeInTheDocument(); - }); - - it('should render editor selector for unkown apps', () => { - setup(CoreApp.Unknown); - - expect(screen.getByTestId('QueryEditorModeToggle')).toBeInTheDocument(); - expect(screen.queryByTestId(alertingTestIds.editor)).toBeNull(); - }); - - it('should render editor selector for explore', () => { - setup(CoreApp.Explore); - - expect(screen.getByTestId('QueryEditorModeToggle')).toBeInTheDocument(); - expect(screen.queryByTestId(alertingTestIds.editor)).toBeNull(); - }); - - it('should render editor selector for dashboard', () => { - setup(CoreApp.Dashboard); - - expect(screen.getByTestId('QueryEditorModeToggle')).toBeInTheDocument(); - expect(screen.queryByTestId(alertingTestIds.editor)).toBeNull(); - }); -}); diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.tsx deleted file mode 100644 index f10a6e3279a..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromQueryEditorByApp.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React, { memo } from 'react'; - -import { CoreApp } from '@grafana/data'; - -import { PromQueryEditorSelector } from '../querybuilder/components/PromQueryEditorSelector'; - -import { PromQueryEditorForAlerting } from './PromQueryEditorForAlerting'; -import { PromQueryEditorProps } from './types'; - -export function PromQueryEditorByApp(props: PromQueryEditorProps) { - const { app } = props; - - switch (app) { - case CoreApp.CloudAlerting: - return ; - default: - return ; - } -} - -export default memo(PromQueryEditorByApp); diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryEditorForAlerting.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryEditorForAlerting.tsx deleted file mode 100644 index b7b57071d8e..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromQueryEditorForAlerting.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; - -import PromQueryField from './PromQueryField'; -import { PromQueryEditorProps } from './types'; - -export function PromQueryEditorForAlerting(props: PromQueryEditorProps) { - const { datasource, query, range, data, onChange, onRunQuery } = props; - - return ( - - ); -} - -export const testIds = { - editor: 'prom-editor-cloud-alerting', -}; diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryField.test.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryField.test.tsx deleted file mode 100644 index 5c8393649a0..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromQueryField.test.tsx +++ /dev/null @@ -1,183 +0,0 @@ -import { getByTestId, render, screen, waitFor } from '@testing-library/react'; -// @ts-ignore -import userEvent from '@testing-library/user-event'; -import React from 'react'; - -import { PanelData, LoadingState, DataFrame, CoreApp } from '@grafana/data'; - -import { PrometheusDatasource } from '../datasource'; -import PromQlLanguageProvider from '../language_provider'; - -import PromQueryField from './PromQueryField'; -import { Props } from './monaco-query-field/MonacoQueryFieldProps'; - -// the monaco-based editor uses lazy-loading and that does not work -// well with this test, and we do not need the monaco-related -// functionality in this test anyway, so we mock it out. -jest.mock('./monaco-query-field/MonacoQueryFieldLazy', () => { - const fakeQueryField = (props: Props) => { - return props.onBlur(e.currentTarget.value)} data-testid={'dummy-code-input'} type={'text'} />; - }; - return { - MonacoQueryFieldLazy: fakeQueryField, - }; -}); - -const defaultProps = { - datasource: { - languageProvider: { - start: () => Promise.resolve([]), - syntax: () => {}, - getLabelKeys: () => [], - metrics: [], - }, - getInitHints: () => [], - } as unknown as PrometheusDatasource, - query: { - expr: '', - refId: '', - }, - onRunQuery: () => {}, - onChange: () => {}, - history: [], -}; - -describe('PromQueryField', () => { - beforeAll(() => { - // @ts-ignore - window.getSelection = () => {}; - }); - - it('renders metrics chooser regularly if lookups are not disabled in the datasource settings', async () => { - const queryField = render(); - - // wait for component to render - await screen.findByRole('button'); - - expect(queryField.getAllByRole('button')).toHaveLength(1); - }); - - it('renders a disabled metrics chooser if lookups are disabled in datasource settings', async () => { - const props = defaultProps; - props.datasource.lookupsDisabled = true; - const queryField = render(); - - // wait for component to render - await screen.findByRole('button'); - - const bcButton = queryField.getByRole('button'); - expect(bcButton).toBeDisabled(); - }); - - it('renders an initial hint if no data and initial hint provided', async () => { - const props = defaultProps; - props.datasource.lookupsDisabled = true; - props.datasource.getInitHints = () => [{ label: 'Initial hint', type: 'INFO' }]; - render(); - - // wait for component to render - await screen.findByRole('button'); - - expect(screen.getByText('Initial hint')).toBeInTheDocument(); - }); - - it('renders query hint if data, query hint and initial hint provided', async () => { - const props = defaultProps; - props.datasource.lookupsDisabled = true; - props.datasource.getInitHints = () => [{ label: 'Initial hint', type: 'INFO' }]; - props.datasource.getQueryHints = () => [{ label: 'Query hint', type: 'INFO' }]; - render( - - ); - - // wait for component to render - await screen.findByRole('button'); - - expect(screen.getByText('Query hint')).toBeInTheDocument(); - expect(screen.queryByText('Initial hint')).not.toBeInTheDocument(); - }); - - it('refreshes metrics when the data source changes', async () => { - const defaultProps = { - query: { expr: '', refId: '' }, - onRunQuery: () => {}, - onChange: () => {}, - history: [], - }; - const metrics = ['foo', 'bar']; - const queryField = render( - [], - } as unknown as PrometheusDatasource - } - {...defaultProps} - /> - ); - - // wait for component to render - await screen.findByRole('button'); - - const changedMetrics = ['baz', 'moo']; - queryField.rerender( - - ); - - // If we check the label browser right away it should be in loading state - let labelBrowser = screen.getByRole('button'); - expect(labelBrowser).toHaveTextContent('Loading'); - - // wait for component to rerender - labelBrowser = await screen.findByRole('button'); - await waitFor(() => { - expect(labelBrowser).toHaveTextContent('Metrics browser'); - }); - }); - - it('should not run query onBlur', async () => { - const onRunQuery = jest.fn(); - const { container } = render(); - - // wait for component to rerender - await screen.findByRole('button'); - - const input = getByTestId(container, 'dummy-code-input'); - expect(input).toBeInTheDocument(); - await userEvent.type(input, 'metric'); - - // blur element - await userEvent.click(document.body); - expect(onRunQuery).not.toHaveBeenCalled(); - }); -}); - -function makeLanguageProvider(options: { metrics: string[][] }) { - const metricsStack = [...options.metrics]; - return { - histogramMetrics: [], - metrics: [], - metricsMetadata: {}, - lookupsDisabled: false, - getLabelKeys: () => [], - start() { - this.metrics = metricsStack.shift(); - return Promise.resolve([]); - }, - } as any as PromQlLanguageProvider; -} diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx deleted file mode 100644 index 496322a5a7d..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx +++ /dev/null @@ -1,290 +0,0 @@ -import { cx } from '@emotion/css'; -import React, { ReactNode } from 'react'; - -import { isDataFrame, QueryEditorProps, QueryHint, TimeRange, toLegacyResponseData } from '@grafana/data'; -import { selectors } from '@grafana/e2e-selectors'; -import { reportInteraction } from '@grafana/runtime'; -import { Icon, Themeable2, withTheme2, clearButtonStyles } from '@grafana/ui'; -import { LocalStorageValueProvider } from 'app/core/components/LocalStorageValueProvider'; -import { - CancelablePromise, - isCancelablePromiseRejection, - makePromiseCancelable, -} from 'app/core/utils/CancelablePromise'; - -import { PrometheusDatasource } from '../datasource'; -import { roundMsToMin } from '../language_utils'; -import { PromOptions, PromQuery } from '../types'; - -import { PrometheusMetricsBrowser } from './PrometheusMetricsBrowser'; -import { MonacoQueryFieldWrapper } from './monaco-query-field/MonacoQueryFieldWrapper'; - -const LAST_USED_LABELS_KEY = 'grafana.datasources.prometheus.browser.labels'; - -function getChooserText(metricsLookupDisabled: boolean, hasSyntax: boolean, hasMetrics: boolean) { - if (metricsLookupDisabled) { - return '(Disabled)'; - } - - if (!hasSyntax) { - return 'Loading metrics...'; - } - - if (!hasMetrics) { - return '(No metrics found)'; - } - - return 'Metrics browser'; -} - -interface PromQueryFieldProps extends QueryEditorProps, Themeable2 { - ExtraFieldElement?: ReactNode; - 'data-testid'?: string; -} - -interface PromQueryFieldState { - labelBrowserVisible: boolean; - syntaxLoaded: boolean; - hint: QueryHint | null; -} - -class PromQueryField extends React.PureComponent { - declare languageProviderInitializationPromise: CancelablePromise; - - constructor(props: PromQueryFieldProps) { - super(props); - - this.state = { - labelBrowserVisible: false, - syntaxLoaded: false, - hint: null, - }; - } - - componentDidMount() { - if (this.props.datasource.languageProvider) { - this.refreshMetrics(); - } - this.refreshHint(); - } - - componentWillUnmount() { - if (this.languageProviderInitializationPromise) { - this.languageProviderInitializationPromise.cancel(); - } - } - - componentDidUpdate(prevProps: PromQueryFieldProps) { - const { - data, - datasource: { languageProvider }, - range, - } = this.props; - - if (languageProvider !== prevProps.datasource.languageProvider) { - // We reset this only on DS change so we do not flesh loading state on every rangeChange which happens on every - // query run if using relative range. - this.setState({ - syntaxLoaded: false, - }); - } - - const changedRangeToRefresh = this.rangeChangedToRefresh(range, prevProps.range); - // We want to refresh metrics when language provider changes and/or when range changes (we round up intervals to a minute) - if (languageProvider !== prevProps.datasource.languageProvider || changedRangeToRefresh) { - this.refreshMetrics(); - } - - if (data && prevProps.data && prevProps.data.series !== data.series) { - this.refreshHint(); - } - } - - refreshHint = () => { - const { datasource, query, data } = this.props; - const initHints = datasource.getInitHints(); - const initHint = initHints.length > 0 ? initHints[0] : null; - - if (!data || data.series.length === 0) { - this.setState({ - hint: initHint, - }); - return; - } - - const result = isDataFrame(data.series[0]) ? data.series.map(toLegacyResponseData) : data.series; - const queryHints = datasource.getQueryHints(query, result); - let queryHint = queryHints.length > 0 ? queryHints[0] : null; - - this.setState({ hint: queryHint ?? initHint }); - }; - - refreshMetrics = async () => { - const { - range, - datasource: { languageProvider }, - } = this.props; - - this.languageProviderInitializationPromise = makePromiseCancelable(languageProvider.start(range)); - - try { - const remainingTasks = await this.languageProviderInitializationPromise.promise; - await Promise.all(remainingTasks); - this.onUpdateLanguage(); - } catch (err) { - if (isCancelablePromiseRejection(err) && err.isCanceled) { - // do nothing, promise was canceled - } else { - throw err; - } - } - }; - - rangeChangedToRefresh(range?: TimeRange, prevRange?: TimeRange): boolean { - if (range && prevRange) { - const sameMinuteFrom = roundMsToMin(range.from.valueOf()) === roundMsToMin(prevRange.from.valueOf()); - const sameMinuteTo = roundMsToMin(range.to.valueOf()) === roundMsToMin(prevRange.to.valueOf()); - // If both are same, don't need to refresh. - return !(sameMinuteFrom && sameMinuteTo); - } - return false; - } - - /** - * TODO #33976: Remove this, add histogram group (query = `histogram_quantile(0.95, sum(rate(${metric}[5m])) by (le))`;) - */ - onChangeLabelBrowser = (selector: string) => { - this.onChangeQuery(selector, true); - this.setState({ labelBrowserVisible: false }); - }; - - onChangeQuery = (value: string, override?: boolean) => { - // Send text change to parent - const { query, onChange, onRunQuery } = this.props; - if (onChange) { - const nextQuery: PromQuery = { ...query, expr: value }; - onChange(nextQuery); - - if (override && onRunQuery) { - onRunQuery(); - } - } - }; - - onClickChooserButton = () => { - this.setState((state) => ({ labelBrowserVisible: !state.labelBrowserVisible })); - - reportInteraction('user_grafana_prometheus_metrics_browser_clicked', { - editorMode: this.state.labelBrowserVisible ? 'metricViewClosed' : 'metricViewOpen', - app: this.props?.app ?? '', - }); - }; - - onClickHintFix = () => { - const { datasource, query, onChange, onRunQuery } = this.props; - const { hint } = this.state; - if (hint?.fix?.action) { - onChange(datasource.modifyQuery(query, hint.fix.action)); - } - onRunQuery(); - }; - - onUpdateLanguage = () => { - const { - datasource: { languageProvider }, - } = this.props; - const { metrics } = languageProvider; - - if (!metrics) { - return; - } - - this.setState({ syntaxLoaded: true }); - }; - - render() { - const { - datasource, - datasource: { languageProvider }, - query, - ExtraFieldElement, - history = [], - theme, - } = this.props; - - const { labelBrowserVisible, syntaxLoaded, hint } = this.state; - const hasMetrics = languageProvider.metrics.length > 0; - const chooserText = getChooserText(datasource.lookupsDisabled, syntaxLoaded, hasMetrics); - const buttonDisabled = !(syntaxLoaded && hasMetrics); - - return ( - storageKey={LAST_USED_LABELS_KEY} defaultValue={[]}> - {(lastUsedLabels, onLastUsedLabelsSave, onLastUsedLabelsDelete) => { - return ( - <> -
- - -
- -
-
- {labelBrowserVisible && ( -
- -
- )} - - {ExtraFieldElement} - {hint ? ( -
-
- {hint.label}{' '} - {hint.fix ? ( - - ) : null} -
-
- ) : null} - - ); - }} - - ); - } -} - -export default withTheme2(PromQueryField); diff --git a/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.test.tsx b/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.test.tsx deleted file mode 100644 index b5cc16744a8..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.test.tsx +++ /dev/null @@ -1,324 +0,0 @@ -import { render, screen, waitFor } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import React from 'react'; - -import { createTheme } from '@grafana/data'; - -import PromQlLanguageProvider from '../language_provider'; - -import { - buildSelector, - facetLabels, - SelectableLabel, - UnthemedPrometheusMetricsBrowser, - BrowserProps, -} from './PrometheusMetricsBrowser'; - -describe('buildSelector()', () => { - it('returns an empty selector for no labels', () => { - expect(buildSelector([])).toEqual('{}'); - }); - it('returns an empty selector for selected labels with no values', () => { - const labels: SelectableLabel[] = [{ name: 'foo', selected: true }]; - expect(buildSelector(labels)).toEqual('{}'); - }); - it('returns an empty selector for one selected label with no selected values', () => { - const labels: SelectableLabel[] = [{ name: 'foo', selected: true, values: [{ name: 'bar' }] }]; - expect(buildSelector(labels)).toEqual('{}'); - }); - it('returns a simple selector from a selected label with a selected value', () => { - const labels: SelectableLabel[] = [{ name: 'foo', selected: true, values: [{ name: 'bar', selected: true }] }]; - expect(buildSelector(labels)).toEqual('{foo="bar"}'); - }); - it('metric selector without labels', () => { - const labels: SelectableLabel[] = [{ name: '__name__', selected: true, values: [{ name: 'foo', selected: true }] }]; - expect(buildSelector(labels)).toEqual('foo{}'); - }); - it('selector with multiple metrics', () => { - const labels: SelectableLabel[] = [ - { - name: '__name__', - selected: true, - values: [ - { name: 'foo', selected: true }, - { name: 'bar', selected: true }, - ], - }, - ]; - expect(buildSelector(labels)).toEqual('{__name__=~"foo|bar"}'); - }); - it('metric selector with labels', () => { - const labels: SelectableLabel[] = [ - { name: '__name__', selected: true, values: [{ name: 'foo', selected: true }] }, - { name: 'bar', selected: true, values: [{ name: 'baz', selected: true }] }, - ]; - expect(buildSelector(labels)).toEqual('foo{bar="baz"}'); - }); -}); - -describe('facetLabels()', () => { - const possibleLabels = { - cluster: ['dev'], - namespace: ['alertmanager'], - }; - const labels: SelectableLabel[] = [ - { name: 'foo', selected: true, values: [{ name: 'bar' }] }, - { name: 'cluster', values: [{ name: 'dev' }, { name: 'ops' }, { name: 'prod' }] }, - { name: 'namespace', values: [{ name: 'alertmanager' }] }, - ]; - - it('returns no labels given an empty label set', () => { - expect(facetLabels([], {})).toEqual([]); - }); - - it('marks all labels as hidden when no labels are possible', () => { - const result = facetLabels(labels, {}); - expect(result.length).toEqual(labels.length); - expect(result[0].hidden).toBeTruthy(); - expect(result[0].values).toBeUndefined(); - }); - - it('keeps values as facetted when they are possible', () => { - const result = facetLabels(labels, possibleLabels); - expect(result.length).toEqual(labels.length); - expect(result[0].hidden).toBeTruthy(); - expect(result[0].values).toBeUndefined(); - expect(result[1].hidden).toBeFalsy(); - expect(result[1].values!.length).toBe(1); - expect(result[1].values![0].name).toBe('dev'); - }); - - it('does not facet out label values that are currently being facetted', () => { - const result = facetLabels(labels, possibleLabels, 'cluster'); - expect(result.length).toEqual(labels.length); - expect(result[0].hidden).toBeTruthy(); - expect(result[1].hidden).toBeFalsy(); - // 'cluster' is being facetted, should show all 3 options even though only 1 is possible - expect(result[1].values!.length).toBe(3); - expect(result[2].values!.length).toBe(1); - }); -}); - -describe('PrometheusMetricsBrowser', () => { - const setupProps = (): BrowserProps => { - const mockLanguageProvider = { - start: () => Promise.resolve(), - getLabelValues: (name: string) => { - switch (name) { - case 'label1': - return ['value1-1', 'value1-2']; - case 'label2': - return ['value2-1', 'value2-2']; - case 'label3': - return ['value3-1', 'value3-2']; - } - return []; - }, - // This must always call the series endpoint - // until we refactor all of the metrics browser - // to never use the series endpoint. - // The metrics browser expects both label names and label values. - // The labels endpoint with match does not supply label values - // and so using it breaks the metrics browser. - fetchSeriesLabels: (selector: string) => { - switch (selector) { - case '{label1="value1-1"}': - return { label1: ['value1-1'], label2: ['value2-1'], label3: ['value3-1'] }; - case '{label1=~"value1-1|value1-2"}': - return { label1: ['value1-1', 'value1-2'], label2: ['value2-1'], label3: ['value3-1', 'value3-2'] }; - } - // Allow full set by default - return { - label1: ['value1-1', 'value1-2'], - label2: ['value2-1', 'value2-2'], - }; - }, - getLabelKeys: () => ['label1', 'label2', 'label3'], - }; - - const defaults: BrowserProps = { - theme: createTheme({ colors: { mode: 'dark' } }), - onChange: () => {}, - autoSelect: 0, - languageProvider: mockLanguageProvider as unknown as PromQlLanguageProvider, - lastUsedLabels: [], - storeLastUsedLabels: () => {}, - deleteLastUsedLabels: () => {}, - }; - - return defaults; - }; - - // Clear label selection manually because it's saved in localStorage - afterEach(async () => { - const clearBtn = screen.getByLabelText('Selector clear button'); - await userEvent.click(clearBtn); - }); - - it('renders and loader shows when empty, and then first set of labels', async () => { - const props = setupProps(); - render(); - // Loading appears and dissappears - screen.getByText(/Loading labels/); - await waitFor(() => { - expect(screen.queryByText(/Loading labels/)).not.toBeInTheDocument(); - }); - // Initial set of labels is available and not selected - expect(screen.queryByRole('option', { name: 'label1' })).toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'label1', selected: true })).not.toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'label2' })).toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'label2', selected: true })).not.toBeInTheDocument(); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{}'); - }); - - it('allows label and value selection/deselection', async () => { - const props = setupProps(); - render(); - // Selecting label2 - const label2 = await screen.findByRole('option', { name: 'label2', selected: false }); - expect(screen.queryByRole('list', { name: /Values/ })).not.toBeInTheDocument(); - await userEvent.click(label2); - expect(screen.queryByRole('option', { name: 'label2', selected: true })).toBeInTheDocument(); - // List of values for label2 appears - expect(screen.queryByLabelText(/Values for/)).toHaveTextContent('label2'); - expect(screen.queryByRole('option', { name: 'value2-1' })).toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'value2-2' })).toBeInTheDocument(); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{}'); - // Selecting label1, list for its values appears - const label1 = await screen.findByRole('option', { name: 'label1', selected: false }); - await userEvent.click(label1); - expect(screen.queryByRole('option', { name: 'label1', selected: true })).toBeInTheDocument(); - await screen.findByLabelText('Values for label1'); - expect(await screen.findAllByRole('list', { name: /Values/ })).toHaveLength(2); - // Selecting value2-2 of label2 - const value = await screen.findByRole('option', { name: 'value2-2', selected: false }); - await userEvent.click(value); - await screen.findByRole('option', { name: 'value2-2', selected: true }); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{label2="value2-2"}'); - // Selecting value2-1 of label2, both values now selected - const value2 = await screen.findByRole('option', { name: 'value2-1', selected: false }); - await userEvent.click(value2); - // await screen.findByRole('option', {name: 'value2-1', selected: true}); - await screen.findByText('{label2=~"value2-1|value2-2"}'); - // Deselecting value2-2, one value should remain - const selectedValue = await screen.findByRole('option', { name: 'value2-2', selected: true }); - await userEvent.click(selectedValue); - await screen.findByRole('option', { name: 'value2-1', selected: true }); - await screen.findByRole('option', { name: 'value2-2', selected: false }); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{label2="value2-1"}'); - }); - - it('allows label selection from multiple labels', async () => { - const props = setupProps(); - render(); - - // Selecting label2 - const label2 = await screen.findByRole('option', { name: 'label2', selected: false }); - await userEvent.click(label2); - // List of values for label2 appears - expect(screen.queryByLabelText(/Values for/)).toHaveTextContent('label2'); - expect(screen.queryByRole('option', { name: 'value2-1' })).toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'value2-2' })).toBeInTheDocument(); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{}'); - // Selecting label1, list for its values appears - const label1 = await screen.findByRole('option', { name: 'label1', selected: false }); - await userEvent.click(label1); - await screen.findByLabelText('Values for label1'); - expect(await screen.findAllByRole('list', { name: /Values/ })).toHaveLength(2); - // Selecting value2-1 of label2 - const value2 = await screen.findByRole('option', { name: 'value2-1', selected: false }); - await userEvent.click(value2); - await screen.findByText('{label2="value2-1"}'); - - // Selecting value from label1 for combined selector - const value1 = await screen.findByRole('option', { name: 'value1-2', selected: false }); - await userEvent.click(value1); - await screen.findByRole('option', { name: 'value1-2', selected: true }); - await screen.findByText('{label1="value1-2",label2="value2-1"}'); - // Deselect label1 should remove label and value - const selectedLabel = (await screen.findAllByRole('option', { name: /label1/, selected: true }))[0]; - await userEvent.click(selectedLabel); - await screen.findByRole('option', { name: /label1/, selected: false }); - expect(await screen.findAllByRole('list', { name: /Values/ })).toHaveLength(1); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{label2="value2-1"}'); - }); - - it('allows clearing the label selection', async () => { - const props = setupProps(); - render(); - - // Selecting label2 - const label2 = await screen.findByRole('option', { name: 'label2', selected: false }); - await userEvent.click(label2); - // List of values for label2 appears - expect(screen.queryByLabelText(/Values for/)).toHaveTextContent('label2'); - expect(screen.queryByRole('option', { name: 'value2-1' })).toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'value2-2' })).toBeInTheDocument(); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{}'); - // Selecting label1, list for its values appears - const label1 = await screen.findByRole('option', { name: 'label1', selected: false }); - await userEvent.click(label1); - await screen.findByLabelText('Values for label1'); - expect(await screen.findAllByRole('list', { name: /Values/ })).toHaveLength(2); - // Selecting value2-1 of label2 - const value2 = await screen.findByRole('option', { name: 'value2-1', selected: false }); - await userEvent.click(value2); - await screen.findByText('{label2="value2-1"}'); - - // Clear selector - const clearBtn = screen.getByLabelText('Selector clear button'); - await userEvent.click(clearBtn); - await screen.findByRole('option', { name: 'label2', selected: false }); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{}'); - }); - - it('filters values by input text', async () => { - const props = setupProps(); - render(); - // Selecting label2 and label1 - const label2 = await screen.findByRole('option', { name: /label2/, selected: false }); - await userEvent.click(label2); - const label1 = await screen.findByRole('option', { name: /label1/, selected: false }); - await userEvent.click(label1); - await screen.findByLabelText('Values for label1'); - await screen.findByLabelText('Values for label2'); - expect(await screen.findAllByRole('option', { name: /value/ })).toHaveLength(4); - // Typing '1' to filter for values - await userEvent.type(screen.getByLabelText('Filter expression for label values'), '1'); - expect(screen.getByLabelText('Filter expression for label values')).toHaveValue('1'); - expect(await screen.findAllByRole('option', { name: /value/ })).toHaveLength(3); - expect(screen.queryByRole('option', { name: 'value2-2' })).not.toBeInTheDocument(); - }); - - it('facets labels', async () => { - const props = setupProps(); - render(); - // Selecting label2 and label1 - const label2 = await screen.findByRole('option', { name: /label2/, selected: false }); - await userEvent.click(label2); - const label1 = await screen.findByRole('option', { name: /label1/, selected: false }); - await userEvent.click(label1); - await screen.findByLabelText('Values for label1'); - await screen.findByLabelText('Values for label2'); - expect(await screen.findAllByRole('option', { name: /value/ })).toHaveLength(4); - expect(screen.queryByRole('option', { name: /label3/ })).toHaveTextContent('label3'); - // Click value1-1 which triggers facetting for value3-x, and still show all value1-x - const value1 = await screen.findByRole('option', { name: 'value1-1', selected: false }); - await userEvent.click(value1); - await waitFor(() => expect(screen.queryByRole('option', { name: 'value2-2' })).not.toBeInTheDocument()); - expect(screen.queryByRole('option', { name: 'value1-2' })).toBeInTheDocument(); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{label1="value1-1"}'); - expect(screen.queryByRole('option', { name: /label3/ })).toHaveTextContent('label3 (1)'); - // Click value1-2 for which facetting will allow more values for value3-x - const value12 = await screen.findByRole('option', { name: 'value1-2', selected: false }); - await userEvent.click(value12); - await screen.findByRole('option', { name: 'value1-2', selected: true }); - await screen.findByRole('option', { name: /label3/, selected: false }); - await userEvent.click(screen.getByRole('option', { name: /label3/ })); - await screen.findByLabelText('Values for label3'); - expect(screen.queryByRole('option', { name: 'value1-1', selected: true })).toBeInTheDocument(); - expect(screen.queryByRole('option', { name: 'value1-2', selected: true })).toBeInTheDocument(); - expect(screen.queryByLabelText('selector')).toHaveTextContent('{label1=~"value1-1|value1-2"}'); - expect(screen.queryAllByRole('option', { name: /label3/ })[0]).toHaveTextContent('label3 (2)'); - }); -}); diff --git a/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx b/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx deleted file mode 100644 index b877843cddb..00000000000 --- a/public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx +++ /dev/null @@ -1,684 +0,0 @@ -import { css, cx } from '@emotion/css'; -import React, { ChangeEvent } from 'react'; -import { FixedSizeList } from 'react-window'; - -import { GrafanaTheme2, TimeRange } from '@grafana/data'; -import { selectors } from '@grafana/e2e-selectors'; -import { - Button, - HorizontalGroup, - Input, - Label, - LoadingPlaceholder, - stylesFactory, - BrowserLabel as PromLabel, - withTheme2, -} from '@grafana/ui'; - -import PromQlLanguageProvider from '../language_provider'; -import { escapeLabelValueInExactSelector, escapeLabelValueInRegexSelector } from '../language_utils'; - -// Hard limit on labels to render -const EMPTY_SELECTOR = '{}'; -const METRIC_LABEL = '__name__'; -const LIST_ITEM_SIZE = 25; - -export interface BrowserProps { - languageProvider: PromQlLanguageProvider; - onChange: (selector: string) => void; - theme: GrafanaTheme2; - autoSelect?: number; - hide?: () => void; - lastUsedLabels: string[]; - storeLastUsedLabels: (labels: string[]) => void; - deleteLastUsedLabels: () => void; - timeRange?: TimeRange; -} - -interface BrowserState { - labels: SelectableLabel[]; - labelSearchTerm: string; - metricSearchTerm: string; - status: string; - error: string; - validationStatus: string; - valueSearchTerm: string; -} - -interface FacettableValue { - name: string; - selected?: boolean; - details?: string; -} - -export interface SelectableLabel { - name: string; - selected?: boolean; - loading?: boolean; - values?: FacettableValue[]; - hidden?: boolean; - facets?: number; -} - -export function buildSelector(labels: SelectableLabel[]): string { - let singleMetric = ''; - const selectedLabels = []; - for (const label of labels) { - if ((label.name === METRIC_LABEL || label.selected) && label.values && label.values.length > 0) { - const selectedValues = label.values.filter((value) => value.selected).map((value) => value.name); - if (selectedValues.length > 1) { - selectedLabels.push(`${label.name}=~"${selectedValues.map(escapeLabelValueInRegexSelector).join('|')}"`); - } else if (selectedValues.length === 1) { - if (label.name === METRIC_LABEL) { - singleMetric = selectedValues[0]; - } else { - selectedLabels.push(`${label.name}="${escapeLabelValueInExactSelector(selectedValues[0])}"`); - } - } - } - } - return [singleMetric, '{', selectedLabels.join(','), '}'].join(''); -} - -export function facetLabels( - labels: SelectableLabel[], - possibleLabels: Record, - lastFacetted?: string -): SelectableLabel[] { - return labels.map((label) => { - const possibleValues = possibleLabels[label.name]; - if (possibleValues) { - let existingValues: FacettableValue[]; - if (label.name === lastFacetted && label.values) { - // Facetting this label, show all values - existingValues = label.values; - } else { - // Keep selection in other facets - const selectedValues: Set = new Set( - label.values?.filter((value) => value.selected).map((value) => value.name) || [] - ); - // Values for this label have not been requested yet, let's use the facetted ones as the initial values - existingValues = possibleValues.map((value) => ({ name: value, selected: selectedValues.has(value) })); - } - return { - ...label, - loading: false, - values: existingValues, - hidden: !possibleValues, - facets: existingValues.length, - }; - } - - // Label is facetted out, hide all values - return { ...label, loading: false, hidden: !possibleValues, values: undefined, facets: 0 }; - }); -} - -const getStyles = stylesFactory((theme: GrafanaTheme2) => ({ - wrapper: css` - background-color: ${theme.colors.background.secondary}; - padding: ${theme.spacing(1)}; - width: 100%; - `, - list: css` - margin-top: ${theme.spacing(1)}; - display: flex; - flex-wrap: wrap; - max-height: 200px; - overflow: auto; - align-content: flex-start; - `, - section: css` - & + & { - margin: ${theme.spacing(2)} 0; - } - position: relative; - `, - selector: css` - font-family: ${theme.typography.fontFamilyMonospace}; - margin-bottom: ${theme.spacing(1)}; - `, - status: css` - padding: ${theme.spacing(0.5)}; - color: ${theme.colors.text.secondary}; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - /* using absolute positioning because flex interferes with ellipsis */ - position: absolute; - width: 50%; - right: 0; - text-align: right; - transition: opacity 100ms linear; - opacity: 0; - `, - statusShowing: css` - opacity: 1; - `, - error: css` - color: ${theme.colors.error.main}; - `, - valueList: css` - margin-right: ${theme.spacing(1)}; - resize: horizontal; - `, - valueListWrapper: css` - border-left: 1px solid ${theme.colors.border.medium}; - margin: ${theme.spacing(1)} 0; - padding: ${theme.spacing(1)} 0 ${theme.spacing(1)} ${theme.spacing(1)}; - `, - valueListArea: css` - display: flex; - flex-wrap: wrap; - margin-top: ${theme.spacing(1)}; - `, - valueTitle: css` - margin-left: -${theme.spacing(0.5)}; - margin-bottom: ${theme.spacing(1)}; - `, - validationStatus: css` - padding: ${theme.spacing(0.5)}; - margin-bottom: ${theme.spacing(1)}; - color: ${theme.colors.text.maxContrast}; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - `, -})); - -/** - * TODO #33976: Remove duplicated code. The component is very similar to LokiLabelBrowser.tsx. Check if it's possible - * to create a single, generic component. - */ -export class UnthemedPrometheusMetricsBrowser extends React.Component { - valueListsRef = React.createRef(); - state: BrowserState = { - labels: [], - labelSearchTerm: '', - metricSearchTerm: '', - status: 'Ready', - error: '', - validationStatus: '', - valueSearchTerm: '', - }; - - onChangeLabelSearch = (event: ChangeEvent) => { - this.setState({ labelSearchTerm: event.target.value }); - }; - - onChangeMetricSearch = (event: ChangeEvent) => { - this.setState({ metricSearchTerm: event.target.value }); - }; - - onChangeValueSearch = (event: ChangeEvent) => { - this.setState({ valueSearchTerm: event.target.value }); - }; - - onClickRunQuery = () => { - const selector = buildSelector(this.state.labels); - this.props.onChange(selector); - }; - - onClickRunRateQuery = () => { - const selector = buildSelector(this.state.labels); - const query = `rate(${selector}[$__rate_interval])`; - this.props.onChange(query); - }; - - onClickClear = () => { - this.setState((state) => { - const labels: SelectableLabel[] = state.labels.map((label) => ({ - ...label, - values: undefined, - selected: false, - loading: false, - hidden: false, - facets: undefined, - })); - return { - labels, - labelSearchTerm: '', - metricSearchTerm: '', - status: '', - error: '', - validationStatus: '', - valueSearchTerm: '', - }; - }); - this.props.deleteLastUsedLabels(); - // Get metrics - this.fetchValues(METRIC_LABEL, EMPTY_SELECTOR); - }; - - onClickLabel = (name: string, value: string | undefined, event: React.MouseEvent) => { - const label = this.state.labels.find((l) => l.name === name); - if (!label) { - return; - } - // Toggle selected state - const selected = !label.selected; - let nextValue: Partial = { selected }; - if (label.values && !selected) { - // Deselect all values if label was deselected - const values = label.values.map((value) => ({ ...value, selected: false })); - nextValue = { ...nextValue, facets: 0, values }; - } - // Resetting search to prevent empty results - this.setState({ labelSearchTerm: '' }); - this.updateLabelState(name, nextValue, '', () => this.doFacettingForLabel(name)); - }; - - onClickValue = (name: string, value: string | undefined, event: React.MouseEvent) => { - const label = this.state.labels.find((l) => l.name === name); - if (!label || !label.values) { - return; - } - // Resetting search to prevent empty results - this.setState({ labelSearchTerm: '' }); - // Toggling value for selected label, leaving other values intact - const values = label.values.map((v) => ({ ...v, selected: v.name === value ? !v.selected : v.selected })); - this.updateLabelState(name, { values }, '', () => this.doFacetting(name)); - }; - - onClickMetric = (name: string, value: string | undefined, event: React.MouseEvent) => { - // Finding special metric label - const label = this.state.labels.find((l) => l.name === name); - if (!label || !label.values) { - return; - } - // Resetting search to prevent empty results - this.setState({ metricSearchTerm: '' }); - // Toggling value for selected label, leaving other values intact - const values = label.values.map((v) => ({ - ...v, - selected: v.name === value || v.selected ? !v.selected : v.selected, - })); - // Toggle selected state of special metrics label - const selected = values.some((v) => v.selected); - this.updateLabelState(name, { selected, values }, '', () => this.doFacetting(name)); - }; - - onClickValidate = () => { - const selector = buildSelector(this.state.labels); - this.validateSelector(selector); - }; - - updateLabelState(name: string, updatedFields: Partial, status = '', cb?: () => void) { - this.setState((state) => { - const labels: SelectableLabel[] = state.labels.map((label) => { - if (label.name === name) { - return { ...label, ...updatedFields }; - } - return label; - }); - // New status overrides errors - const error = status ? '' : state.error; - return { labels, status, error, validationStatus: '' }; - }, cb); - } - - componentDidMount() { - const { languageProvider, lastUsedLabels } = this.props; - if (languageProvider) { - const selectedLabels: string[] = lastUsedLabels; - languageProvider.start(this.props.timeRange).then(() => { - let rawLabels: string[] = languageProvider.getLabelKeys(); - // Get metrics - this.fetchValues(METRIC_LABEL, EMPTY_SELECTOR); - // Auto-select previously selected labels - const labels: SelectableLabel[] = rawLabels.map((label, i, arr) => ({ - name: label, - selected: selectedLabels.includes(label), - loading: false, - })); - // Pre-fetch values for selected labels - this.setState({ labels }, () => { - this.state.labels.forEach((label) => { - if (label.selected) { - this.fetchValues(label.name, EMPTY_SELECTOR); - } - }); - }); - }); - } - } - - doFacettingForLabel(name: string) { - const label = this.state.labels.find((l) => l.name === name); - if (!label) { - return; - } - const selectedLabels = this.state.labels.filter((label) => label.selected).map((label) => label.name); - this.props.storeLastUsedLabels(selectedLabels); - if (label.selected) { - // Refetch values for newly selected label... - if (!label.values) { - this.fetchValues(name, buildSelector(this.state.labels)); - } - } else { - // Only need to facet when deselecting labels - this.doFacetting(); - } - } - - doFacetting = (lastFacetted?: string) => { - const selector = buildSelector(this.state.labels); - if (selector === EMPTY_SELECTOR) { - // Clear up facetting - const labels: SelectableLabel[] = this.state.labels.map((label) => { - return { ...label, facets: 0, values: undefined, hidden: false }; - }); - this.setState({ labels }, () => { - // Get fresh set of values - this.state.labels.forEach( - (label) => (label.selected || label.name === METRIC_LABEL) && this.fetchValues(label.name, selector) - ); - }); - } else { - // Do facetting - this.fetchSeries(selector, lastFacetted); - } - }; - - async fetchValues(name: string, selector: string) { - const { languageProvider } = this.props; - this.updateLabelState(name, { loading: true }, `Fetching values for ${name}`); - try { - let rawValues = await languageProvider.getLabelValues(name); - // If selector changed, clear loading state and discard result by returning early - if (selector !== buildSelector(this.state.labels)) { - this.updateLabelState(name, { loading: false }); - return; - } - const values: FacettableValue[] = []; - const { metricsMetadata } = languageProvider; - for (const labelValue of rawValues) { - const value: FacettableValue = { name: labelValue }; - // Adding type/help text to metrics - if (name === METRIC_LABEL && metricsMetadata) { - const meta = metricsMetadata[labelValue]; - if (meta) { - value.details = `(${meta.type}) ${meta.help}`; - } - } - values.push(value); - } - this.updateLabelState(name, { values, loading: false }); - } catch (error) { - console.error(error); - } - } - - async fetchSeries(selector: string, lastFacetted?: string) { - const { languageProvider } = this.props; - if (lastFacetted) { - this.updateLabelState(lastFacetted, { loading: true }, `Facetting labels for ${selector}`); - } - try { - const possibleLabels = await languageProvider.fetchSeriesLabels(selector, true); - // If selector changed, clear loading state and discard result by returning early - if (selector !== buildSelector(this.state.labels)) { - if (lastFacetted) { - this.updateLabelState(lastFacetted, { loading: false }); - } - return; - } - if (Object.keys(possibleLabels).length === 0) { - this.setState({ error: `Empty results, no matching label for ${selector}` }); - return; - } - const labels: SelectableLabel[] = facetLabels(this.state.labels, possibleLabels, lastFacetted); - this.setState({ labels, error: '' }); - if (lastFacetted) { - this.updateLabelState(lastFacetted, { loading: false }); - } - } catch (error) { - console.error(error); - } - } - - async validateSelector(selector: string) { - const { languageProvider } = this.props; - this.setState({ validationStatus: `Validating selector ${selector}`, error: '' }); - const streams = await languageProvider.fetchSeries(selector); - this.setState({ validationStatus: `Selector is valid (${streams.length} series found)` }); - } - - render() { - const { theme } = this.props; - const { labels, labelSearchTerm, metricSearchTerm, status, error, validationStatus, valueSearchTerm } = this.state; - const styles = getStyles(theme); - if (labels.length === 0) { - return ( -
- -
- ); - } - - // Filter metrics - let metrics = labels.find((label) => label.name === METRIC_LABEL); - if (metrics && metricSearchTerm) { - metrics = { - ...metrics, - values: metrics.values?.filter((value) => value.selected || value.name.includes(metricSearchTerm)), - }; - } - - // Filter labels - let nonMetricLabels = labels.filter((label) => !label.hidden && label.name !== METRIC_LABEL); - if (labelSearchTerm) { - nonMetricLabels = nonMetricLabels.filter((label) => label.selected || label.name.includes(labelSearchTerm)); - } - - // Filter non-metric label values - let selectedLabels = nonMetricLabels.filter((label) => label.selected && label.values); - if (valueSearchTerm) { - selectedLabels = selectedLabels.map((label) => ({ - ...label, - values: label.values?.filter((value) => value.selected || value.name.includes(valueSearchTerm)), - })); - } - const selector = buildSelector(this.state.labels); - const empty = selector === EMPTY_SELECTOR; - const metricCount = metrics?.values?.length || 0; - - return ( -
- -
-
- -
- -
-
- metrics!.values![i].name} - width={300} - className={styles.valueList} - > - {({ index, style }) => { - const value = metrics?.values?.[index]; - if (!value) { - return null; - } - return ( -
- -
- ); - }} -
-
-
-
- -
-
- -
- -
- {/* Using fixed height here to prevent jumpy layout */} -
- {nonMetricLabels.map((label) => ( -
-
-
- -
- -
-
- {selectedLabels.map((label) => ( -
-
-
- label.values![i].name} - width={200} - className={styles.valueList} - > - {({ index, style }) => { - const value = label.values?.[index]; - if (!value) { - return null; - } - return ( -
- -
- ); - }} -
-
- ))} -
-
-
-
- -
- -
- {selector} -
- {validationStatus &&
{validationStatus}
} - - - - - -
- {error || status} -
-
-
-
- ); - } -} - -export const PrometheusMetricsBrowser = withTheme2(UnthemedPrometheusMetricsBrowser); diff --git a/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.test.tsx b/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.test.tsx deleted file mode 100644 index 1804f3efff1..00000000000 --- a/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.test.tsx +++ /dev/null @@ -1,392 +0,0 @@ -import { render, screen, waitFor } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import React from 'react'; -import { selectOptionInTest } from 'test/helpers/selectOptionInTest'; - -import { dateTime, TimeRange } from '@grafana/data'; - -import { PrometheusDatasource } from '../datasource'; -import PrometheusLanguageProvider from '../language_provider'; -import { migrateVariableEditorBackToVariableSupport } from '../migrations/variableMigration'; -import { PromVariableQuery, PromVariableQueryType, StandardPromVariableQuery } from '../types'; - -import { PromVariableQueryEditor, Props, variableMigration } from './VariableQueryEditor'; - -const refId = 'PrometheusVariableQueryEditor-VariableQuery'; - -describe('PromVariableQueryEditor', () => { - let props: Props; - - test('Migrates from standard variable support to custom variable query', () => { - const query: StandardPromVariableQuery = { - query: 'label_names()', - refId: 'StandardVariableQuery', - }; - - const migration: PromVariableQuery = variableMigration(query); - - const expected: PromVariableQuery = { - qryType: PromVariableQueryType.LabelNames, - refId: 'PrometheusDatasource-VariableQuery', - }; - - expect(migration).toEqual(expected); - }); - - test('Allows for use of variables to interpolate label names in the label values query type.', () => { - const query: StandardPromVariableQuery = { - query: 'label_values($label_name)', - refId: 'StandardVariableQuery', - }; - - const migration: PromVariableQuery = variableMigration(query); - - const expected: PromVariableQuery = { - qryType: PromVariableQueryType.LabelValues, - label: '$label_name', - refId: 'PrometheusDatasource-VariableQuery', - }; - - expect(migration).toEqual(expected); - }); - - test('Migrates from jsonnet grafana as code variable to custom variable query', () => { - const query = 'label_names()'; - - const migration: PromVariableQuery = variableMigration(query); - - const expected: PromVariableQuery = { - qryType: PromVariableQueryType.LabelNames, - refId: 'PrometheusDatasource-VariableQuery', - }; - - expect(migration).toEqual(expected); - }); - - test('Migrates label filters to the query object for label_values()', () => { - const query: StandardPromVariableQuery = { - query: 'label_values(metric{label="value"},name)', - refId: 'StandardVariableQuery', - }; - - const migration: PromVariableQuery = variableMigration(query); - - const expected: PromVariableQuery = { - qryType: PromVariableQueryType.LabelValues, - label: 'name', - metric: 'metric', - labelFilters: [ - { - label: 'label', - op: '=', - value: 'value', - }, - ], - refId: 'PrometheusDatasource-VariableQuery', - }; - - expect(migration).toEqual(expected); - }); - - test('Migrates a query object with label filters to an expression correctly', () => { - const query: PromVariableQuery = { - qryType: PromVariableQueryType.LabelValues, - label: 'name', - metric: 'metric', - labelFilters: [ - { - label: 'label', - op: '=', - value: 'value', - }, - ], - refId: 'PrometheusDatasource-VariableQuery', - }; - - const migration: string = migrateVariableEditorBackToVariableSupport(query); - - const expected = 'label_values(metric{label="value"},name)'; - - expect(migration).toEqual(expected); - }); - - test('Migrates a query object with no metric and only label filters to an expression correctly', () => { - const query: PromVariableQuery = { - qryType: PromVariableQueryType.LabelValues, - label: 'name', - labelFilters: [ - { - label: 'label', - op: '=', - value: 'value', - }, - ], - refId: 'PrometheusDatasource-VariableQuery', - }; - - const migration: string = migrateVariableEditorBackToVariableSupport(query); - - const expected = 'label_values({label="value"},name)'; - - expect(migration).toEqual(expected); - }); - - beforeEach(() => { - props = { - datasource: { - hasLabelsMatchAPISupport: () => true, - languageProvider: { - start: () => Promise.resolve([]), - syntax: () => {}, - getLabelKeys: () => [], - metrics: [], - metricsMetadata: {}, - getLabelValues: jest.fn().mockImplementation(() => ['that']), - fetchLabelsWithMatch: jest.fn().mockImplementation(() => Promise.resolve({ those: 'those' })), - } as Partial as PrometheusLanguageProvider, - getInitHints: () => [], - getDebounceTimeInMilliseconds: jest.fn(), - getTagKeys: jest.fn().mockImplementation(() => Promise.resolve(['this'])), - getVariables: jest.fn().mockImplementation(() => []), - metricFindQuery: jest.fn().mockImplementation(() => Promise.resolve(['that'])), - getSeriesLabels: jest.fn().mockImplementation(() => Promise.resolve(['that'])), - } as Partial as PrometheusDatasource, - query: { - refId: 'test', - query: 'label_names()', - }, - onRunQuery: () => {}, - onChange: () => {}, - history: [], - }; - }); - - test('Displays a group of function options', async () => { - render(); - - const select = screen.getByLabelText('Query type').parentElement!; - await userEvent.click(select); - - await waitFor(() => expect(screen.getAllByText('Label names')).toHaveLength(2)); - await waitFor(() => expect(screen.getByText('Label values')).toBeInTheDocument()); - await waitFor(() => expect(screen.getByText('Metrics')).toBeInTheDocument()); - await waitFor(() => expect(screen.getByText('Query result')).toBeInTheDocument()); - await waitFor(() => expect(screen.getByText('Series query')).toBeInTheDocument()); - await waitFor(() => expect(screen.getByText('Classic query')).toBeInTheDocument()); - }); - - test('Calls onChange for label_names(match) query', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: '', - match: 'that', - }; - - render(); - - await selectOptionInTest(screen.getByLabelText('Query type'), 'Label names'); - - expect(onChange).toHaveBeenCalledWith({ - query: 'label_names(that)', - refId, - qryType: 0, - }); - }); - - test('Calls onChange for label_names, label_values, metrics, query result and and classic query.', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: '', - }; - - render(); - - await selectOptionInTest(screen.getByLabelText('Query type'), 'Label names'); - await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values'); - await selectOptionInTest(screen.getByLabelText('Query type'), 'Metrics'); - await selectOptionInTest(screen.getByLabelText('Query type'), 'Query result'); - await selectOptionInTest(screen.getByLabelText('Query type'), 'Classic query'); - - expect(onChange).toHaveBeenCalledTimes(5); - }); - - test('Does not call onChange for series query', async () => { - const onChange = jest.fn(); - - render(); - - await selectOptionInTest(screen.getByLabelText('Query type'), 'Series query'); - - expect(onChange).not.toHaveBeenCalled(); - }); - - test('Calls onChange for metrics() after input', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: 'label_names()', - }; - - render(); - - await selectOptionInTest(screen.getByLabelText('Query type'), 'Metrics'); - const metricInput = screen.getByLabelText('Metric selector'); - await userEvent.type(metricInput, 'a'); - const queryType = screen.getByLabelText('Query type'); - // click elsewhere to trigger the onBlur - await userEvent.click(queryType); - - await waitFor(() => - expect(onChange).toHaveBeenCalledWith({ - query: 'metrics(a)', - refId, - qryType: 2, - }) - ); - }); - - test('Calls onChange for label_values() after selecting label', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: 'label_names()', - qryType: 0, - }; - - render(); - - await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values'); - const labelSelect = screen.getByLabelText('label-select'); - await userEvent.type(labelSelect, 'this'); - await selectOptionInTest(labelSelect, 'this'); - - await waitFor(() => - expect(onChange).toHaveBeenCalledWith({ - query: 'label_values(this)', - refId, - qryType: 1, - }) - ); - }); - - test('Calls onChange for label_values() after selecting metric', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: 'label_names()', - }; - - render(); - - await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values'); - const labelSelect = screen.getByLabelText('label-select'); - await userEvent.type(labelSelect, 'this'); - await selectOptionInTest(labelSelect, 'this'); - - const metricSelect = screen.getByLabelText('Metric'); - await userEvent.type(metricSelect, 'that'); - await selectOptionInTest(metricSelect, 'that'); - - await waitFor(() => - expect(onChange).toHaveBeenCalledWith({ - query: 'label_values(that,this)', - refId, - qryType: 1, - }) - ); - }); - - test('Calls onChange for query_result() with argument onBlur', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: 'query_result(a)', - }; - - render(); - - const labelSelect = screen.getByLabelText('Prometheus Query'); - await userEvent.click(labelSelect); - const functionSelect = screen.getByLabelText('Query type').parentElement!; - await userEvent.click(functionSelect); - - expect(onChange).toHaveBeenCalledWith({ - query: 'query_result(a)', - refId, - qryType: 3, - }); - }); - - test('Calls onChange for Match[] series with argument onBlur', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - query: '{a: "example"}', - }; - - render(); - - const labelSelect = screen.getByLabelText('Series Query'); - await userEvent.click(labelSelect); - const functionSelect = screen.getByLabelText('Query type').parentElement!; - await userEvent.click(functionSelect); - - expect(onChange).toHaveBeenCalledWith({ - query: '{a: "example"}', - refId, - qryType: 4, - }); - }); - - test('Calls onChange for classic query onBlur', async () => { - const onChange = jest.fn(); - - props.query = { - refId: 'test', - qryType: 5, - query: 'label_values(instance)', - }; - - render(); - - const labelSelect = screen.getByLabelText('Classic Query'); - await userEvent.click(labelSelect); - const functionSelect = screen.getByLabelText('Query type').parentElement!; - await userEvent.click(functionSelect); - - expect(onChange).toHaveBeenCalledWith({ - query: 'label_values(instance)', - refId, - qryType: 5, - }); - }); - - test('Calls language provider with the time range received in props', async () => { - const now = dateTime('2023-09-16T21:26:00Z'); - const range: TimeRange = { - from: dateTime(now).subtract(2, 'days'), - to: now, - raw: { - from: 'now-2d', - to: 'now', - }, - }; - props.range = range; - - const languageProviderStartMock = jest.fn(); - props.datasource.languageProvider.start = languageProviderStartMock; - - render(); - - expect(languageProviderStartMock).toHaveBeenCalledWith(range); - }); -}); diff --git a/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx b/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx deleted file mode 100644 index fce9bf1e1df..00000000000 --- a/public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx +++ /dev/null @@ -1,437 +0,0 @@ -import React, { FormEvent, useCallback, useEffect, useState } from 'react'; - -import { QueryEditorProps, SelectableValue } from '@grafana/data'; -import { selectors } from '@grafana/e2e-selectors'; -import { InlineField, InlineFieldRow, Input, Select, TextArea } from '@grafana/ui'; - -import { PrometheusDatasource } from '../datasource'; -import { - migrateVariableEditorBackToVariableSupport, - migrateVariableQueryToEditor, -} from '../migrations/variableMigration'; -import { promQueryModeller } from '../querybuilder/PromQueryModeller'; -import { MetricsLabelsSection } from '../querybuilder/components/MetricsLabelsSection'; -import { QueryBuilderLabelFilter } from '../querybuilder/shared/types'; -import { PromVisualQuery } from '../querybuilder/types'; -import { - PromOptions, - PromQuery, - PromVariableQuery, - PromVariableQueryType as QueryType, - StandardPromVariableQuery, -} from '../types'; - -export const variableOptions = [ - { label: 'Label names', value: QueryType.LabelNames }, - { label: 'Label values', value: QueryType.LabelValues }, - { label: 'Metrics', value: QueryType.MetricNames }, - { label: 'Query result', value: QueryType.VarQueryResult }, - { label: 'Series query', value: QueryType.SeriesQuery }, - { label: 'Classic query', value: QueryType.ClassicQuery }, -]; - -export type Props = QueryEditorProps; - -const refId = 'PrometheusVariableQueryEditor-VariableQuery'; - -export const PromVariableQueryEditor = ({ onChange, query, datasource, range }: Props) => { - // to select the query type, i.e. label_names, label_values, etc. - const [qryType, setQryType] = useState(undefined); - // list of variables for each function - const [label, setLabel] = useState(''); - - const [labelNamesMatch, setLabelNamesMatch] = useState(''); - - // metric is used for both label_values() and metric() - // label_values() metric requires a whole/complete metric - // metric() is expected to be a part of a metric string - const [metric, setMetric] = useState(''); - // varQuery is a whole query, can include math/rates/etc - const [varQuery, setVarQuery] = useState(''); - // seriesQuery is only a whole - const [seriesQuery, setSeriesQuery] = useState(''); - - // the original variable query implementation, e.g. label_value(metric, label_name) - const [classicQuery, setClassicQuery] = useState(''); - - // list of label names for label_values(), /api/v1/labels, contains the same results as label_names() function - const [labelOptions, setLabelOptions] = useState>>([]); - - // label filters have been added as a filter for metrics in label values query type - const [labelFilters, setLabelFilters] = useState([]); - - useEffect(() => { - datasource.languageProvider.start(range); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - useEffect(() => { - if (!query) { - return; - } - - if (query.qryType === QueryType.ClassicQuery) { - setQryType(query.qryType); - setClassicQuery(query.query ?? ''); - } else { - // 1. Changing from standard to custom variable editor changes the string attr from expr to query - // 2. jsonnet grafana as code passes a variable as a string - const variableQuery = variableMigration(query); - - setLabelNamesMatch(variableQuery.match ?? ''); - setQryType(variableQuery.qryType); - setLabel(variableQuery.label ?? ''); - setMetric(variableQuery.metric ?? ''); - setLabelFilters(variableQuery.labelFilters ?? []); - setVarQuery(variableQuery.varQuery ?? ''); - setSeriesQuery(variableQuery.seriesQuery ?? ''); - setClassicQuery(variableQuery.classicQuery ?? ''); - } - }, [query]); - - // set the label names options for the label values var query - useEffect(() => { - if (qryType !== QueryType.LabelValues) { - return; - } - const variables = datasource.getVariables().map((variable: string) => ({ label: variable, value: variable })); - if (!metric) { - // get all the labels - datasource.getTagKeys({ filters: [] }).then((labelNames: Array<{ text: string }>) => { - const names = labelNames.map(({ text }) => ({ label: text, value: text })); - setLabelOptions([...variables, ...names]); - }); - } else { - // fetch the labels filtered by the metric - const labelToConsider = [{ label: '__name__', op: '=', value: metric }]; - const expr = promQueryModeller.renderLabels(labelToConsider); - - datasource.languageProvider.fetchLabelsWithMatch(expr).then((labelsIndex: Record) => { - const labelNames = Object.keys(labelsIndex); - const names = labelNames.map((value) => ({ label: value, value: value })); - setLabelOptions([...variables, ...names]); - }); - } - }, [datasource, qryType, metric]); - - const onChangeWithVariableString = ( - updateVar: { [key: string]: QueryType | string }, - updLabelFilters?: QueryBuilderLabelFilter[] - ) => { - const queryVar = { - qryType, - label, - metric, - match: labelNamesMatch, - varQuery, - seriesQuery, - classicQuery, - refId: 'PrometheusVariableQueryEditor-VariableQuery', - }; - - let updateLabelFilters = updLabelFilters ? { labelFilters: updLabelFilters } : { labelFilters: labelFilters }; - - const updatedVar = { ...queryVar, ...updateVar, ...updateLabelFilters }; - - const queryString = migrateVariableEditorBackToVariableSupport(updatedVar); - - // setting query.query property allows for update of variable definition - onChange({ - query: queryString, - qryType: updatedVar.qryType, - refId, - }); - }; - - /** Call onchange for label names query type change */ - const onQueryTypeChange = (newType: SelectableValue) => { - setQryType(newType.value); - if (newType.value !== QueryType.SeriesQuery) { - onChangeWithVariableString({ qryType: newType.value ?? 0 }); - } - }; - - /** Call onchange for label select when query type is label values */ - const onLabelChange = (newLabel: SelectableValue) => { - const newLabelvalue = newLabel && newLabel.value ? newLabel.value : ''; - setLabel(newLabelvalue); - if (qryType === QueryType.LabelValues && newLabelvalue) { - onChangeWithVariableString({ label: newLabelvalue }); - } - }; - - /** - * Call onChange for MetricsLabels component change for label values query type - * if there is a label (required) and - * if the labels or metric are updated. - */ - const metricsLabelsChange = (update: PromVisualQuery) => { - setMetric(update.metric); - setLabelFilters(update.labels); - - const updMetric = update.metric; - const updLabelFilters = update.labels ?? []; - - if (qryType === QueryType.LabelValues && label && (updMetric || updLabelFilters)) { - onChangeWithVariableString({ qryType, metric: updMetric }, updLabelFilters); - } - }; - - const onLabelNamesMatchChange = (regex: string) => { - if (qryType === QueryType.LabelNames) { - onChangeWithVariableString({ qryType, match: regex }); - } - }; - - /** - * Call onchange for metric change if metrics names (regex) query type - * Debounce this because to not call the API for every keystroke. - */ - const onMetricChange = (value: string) => { - if (qryType === QueryType.MetricNames && value) { - onChangeWithVariableString({ metric: value }); - } - }; - - /** - * Do not call onchange for variable query result when query type is var query result - * because the query may not be finished typing and an error is returned - * for incorrectly formatted series. Call onchange for blur instead. - */ - const onVarQueryChange = (e: FormEvent) => { - setVarQuery(e.currentTarget.value); - }; - - /** - * Do not call onchange for seriesQuery when query type is series query - * because the series may not be finished typing and an error is returned - * for incorrectly formatted series. Call onchange for blur instead. - */ - const onSeriesQueryChange = (e: FormEvent) => { - setSeriesQuery(e.currentTarget.value); - }; - - const onClassicQueryChange = (e: FormEvent) => { - setClassicQuery(e.currentTarget.value); - }; - - const promVisualQuery = useCallback(() => { - return { metric: metric, labels: labelFilters, operations: [] }; - }, [metric, labelFilters]); - - return ( - <> - - The Prometheus data source plugin provides the following query types for template variables. - } - > - - - - {/* Used to select an optional metric with optional label filters */} - - - )} - - {qryType === QueryType.LabelNames && ( - - Returns a list of label names, optionally filtering by specified metric regex.} - > - { - setLabelNamesMatch(event.currentTarget.value); - onLabelNamesMatchChange(event.currentTarget.value); - }} - onChange={(e) => { - setLabelNamesMatch(e.currentTarget.value); - }} - width={25} - data-testid={selectors.components.DataSource.Prometheus.variableQueryEditor.labelnames.metricRegex} - /> - - - )} - - {qryType === QueryType.MetricNames && ( - - Returns a list of metrics matching the specified metric regex.} - > - { - setMetric(e.currentTarget.value); - }} - onBlur={(e) => { - setMetric(e.currentTarget.value); - onMetricChange(e.currentTarget.value); - }} - width={25} - data-testid={selectors.components.DataSource.Prometheus.variableQueryEditor.metricNames.metricRegex} - /> - - - )} - - {qryType === QueryType.VarQueryResult && ( - - - Returns a list of Prometheus query results for the query. This can include Prometheus functions, i.e. - sum(go_goroutines). - - } - > -