Skip to content

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

chore(iam): permissions for plan/issue/rollout (#18851)

ecmadaob674ae50ea47
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index ce002f5453..83a3d10e6d 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -5,12 +5,17 @@
<RolloutReadyLink v-if="shouldShowRolloutReadyLink" />
<!-- Primary action: special components for specific actions -->
- <CreateIssueButton v-if="primaryAction?.id === 'ISSUE_CREATE'" />
+ <CreateIssueButton
+ v-if="primaryAction?.id === 'ISSUE_CREATE'"
+ :disabled="isActionDisabled(primaryAction)"
+ :disabled-reason="getDisabledReason(primaryAction)"
+ />
<IssueReviewButton
v-else-if="primaryAction?.id === 'ISSUE_REVIEW'"
- :can-approve="context.permissions.canApprove"
- :can-reject="context.permissions.canReject"
+ :can-approve="context.permissions.isApprovalCandidate"
+ :can-reject="context.permissions.isApprovalCandidate"
:disabled="isActionDisabled(primaryAction)"
+ :disabled-reason="getDisabledReason(primaryAction)"
/>
<ExportArchiveDownloadAction
v-else-if="primaryAction?.id === 'EXPORT_DOWNLOAD'"
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue
index 8d2dc3a0e9..ba19ca84c5 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue
@@ -12,7 +12,7 @@
type="primary"
size="medium"
tag="div"
- :disabled="errors.length > 0 || loading"
+ :disabled="disabled || errors.length > 0 || loading"
:loading="loading"
>
{{ $t("plan.ready-for-review") }}
@@ -95,6 +95,11 @@ import type { Plan, Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import { Advice_Level } from "@/types/proto-es/v1/sql_service_pb";
import { extractIssueUID, extractProjectResourceName } from "@/utils";
+const props = defineProps<{
+ disabled: boolean;
+ disabledReason?: string;
+}>();
+
const { t } = useI18n();
const router = useRouter();
const { project } = useCurrentProjectV1();
@@ -125,6 +130,10 @@ watch(showPopover, (show) => {
const errors = computed(() => {
const list: string[] = [];
+ if (props.disabledReason) {
+ list.push(props.disabledReason);
+ }
+
// Check if all specs have valid statements
if (plan.value.specs.some((spec) => isSpecEmpty(spec))) {
list.push(t("plan.navigator.statement-empty"));
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/issue.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/issue.ts
index 0d4b75a8c7..b8ac1633d0 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/issue.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/issue.ts
@@ -17,15 +17,20 @@ export const ISSUE_CREATE: ActionDefinition = {
!ctx.isIssueOnly &&
ctx.plan.issue === "" &&
!ctx.plan.hasRollout &&
- ctx.planState === State.ACTIVE &&
- ctx.permissions.createIssue,
+ ctx.planState === State.ACTIVE,
isDisabled: (ctx) =>
+ !ctx.permissions.createIssue ||
ctx.validation.hasEmptySpec ||
ctx.validation.planChecksRunning ||
(ctx.validation.planChecksFailed && ctx.project.enforceSqlReview),
disabledReason: (ctx) => {
+ if (!ctx.permissions.createIssue) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.issues.create",
+ });
+ }
if (ctx.validation.hasEmptySpec) {
return t("plan.navigator.statement-empty");
}
@@ -79,13 +84,19 @@ export const ISSUE_STATUS_RESOLVE: ActionDefinition = {
(ctx.approvalStatus === Issue_ApprovalStatus.APPROVED ||
ctx.approvalStatus === Issue_ApprovalStatus.SKIPPED) &&
ctx.allTasksFinished &&
- ctx.plan.hasRollout &&
- ctx.permissions.updateIssue
+ ctx.plan.hasRollout
);
},
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.updateIssue,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.updateIssue) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.issues.update",
+ });
+ }
+ return undefined;
+ },
executeType: "panel:issue-status",
};
@@ -98,12 +109,17 @@ export const ISSUE_STATUS_CLOSE: ActionDefinition = {
priority: 90,
isVisible: (ctx) =>
- ctx.issueStatus === IssueStatus.OPEN &&
- !ctx.plan.hasRollout &&
- ctx.permissions.updateIssue,
+ ctx.issueStatus === IssueStatus.OPEN && !ctx.plan.hasRollout,
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.updateIssue,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.updateIssue) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.issues.update",
+ });
+ }
+ return undefined;
+ },
executeType: "panel:issue-status",
};
@@ -116,11 +132,17 @@ export const ISSUE_STATUS_REOPEN: ActionDefinition = {
priority: 20,
// Only show reopen for canceled issues, not for done/resolved issues
- isVisible: (ctx) =>
- ctx.issueStatus === IssueStatus.CANCELED && ctx.permissions.updateIssue,
+ isVisible: (ctx) => ctx.issueStatus === IssueStatus.CANCELED,
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.updateIssue,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.updateIssue) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.issues.update",
+ });
+ }
+ return undefined;
+ },
executeType: "panel:issue-status",
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/plan.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/plan.ts
index 58786d9353..4ecb061727 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/plan.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/plan.ts
@@ -13,11 +13,20 @@ export const PLAN_CLOSE: ActionDefinition = {
!ctx.isIssueOnly &&
ctx.plan.issue === "" &&
!ctx.plan.hasRollout &&
- ctx.planState === State.ACTIVE &&
- ctx.permissions.updatePlan,
+ ctx.planState === State.ACTIVE,
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.updatePlan,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.updatePlan) {
+ if (!ctx.isCreator) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.plans.update",
+ });
+ }
+ return t("common.only-creator-allowed-action");
+ }
+ return undefined;
+ },
executeType: "confirm-dialog",
confirmTitle: () => t("common.close"),
@@ -35,11 +44,20 @@ export const PLAN_REOPEN: ActionDefinition = {
!ctx.isIssueOnly &&
ctx.plan.issue === "" &&
!ctx.plan.hasRollout &&
- ctx.planState === State.DELETED &&
- ctx.permissions.updatePlan,
+ ctx.planState === State.DELETED,
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.updatePlan,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.updatePlan) {
+ if (!ctx.isCreator) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.plans.update",
+ });
+ }
+ return t("common.only-creator-allowed-action");
+ }
+ return undefined;
+ },
executeType: "confirm-dialog",
confirmTitle: () => t("common.reopen"),
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/rollout.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/rollout.ts
index 610ddf4258..1dc1c28749 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/rollout.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/actions/rollout.ts
@@ -17,14 +17,20 @@ export const ROLLOUT_CREATE: ActionDefinition = {
if (!ctx.issue) return false;
// Don't show create rollout when issue is closed
if (ctx.issueStatus === IssueStatus.CANCELED) return false;
- if (!ctx.permissions.createRollout) return false;
// Project setting validations are handled in RolloutCreatePanel
return true;
},
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.createRollout,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.createRollout) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.rollouts.create, bb.taskRuns.create",
+ });
+ }
+ return undefined;
+ },
executeType: "immediate",
};
@@ -41,19 +47,27 @@ export const ROLLOUT_START: ActionDefinition = {
if (ctx.hasDeferredRollout) {
if (!ctx.issue || !ctx.issueApproved) return false;
// Show if no rollout yet (will create it) or has startable tasks
- if (!ctx.rollout) return ctx.permissions.runTasks;
- return ctx.hasStartableTasks && ctx.permissions.runTasks;
+ if (!ctx.rollout) return true;
+ return ctx.hasStartableTasks;
}
// Regular plans: rollout must already exist
if (!ctx.rollout) return false;
if (!ctx.issueApproved) return false;
if (!ctx.hasDatabaseCreateOrExportTasks) return false;
if (!ctx.hasStartableTasks) return false;
- return ctx.permissions.runTasks;
+ return true;
},
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.runTasks,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.runTasks) {
+ if (ctx.isExportPlan) {
+ return t("common.only-creator-allowed-export");
+ }
+ return t("common.missing-required-permission");
+ }
+ return undefined;
+ },
executeType: "panel:rollout",
};
@@ -69,11 +83,18 @@ export const ROLLOUT_CANCEL: ActionDefinition = {
if (!ctx.rollout) return false;
if (!ctx.issueApproved) return false;
if (!ctx.hasRunningTasks) return false;
- return ctx.permissions.runTasks;
+ return true;
},
- isDisabled: () => false,
- disabledReason: () => undefined,
+ isDisabled: (ctx) => !ctx.permissions.runTasks,
+ disabledReason: (ctx) => {
+ if (!ctx.permissions.runTasks) {
+ return t("common.missing-required-permission", {
+ permissions: "bb.taskRuns.create",
+ });
+ }
+ return undefined;
+ },
executeType: "panel:rollout",
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/components/IssueReviewButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/components/IssueReviewButton.vue
index 77ef7f87fc..0ac6c7c0da 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/components/IssueReviewButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/components/IssueReviewButton.vue
@@ -190,10 +190,11 @@ import {
// Internal action type for the review button
type ReviewAction = "APPROVE" | "REJECT" | "COMMENT";
-defineProps<{
+const props = defineProps<{
canApprove: boolean;
canReject: boolean;
disabled?: boolean;
+ disabledReason?: string;
}>();
const { t } = useI18n();
@@ -208,8 +209,14 @@ const comment = ref("");
const selectedAction = ref<ReviewAction>("COMMENT");
const performActionAnyway = ref(false);
-// No errors that disable the main button currently
-const errors: string[] = [];
+// Errors that disable the main button
+const errors = computed(() => {
+ const list: string[] = [];
+ if (props.disabledReason) {
+ list.push(props.disabledReason);
+ }
+ return list;
+});
// Reset state when popover opens
watch(showPopover, (show) => {
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/context.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/context.ts
index 379d79a377..39e99960c3 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/context.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/context.ts
@@ -185,8 +185,6 @@ export function buildActionContext(input: ContextBuilderInput): ActionContext {
? currentUserEmail === extractUserId(issue.creator)
: hasProjectPermissionV2(project, "bb.taskRuns.create"),
isApprovalCandidate,
- canApprove: isApprovalCandidate,
- canReject: isApprovalCandidate,
};
// Compute validation state
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/types.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/types.ts
index 5015f2fc05..221ba90a6a 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/registry/types.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/registry/types.ts
@@ -52,8 +52,6 @@ export interface ActionPermissions {
createRollout: boolean;
runTasks: boolean;
isApprovalCandidate: boolean;
- canApprove: boolean;
- canReject: boolean;
}
export interface ActionValidation {
diff --git a/frontend/src/components/Plan/components/IssueReviewView/GrantRequestView/RequestDetailsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/GrantRequestView/RequestDetailsSection.vue
index f012e0d56e..2c808e995b 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/GrantRequestView/RequestDetailsSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/GrantRequestView/RequestDetailsSection.vue
@@ -18,6 +18,9 @@
<div v-if="requestRole" class="flex flex-col gap-y-2">
<span class="text-sm text-control-light">
{{ $t("common.permissions") }}
+ ({{
+ requestRole.permissions.length
+ }})
</span>
<div class="max-h-[10em] overflow-auto border rounded-sm p-2">
<p
diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vue
index ecaef58424..23964b2448 100644
--- a/frontend/src/components/ProjectDatabasesPanel.vue
+++ b/frontend/src/components/ProjectDatabasesPanel.vue
@@ -13,7 +13,10 @@
<PermissionGuardWrapper
v-slot="slotProps"
:project="project"
- :permissions="['bb.instances.list', 'bb.issues.create', 'bb.plans.create']"
+ :permissions="[
+ 'bb.instances.list',
+ ...PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
+ ]"
>
<NButton
type="primary"
@@ -74,6 +77,7 @@ import {
extractProjectResourceName,
getValueFromSearchParams,
getValuesFromSearchParams,
+ PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
} from "@/utils";
import AdvancedSearch from "./AdvancedSearch";
import { useCommonSearchScopeOptions } from "./AdvancedSearch/useCommonSearchScopeOptions";
diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
index b5a6930582..b47afa1e18 100644
--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
@@ -31,7 +31,12 @@
</div>
<div v-if="selectedRole" class="w-full flex flex-col gap-y-2">
<div class="flex items-center gap-x-1">
- <span>{{ $t("common.permissions") }}</span>
+ <span>
+ {{ $t("common.permissions") }}
+ ({{
+ selectedRole.permissions.length
+ }})
+ </span>
</div>
<div class="max-h-[10em] overflow-auto border rounded-sm p-2">
<p
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
index 247ebae912..a964f3dfbc 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
@@ -145,7 +145,12 @@ import {
DatabaseSchema$,
UpdateDatabaseRequestSchema,
} from "@/types/proto-es/v1/database_service_pb";
-import { extractProjectResourceName, generateIssueTitle } from "@/utils";
+import {
+ extractProjectResourceName,
+ generateIssueTitle,
+ PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE,
+ PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,
+} from "@/utils";
interface DatabaseAction {
icon: VNode;
@@ -418,12 +423,7 @@ const actions = computed((): DatabaseAction[] => {
selectedDatabaseNameList.value
);
},
- requiredPermissions: [
- "bb.issues.create",
- "bb.plans.create",
- "bb.rollouts.create",
- "bb.sheets.create",
- ],
+ requiredPermissions: [...PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE],
});
}
break;
@@ -437,11 +437,7 @@ const actions = computed((): DatabaseAction[] => {
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
click: () => generateMultiDb("bb.issue.database.data.export"),
- requiredPermissions: [
- "bb.issues.create",
- "bb.plans.create",
- "bb.rollouts.create",
- ],
+ requiredPermissions: [...PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE],
});
}
break;
diff --git a/frontend/src/components/v2/Select/RoleSelect.vue b/frontend/src/components/v2/Select/RoleSelect.vue
index eefc09d71b..400cdf65d2 100644
--- a/frontend/src/components/v2/Select/RoleSelect.vue
+++ b/frontend/src/components/v2/Select/RoleSelect.vue
@@ -3,7 +3,7 @@
v-bind="$attrs"
:value="value"
:multiple="multiple"
- :disabled="disabled"
+ :disabled="disabled || !hasPermission"
:clearable="clearable"
:options="availableRoleOptions"
:max-tag-count="'responsive'"
@@ -23,7 +23,7 @@
<script setup lang="tsx">
import type { SelectGroupOption, SelectOption } from "naive-ui";
-import { NSelect } from "naive-ui";
+import { NSelect, NTag } from "naive-ui";
import type { SelectBaseOption } from "naive-ui/lib/select/src/interface";
import { computed, ref } from "vue";
import FeatureBadge from "@/components/FeatureGuard/FeatureBadge.vue";
@@ -37,7 +37,11 @@ import {
} from "@/types";
import type { Role } from "@/types/proto-es/v1/role_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-import { displayRoleDescription, displayRoleTitle } from "@/utils";
+import {
+ displayRoleDescription,
+ displayRoleTitle,
+ hasWorkspacePermissionV2,
+} from "@/utils";
type RoleSelectOption = SelectOption & {
role: Role;
@@ -70,6 +74,7 @@ const emit = defineEmits<{
const roleStore = useRoleStore();
const showFeatureModal = ref(false);
const hasCustomRoleFeature = featureToRef(PlanFeature.FEATURE_CUSTOM_ROLES);
+const hasPermission = computed(() => hasWorkspacePermissionV2("bb.roles.list"));
const filterRole = (role: string) => {
if (!props.filter) {
@@ -130,8 +135,18 @@ const availableRoleOptions = computed(
}
);
-const renderTag = ({ option }: { option: SelectBaseOption }) => {
- return option.label as string;
+const renderTag = ({
+ option,
+ handleClose,
+}: {
+ option: SelectBaseOption;
+ handleClose: () => void;
+}) => {
+ return (
+ <NTag closable={!props.disabled} onClose={handleClose}>
+ {option.label as string}
+ </NTag>
+ );
};
const renderLabel = (option: SelectBaseOption & SelectGroupOption) => {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 5c3d98d672..4544a24e69 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -207,8 +207,10 @@
"view-details": "View details",
"force-verb": "Force {verb}",
"untitled": "Untitled",
- "missing-required-permission": "Missing required permissions",
+ "missing-required-permission": "Missing required permissions {permissions}",
"missing-required-permission-for-resource": "Missing required permissions for resource {resource}",
+ "only-creator-allowed-action": "Only the creator is allowed to take action",
+ "only-creator-allowed-export": "Only the creator is allowed to export",
"required-permission": "Required permissions",
"resource-not-found": "Resource not found",
"continue-anyway": "Continue anyway",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 3bb7778598..359aaa9020 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -207,8 +207,10 @@
"view-details": "Ver detalles",
"force-verb": "forzar {verbo}",
"untitled": "Intitulado",
- "missing-required-permission": "Faltan permisos requeridos",
+ "missing-required-permission": "Faltan permisos requeridos {permissions}",
"missing-required-permission-for-resource": "Faltan permisos requeridos para el recurso {resource}",
+ "only-creator-allowed-action": "Solo el creador puede realizar esta acción",
+ "only-creator-allowed-export": "Solo el creador puede exportar",
"required-permission": "Permisos necesarios",
"resource-not-found": "Recurso no encontrado",
"continue-anyway": "De todas maneras, continúe",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 39aab7435a..a22071cd0f 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -207,8 +207,10 @@
"view-details": "詳細を確認する",
"force-verb": "フォース{verb}",
"untitled": "名前のない",
- "missing-required-permission": "必要な権限がありません",
+ "missing-required-permission": "必要な権限がありません {permissions}",
"missing-required-permission-for-resource": "リソース {resource} に必要な権限がありません",
+ "only-creator-allowed-action": "この操作は作成者のみが実行できます",
+ "only-creator-allowed-export": "エクスポートは作成者のみが実行できます",
"required-permission": "必要な権限",
"resource-not-found": "リソースが見つかりません",
"continue-anyway": "まだ続けたい",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index c32c1fbb81..f526576244 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -207,8 +207,10 @@
"view-details": "Xem chi tiết",
"force-verb": "Buộc {verb}",
"untitled": "Không tiêu đề",
- "missing-required-permission": "Thiếu quyền cần thiết",
+ "missing-required-permission": "Thiếu quyền cần thiết {permissions}",
"missing-required-permission-for-resource": "Thiếu quyền cần thiết cho tài nguyên {resource}",
+ "only-creator-allowed-action": "Chỉ người tạo mới được phép thực hiện hành động này",
+ "only-creator-allowed-export": "Chỉ người tạo mới được phép xuất",
"required-permission": "Quyền hạn cần thiết",
"resource-not-found": "Không tìm thấy tài nguyên",
"continue-anyway": "Tiếp tục",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index a5d8a2fe3a..49e65aa1ef 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -207,8 +207,10 @@
"view-details": "查看详情",
"force-verb": "强制{verb}",
"untitled": "未命名",
- "missing-required-permission": "缺少必需的权限",
+ "missing-required-permission": "缺少必需的权限 {permissions}",
"missing-required-permission-for-resource": "缺少资源 {resource} 的必需权限",
+ "only-creator-allowed-action": "只有创建者才能执行此操作",
+ "only-creator-allowed-export": "只有创建者才能执行导出",
"required-permission": "所需权限",
"resource-not-found": "未找到请求的资源",
"continue-anyway": "仍要继续",
diff --git a/frontend/src/utils/iam/permission-utils.ts b/frontend/src/utils/iam/permission-utils.ts
index a518fffa7d..9d776abd47 100644
--- a/frontend/src/utils/iam/permission-utils.ts
+++ b/frontend/src/utils/iam/permission-utils.ts
@@ -1,15 +1,26 @@
-import { type ComposedDatabase } from "@/types";
+import type { ComposedDatabase, Permission } from "@/types";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { hasProjectPermissionV2 } from "./permission";
+export const PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE: Permission[] = [
+ "bb.plans.create",
+ "bb.sheets.create",
+];
+
+export const PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE: Permission[] = [
+ "bb.issues.create",
+ ...PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE,
+];
+
+export const PERMISSIONS_FOR_DATABASE_CREATE_ISSUE: Permission[] = [
+ ...PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,
+];
+
export const hasPermissionToCreateChangeDatabaseIssueInProject = (
project: Project
) => {
- return (
- hasProjectPermissionV2(project, "bb.issues.create") &&
- hasProjectPermissionV2(project, "bb.plans.create") &&
- hasProjectPermissionV2(project, "bb.rollouts.create") &&
- hasProjectPermissionV2(project, "bb.sheets.create")
+ return PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE.every((p) =>
+ hasProjectPermissionV2(project, p)
);
};
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index f85f99d110..09246a79d6 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -11,7 +11,10 @@
/>
<PermissionGuardWrapper
v-slot="slotProps"
- :permissions="['bb.instances.list', 'bb.issues.create', 'bb.plans.create']"
+ :permissions="[
+ 'bb.instances.list',
+ ...PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
+ ]"
>
<NButton
type="primary"
@@ -83,6 +86,7 @@ import {
extractProjectResourceName,
getValueFromSearchParams,
getValuesFromSearchParams,
+ PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
} from "@/utils";
interface LocalState {
diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vue
index bb377eb49c..0d3eb8a126 100644
--- a/frontend/src/views/ExportCenter/index.vue
+++ b/frontend/src/views/ExportCenter/index.vue
@@ -13,7 +13,9 @@
<PermissionGuardWrapper
v-slot="slotProps"
:project="specificProject"
- :permissions="['bb.issues.create', 'bb.plans.create', 'bb.rollouts.create']"
+ :permissions="[
+ ...PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE
+ ]"
>
<NButton
type="primary"
@@ -82,6 +84,7 @@ import { Issue_Type, IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import {
buildIssueFilterBySearchParams,
extractProjectResourceName,
+ PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,
type SearchParams,
type SearchScope,
type SearchScopeId,
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 3707791242..34a8860b20 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -25,7 +25,9 @@
<PermissionGuardWrapper
v-if="allowCreateDatabase"
v-slot="slotProps"
- :permissions="['bb.issues.create', 'bb.plans.create']"
+ :permissions="[
+ ...PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
+ ]"
>
<NButton
type="primary"
@@ -147,6 +149,7 @@ import {
getValuesFromSearchParams,
instanceV1HasCreateDatabase,
instanceV1Name,
+ PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
} from "@/utils";
const instanceHashList = ["overview", "databases", "users"] as const;
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
index 3663e56d84..4fb0e435fe 100644
--- a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
+++ b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
@@ -17,10 +17,7 @@
v-slot="slotProps"
:project="project"
:permissions="[
- 'bb.issues.create',
- 'bb.plans.create',
- 'bb.rollouts.create',
- 'bb.sheets.create',
+ ...PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE
]"
>
<NTooltip
@@ -81,6 +78,7 @@ import {
} from "@/store/modules/v1/common";
import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
+import { PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE } from "@/utils";
interface LocalState {
editing: boolean;