Skip to content

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

fix: issue batch action text (#12919)

ecmadao18913664c707
diff --git a/frontend/src/components/IssueV1/components/BatchIssueActionsV1.vue b/frontend/src/components/IssueV1/components/BatchIssueActionsV1.vue
index a97aaf4762..d0bbb41310 100644
--- a/frontend/src/components/IssueV1/components/BatchIssueActionsV1.vue
+++ b/frontend/src/components/IssueV1/components/BatchIssueActionsV1.vue
@@ -67,7 +67,6 @@
<script lang="ts" setup>
import type { PropType } from "vue";
import { computed, reactive, ref } from "vue";
-import { useI18n } from "vue-i18n";
import { TooltipButton } from "@/components/v2";
import { refreshIssueList } from "@/store";
import type { ComposedIssue } from "@/types";
@@ -93,8 +92,6 @@ const state = reactive<LocalState>({
isRequesting: false,
});
-const { t } = useI18n();
-
const ongoingIssueStatusAction = ref<{
action: IssueStatusAction;
title: string;
@@ -122,10 +119,7 @@ const handleUpdated = () => {
const startBatchIssueStatusAction = (action: IssueStatusAction) => {
ongoingIssueStatusAction.value = {
action,
- title: t("issue.batch-transition.action-n-issues", {
- action: issueStatusActionDisplayName(action),
- n: props.issueList.length,
- }),
+ title: issueStatusActionDisplayName(action, props.issueList.length),
};
};
</script>
diff --git a/frontend/src/components/IssueV1/components/Panel/BatchIssueStatusActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/BatchIssueStatusActionPanel.vue
index cdd0b67cdd..09ac3ffc44 100644
--- a/frontend/src/components/IssueV1/components/Panel/BatchIssueStatusActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/BatchIssueStatusActionPanel.vue
@@ -97,10 +97,7 @@ const title = computed(() => {
const { action } = props;
if (!action) return "";
- return t("issue.batch-transition.action-n-issues", {
- action: issueStatusActionDisplayName(action),
- n: props.issueList.length,
- });
+ return issueStatusActionDisplayName(action, props.issueList.length);
});
const confirmButtonProps = computed(() => {
diff --git a/frontend/src/components/IssueV1/logic/action/issue.ts b/frontend/src/components/IssueV1/logic/action/issue.ts
index 0ef5ad637d..e9f5478076 100644
--- a/frontend/src/components/IssueV1/logic/action/issue.ts
+++ b/frontend/src/components/IssueV1/logic/action/issue.ts
@@ -63,15 +63,28 @@ export const getApplicableIssueStatusActionList = (
});
};
-export const issueStatusActionDisplayName = (action: IssueStatusAction) => {
+export const issueStatusActionDisplayName = (
+ action: IssueStatusAction,
+ count: number = 1
+) => {
+ let actionText = "";
switch (action) {
case "RESOLVE":
- return t("issue.status-transition.dropdown.resolve");
+ actionText = t("issue.batch-transition.resolve");
+ break;
case "CLOSE":
- return t("issue.status-transition.dropdown.close");
+ actionText = t("issue.batch-transition.close");
+ break;
case "REOPEN":
- return t("issue.status-transition.dropdown.reopen");
+ actionText = t("issue.batch-transition.reopen");
+ break;
+ default:
+ return "";
}
+ return t("issue.batch-transition.action-n-issues", {
+ action: actionText,
+ n: count,
+ });
};
export const issueStatusActionButtonProps = (
diff --git a/frontend/src/components/IssueV1/logic/transition.ts b/frontend/src/components/IssueV1/logic/transition.ts
deleted file mode 100644
index 899c3d8184..0000000000
--- a/frontend/src/components/IssueV1/logic/transition.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { useCurrentUserV1 } from "@/store";
-import type {
- ComposedIssue,
- IssueStatusTransitionType,
- IssueStatusTransition,
- ComposedUser,
-} from "@/types";
-import { ISSUE_STATUS_TRANSITION_LIST } from "@/types";
-import { IssueStatus } from "@/types/proto/v1/issue_service";
-import { Task_Status } from "@/types/proto/v1/rollout_service";
-import {
- isDatabaseChangeRelatedIssue,
- flattenTaskV1List,
- isGrantRequestIssue,
- activeTaskInRollout,
- hasProjectPermissionV2,
-} from "@/utils";
-import { extractReviewContext } from "./review";
-
-// The first transition in the list is the primary action and the rests are
-// the normal action. For now there are at most 1 primary 1 normal action.
-const APPLICABLE_ISSUE_ACTION_LIST: Map<
- IssueStatus,
- IssueStatusTransitionType[]
-> = new Map([
- [IssueStatus.OPEN, ["RESOLVE", "CANCEL"]],
- [IssueStatus.DONE, ["REOPEN"]],
- [IssueStatus.CANCELED, ["REOPEN"]],
-]);
-
-export const calcApplicableIssueStatusTransitionList = (
- issue: ComposedIssue
-): IssueStatusTransition[] => {
- const transitionTypeList: IssueStatusTransitionType[] = [];
- const currentUserV1 = useCurrentUserV1();
-
- if (allowUserToApplyIssueStatusTransition(issue, currentUserV1.value)) {
- const actions = APPLICABLE_ISSUE_ACTION_LIST.get(issue.status);
- if (actions) {
- transitionTypeList.push(...actions);
- }
- }
-
- const applicableTransitionList: IssueStatusTransition[] = [];
- transitionTypeList.forEach((type) => {
- const transition = ISSUE_STATUS_TRANSITION_LIST.get(type);
- if (!transition) return;
-
- if (type === "RESOLVE") {
- // If an issue is not "Approved" in review stage
- // it cannot be Resolved.
- if (!isIssueReviewDone(issue)) {
- return;
- }
- } else if (type === "REOPEN") {
- // Don't show the REOPEN button for request granting issues.
- if (isGrantRequestIssue(issue)) {
- return;
- }
- }
-
- if (isDatabaseChangeRelatedIssue(issue)) {
- const currentTask = activeTaskInRollout(issue.rolloutEntity);
- const flattenTaskList = flattenTaskV1List(issue.rolloutEntity);
- if (flattenTaskList.some((task) => task.status === Task_Status.RUNNING)) {
- // Disallow any issue status transition if some of the tasks are in RUNNING state.
- return;
- }
- if (type === "RESOLVE") {
- if (transition.type === "RESOLVE" && flattenTaskList.length > 0) {
- const lastTask = flattenTaskList[flattenTaskList.length - 1];
- // Don't display the RESOLVE action if the pipeline doesn't reach the
- // last task
- if (lastTask.uid !== currentTask.uid) {
- return;
- }
- // Don't display the RESOLVE action if the last task is not DONE.
- if (currentTask.status !== Task_Status.DONE) {
- return;
- }
- }
- }
- }
- applicableTransitionList.push(transition);
- });
- return applicableTransitionList;
-};
-
-const allowUserToApplyIssueStatusTransition = (
- issue: ComposedIssue,
- user: ComposedUser
-) => {
- // Allowed if the user has issues.update permission in the project
- if (hasProjectPermissionV2(issue.projectEntity, user, "bb.issues.update")) {
- return true;
- }
-
- // The creator can apply issue status transition
- if (user.name === issue.creatorEntity.name) {
- return true;
- }
-
- return false;
-};
-
-function isIssueReviewDone(issue: ComposedIssue) {
- const context = extractReviewContext(issue);
- return context.done.value;
-}
diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts
index b3b4853178..2ff0c26e80 100644
--- a/frontend/src/types/issue.ts
+++ b/frontend/src/types/issue.ts
@@ -19,47 +19,3 @@ export type IssueType =
| IssueTypeDataSource
| IssueTypeDatabase
| IssueTypeGrantRequest;
-
-export type IssueStatus = "OPEN" | "DONE" | "CANCELED";
-
-export type IssueStatusTransitionType = "RESOLVE" | "CANCEL" | "REOPEN";
-
-export interface IssueStatusTransition {
- type: IssueStatusTransitionType;
- to: IssueStatus;
- buttonName: string;
- buttonClass: string;
-}
-
-export const ISSUE_STATUS_TRANSITION_LIST: Map<
- IssueStatusTransitionType,
- IssueStatusTransition
-> = new Map([
- [
- "RESOLVE",
- {
- type: "RESOLVE",
- to: "DONE",
- buttonName: "issue.status-transition.dropdown.resolve",
- buttonClass: "btn-success",
- },
- ],
- [
- "CANCEL",
- {
- type: "CANCEL",
- to: "CANCELED",
- buttonName: "issue.status-transition.dropdown.cancel",
- buttonClass: "btn-normal",
- },
- ],
- [
- "REOPEN",
- {
- type: "REOPEN",
- to: "OPEN",
- buttonName: "issue.status-transition.dropdown.reopen",
- buttonClass: "btn-normal",
- },
- ],
-]);