From 54ccfb528e30022fc365f98da7ac747b0b31868f Mon Sep 17 00:00:00 2001 From: Dominik Broj Date: Thu, 11 Jan 2024 21:12:03 +0100 Subject: [PATCH] Brojd/get stack from backend on insights (#3654) # What this PR does get stack from backend instead of parsing url ## Which issue(s) this PR fixes https://github.com/grafana/oncall-private/issues/2434 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --- .../src/models/organization/organization.types.ts | 1 + grafana-plugin/src/pages/insights/Insights.tsx | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/grafana-plugin/src/models/organization/organization.types.ts b/grafana-plugin/src/models/organization/organization.types.ts index 0c6a158e..889c461f 100644 --- a/grafana-plugin/src/models/organization/organization.types.ts +++ b/grafana-plugin/src/models/organization/organization.types.ts @@ -13,6 +13,7 @@ export interface Organization { discussion_group_name: string; }; name: string; + stack_slug: string; slack_team_identity: { general_log_channel_id: string; general_log_channel_pk: string; diff --git a/grafana-plugin/src/pages/insights/Insights.tsx b/grafana-plugin/src/pages/insights/Insights.tsx index 1a49a2c9..655031e0 100644 --- a/grafana-plugin/src/pages/insights/Insights.tsx +++ b/grafana-plugin/src/pages/insights/Insights.tsx @@ -39,11 +39,12 @@ import getTotalAlertGroupsScene from './scenes/TotalAlertGroups'; import getTotalAlertGroupsByStateScene from './scenes/TotalAlertGroupsByState'; import getVariables from './variables'; -const getDefaultStackValue = (isOpenSource: boolean) => - isOpenSource ? 'self_hosted_stack' : location.host.split('.')[0]; - const Insights = observer(() => { - const { isOpenSource, insightsDatasource } = useStore(); + const { + isOpenSource, + insightsDatasource, + organizationStore: { currentOrganization }, + } = useStore(); const [showAllStackInfo, setShowAllStackInfo] = useState(false); const [datasource, setDatasource] = useState(); @@ -51,7 +52,7 @@ const Insights = observer(() => { () => ({ isOpenSource, datasource: { uid: isOpenSource ? '$datasource' : insightsDatasource }, - stack: getDefaultStackValue(isOpenSource), + stack: currentOrganization?.stack_slug, }), [] );