Alerting: Show Insights page only on cloud (when required ds's are available) (#89679)

* Show Insights page only on cloud (when required ds's are available)

* fix typo

* remove unnecessary export
This commit is contained in:
Sonia Aguilar 2024-07-01 17:44:33 +02:00 committed by GitHub
parent 9c6d3590a2
commit 579250a89a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -4,15 +4,14 @@ import { config } from '@grafana/runtime';
import { Box, Stack, Tab, TabContent, TabsBar } from '@grafana/ui';
import { AlertingPageWrapper } from '../components/AlertingPageWrapper';
import { isLocalDevEnv, isOpenSourceEdition } from '../utils/misc';
import { isLocalDevEnv } from '../utils/misc';
import GettingStarted, { WelcomeHeader } from './GettingStarted';
import { getInsightsScenes } from './Insights';
import { getInsightsScenes, insightsIsAvailable } from './Insights';
import { PluginIntegrations } from './PluginIntegrations';
export default function Home() {
const insightsEnabled =
(!isOpenSourceEdition() || isLocalDevEnv()) && Boolean(config.featureToggles.alertingInsights);
const insightsEnabled = (insightsIsAvailable() || isLocalDevEnv()) && Boolean(config.featureToggles.alertingInsights);
const [activeTab, setActiveTab] = useState<'insights' | 'overview'>(insightsEnabled ? 'insights' : 'overview');
const insightsScene = getInsightsScenes();

View File

@ -98,12 +98,22 @@ const namespace = config.bootData.settings.namespace;
export const INSTANCE_ID = namespace.includes('stack-') ? namespace.replace('stack-', '') : undefined;
export function getInsightsScenes() {
const getInsightsDataSources = () => {
const dataSourceSrv = getDataSourceSrv();
[ashDs, cloudUsageDs, grafanaCloudPromDs].forEach((ds) => {
ds.settings = dataSourceSrv.getInstanceSettings(ds.uid);
});
return [ashDs, cloudUsageDs, grafanaCloudPromDs];
};
export const insightsIsAvailable = () => {
const [_, cloudUsageDs, __] = getInsightsDataSources();
return cloudUsageDs.settings;
};
export function getInsightsScenes() {
const [ashDs, cloudUsageDs, grafanaCloudPromDs] = getInsightsDataSources();
const categories = [];