Skip to content

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

feat: support --force option when archiving projects (#6766)

Liu Ji502f535315df
diff --git a/frontend/src/bbkit/BBAlert.vue b/frontend/src/bbkit/BBAlert.vue
index 936859171b..3352f489a8 100644
--- a/frontend/src/bbkit/BBAlert.vue
+++ b/frontend/src/bbkit/BBAlert.vue
@@ -86,6 +86,9 @@
</p>
</div>
</div>
+ <div class="sm:mt-0 sm:ml-14 sm:text-left">
+ <slot name="default" />
+ </div>
</div>
<div class="mt-5 flex flex-col space-y-4">
<div class="flex justify-end">
diff --git a/frontend/src/bbkit/BBButtonConfirm.vue b/frontend/src/bbkit/BBButtonConfirm.vue
index 461dcd7b27..dd3a7c5bcb 100644
--- a/frontend/src/bbkit/BBButtonConfirm.vue
+++ b/frontend/src/bbkit/BBButtonConfirm.vue
@@ -46,6 +46,7 @@
"
@cancel="state.showModal = false"
>
+ <slot name="default" />
</BBAlert>
</template>
diff --git a/frontend/src/components/Project/ProjectArchiveRestoreButton.vue b/frontend/src/components/Project/ProjectArchiveRestoreButton.vue
new file mode 100644
index 0000000000..2e00a0da2c
--- /dev/null
+++ b/frontend/src/components/Project/ProjectArchiveRestoreButton.vue
@@ -0,0 +1,87 @@
+<template>
+ <template v-if="allowArchiveOrRestore">
+ <template v-if="project.state === State.ACTIVE">
+ <BBButtonConfirm
+ :style="'ARCHIVE'"
+ :button-text="$t('project.settings.archive.btn-text')"
+ :ok-text="$t('common.archive')"
+ :confirm-title="
+ $t('project.settings.archive.title') + ` '${project.title}'?`
+ "
+ :confirm-description="$t('project.settings.archive.description')"
+ :require-confirm="true"
+ @confirm="archiveOrRestoreProject(true)"
+ >
+ <div class="mt-3">
+ <NCheckbox v-model:checked="force">
+ <div class="text-sm font-normal text-control-light">
+ {{ $t("project.settings.archive.force.description") }}
+ </div>
+ </NCheckbox>
+ </div>
+ </BBButtonConfirm>
+ </template>
+ <template v-else-if="project.state === State.DELETED">
+ <BBButtonConfirm
+ :style="'RESTORE'"
+ :button-text="$t('project.settings.restore.btn-text')"
+ :ok-text="$t('common.restore')"
+ :confirm-title="
+ $t('project.settings.restore.title') + ` '${project.title}'?`
+ "
+ :confirm-description="''"
+ :require-confirm="true"
+ @confirm="archiveOrRestoreProject(false)"
+ />
+ </template>
+ </template>
+</template>
+
+<script setup lang="ts">
+import { computed, ref } from "vue";
+
+import { useCurrentUserV1, useProjectV1Store } from "@/store";
+import { ComposedProject } from "@/types";
+import { State } from "@/types/proto/v1/common";
+import { hasPermissionInProjectV1, hasWorkspacePermissionV1 } from "@/utils";
+import { NCheckbox } from "naive-ui";
+
+const props = defineProps<{
+ project: ComposedProject;
+}>();
+
+const currentUserV1 = useCurrentUserV1();
+const projectV1Store = useProjectV1Store();
+
+const force = ref(false);
+
+const allowArchiveOrRestore = computed(() => {
+ if (
+ hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-project",
+ currentUserV1.value.userRole
+ )
+ ) {
+ return true;
+ }
+
+ if (
+ hasPermissionInProjectV1(
+ props.project.iamPolicy,
+ currentUserV1.value,
+ "bb.permission.project.manage-general"
+ )
+ ) {
+ return true;
+ }
+ return false;
+});
+
+const archiveOrRestoreProject = async (archive: boolean) => {
+ if (archive) {
+ await projectV1Store.archiveProject(props.project, force.value);
+ } else {
+ await projectV1Store.restoreProject(props.project);
+ }
+};
+</script>
diff --git a/frontend/src/components/ProjectSettingPanel.vue b/frontend/src/components/ProjectSettingPanel.vue
index f8a50a6e48..f4e8784624 100644
--- a/frontend/src/components/ProjectSettingPanel.vue
+++ b/frontend/src/components/ProjectSettingPanel.vue
@@ -3,50 +3,18 @@
<div class="divide-y divide-block-border space-y-6">
<ProjectGeneralSettingPanel :project="project" :allow-edit="allowEdit" />
</div>
- <template v-if="allowArchiveOrRestore">
- <template v-if="project.state === State.ACTIVE">
- <BBButtonConfirm
- :style="'ARCHIVE'"
- :button-text="$t('project.settings.archive.btn-text')"
- :ok-text="$t('common.archive')"
- :confirm-title="
- $t('project.settings.archive.title') + ` '${project.name}'?`
- "
- :confirm-description="$t('project.settings.archive.description')"
- :require-confirm="true"
- @confirm="archiveOrRestoreProject(true)"
- />
- </template>
- <template v-else-if="project.state === State.DELETED">
- <BBButtonConfirm
- :style="'RESTORE'"
- :button-text="$t('project.settings.restore.btn-text')"
- :ok-text="$t('common.restore')"
- :confirm-title="
- $t('project.settings.restore.title') + ` '${project.name}'?`
- "
- :confirm-description="''"
- :require-confirm="true"
- @confirm="archiveOrRestoreProject(false)"
- />
- </template>
- </template>
+ <ProjectArchiveRestoreButton :project="project" />
</div>
</template>
<script lang="ts" setup>
-import { computed, PropType } from "vue";
-import { hasPermissionInProjectV1, hasWorkspacePermissionV1 } from "../utils";
-import ProjectGeneralSettingPanel from "../components/Project/ProjectGeneralSettingPanel.vue";
-import {
- useCurrentUserV1,
- useGracefulRequest,
- useProjectV1Store,
-} from "@/store";
+import { PropType } from "vue";
+
import { ComposedProject } from "@/types";
-import { State } from "@/types/proto/v1/common";
+import ProjectGeneralSettingPanel from "./Project/ProjectGeneralSettingPanel.vue";
+import ProjectArchiveRestoreButton from "./Project/ProjectArchiveRestoreButton.vue";
-const props = defineProps({
+defineProps({
project: {
required: true,
type: Object as PropType<ComposedProject>,
@@ -56,39 +24,4 @@ const props = defineProps({
type: Boolean,
},
});
-
-const currentUserV1 = useCurrentUserV1();
-const projectV1Store = useProjectV1Store();
-
-const allowArchiveOrRestore = computed(() => {
- if (
- hasWorkspacePermissionV1(
- "bb.permission.workspace.manage-project",
- currentUserV1.value.userRole
- )
- ) {
- return true;
- }
-
- if (
- hasPermissionInProjectV1(
- props.project.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.manage-general"
- )
- ) {
- return true;
- }
- return false;
-});
-
-const archiveOrRestoreProject = (archive: boolean) => {
- useGracefulRequest(async () => {
- if (archive) {
- await projectV1Store.archiveProject(props.project);
- } else {
- await projectV1Store.restoreProject(props.project);
- }
- });
-};
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index b18a46b005..dba6922ff9 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1455,7 +1455,10 @@
"archive": {
"title": "Archive project",
"description": "Archived project will not be shown on the normal interface. You can click \"Archive\" on the bottom left to find and restore it.",
- "btn-text": "Archive this @.lower:{'common.project'}"
+ "btn-text": "Archive this @.lower:{'common.project'}",
+ "force": {
+ "description": "Force to archive. All releated issues will be resolved, and all related sheets will be deleted."
+ }
},
"restore": {
"title": "Restore project",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 6c110081e0..86c668b5d7 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1448,7 +1448,10 @@
"archive": {
"title": "Archivar proyecto",
"description": "El proyecto archivado no se mostrará en la interfaz normal. Puede hacer clic en \"Archivar\" en la parte inferior izquierda para encontrarlo y restaurarlo.",
- "btn-text": "Archivar este @.lower:{'common.project'}"
+ "btn-text": "Archivar este @.lower:{'common.project'}",
+ "force": {
+ "description": "Forzar a archivar. \nTodos los problemas relacionados se resolverán y todas las hojas relacionadas se eliminarán."
+ }
},
"restore": {
"title": "Restaurar proyecto",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index e5b5291df4..67514ec61f 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1450,7 +1450,10 @@
"archive": {
"title": "归档项目",
"description": "已归档的项目将不会显示在日常界面,您可以通过点击页面左下方的 \"归档\"来恢复。",
- "btn-text": "归档这个@:common.project"
+ "btn-text": "归档这个@:common.project",
+ "force": {
+ "description": "强制归档。所有关联的工单都将被解决,所有关联的工作表都将被删除。"
+ }
},
"restore": {
"title": "恢复项目",
diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.ts
index 7555d20184..707759ae03 100644
--- a/frontend/src/store/modules/v1/project.ts
+++ b/frontend/src/store/modules/v1/project.ts
@@ -125,9 +125,10 @@ export const useProjectV1Store = defineStore("project_v1", () => {
await upsertProjectMap([updated]);
return updated;
};
- const archiveProject = async (project: Project) => {
+ const archiveProject = async (project: Project, force = false) => {
await projectServiceClient.deleteProject({
name: project.name,
+ force,
});
project.state = State.DELETED;
await upsertProjectMap([project]);