diff --git a/CHANGELOG.md b/CHANGELOG.md index 1354cdd2..bb001bae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Allow users with `viewer` role to fetch cloud connection status using the internal API ([#1181](https://github.com/grafana/oncall/pull/1181)) +- When removing the Slack ChatOps integration, make it more explicit to the user what the implications of doing so are ### Fixed diff --git a/grafana-plugin/src/components/WithConfirm/WithConfirm.tsx b/grafana-plugin/src/components/WithConfirm/WithConfirm.tsx index e16e288b..569cee31 100644 --- a/grafana-plugin/src/components/WithConfirm/WithConfirm.tsx +++ b/grafana-plugin/src/components/WithConfirm/WithConfirm.tsx @@ -1,18 +1,21 @@ import React, { ReactElement, useCallback, useState } from 'react'; -import { ConfirmModal } from '@grafana/ui'; +import { ConfirmModal, ConfirmModalProps } from '@grafana/ui'; -interface WithConfirmProps { +type WithConfirmProps = Partial & { children: ReactElement; - title?: string; - body?: React.ReactNode; - confirmText?: string; disabled?: boolean; -} - -const WithConfirm = (props: WithConfirmProps) => { - const { children, title = 'Are you sure to delete?', body, confirmText = 'Delete', disabled } = props; +}; +const WithConfirm: React.FC = ({ + title = 'Are you sure to delete?', + confirmText = 'Delete', + body, + description, + confirmationText, + children, + disabled, +}) => { const [showConfirmation, setShowConfirmation] = useState(false); const onClickCallback = useCallback((event) => { @@ -39,6 +42,8 @@ const WithConfirm = (props: WithConfirmProps) => { dismissText="Cancel" onConfirm={onConfirmCallback} body={body} + description={description} + confirmationText={confirmationText} onDismiss={() => { setShowConfirmation(false); }} diff --git a/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx b/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx deleted file mode 100644 index 2eab10f6..00000000 --- a/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import React, { useCallback, useState } from 'react'; - -import { Button, Modal } from '@grafana/ui'; -import { observer } from 'mobx-react'; - -import WithConfirm from 'components/WithConfirm/WithConfirm'; -import { WithPermissionControl } from 'containers/WithPermissionControl/WithPermissionControl'; -import { useStore } from 'state/useStore'; -import { UserActions } from 'utils/authorization'; - -const SlackIntegrationButton = observer((props: { className: string; disabled?: boolean }) => { - const { className, disabled } = props; - - const [showModal, setShowModal] = useState(false); - - const store = useStore(); - - const onInstallModalCallback = useCallback(() => { - setShowModal(true); - }, []); - - const onInstallModalHideCallback = useCallback(() => { - setShowModal(false); - }, []); - - const onRemoveClickCallback = useCallback(() => { - store.slackStore.removeSlackIntegration().then(() => { - store.teamStore.loadCurrentTeam(); - }); - }, []); - - const onInstallClickCallback = useCallback(() => { - store.slackStore.installSlackIntegration(); - }, []); - - if (store.teamStore.currentTeam?.slack_team_identity) { - return ( - - - - - - ); - } - - return ( - <> - - - - {showModal && } - - ); -}); - -interface SlackModalProps { - onHide: () => void; - onConfirm: () => void; -} - -const SlackModal = (props: SlackModalProps) => { - const { onHide, onConfirm } = props; - - return ( - -
- You can view your Slack Workspace at the top-right corner after you are redirected. It should be a Workspace - with App Bot installed: -
- - -
- ); -}; - -export default SlackIntegrationButton; diff --git a/grafana-plugin/src/img/slack_workspace_choose_attention.png b/grafana-plugin/src/img/slack_workspace_choose_attention.png deleted file mode 100644 index 02d9fc73..00000000 Binary files a/grafana-plugin/src/img/slack_workspace_choose_attention.png and /dev/null differ diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx b/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx index 558e7a94..3f532d21 100644 --- a/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/tabs/SlackSettings/SlackSettings.tsx @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import { Field, HorizontalGroup, LoadingPlaceholder, VerticalGroup, Icon, Button } from '@grafana/ui'; +import { Alert, Field, HorizontalGroup, LoadingPlaceholder, VerticalGroup, Icon, Button } from '@grafana/ui'; import cn from 'classnames/bind'; import { observer } from 'mobx-react'; @@ -124,8 +124,30 @@ class SlackSettings extends Component { - - + + +

Are you sure to delete this Slack Integration?

+

+ Removing the integration will also irreverisbly remove the following data for your OnCall plugin: +

+
    +
  • default organization Slack channel
  • +
  • default Slack channels for OnCall Integrations
  • +
  • Slack channels & Slack user groups for OnCall Schedules
  • +
  • linked Slack usernames for OnCall Users
  • +
+
+

+ If you would like to instead remove your linked Slack username, please head{' '} + here. +

+ + } + confirmationText="DELETE" + > @@ -189,16 +211,6 @@ class SlackSettings extends Component { ); }; - renderActionButtons = () => { - - - - - ; - }; - removeSlackIntegration = () => { const { store } = this.props; store.slackStore.removeSlackIntegration().then(() => {