Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(frontend): migrate some bb.issues.updates permission checks to more detailed permission s (#10415)
Liu Ji4de927e4cc73
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vueindex fc88a688cb..04f7287409 100644--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue@@ -99,11 +99,12 @@ const issueStatusActionList = computed(() => {return getApplicableIssueStatusActionList(issue.value);});const forceRolloutActionList = computed((): ExtraActionOption[] => {+ // Still using role based permission checksif (currentUser.value.roles.includes(PresetRoleType.WORKSPACE_ADMIN) ||currentUser.value.roles.includes(PresetRoleType.WORKSPACE_DBA)) {- // Only for workspace Owners and DBAs.+ // Only for workspace admins and DBAs.return [];}diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButtonGroup.vueindex 6cf835f47d..1178cf6075 100644--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButtonGroup.vue+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButtonGroup.vue@@ -26,51 +26,4 @@ defineProps<{defineEmits<{(event: "perform-action", action: RolloutAction): void;}>();--// const issueLogic = useIssueLogic();-// const issue = issueLogic.issue as Ref<Issue>;--// const currentTask = computed(() => {-// if (!isDatabaseRelatedIssueType(issue.value.type)) {-// return undefined;-// }-// return issueLogic.activeTaskOfPipeline(issue.value.pipeline!);-// });--// const allowApplyTaskTransition = (transition: TaskStatusTransition) => {-// if (transition.to === "PENDING") {-// // "Approve" is disabled when the task checks are not ready.-// const summary = taskCheckRunSummary(currentTask.value);-// if (summary.runningCount > 0 || summary.errorCount > 0) {-// return false;-// }-// }-// return true;-// };--// const allowApplyTaskTransitionToStage = (transition: TaskStatusTransition) => {-// // Only available for the issue type of schema.update and data.update.-// const stage = currentTask.value?.stage;-// if (!stage) return false;--// // Only available when the stage has multiple tasks.-// if (stage.taskList.length <= 1) {-// return false;-// }--// // Available to apply a taskStatusTransition to the stage when the transition-// // type is also applicable to the stage.-// return (-// props.stageStatusTransitionList.findIndex(-// (t) => t.type === transition.type-// ) >= 0-// );-// };--// const onClickTaskStatusTransitionActionButton = (-// action: TaskStatusTransitionButtonAction-// ) => {-// const { transition, target } = action.params;-// emit("apply-task-transition", transition, target);-// };</script>diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckRunButton.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckRunButton.vueindex d8b9b7ddb8..7490278914 100644--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckRunButton.vue+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckRunButton.vue@@ -74,29 +74,6 @@ const actionList = computed(() => {taskList: [props.task],},});-- // TODO: never show 'run checks in current stage' by now- // since RolloutService.RunPlanChecks will actually run all plan checks- // for the entire plan-- // // Don't only show 'run checks in current stage' if we don't show 'run checks'- // // since that might be weird.- // const stage = stageForTask(issue.value, props.task);- // if (stage) {- // const taskListInStage = stage.tasks;- // const runnableTaskList = taskListInStage.filter((task) =>- // allowRunChecksForTask(task)- // );- // if (runnableTaskList.length > 1) {- // actionList.push({- // key: "RUN-CHECKS-IN-CURRENT-STAGE",- // text: t("task.run-checks-in-current-stage"),- // params: {- // taskList: runnableTaskList,- // },- // });- // }- // }}return actionList;});diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vueindex 6a48b5a8d6..3ddb97e6a1 100644--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue@@ -48,7 +48,7 @@ const allowRunChecks = computed(() => {// Allowing below users to run plan checks// - the creator of the issue// - the assignee of the issue- // - ones who have bb.issues.update permission in the project+ // - ones who have bb.planCheckRuns.run permission in the projectconst me = currentUser.value;if (extractUserResourceName(issue.value.creator) === me.email) {return true;@@ -57,7 +57,11 @@ const allowRunChecks = computed(() => {return true;}if (- hasProjectPermissionV2(issue.value.projectEntity, me, "bb.issues.update")+ hasProjectPermissionV2(+ issue.value.projectEntity,+ me,+ "bb.planCheckRuns.run"+ )) {return true;}diff --git a/frontend/src/components/IssueV1/components/Sidebar/Assignee/Assignee.vue b/frontend/src/components/IssueV1/components/Sidebar/Assignee/Assignee.vueindex 68b25252de..e6b2fb18fa 100644--- a/frontend/src/components/IssueV1/components/Sidebar/Assignee/Assignee.vue+++ b/frontend/src/components/IssueV1/components/Sidebar/Assignee/Assignee.vue@@ -154,6 +154,8 @@ const changeAssigneeUID = async (uid: string | undefined) => {};const filterAssignee = (user: User): boolean => {+ // Users can be assignee candidates only if they have permission to "See"+ // the issuereturn hasProjectPermissionV2(issue.value.projectEntity,user,diff --git a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vueindex 60578054dd..0a6042d25d 100644--- a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue+++ b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue@@ -143,7 +143,7 @@ const disallowEditReasons = computed(() => {hasProjectPermissionV2(issue.value.projectEntity,currentUser.value,- "bb.issues.update"+ "bb.plans.update")) {allow = true;diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.tsindex a25d35105e..a9b74c5db5 100644--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts@@ -86,7 +86,7 @@ export const provideIssueGhostContext = () => {!hasProjectPermissionV2(issue.value.projectEntity,me.value,- "bb.issues.update"+ "bb.plans.update")) {return [t("issue.error.you-don-have-privilege-to-edit-this-issue")];diff --git a/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/common.tsindex 8d602b342d..b57d64f256 100644--- a/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/common.ts+++ b/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/common.ts@@ -99,7 +99,7 @@ export const useRollbackContext = () => {return true;}- if (hasProjectPermissionV2(project.value, user, "bb.issues.update")) {+ if (hasProjectPermissionV2(project.value, user, "bb.plans.update")) {return true;}diff --git a/frontend/src/components/IssueV1/logic/action/task.ts b/frontend/src/components/IssueV1/logic/action/task.tsindex bfed5c3b83..396edfece0 100644--- a/frontend/src/components/IssueV1/logic/action/task.ts+++ b/frontend/src/components/IssueV1/logic/action/task.ts@@ -1,10 +1,9 @@import { ButtonProps } from "naive-ui";import { t } from "@/plugins/i18n";-import { ComposedIssue } from "@/types";+import { ComposedIssue, PresetRoleType } from "@/types";import { User } from "@/types/proto/v1/auth_service";import { IssueStatus } from "@/types/proto/v1/issue_service";import { Task, Task_Status, Task_Type } from "@/types/proto/v1/rollout_service";-import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";export type TaskRolloutAction =| "ROLLOUT" // NOT_STARTED -> PENDING@@ -130,23 +129,14 @@ export const allowUserToApplyTaskRolloutAction = (action: TaskRolloutAction,releaserCandidates: User[]) => {- if (extractUserResourceName(issue.assignee) === user.email) {- return true;- }-- if (hasProjectPermissionV2(issue.projectEntity, user, "bb.issues.update")) {- // Owners are always allowed to rollout issues.- return true;- }-- // Otherwise anyone might to be assignee can rollout the issue.- // if the rollout policy is "auto rollout", anyone in the project is allowed.+ // Special for workspace admins and DBAs+ // Still using role-based permission checksif (- releaserCandidates.findIndex((candidate) => candidate.name === user.name) >=- 0+ user.roles.includes(PresetRoleType.WORKSPACE_ADMIN) ||+ user.roles.includes(PresetRoleType.WORKSPACE_DBA)) {return true;}- return false;+ return releaserCandidates.some((candidate) => candidate.name === user.name);};diff --git a/frontend/src/components/IssueV1/logic/releaser.ts b/frontend/src/components/IssueV1/logic/releaser.tsindex 8d46617e8b..4b3119e247 100644--- a/frontend/src/components/IssueV1/logic/releaser.ts+++ b/frontend/src/components/IssueV1/logic/releaser.ts@@ -19,8 +19,8 @@ export const releaserCandidatesForIssue = (issue: ComposedIssue) => {);users.push(...projectMembers- .filter((user) => user.roleList.includes(releaserRole))- .map((user) => user.user)+ .filter((membership) => membership.roleList.includes(releaserRole))+ .map((membership) => membership.user));}if (releaserRole.startsWith("users/")) {diff --git a/frontend/src/components/IssueV1/logic/rollout.ts b/frontend/src/components/IssueV1/logic/rollout.tsindex fd9902fe7d..df5b34e781 100644--- a/frontend/src/components/IssueV1/logic/rollout.ts+++ b/frontend/src/components/IssueV1/logic/rollout.ts@@ -1,3 +1,4 @@+import { t } from "@/plugins/i18n";import { ComposedIssue } from "@/types";import { User } from "@/types/proto/v1/auth_service";import { IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";@@ -88,15 +89,15 @@ export const allowUserToEditStatementForTask = (// if not creating, we are allowed to edit sql statement only when:// - user is the creator- // - OR user has issues.update permission in the project+ // - OR user has plans.update permission in the projectdenyReasons.push(...isTaskEditable(issue, task));if (extractUserResourceName(issue.creator) !== user.email) {- if (- !hasProjectPermissionV2(issue.projectEntity, user, "bb.issues.update")- ) {- denyReasons.push("You don't have the privilege to edit this issue");+ if (!hasProjectPermissionV2(issue.projectEntity, user, "bb.plans.update")) {+ denyReasons.push(+ t("issue.error.you-don-have-privilege-to-edit-this-issue")+ );}}return denyReasons;