Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: add confirm dialog for disable password login setting

Stevena6b09aa5b152
diff --git a/web/src/components/Settings/SystemSection.tsx b/web/src/components/Settings/SystemSection.tsx
index db7d15f09..5517779d2 100644
--- a/web/src/components/Settings/SystemSection.tsx
+++ b/web/src/components/Settings/SystemSection.tsx
@@ -9,6 +9,7 @@ import { WorkspaceSettingPrefix } from "@/store/v1";
import { WorkspaceGeneralSetting } from "@/types/proto/api/v2/workspace_setting_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { useTranslate } from "@/utils/i18n";
+import { showCommonDialog } from "../Dialog/CommonDialog";
import Icon from "../Icon";
import showUpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
@@ -72,14 +73,29 @@ const SystemSection = () => {
};
const handleDisablePasswordLoginChanged = async (value: boolean) => {
- const setting = { ...workspaceGeneralSetting, disallowPasswordLogin: value };
- await workspaceSettingServiceClient.setWorkspaceSetting({
- setting: {
- name: `${WorkspaceSettingPrefix}${WorkspaceSettingKey.WORKSPACE_SETTING_GENERAL}`,
- generalSetting: setting,
- },
- });
- setWorkspaceGeneralSetting(setting);
+ const updateSetting = async () => {
+ const setting = { ...workspaceGeneralSetting, disallowPasswordLogin: value };
+ await workspaceSettingServiceClient.setWorkspaceSetting({
+ setting: {
+ name: `${WorkspaceSettingPrefix}${WorkspaceSettingKey.WORKSPACE_SETTING_GENERAL}`,
+ generalSetting: setting,
+ },
+ });
+ setWorkspaceGeneralSetting(setting);
+ };
+ if (value) {
+ showCommonDialog({
+ title: "Confirm",
+ content: "Are you sure to disable password login?",
+ style: "danger",
+ dialogName: "disable-password-login-dialog",
+ onConfirm: async () => {
+ await updateSetting();
+ },
+ });
+ } else {
+ await updateSetting();
+ }
};
const handleUpdateCustomizedProfileButtonClick = () => {