From 5d88b8a4f58abeafc11553865f99df69b760fcd3 Mon Sep 17 00:00:00 2001 From: Virginia Cepeda Date: Thu, 14 Sep 2023 09:58:04 -0300 Subject: [PATCH] [Alerting Insights] - Use Grafana feature flag system (#74749) Use Grafana feature flag system --- .../feature-toggles/index.md | 1 + .../src/types/featureToggles.gen.ts | 1 + pkg/services/featuremgmt/registry.go | 7 +++ pkg/services/featuremgmt/toggles_gen.csv | 1 + pkg/services/featuremgmt/toggles_gen.go | 4 ++ .../app/features/alerting/unified/features.ts | 5 -- .../features/alerting/unified/home/Home.tsx | 61 ++++++++++--------- 7 files changed, 45 insertions(+), 35 deletions(-) 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 568c6485b9d..4d90b23d636 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -134,6 +134,7 @@ Experimental features might be changed or removed without prior notice. | `sseGroupByDatasource` | Send query to the same datasource in a single request when using server side expressions | | `requestInstrumentationStatusSource` | Include a status source label for request metrics and logs | | `wargamesTesting` | Placeholder feature flag for internal testing | +| `alertingInsights` | Show the new alerting insights landing page | ## Development feature toggles diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 5d9ff14c722..541ad9d44e8 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -124,4 +124,5 @@ export interface FeatureToggles { sseGroupByDatasource?: boolean; requestInstrumentationStatusSource?: boolean; wargamesTesting?: boolean; + alertingInsights?: boolean; } diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 45f3a4a11ff..b134414c6e1 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -737,5 +737,12 @@ var ( FrontendOnly: false, Owner: hostedGrafanaTeam, }, + { + Name: "alertingInsights", + Description: "Show the new alerting insights landing page", + FrontendOnly: true, + Stage: FeatureStageExperimental, + Owner: grafanaAlertingSquad, + }, } ) diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index 1bfc9f529fe..08a02bcb957 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -105,3 +105,4 @@ newBrowseDashboards,preview,@grafana/grafana-frontend-platform,false,false,false sseGroupByDatasource,experimental,@grafana/observability-metrics,false,false,false,false requestInstrumentationStatusSource,experimental,@grafana/plugins-platform-backend,false,false,false,false wargamesTesting,experimental,@grafana/hosted-grafana-team,false,false,false,false +alertingInsights,experimental,@grafana/alerting-squad,false,false,false,true diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index fa3f0ee0f46..954a4471e88 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -430,4 +430,8 @@ const ( // FlagWargamesTesting // Placeholder feature flag for internal testing FlagWargamesTesting = "wargamesTesting" + + // FlagAlertingInsights + // Show the new alerting insights landing page + FlagAlertingInsights = "alertingInsights" ) diff --git a/public/app/features/alerting/unified/features.ts b/public/app/features/alerting/unified/features.ts index 4de5819d18d..76447761dea 100644 --- a/public/app/features/alerting/unified/features.ts +++ b/public/app/features/alerting/unified/features.ts @@ -6,7 +6,6 @@ export enum AlertingFeature { NotificationPoliciesV2MatchingInstances = 'notification-policies.v2.matching-instances', DetailsViewV2 = 'details-view.v2', ContactPointsV2 = 'contact-points.v2', - InsightsPage = 'insights-page', } const FEATURES: FeatureDescription[] = [ @@ -22,9 +21,5 @@ const FEATURES: FeatureDescription[] = [ name: AlertingFeature.DetailsViewV2, defaultValue: false, }, - { - name: AlertingFeature.InsightsPage, - defaultValue: false, - }, ]; export default FEATURES; diff --git a/public/app/features/alerting/unified/home/Home.tsx b/public/app/features/alerting/unified/home/Home.tsx index 619a00c0f57..b164858a6b9 100644 --- a/public/app/features/alerting/unified/home/Home.tsx +++ b/public/app/features/alerting/unified/home/Home.tsx @@ -1,10 +1,9 @@ import React, { useState } from 'react'; -import { Enable, Disable } from 'react-enable'; +import { config } from '@grafana/runtime'; import { Tab, TabContent, TabsBar } from '@grafana/ui'; import { AlertingPageWrapper } from '../components/AlertingPageWrapper'; -import { AlertingFeature } from '../features'; import GettingStarted, { WelcomeHeader } from './GettingStarted'; import Insights from './Insights'; @@ -14,36 +13,38 @@ type HomeTabs = 'insights' | 'gettingStarted'; export default function Home() { const [activeTab, setActiveTab] = useState('insights'); + const alertingInsightsEnabled = config.featureToggles.alertingInsights; return ( - - - - { - setActiveTab('insights'); - }} - /> - { - setActiveTab('gettingStarted'); - }} - /> - - - {activeTab === 'insights' && } - {activeTab === 'gettingStarted' && } - - - - - + {alertingInsightsEnabled && ( + <> + + + { + setActiveTab('insights'); + }} + /> + { + setActiveTab('gettingStarted'); + }} + /> + + + {activeTab === 'insights' && } + {activeTab === 'gettingStarted' && } + + + )} + + {!alertingInsightsEnabled && } ); }