From f582b10ee58a2a65a7be1ef81ee6feb189fb2bba Mon Sep 17 00:00:00 2001 From: Yulia Shanyrova Date: Wed, 20 Jul 2022 12:47:51 +0200 Subject: [PATCH] connectivity warning changed the logic and added helper file --- .../DefaultPageLayout/DefaultPageLayout.tsx | 28 +++++++++---------- .../containers/DefaultPageLayout/helper.ts | 7 +++++ 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 grafana-plugin/src/containers/DefaultPageLayout/helper.ts diff --git a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx index 2f4cf07f..af7ed097 100644 --- a/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx +++ b/grafana-plugin/src/containers/DefaultPageLayout/DefaultPageLayout.tsx @@ -16,6 +16,7 @@ import sanitize from 'utils/sanitize'; import { getSlackMessage } from './DefaultPageLayout.helpers'; import { SlackError } from './DefaultPageLayout.types'; +import { getIfChatOpsConnected } from './helper'; import styles from './DefaultPageLayout.module.css'; @@ -61,6 +62,9 @@ const DefaultPageLayout: FC = observer((props) => { const { currentTeam } = teamStore; const { currentUser } = userStore; + const isChatOpsConnected = getIfChatOpsConnected(currentUser); + const isPhoneVerified = currentUser?.cloud_connection_status === 3 ? true : currentUser?.verified_phone_number; + return (
@@ -117,9 +121,7 @@ const DefaultPageLayout: FC = observer((props) => { currentTeam && currentUser && store.isUserActionAllowed(UserAction.UpdateOwnSettings) && - (!currentUser.verified_phone_number || - !currentUser.slack_user_identity || - currentUser.cloud_connection_status !== 3) && + (!isPhoneVerified || !isChatOpsConnected) && !getItem(AlertID.CONNECTIVITY_WARNING) ) && ( = observer((props) => { > { <> - {!currentTeam.slack_team_identity && ( + {!isChatOpsConnected && ( <> - Slack Integration is not installed. Please fix it in{' '} - Slack Settings - {'. '} + Communication channels are not connected. Configure at least one channel to receive notifications. + + )} + {!isPhoneVerified && ( + <> + Your phone number is not verified. You can change your configuration in{' '} + User settings )} - {currentUser.cloud_connection_status !== 3 && - !currentUser.verified_phone_number && - 'Your phone number is not verified. '} - {currentTeam.slack_team_identity && - !currentUser.slack_user_identity && - 'Your slack account is not connected. '} - You can change your configuration in{' '} - User settings } diff --git a/grafana-plugin/src/containers/DefaultPageLayout/helper.ts b/grafana-plugin/src/containers/DefaultPageLayout/helper.ts new file mode 100644 index 00000000..5af787af --- /dev/null +++ b/grafana-plugin/src/containers/DefaultPageLayout/helper.ts @@ -0,0 +1,7 @@ +import React from 'react'; + +import { User } from 'models/user/user.types'; + +export const getIfChatOpsConnected = (user: User) => { + return user?.slack_user_identity || user?.telegram_configuration; +};