mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Show Insights only for cloud users (#75676)
* Add functions to detect build edition and env * Prevent showing insights for OSS * Use common functions for Declare Incident button * Address review comments
This commit is contained in:
@@ -3,7 +3,6 @@ import React, { Fragment, useState } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
import { GrafanaTheme2, textUtil, urlUtil } from '@grafana/data';
|
||||
import { GrafanaEdition } from '@grafana/data/src/types/config';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Button, ClipboardButton, ConfirmModal, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui';
|
||||
import { useAppNotification } from 'app/core/copy/appNotification';
|
||||
@@ -21,7 +20,13 @@ import { getRulesPermissions } from '../../utils/access-control';
|
||||
import { getAlertmanagerByUid } from '../../utils/alertmanager';
|
||||
import { Annotation } from '../../utils/constants';
|
||||
import { getRulesSourceName, isCloudRulesSource, isGrafanaRulesSource } from '../../utils/datasource';
|
||||
import { createExploreLink, createShareLink, makeRuleBasedSilenceLink } from '../../utils/misc';
|
||||
import {
|
||||
createExploreLink,
|
||||
createShareLink,
|
||||
isLocalDevEnv,
|
||||
isOpenSourceEdition,
|
||||
makeRuleBasedSilenceLink,
|
||||
} from '../../utils/misc';
|
||||
import * as ruleId from '../../utils/rule-id';
|
||||
import { isAlertingRule, isFederatedRuleGroup, isGrafanaRulerRule } from '../../utils/rules';
|
||||
import { DeclareIncident } from '../bridges/DeclareIncidentButton';
|
||||
@@ -267,11 +272,7 @@ export const RuleDetailsActionButtons = ({ rule, rulesSource, isViewMode }: Prop
|
||||
* We should show it in development mode
|
||||
*/
|
||||
function shouldShowDeclareIncidentButton() {
|
||||
const buildInfo = config.buildInfo;
|
||||
const isOpenSourceEdition = buildInfo.edition === GrafanaEdition.OpenSource;
|
||||
const isDevelopment = buildInfo.env === 'development';
|
||||
|
||||
return !isOpenSourceEdition || isDevelopment;
|
||||
return !isOpenSourceEdition() || isLocalDevEnv();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,8 @@ import { SceneApp, SceneAppPage } from '@grafana/scenes';
|
||||
import { usePageNav } from 'app/core/components/Page/usePageNav';
|
||||
import { PluginPageContext, PluginPageContextType } from 'app/features/plugins/components/PluginPageContext';
|
||||
|
||||
import { isLocalDevEnv, isOpenSourceEdition } from '../utils/misc';
|
||||
|
||||
import { getOverviewScene, WelcomeHeader } from './GettingStarted';
|
||||
import { getGrafanaScenes } from './Insights';
|
||||
|
||||
@@ -56,7 +58,8 @@ export function getHomeApp(insightsEnabled: boolean) {
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const insightsEnabled = !!config.featureToggles.alertingInsights;
|
||||
const insightsEnabled =
|
||||
(!isOpenSourceEdition() || isLocalDevEnv()) && Boolean(config.featureToggles.alertingInsights);
|
||||
|
||||
const appScene = getHomeApp(insightsEnabled);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { sortBy } from 'lodash';
|
||||
|
||||
import { UrlQueryMap, Labels, DataSourceInstanceSettings, DataSourceJsonData } from '@grafana/data';
|
||||
import { GrafanaEdition } from '@grafana/data/src/types/config';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { DataSourceRef } from '@grafana/schema';
|
||||
import { alertInstanceKey } from 'app/features/alerting/unified/utils/rules';
|
||||
import { SortOrder } from 'app/plugins/panel/alertlist/types';
|
||||
@@ -206,3 +208,13 @@ export function sortAlerts(sortOrder: SortOrder, alerts: Alert[]): Alert[] {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function isOpenSourceEdition() {
|
||||
const buildInfo = config.buildInfo;
|
||||
return buildInfo.edition === GrafanaEdition.OpenSource;
|
||||
}
|
||||
|
||||
export function isLocalDevEnv() {
|
||||
const buildInfo = config.buildInfo;
|
||||
return buildInfo.env === 'development';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user