From 6751a93d49aff9b88a02368e572ad3232e98ed37 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 14 Mar 2023 10:47:32 -0700 Subject: [PATCH] FeatureToggles: remove open type declaration (#64645) --- .betterer.results | 3 ++- packages/grafana-data/src/types/featureToggles.gen.ts | 8 +++++--- packages/grafana-runtime/src/config.ts | 5 +++-- pkg/services/featuremgmt/codeowners.go | 1 + pkg/services/featuremgmt/toggles_gen_test.go | 8 +++++--- .../datasource/azuremonitor/grafanaTemplateVariableFns.ts | 7 +------ 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.betterer.results b/.betterer.results index 3204961fbff..e537a2024aa 100644 --- a/.betterer.results +++ b/.betterer.results @@ -767,7 +767,8 @@ exports[`better eslint`] = { "packages/grafana-runtime/src/config.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Do not use any type assertions.", "2"], + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "packages/grafana-runtime/src/services/AngularLoader.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 6cb93a677bc..0838bf742f7 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -9,13 +9,15 @@ * conf/custom.ini to enable features under development or not yet available in * stable version. * - * Only enabled values will be returned in this interface + * Only enabled values will be returned in this interface. + * + * NOTE: the possible values may change between versions without notice, although + * this may cause compilation issues when depending on removed feature keys, the + * runtime state will continue to work. * * @public */ export interface FeatureToggles { - [name: string]: boolean | undefined; // support any string value - alertingBigTransactions?: boolean; trimDefaults?: boolean; disableEnvelopeEncryption?: boolean; diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index 50706bef145..5f2afb86472 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -230,10 +230,11 @@ function overrideFeatureTogglesFromUrl(config: GrafanaBootConfig) { const params = new URLSearchParams(window.location.search); params.forEach((value, key) => { if (key.startsWith('__feature.')) { + const featureToggles = config.featureToggles as Record; const featureName = key.substring(10); const toggleState = value === 'true'; - if (toggleState !== config.featureToggles[key]) { - config.featureToggles[featureName] = toggleState; + if (toggleState !== featureToggles[key]) { + featureToggles[featureName] = toggleState; console.log(`Setting feature toggle ${featureName} = ${toggleState}`); } } diff --git a/pkg/services/featuremgmt/codeowners.go b/pkg/services/featuremgmt/codeowners.go index 52eb0bd3489..5b41d6d573e 100644 --- a/pkg/services/featuremgmt/codeowners.go +++ b/pkg/services/featuremgmt/codeowners.go @@ -22,4 +22,5 @@ const ( hostedGrafanaTeam codeowner = "@grafana/hosted-grafana-team" awsPluginsSquad codeowner = "@grafana/aws-plugins" appO11ySquad codeowner = "@grafana/app-o11y" + grafanaPartnerPluginsSquad codeowner = "@grafana/partner-plugins" ) diff --git a/pkg/services/featuremgmt/toggles_gen_test.go b/pkg/services/featuremgmt/toggles_gen_test.go index ae61f5e7c9c..afb33892f08 100644 --- a/pkg/services/featuremgmt/toggles_gen_test.go +++ b/pkg/services/featuremgmt/toggles_gen_test.go @@ -128,13 +128,15 @@ func generateTypeScript() string { * conf/custom.ini to enable features under development or not yet available in * stable version. * - * Only enabled values will be returned in this interface + * Only enabled values will be returned in this interface. + * + * NOTE: the possible values may change between versions without notice, although + * this may cause compilation issues when depending on removed feature keys, the + * runtime state will continue to work. * * @public */ export interface FeatureToggles { - [name: string]: boolean | undefined; // support any string value - ` for _, flag := range standardFeatureFlags { buf += " " + getTypeScriptKey(flag.Name) + "?: boolean;\n" diff --git a/public/app/plugins/datasource/azuremonitor/grafanaTemplateVariableFns.ts b/public/app/plugins/datasource/azuremonitor/grafanaTemplateVariableFns.ts index 1b7578ee774..b4859079099 100644 --- a/public/app/plugins/datasource/azuremonitor/grafanaTemplateVariableFns.ts +++ b/public/app/plugins/datasource/azuremonitor/grafanaTemplateVariableFns.ts @@ -1,5 +1,3 @@ -import { config } from '@grafana/runtime'; - import { isGUIDish } from './components/ResourcePicker/utils'; import DataSource from './datasource'; import { AzureMonitorQuery, AzureQueryType } from './types'; @@ -321,10 +319,7 @@ export const migrateQuery = async ( ): Promise => { let query = await migrateStringQueriesToObjectQueries(rawQuery, options); - if ( - !config.featureToggles.azLegacyTemplateVariables && - query.queryType === AzureQueryType.GrafanaTemplateVariableFn - ) { + if (query.queryType === AzureQueryType.GrafanaTemplateVariableFn) { query = migrateGrafanaTemplateVariableFn(query); }