From fd55acfea4ae01382753b41b7aa2d23478fd2111 Mon Sep 17 00:00:00 2001 From: Yulia Shanyrova Date: Wed, 2 Nov 2022 10:30:00 +0100 Subject: [PATCH 1/2] live settings availability check has been added --- .../DefaultPageLayout/DefaultPageLayout.helpers.tsx | 12 +++++++++--- .../DefaultPageLayout/DefaultPageLayout.tsx | 2 +- .../parts/tabs/TelegramInfo/TelegramInfo.tsx | 8 +++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx index 983597c3..a89dc451 100644 --- a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx +++ b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx @@ -2,10 +2,12 @@ import React from 'react'; import PluginLink from 'components/PluginLink/PluginLink'; import { Team } from 'models/team/team.types'; +import { RootStore } from 'state'; +import { AppFeature } from 'state/features'; import { SlackError } from './DefaultPageLayout.types'; -export function getSlackMessage(slackError: SlackError, team: Team) { +export function getSlackMessage(slackError: SlackError, team: Team, store: RootStore) { if (slackError === SlackError.WRONG_WORKSPACE) { return ( <> @@ -30,8 +32,12 @@ export function getSlackMessage(slackError: SlackError, team: Team) { return ( <> An error has occurred with Slack authentication.{' '} - Check ENV variables related to Slack and try again - please. + {store.hasFeature(AppFeature.LiveSettings) && ( + <> + Check ENV variables related to Slack and try + again please. + + )} ); } diff --git a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx index 95d6d253..d9e395ff 100644 --- a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx +++ b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx @@ -79,7 +79,7 @@ const DefaultPageLayout: FC = observer((props) => { // @ts-ignore title="Slack integration warning" > - {getSlackMessage(showSlackInstallAlert, store.teamStore.currentTeam)} + {getSlackMessage(showSlackInstallAlert, store.teamStore.currentTeam, store)} )} {currentTeam?.banner.title != null && !getItem(currentTeam?.banner.title) && ( diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx index f0750886..3c186429 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx @@ -95,9 +95,11 @@ const TelegramInfo = observer((_props: TelegramInfoProps) => { - - - + {store.hasFeature(AppFeature.LiveSettings) && ( + + + + )} )} From c01e7d202b8cae167afab12ba9a764ecfeb3b412 Mon Sep 17 00:00:00 2001 From: Yulia Shanyrova Date: Wed, 2 Nov 2022 12:47:52 +0100 Subject: [PATCH 2/2] Changes after review --- .../DefaultPageLayout/DefaultPageLayout.helpers.tsx | 6 ++---- .../src/containers/DefaultPageLayout/DefaultPageLayout.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx index a89dc451..0f05c0d8 100644 --- a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx +++ b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.helpers.tsx @@ -2,12 +2,10 @@ import React from 'react'; import PluginLink from 'components/PluginLink/PluginLink'; import { Team } from 'models/team/team.types'; -import { RootStore } from 'state'; -import { AppFeature } from 'state/features'; import { SlackError } from './DefaultPageLayout.types'; -export function getSlackMessage(slackError: SlackError, team: Team, store: RootStore) { +export function getSlackMessage(slackError: SlackError, team: Team, hasLiveSettingsFeature: boolean) { if (slackError === SlackError.WRONG_WORKSPACE) { return ( <> @@ -32,7 +30,7 @@ export function getSlackMessage(slackError: SlackError, team: Team, store: RootS return ( <> An error has occurred with Slack authentication.{' '} - {store.hasFeature(AppFeature.LiveSettings) && ( + {hasLiveSettingsFeature && ( <> Check ENV variables related to Slack and try again please. diff --git a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx index d9e395ff..d40b3a26 100644 --- a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx +++ b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx @@ -9,6 +9,7 @@ import { observer } from 'mobx-react'; import PluginLink from 'components/PluginLink/PluginLink'; import { getIfChatOpsConnected } from 'containers/DefaultPageLayout/helper'; +import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; import { UserAction } from 'state/userAction'; import { GRAFANA_LICENSE_OSS } from 'utils/consts'; @@ -79,7 +80,11 @@ const DefaultPageLayout: FC = observer((props) => { // @ts-ignore title="Slack integration warning" > - {getSlackMessage(showSlackInstallAlert, store.teamStore.currentTeam, store)} + {getSlackMessage( + showSlackInstallAlert, + store.teamStore.currentTeam, + store.hasFeature(AppFeature.LiveSettings) + )} )} {currentTeam?.banner.title != null && !getItem(currentTeam?.banner.title) && (