Skip to content

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

chore: disallow to click the trash button for the last owner role (#7721)

Liu Ji45f3c15b11f4
diff --git a/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue b/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue
index db67dc0348..cf90721566 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue
@@ -92,14 +92,24 @@
<div class="bb-grid-cell space-x-1">
<NTooltip v-if="allowAdmin" trigger="hover">
<template #trigger>
- <button
+ <NButton
+ tag="div"
+ text
class="cursor-pointer opacity-60 hover:opacity-100"
+ :disabled="!allowDeleteCondition(item)"
@click="handleDeleteCondition(item)"
>
<heroicons-outline:trash class="w-4 h-4" />
- </button>
+ </NButton>
+ </template>
+ <template #default>
+ <template v-if="!allowDeleteCondition(item)">
+ {{ $t("project.members.cannot-remove-last-owner") }}
+ </template>
+ <template v-else>
+ {{ $t("common.delete") }}
+ </template>
</template>
- {{ $t("common.delete") }}
</NTooltip>
</div>
</template>
@@ -354,6 +364,13 @@ const handleDeleteRole = (role: string) => {
});
};
+const allowDeleteCondition = (singleBinding: SingleBinding) => {
+ if (singleBinding.rawBinding.role === PresetRoleType.OWNER) {
+ return allowRemoveRole(PresetRoleType.OWNER);
+ }
+ return true;
+};
+
const handleDeleteCondition = async (singleBinding: SingleBinding) => {
const conditionName =
singleBinding.rawBinding.condition?.title ||