[Alerting Insights] - Use Grafana feature flag system (#74749)

Use Grafana feature flag system
This commit is contained in:
Virginia Cepeda 2023-09-14 09:58:04 -03:00 committed by GitHub
parent 5af35f1f3c
commit 5d88b8a4f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 35 deletions

View File

@ -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

View File

@ -124,4 +124,5 @@ export interface FeatureToggles {
sseGroupByDatasource?: boolean;
requestInstrumentationStatusSource?: boolean;
wargamesTesting?: boolean;
alertingInsights?: boolean;
}

View File

@ -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,
},
}
)

View File

@ -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

1 Name Stage Owner requiresDevMode RequiresLicense RequiresRestart FrontendOnly
105 sseGroupByDatasource experimental @grafana/observability-metrics false false false false
106 requestInstrumentationStatusSource experimental @grafana/plugins-platform-backend false false false false
107 wargamesTesting experimental @grafana/hosted-grafana-team false false false false
108 alertingInsights experimental @grafana/alerting-squad false false false true

View File

@ -430,4 +430,8 @@ const (
// FlagWargamesTesting
// Placeholder feature flag for internal testing
FlagWargamesTesting = "wargamesTesting"
// FlagAlertingInsights
// Show the new alerting insights landing page
FlagAlertingInsights = "alertingInsights"
)

View File

@ -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;

View File

@ -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<HomeTabs>('insights');
const alertingInsightsEnabled = config.featureToggles.alertingInsights;
return (
<AlertingPageWrapper pageId={'alerting'}>
<Enable feature={AlertingFeature.InsightsPage}>
<WelcomeHeader />
<TabsBar>
<Tab
key={'insights'}
label={'Insights'}
active={activeTab === 'insights'}
onChangeTab={() => {
setActiveTab('insights');
}}
/>
<Tab
key={'gettingStarted'}
label={'Overview'}
active={activeTab === 'gettingStarted'}
onChangeTab={() => {
setActiveTab('gettingStarted');
}}
/>
</TabsBar>
<TabContent>
{activeTab === 'insights' && <Insights />}
{activeTab === 'gettingStarted' && <GettingStarted />}
</TabContent>
</Enable>
<Disable feature={AlertingFeature.InsightsPage}>
<GettingStarted showWelcomeHeader={true} />
</Disable>
{alertingInsightsEnabled && (
<>
<WelcomeHeader />
<TabsBar>
<Tab
key={'insights'}
label={'Insights'}
active={activeTab === 'insights'}
onChangeTab={() => {
setActiveTab('insights');
}}
/>
<Tab
key={'gettingStarted'}
label={'Overview'}
active={activeTab === 'gettingStarted'}
onChangeTab={() => {
setActiveTab('gettingStarted');
}}
/>
</TabsBar>
<TabContent>
{activeTab === 'insights' && <Insights />}
{activeTab === 'gettingStarted' && <GettingStarted />}
</TabContent>
</>
)}
{!alertingInsightsEnabled && <GettingStarted showWelcomeHeader={true} />}
</AlertingPageWrapper>
);
}