Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: double confirm (#7731)

Liu Ji9f1a2083a0f7
diff --git a/frontend/src/components/User/Settings/UserTable.vue b/frontend/src/components/User/Settings/UserTable.vue
index fc222f1548..5e4d11df77 100644
--- a/frontend/src/components/User/Settings/UserTable.vue
+++ b/frontend/src/components/User/Settings/UserTable.vue
@@ -134,12 +134,8 @@
:style="'ARCHIVE'"
:require-confirm="true"
:ok-text="$t('settings.members.action.deactivate')"
- :confirm-title="`${$t(
- 'settings.members.action.deactivate-confirm-title'
- )} '${user.title}'?`"
- :confirm-description="
- $t('settings.members.action.deactivate-confirm-description')
- "
+ :confirm-title="deactivateConfirmation(user).title"
+ :confirm-description="deactivateConfirmation(user).description"
@confirm="changeRowStatus(user, State.DELETED)"
/>
<BBButtonConfirm
@@ -165,13 +161,21 @@
@ok="resetServiceKey"
@cancel="state.showResetKeyAlert = false"
/>
+ <BBAlertDialog
+ ref="removeSelfOwnerDialog"
+ :style="'CRITICAL'"
+ :ok-text="$t('common.confirm')"
+ :title="$t('settings.members.remove-self-owner.title')"
+ :description="$t('settings.members.remove-self-owner.description')"
+ />
</template>
<script lang="ts" setup>
import { toClipboard } from "@soerenmartius/vue3-clipboard";
import { cloneDeep } from "lodash-es";
-import { computed, reactive } from "vue";
+import { computed, reactive, ref } from "vue";
import { useI18n } from "vue-i18n";
+import { BBAlertDialog } from "@/bbkit";
import { BBTableSectionDataSource } from "@/bbkit/types";
import { RoleSelect } from "@/components/v2";
import {
@@ -214,6 +218,7 @@ const props = defineProps<{
const { t } = useI18n();
const currentUserV1 = useCurrentUserV1();
const userStore = useUserStore();
+const removeSelfOwnerDialog = ref<InstanceType<typeof BBAlertDialog>>();
const hasRBACFeature = featureToRef("bb.feature.rbac");
@@ -336,7 +341,37 @@ const allowActivateMember = (user: User) => {
return allowEdit.value && user.state === State.DELETED;
};
-const changeRole = (user: User, role: UserRole) => {
+const deactivateConfirmation = (user: User) => {
+ const me = currentUserV1.value;
+ if (user.name === me.name && user.userRole === UserRole.OWNER) {
+ return {
+ title: t("settings.members.remove-self-owner.title"),
+ description: t("settings.members.remove-self-owner.description"),
+ };
+ }
+ return {
+ title: `${t("settings.members.action.deactivate-confirm-title")} '${
+ user.title
+ }'?`,
+ description: t("settings.members.action.deactivate-confirm-description"),
+ };
+};
+
+const changeRole = async (user: User, role: UserRole) => {
+ const me = currentUserV1.value;
+ if (user.name === me.name) {
+ if (user.userRole === UserRole.OWNER && role !== UserRole.OWNER) {
+ const dialog = removeSelfOwnerDialog.value;
+ if (!dialog) {
+ throw new Error("dialog is not loaded");
+ }
+ const result = await dialog.open();
+ if (!result) {
+ return;
+ }
+ }
+ }
+
const userPatch = cloneDeep(user);
userPatch.userRole = role;
userStore.updateUser({
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 726d1383b5..cc0ad4aadf 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -473,7 +473,11 @@
"reset-service-key-alert": "This action cannot be undone. The old key will stop working immediately. Are you sure you want to reset this service key?",
"service-key-copied": "Service Key copied to clipboard, please keep it in secret.",
"create-as-service-account": "Create as service account",
- "show-inactive": "Show inactive members"
+ "show-inactive": "Show inactive members",
+ "remove-self-owner": {
+ "title": "Are you sure to revoke OWNER from yourself?",
+ "description": "Please make sure the remaining OWNER(s) can sign in, otherwise, no one can manage users."
+ }
},
"im-integration": {
"enable": "Enable",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index dbbe479d3b..287624e828 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -472,7 +472,11 @@
"reset-service-key-alert": "Esta acción no se puede deshacer. La clave antigua dejará de funcionar de inmediato. ¿Está seguro de que desea restablecer esta clave de servicio?",
"service-key-copied": "Clave de Servicio copiada al portapapeles, por favor manténgala en secreto.",
"create-as-service-account": "Crear como cuenta de servicio",
- "show-inactive": "Mostrar miembros inactivos"
+ "show-inactive": "Mostrar miembros inactivos",
+ "remove-self-owner": {
+ "title": "¿Estás seguro de revocarte PROPIETARIO?",
+ "description": "Asegúrese de que los PROPIETARIOS restantes puedan iniciar sesión; de lo contrario, nadie podrá administrar los usuarios."
+ }
},
"im-integration": {
"enable": "Habilitar",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index d0253d434c..3702003f8e 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -470,7 +470,11 @@
"reset-service-key-alert": "旧 Service Key 将立即被重置,该操作不可逆。确定要重置 Service Key 吗?",
"service-key-copied": "Service Key 已复制,请勿泄漏",
"create-as-service-account": "创建为服务账号",
- "show-inactive": "查看未激活的成员"
+ "show-inactive": "查看未激活的成员",
+ "remove-self-owner": {
+ "title": "请确认您要移除您的 OWNER 角色。",
+ "description": "请确保剩下的 Owner 成员可以登录,否则就无人可以管理用户了。"
+ }
},
"im-integration": {
"enable": "启用",