diff --git a/Common/UI/Components/ComingSoon/ComingSoon.tsx b/Common/UI/Components/ComingSoon/ComingSoon.tsx index 011814eb52..1cabd9363b 100644 --- a/Common/UI/Components/ComingSoon/ComingSoon.tsx +++ b/Common/UI/Components/ComingSoon/ComingSoon.tsx @@ -7,13 +7,18 @@ export interface ComponentProps { description?: string | undefined; } -const ComingSoon: FunctionComponent = (props: ComponentProps): ReactElement => { +const ComingSoon: FunctionComponent = ( + props: ComponentProps, +): ReactElement => { return ( ); }; diff --git a/Common/UI/Components/Icon/Icon.tsx b/Common/UI/Components/Icon/Icon.tsx index d24bcf8498..4f87617113 100644 --- a/Common/UI/Components/Icon/Icon.tsx +++ b/Common/UI/Components/Icon/Icon.tsx @@ -149,10 +149,13 @@ const Icon: FunctionComponent = ({ } else if (icon === IconProp.MicrosoftTeams) { return getSvgWrapper( - - + - + - + c0,0.764,0.62,1.384,1.384,1.384h5.008C30.728,64.209,31.348,63.589,31.348,62.825z" + > + , ); } else if (icon === IconProp.ShieldCheck) { return getSvgWrapper( diff --git a/Dashboard/src/Pages/Alerts/SideMenu.tsx b/Dashboard/src/Pages/Alerts/SideMenu.tsx index 58ea6d96f3..da78218e21 100644 --- a/Dashboard/src/Pages/Alerts/SideMenu.tsx +++ b/Dashboard/src/Pages/Alerts/SideMenu.tsx @@ -64,7 +64,9 @@ const DashboardSideMenu: FunctionComponent = ( link={{ title: "Microsoft Teams", to: RouteUtil.populateRouteParams( - RouteMap[PageMap.ALERTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS] as Route, + RouteMap[ + PageMap.ALERTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS + ] as Route, ), }} icon={IconProp.MicrosoftTeams} diff --git a/Dashboard/src/Pages/Alerts/WorkspaceConnectionMicrosoftTeams.tsx b/Dashboard/src/Pages/Alerts/WorkspaceConnectionMicrosoftTeams.tsx new file mode 100644 index 0000000000..0fd90a218e --- /dev/null +++ b/Dashboard/src/Pages/Alerts/WorkspaceConnectionMicrosoftTeams.tsx @@ -0,0 +1,86 @@ +import WorkspaceType from "Common/Types/Workspace/WorkspaceType"; +import WorkspaceNotificationRuleTable from "../../Components/Workspace/WorkspaceNotificationRulesTable"; +import PageComponentProps from "../PageComponentProps"; +import React, { FunctionComponent, ReactElement } from "react"; +import NotificationRuleEventType from "Common/Types/Workspace/NotificationRules/EventType"; +import WorkspaceUtil from "../../Utils/Workspace/Workspace"; +import API from "Common/UI/Utils/API/API"; +import Exception from "Common/Types/Exception/Exception"; +import PageLoader from "Common/UI/Components/Loader/PageLoader"; +import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; +import EmptyState from "Common/UI/Components/EmptyState/EmptyState"; +import IconProp from "Common/Types/Icon/IconProp"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import ComingSoon from "Common/UI/Components/ComingSoon/ComingSoon"; + +const IncidentsPage: FunctionComponent< + PageComponentProps +> = (): ReactElement => { + const [isMicrosoftTeamsConnected, setIsMicrosoftTeamsConnected] = + React.useState(false); + const [isLoading, setIsLoading] = React.useState(false); + const [error, setError] = React.useState(null); + + const [showComingSoon, setShowComingSoon] = React.useState(false); + + const loadItems: PromiseVoidFunction = async (): Promise => { + setShowComingSoon(true); + try { + setError(null); + setIsLoading(true); + const isMicrosoftTeamsConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( + WorkspaceType.MicrosoftTeams, + ); + + setIsMicrosoftTeamsConnected(isMicrosoftTeamsConnected); + setIsLoading(false); + } catch (error) { + setIsLoading(false); + setError(API.getFriendlyErrorMessage(error as Exception)); + } + }; + + React.useEffect(() => { + loadItems().catch(() => { + // Do nothing + }); + }, []); + + if (isLoading) { + return ; + } + + if (error) { + return ; + } + + if(showComingSoon){ + return + } + + return ( +
+ {isMicrosoftTeamsConnected && ( + + )} + {!isMicrosoftTeamsConnected && ( +
+ +
+ )} +
+ ); +}; + +export default IncidentsPage; diff --git a/Dashboard/src/Pages/Alerts/WorkspaceConnectionSlack.tsx b/Dashboard/src/Pages/Alerts/WorkspaceConnectionSlack.tsx index 7c90ca3d88..5ba1650106 100644 --- a/Dashboard/src/Pages/Alerts/WorkspaceConnectionSlack.tsx +++ b/Dashboard/src/Pages/Alerts/WorkspaceConnectionSlack.tsx @@ -24,9 +24,8 @@ const IncidentsPage: FunctionComponent< try { setError(null); setIsLoading(true); - const isSlackConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( - WorkspaceType.Slack, - ); + const isSlackConnected: boolean = + await WorkspaceUtil.isWorkspaceConnected(WorkspaceType.Slack); setIsSlackConnected(isSlackConnected); setIsLoading(false); diff --git a/Dashboard/src/Pages/Alerts/WorkspaceConnectionTeams.tsx b/Dashboard/src/Pages/Alerts/WorkspaceConnectionTeams.tsx index 0fd90a218e..f500cbda41 100644 --- a/Dashboard/src/Pages/Alerts/WorkspaceConnectionTeams.tsx +++ b/Dashboard/src/Pages/Alerts/WorkspaceConnectionTeams.tsx @@ -28,9 +28,8 @@ const IncidentsPage: FunctionComponent< try { setError(null); setIsLoading(true); - const isMicrosoftTeamsConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( - WorkspaceType.MicrosoftTeams, - ); + const isMicrosoftTeamsConnected: boolean = + await WorkspaceUtil.isWorkspaceConnected(WorkspaceType.MicrosoftTeams); setIsMicrosoftTeamsConnected(isMicrosoftTeamsConnected); setIsLoading(false); @@ -54,11 +53,13 @@ const IncidentsPage: FunctionComponent< return ; } - if(showComingSoon){ - return + if (showComingSoon) { + return ( + + ); } return ( diff --git a/Dashboard/src/Pages/Incidents/SideMenu.tsx b/Dashboard/src/Pages/Incidents/SideMenu.tsx index b37fde1253..eff5eeb149 100644 --- a/Dashboard/src/Pages/Incidents/SideMenu.tsx +++ b/Dashboard/src/Pages/Incidents/SideMenu.tsx @@ -60,20 +60,18 @@ const DashboardSideMenu: FunctionComponent = ( icon={IconProp.Slack} /> - - - - - ); }; diff --git a/Dashboard/src/Pages/Incidents/WorkspaceConnectionMicrosoftTeams.tsx b/Dashboard/src/Pages/Incidents/WorkspaceConnectionMicrosoftTeams.tsx new file mode 100644 index 0000000000..6ad743f41f --- /dev/null +++ b/Dashboard/src/Pages/Incidents/WorkspaceConnectionMicrosoftTeams.tsx @@ -0,0 +1,86 @@ +import WorkspaceType from "Common/Types/Workspace/WorkspaceType"; +import WorkspaceNotificationRuleTable from "../../Components/Workspace/WorkspaceNotificationRulesTable"; +import PageComponentProps from "../PageComponentProps"; +import React, { FunctionComponent, ReactElement } from "react"; +import NotificationRuleEventType from "Common/Types/Workspace/NotificationRules/EventType"; +import WorkspaceUtil from "../../Utils/Workspace/Workspace"; +import API from "Common/UI/Utils/API/API"; +import Exception from "Common/Types/Exception/Exception"; +import PageLoader from "Common/UI/Components/Loader/PageLoader"; +import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; +import EmptyState from "Common/UI/Components/EmptyState/EmptyState"; +import IconProp from "Common/Types/Icon/IconProp"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import ComingSoon from "Common/UI/Components/ComingSoon/ComingSoon"; + +const IncidentsPage: FunctionComponent< + PageComponentProps +> = (): ReactElement => { + const [isMicrosoftTeamsConnected, setIsMicrosoftTeamsConnected] = + React.useState(false); + const [isLoading, setIsLoading] = React.useState(false); + const [error, setError] = React.useState(null); + + const [showComingSoon, setShowComingSoon] = React.useState(false); + + const loadItems: PromiseVoidFunction = async (): Promise => { + setShowComingSoon(true); + try { + setError(null); + setIsLoading(true); + const isMicrosoftTeamsConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( + WorkspaceType.MicrosoftTeams, + ); + + setIsMicrosoftTeamsConnected(isMicrosoftTeamsConnected); + setIsLoading(false); + } catch (error) { + setIsLoading(false); + setError(API.getFriendlyErrorMessage(error as Exception)); + } + }; + + React.useEffect(() => { + loadItems().catch(() => { + // Do nothing + }); + }, []); + + if (isLoading) { + return ; + } + + if (error) { + return ; + } + + if(showComingSoon){ + return + } + + return ( +
+ {isMicrosoftTeamsConnected && ( + + )} + {!isMicrosoftTeamsConnected && ( +
+ +
+ )} +
+ ); +}; + +export default IncidentsPage; diff --git a/Dashboard/src/Pages/Incidents/WorkspaceConnectionSlack.tsx b/Dashboard/src/Pages/Incidents/WorkspaceConnectionSlack.tsx index f2df437d2c..e1a23dfc16 100644 --- a/Dashboard/src/Pages/Incidents/WorkspaceConnectionSlack.tsx +++ b/Dashboard/src/Pages/Incidents/WorkspaceConnectionSlack.tsx @@ -24,9 +24,8 @@ const IncidentsPage: FunctionComponent< try { setError(null); setIsLoading(true); - const isSlackConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( - WorkspaceType.Slack, - ); + const isSlackConnected: boolean = + await WorkspaceUtil.isWorkspaceConnected(WorkspaceType.Slack); setIsSlackConnected(isSlackConnected); setIsLoading(false); diff --git a/Dashboard/src/Pages/Incidents/WorkspaceConnectionTeams.tsx b/Dashboard/src/Pages/Incidents/WorkspaceConnectionTeams.tsx index 6ad743f41f..ed616f5ccb 100644 --- a/Dashboard/src/Pages/Incidents/WorkspaceConnectionTeams.tsx +++ b/Dashboard/src/Pages/Incidents/WorkspaceConnectionTeams.tsx @@ -28,9 +28,8 @@ const IncidentsPage: FunctionComponent< try { setError(null); setIsLoading(true); - const isMicrosoftTeamsConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( - WorkspaceType.MicrosoftTeams, - ); + const isMicrosoftTeamsConnected: boolean = + await WorkspaceUtil.isWorkspaceConnected(WorkspaceType.MicrosoftTeams); setIsMicrosoftTeamsConnected(isMicrosoftTeamsConnected); setIsLoading(false); @@ -54,11 +53,13 @@ const IncidentsPage: FunctionComponent< return ; } - if(showComingSoon){ - return + if (showComingSoon) { + return ( + + ); } return ( diff --git a/Dashboard/src/Pages/ScheduledMaintenanceEvents/SideMenu.tsx b/Dashboard/src/Pages/ScheduledMaintenanceEvents/SideMenu.tsx index 4faf861f41..f1b6a7c360 100644 --- a/Dashboard/src/Pages/ScheduledMaintenanceEvents/SideMenu.tsx +++ b/Dashboard/src/Pages/ScheduledMaintenanceEvents/SideMenu.tsx @@ -63,18 +63,18 @@ const DashboardSideMenu: FunctionComponent = ( icon={IconProp.Slack} /> - - ); diff --git a/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionMicrosoftTeams.tsx b/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionMicrosoftTeams.tsx new file mode 100644 index 0000000000..485d4a7f20 --- /dev/null +++ b/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionMicrosoftTeams.tsx @@ -0,0 +1,86 @@ +import WorkspaceType from "Common/Types/Workspace/WorkspaceType"; +import WorkspaceNotificationRuleTable from "../../Components/Workspace/WorkspaceNotificationRulesTable"; +import PageComponentProps from "../PageComponentProps"; +import React, { FunctionComponent, ReactElement } from "react"; +import NotificationRuleEventType from "Common/Types/Workspace/NotificationRules/EventType"; +import WorkspaceUtil from "../../Utils/Workspace/Workspace"; +import API from "Common/UI/Utils/API/API"; +import Exception from "Common/Types/Exception/Exception"; +import PageLoader from "Common/UI/Components/Loader/PageLoader"; +import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; +import EmptyState from "Common/UI/Components/EmptyState/EmptyState"; +import IconProp from "Common/Types/Icon/IconProp"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import ComingSoon from "Common/UI/Components/ComingSoon/ComingSoon"; + +const IncidentsPage: FunctionComponent< + PageComponentProps +> = (): ReactElement => { + const [isMicrosoftTeamsConnected, setIsMicrosoftTeamsConnected] = + React.useState(false); + const [isLoading, setIsLoading] = React.useState(false); + const [error, setError] = React.useState(null); + + const [showComingSoon, setShowComingSoon] = React.useState(false); + + const loadItems: PromiseVoidFunction = async (): Promise => { + setShowComingSoon(true); + try { + setError(null); + setIsLoading(true); + const isMicrosoftTeamsConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( + WorkspaceType.MicrosoftTeams, + ); + + setIsMicrosoftTeamsConnected(isMicrosoftTeamsConnected); + setIsLoading(false); + } catch (error) { + setIsLoading(false); + setError(API.getFriendlyErrorMessage(error as Exception)); + } + }; + + React.useEffect(() => { + loadItems().catch(() => { + // Do nothing + }); + }, []); + + if (isLoading) { + return ; + } + + if (error) { + return ; + } + + if(showComingSoon){ + return + } + + return ( +
+ {isMicrosoftTeamsConnected && ( + + )} + {!isMicrosoftTeamsConnected && ( +
+ +
+ )} +
+ ); +}; + +export default IncidentsPage; diff --git a/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionSlack.tsx b/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionSlack.tsx index 7306fd12a2..6f18b73019 100644 --- a/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionSlack.tsx +++ b/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionSlack.tsx @@ -20,13 +20,12 @@ const IncidentsPage: FunctionComponent< const [isLoading, setIsLoading] = React.useState(false); const [error, setError] = React.useState(null); - const loadItems: PromiseVoidFunction = async (): Promise => { + const loadItems: PromiseVoidFunction = async (): Promise => { try { setError(null); setIsLoading(true); - const isSlackConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( - WorkspaceType.Slack, - ); + const isSlackConnected: boolean = + await WorkspaceUtil.isWorkspaceConnected(WorkspaceType.Slack); setIsSlackConnected(isSlackConnected); setIsLoading(false); diff --git a/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionTeams.tsx b/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionTeams.tsx index 485d4a7f20..91441c1d9d 100644 --- a/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionTeams.tsx +++ b/Dashboard/src/Pages/ScheduledMaintenanceEvents/WorkspaceConnectionTeams.tsx @@ -28,9 +28,8 @@ const IncidentsPage: FunctionComponent< try { setError(null); setIsLoading(true); - const isMicrosoftTeamsConnected: boolean = await WorkspaceUtil.isWorkspaceConnected( - WorkspaceType.MicrosoftTeams, - ); + const isMicrosoftTeamsConnected: boolean = + await WorkspaceUtil.isWorkspaceConnected(WorkspaceType.MicrosoftTeams); setIsMicrosoftTeamsConnected(isMicrosoftTeamsConnected); setIsLoading(false); @@ -54,11 +53,13 @@ const IncidentsPage: FunctionComponent< return ; } - if(showComingSoon){ - return + if (showComingSoon) { + return ( + + ); } return ( diff --git a/Dashboard/src/Pages/Settings/MicrosoftTeamsIntegration.tsx b/Dashboard/src/Pages/Settings/MicrosoftTeamsIntegration.tsx new file mode 100644 index 0000000000..374415eee9 --- /dev/null +++ b/Dashboard/src/Pages/Settings/MicrosoftTeamsIntegration.tsx @@ -0,0 +1,18 @@ +import PageComponentProps from "../PageComponentProps"; +import React, { FunctionComponent, ReactElement } from "react"; +import ComingSoon from "Common/UI/Components/ComingSoon/ComingSoon"; + +const SlackIntegrationPage: FunctionComponent = ( + _props: PageComponentProps, +): ReactElement => { + return ( +
+ +
+ ); +}; + +export default SlackIntegrationPage; diff --git a/Dashboard/src/Routes/AlertRoutes.tsx b/Dashboard/src/Routes/AlertRoutes.tsx index 61514b86e8..5ba3ea4559 100644 --- a/Dashboard/src/Routes/AlertRoutes.tsx +++ b/Dashboard/src/Routes/AlertRoutes.tsx @@ -31,7 +31,6 @@ const AlertsWorkspaceConnectionSlack: LazyExoticComponent< return import("../Pages/Alerts/WorkspaceConnectionSlack"); }); - const AlertsWorkspaceConnectionMicrosoftTeams: LazyExoticComponent< FunctionComponent > = lazy(() => { @@ -137,16 +136,20 @@ const AlertsRoutes: FunctionComponent = ( } /> - diff --git a/Dashboard/src/Routes/ScheduleMaintenaceEventsRoutes.tsx b/Dashboard/src/Routes/ScheduleMaintenaceEventsRoutes.tsx index 47b9f41e2e..8eed04fb20 100644 --- a/Dashboard/src/Routes/ScheduleMaintenaceEventsRoutes.tsx +++ b/Dashboard/src/Routes/ScheduleMaintenaceEventsRoutes.tsx @@ -38,11 +38,12 @@ const ScheduledMaintenanceEventViewDelete: LazyExoticComponent< return import("../Pages/ScheduledMaintenanceEvents/View/Delete"); }); - const ScheduledMaintenanceEventsWorkspaceConnectionMicrosoftTeams: LazyExoticComponent< FunctionComponent > = lazy(() => { - return import("../Pages/ScheduledMaintenanceEvents/WorkspaceConnectionMicrosoftTeams"); + return import( + "../Pages/ScheduledMaintenanceEvents/WorkspaceConnectionMicrosoftTeams" + ); }); const ScheduledMaintenanceEventViewOwner: LazyExoticComponent< @@ -176,10 +177,11 @@ const ScheduledMaintenanceEventsRoutes: FunctionComponent = ( } /> - | undefined { "Alerts", "Slack Connection", ]), - ...BuildBreadcrumbLinksByTitles(PageMap.ALERTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS, [ - "Project", - "Alerts", - "Microsoft Teams Connection", - ]), + ...BuildBreadcrumbLinksByTitles( + PageMap.ALERTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS, + ["Project", "Alerts", "Microsoft Teams Connection"], + ), ...BuildBreadcrumbLinksByTitles(PageMap.ALERT_VIEW, [ "Project", "Alerts", diff --git a/Dashboard/src/Utils/RouteMap.ts b/Dashboard/src/Utils/RouteMap.ts index aa02b77ce0..6c7e8164bd 100644 --- a/Dashboard/src/Utils/RouteMap.ts +++ b/Dashboard/src/Utils/RouteMap.ts @@ -141,7 +141,8 @@ export const StatusPagesRoutePath: Dictionary = { export const IncidentsRoutePath: Dictionary = { [PageMap.UNRESOLVED_INCIDENTS]: "unresolved", [PageMap.INCIDENTS_WORKSPACE_CONNECTION_SLACK]: "workspace-connection-slack", - [PageMap.INCIDENTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS]: "workspace-connection-microsoft-teams", + [PageMap.INCIDENTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS]: + "workspace-connection-microsoft-teams", [PageMap.INCIDENT_CREATE]: "create", [PageMap.INCIDENT_VIEW]: `${RouteParams.ModelID}`, [PageMap.INCIDENT_VIEW_STATE_TIMELINE]: `${RouteParams.ModelID}/state-timeline`, @@ -160,7 +161,8 @@ export const IncidentsRoutePath: Dictionary = { export const AlertsRoutePath: Dictionary = { [PageMap.UNRESOLVED_ALERTS]: "unresolved", [PageMap.ALERTS_WORKSPACE_CONNECTION_SLACK]: "workspace-connection-slack", - [PageMap.ALERTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS]: "workspace-connection-microsoft-teams", + [PageMap.ALERTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS]: + "workspace-connection-microsoft-teams", [PageMap.ALERT_VIEW]: `${RouteParams.ModelID}`, [PageMap.ALERT_VIEW_STATE_TIMELINE]: `${RouteParams.ModelID}/state-timeline`, [PageMap.ALERT_VIEW_OWNERS]: `${RouteParams.ModelID}/owners`, @@ -651,13 +653,15 @@ const RouteMap: Dictionary = { }`, ), - [PageMap.SCHEDULED_MAINTENANCE_EVENTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS]: new Route( - `/dashboard/${RouteParams.ProjectID}/scheduled-maintenance-events/${ - ScheduledMaintenanceEventsRoutePath[ - PageMap.SCHEDULED_MAINTENANCE_EVENTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS - ] - }`, - ), + [PageMap.SCHEDULED_MAINTENANCE_EVENTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS]: + new Route( + `/dashboard/${RouteParams.ProjectID}/scheduled-maintenance-events/${ + ScheduledMaintenanceEventsRoutePath[ + PageMap + .SCHEDULED_MAINTENANCE_EVENTS_WORKSPACE_CONNECTION_MICROSOFT_TEAMS + ] + }`, + ), [PageMap.SCHEDULED_MAINTENANCE_EVENT_CREATE]: new Route( `/dashboard/${RouteParams.ProjectID}/scheduled-maintenance-events/${