Skip to content

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

feat(frontend): allow cancelling gh-ost sync tasks (#2950)

Liu Ji4b05cb504b66
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vue
index 8e46432afd..026a6de832 100644
--- a/frontend/src/components/Issue/IssueActivityPanel.vue
+++ b/frontend/src/components/Issue/IssueActivityPanel.vue
@@ -562,6 +562,9 @@ const actionIcon = (activity: Activity): ActionIconType => {
}
break;
}
+ case "CANCELED": {
+ return "cancel";
+ }
case "RUNNING": {
return "run";
}
diff --git a/frontend/src/components/Issue/StatusTransitionForm.vue b/frontend/src/components/Issue/StatusTransitionForm.vue
index 7e5d92a0fd..fcfd2d6606 100644
--- a/frontend/src/components/Issue/StatusTransitionForm.vue
+++ b/frontend/src/components/Issue/StatusTransitionForm.vue
@@ -104,7 +104,7 @@
class="btn-normal mt-3 px-4 py-2 sm:mt-0 sm:w-auto"
@click.prevent="$emit('cancel')"
>
- {{ $t("common.cancel") }}
+ {{ cancelText }}
</button>
<button
type="button"
@@ -113,7 +113,7 @@
:disabled="!allowSubmit"
@click.prevent="$emit('submit', state.comment)"
>
- {{ okText }}
+ {{ displayingOkText }}
</button>
</div>
</div>
@@ -127,6 +127,7 @@ import TaskCheckBar from "./TaskCheckBar.vue";
import { Issue, IssueStatusTransition, Task } from "@/types";
import { OutputField } from "@/plugins";
import { activeEnvironment, TaskStatusTransition } from "@/utils";
+import { useI18n } from "vue-i18n";
type CheckSummary = {
successCount: number;
@@ -171,6 +172,7 @@ export default defineComponent({
},
emits: ["submit", "cancel"],
setup(props) {
+ const { t } = useI18n();
const commentTextArea = ref("");
const state = reactive<LocalState>({
@@ -180,6 +182,16 @@ export default defineComponent({
),
});
+ const cancelText = computed(() => t("common.cancel"));
+ const displayingOkText = computed(() => {
+ if (props.okText === cancelText.value) {
+ // We don't want to see [Cancel] [Cancel]
+ // So fall back to [Cancel] [Confirm] if okText===cancelText
+ return t("common.confirm");
+ }
+ return props.okText;
+ });
+
const environmentId = computed(() => {
return activeEnvironment(props.issue.pipeline).id;
});
@@ -297,6 +309,8 @@ export default defineComponent({
return {
state,
+ cancelText,
+ displayingOkText,
environmentId,
showTaskCheckBar,
commentTextArea,
diff --git a/frontend/src/components/Issue/TaskStatusIcon.vue b/frontend/src/components/Issue/TaskStatusIcon.vue
index e679ffc52b..c8971c7979 100644
--- a/frontend/src/components/Issue/TaskStatusIcon.vue
+++ b/frontend/src/components/Issue/TaskStatusIcon.vue
@@ -41,6 +41,11 @@
>!</span
>
</template>
+ <template v-else-if="status === 'CANCELED'">
+ <heroicons-solid:minus-sm
+ class="w-6 h-6 rounded-full select-none bg-white border-2 border-gray-400 text-gray-400"
+ />
+ </template>
</div>
</template>
diff --git a/frontend/src/components/Issue/activity/ActionSentence.vue b/frontend/src/components/Issue/activity/ActionSentence.vue
index 690da5709a..8752a3be06 100644
--- a/frontend/src/components/Issue/activity/ActionSentence.vue
+++ b/frontend/src/components/Issue/activity/ActionSentence.vue
@@ -74,6 +74,10 @@ const renderActionSentence = () => {
str = t("activity.sentence.failed");
break;
}
+ case "CANCELED": {
+ str = t("activity.sentence.canceled");
+ break;
+ }
}
if (activity.creator.id != SYSTEM_BOT_ID) {
// If creator is not the robot (which means we do NOT use task name in the subject),
diff --git a/frontend/src/components/Issue/logic/GhostModeProvider.ts b/frontend/src/components/Issue/logic/GhostModeProvider.ts
index ce1876b62d..d795504d1f 100644
--- a/frontend/src/components/Issue/logic/GhostModeProvider.ts
+++ b/frontend/src/components/Issue/logic/GhostModeProvider.ts
@@ -79,6 +79,13 @@ export default defineComponent({
return false;
}
}
+ if (
+ task.type === "bb.task.database.schema.update.ghost.sync" &&
+ to === "CANCELED"
+ ) {
+ // CANCELing gh-ost sync task is allowed.
+ return true;
+ }
return baseAllowApplyTaskStatusTransition(task, to);
};
diff --git a/frontend/src/components/Issue/logic/base.ts b/frontend/src/components/Issue/logic/base.ts
index a533efd3e5..d7bedec7f6 100644
--- a/frontend/src/components/Issue/logic/base.ts
+++ b/frontend/src/components/Issue/logic/base.ts
@@ -9,6 +9,7 @@ import {
StageId,
Task,
TaskCreate,
+ TaskStatus,
} from "@/types";
import { useRoute, useRouter } from "vue-router";
import {
@@ -206,7 +207,13 @@ export const useBaseIssueLogic = (params: {
return true;
};
- const allowApplyTaskStatusTransition = () => {
+ const allowApplyTaskStatusTransition = (task: Task, to: TaskStatus) => {
+ if (to === "CANCELED") {
+ // All task types are not CANCELable by default.
+ // Might be overwritten by other issue logic providers.
+ return false;
+ }
+
// no extra logic by default
return true;
};
diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.ts
index a9e735d577..e17b8c28e7 100644
--- a/frontend/src/utils/pipeline.ts
+++ b/frontend/src/utils/pipeline.ts
@@ -204,7 +204,7 @@ const TASK_STATUS_TRANSITION_LIST: Map<
"CANCEL",
{
type: "CANCEL",
- to: "PENDING",
+ to: "CANCELED",
buttonName: "common.cancel",
buttonType: "NORMAL",
},
@@ -218,9 +218,10 @@ const APPLICABLE_TASK_TRANSITION_LIST: Map<
> = new Map([
["PENDING", []],
["PENDING_APPROVAL", ["APPROVE"]],
- ["RUNNING", []],
+ ["RUNNING", ["CANCEL"]],
["DONE", []],
["FAILED", ["RETRY"]],
+ ["CANCELED", []],
]);
export function applicableTaskTransition(