From 84bc76263fd2d41e072ddd984eb749e99dafd560 Mon Sep 17 00:00:00 2001 From: Timofey Boyko Date: Fri, 8 Dec 2023 13:16:59 +0300 Subject: [PATCH] Client:PortalSettings:OAuth2: add disable application dialog --- packages/client/public/locales/en/OAuth.json | 4 + .../developer-tools/OAuth/OAuth.types.ts | 1 + .../developer-tools/OAuth/index.tsx | 5 + .../OAuth/sub-components/DisableDialog.tsx | 100 ++++++++++++++++++ packages/client/src/store/OAuthStore.ts | 23 +++- 5 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/DisableDialog.tsx diff --git a/packages/client/public/locales/en/OAuth.json b/packages/client/public/locales/en/OAuth.json index 39ab54c741..932636b8d7 100644 --- a/packages/client/public/locales/en/OAuth.json +++ b/packages/client/public/locales/en/OAuth.json @@ -17,6 +17,8 @@ "Creator": "Creator", "ClientHelpButton": "Credentials for using OAth 2.0 as your Authentication type.
Note: Any enterprise admin who knows the app's client ID will be able to retrieve information about the app including app name, authentication type, app scopes and redirect URI.", "CodeVerifier": "Code verifier", + "DisableApplication": "Disable application", + "DisableApplicationDescription": "If you disable this application, all active consents will be revoked. If necessary, you can later enable the disabled application.
Note that all users will again be required to complete the consent screen.", "EditApp": "Edit application", "EnterDescription": "Enter description", "ErrorName": "Minimal name length:", @@ -40,6 +42,8 @@ "RedirectsURLSHelpButton": "After a user successfully authorizes an application, the authorization server will redirect the user back to the application with sensitive information.", "RegisterNewApp": "Register a new application", "Reset": "Reset", + "ResetHeader": "Reset client secret", + "ResetDescription": "If you reset client secret, all active consents will be revoked. For apply next consent need use new client secret.
Note that all users will again be required to complete the consent screen.", "Revoke": "Revoke", "RevokeConsent": "Revoke consent", "RevokeConsentDescription": "Once you revoke the consent to use the ONLYOFFICE DocSpace auth data in the service {{name}}, ONLYOFFICE DocSpace will automatically stop logging into {{name}}. Your account in {{name}} will not be deleted.", diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/OAuth.types.ts b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/OAuth.types.ts index 209a60c2c3..917b0b2c53 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/OAuth.types.ts +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/OAuth.types.ts @@ -18,6 +18,7 @@ export interface OAuthProps { infoDialogVisible?: boolean; previewDialogVisible?: boolean; + disableDialogVisible?: boolean; isInit: boolean; setIsInit: (value: boolean) => void; } diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/index.tsx b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/index.tsx index b3e471ecdf..7abca1e004 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/index.tsx +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/index.tsx @@ -17,6 +17,7 @@ import { OAuthProps } from "./OAuth.types"; import InfoDialog from "./sub-components/InfoDialog"; import PreviewDialog from "./sub-components/PreviewDialog"; import OAuthLoader from "./sub-components/List/Loader"; +import DisableDialog from "./sub-components/DisableDialog"; const MIN_LOADER_TIME = 500; @@ -32,6 +33,7 @@ const OAuth = ({ previewDialogVisible, isInit, setIsInit, + disableDialogVisible, }: OAuthProps) => { const { t } = useTranslation(["OAuth"]); @@ -97,6 +99,7 @@ const OAuth = ({ )} {infoDialogVisible && } + {disableDialogVisible && } {previewDialogVisible && } ); @@ -116,6 +119,7 @@ export default inject( previewDialogVisible, isInit, setIsInit, + disableDialogVisible, } = oauthStore; return { viewAs, @@ -129,6 +133,7 @@ export default inject( fetchScopes, isInit, setIsInit, + disableDialogVisible, }; } )(observer(OAuth)); diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/DisableDialog.tsx b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/DisableDialog.tsx new file mode 100644 index 0000000000..b7ce9d29ed --- /dev/null +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/DisableDialog.tsx @@ -0,0 +1,100 @@ +import React from "react"; +import { inject, observer } from "mobx-react"; +import { useTranslation, Trans } from "react-i18next"; + +// @ts-ignore +import ModalDialog from "@docspace/components/modal-dialog"; +// @ts-ignore +import Button from "@docspace/components/button"; +// @ts-ignore +import toastr from "@docspace/components/toast/toastr"; + +// @ts-ignore +import { OAuthStoreProps } from "SRC_DIR/store/OAuthStore"; + +interface DisableClientDialog { + isVisible?: boolean; + onClose?: () => void; + onDisable?: () => Promise; +} + +const DisableClientDialog = (props: DisableClientDialog) => { + const { t, ready } = useTranslation(["OAuth", "Common"]); + const { isVisible, onClose, onDisable } = props; + + const [isRequestRunning, setIsRequestRunning] = React.useState(false); + + const onDisableClick = async () => { + try { + setIsRequestRunning(true); + await onDisable?.(); + + setIsRequestRunning(true); + onClose?.(); + } catch (error) { + toastr.error(error); + onClose?.(); + } + }; + + return ( + + {t("DisableApplication")} + + + + +