Skip to content

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

Patch task with stage progress

Tianzhou Chen195cc4319245
diff --git a/frontend/src/miragejs/factories/taskPatch.js b/frontend/src/miragejs/factories/taskPatch.js
index c47b349bc4..a2909155c5 100644
--- a/frontend/src/miragejs/factories/taskPatch.js
+++ b/frontend/src/miragejs/factories/taskPatch.js
@@ -18,6 +18,14 @@ export default {
name: "Jim Gray",
};
},
+ stageProgressList() {
+ return [
+ {
+ id: "1",
+ status: "RUNNING",
+ },
+ ];
+ },
payload() {
return {
type: "bytebase.datasource.create",
diff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.js
index 622f6586ca..50818d4e7c 100644
--- a/frontend/src/miragejs/routes/index.js
+++ b/frontend/src/miragejs/routes/index.js
@@ -92,9 +92,24 @@ export default function routes() {
this.patch("/task/:taskId", function (schema, request) {
const attrs = this.normalizedRequestAttrs("task-patch");
- return schema.tasks
- .find(request.params.taskId)
- .update({ ...attrs, lastUpdatedTs: Date.now() });
+ const task = schema.tasks.find(request.params.taskId);
+ if (task) {
+ attrs.stageProgressList = task.stageProgressList.map((item) => {
+ for (const stage of attrs.stageProgressList) {
+ if (item.id === stage.id) {
+ item.status = stage.status;
+ break;
+ }
+ }
+ return item;
+ });
+ return task.update({ ...attrs, lastUpdatedTs: Date.now() });
+ }
+ return new Response(
+ 404,
+ {},
+ { errors: "Task " + request.params.id + " not found" }
+ );
});
// environment
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 7a3ed2d0c1..779318499b 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -61,6 +61,11 @@ export type StageProgress = Stage & {
status: StageStatus;
};
+export type StageProgressPatch = {
+ id: StageId;
+ status: StageStatus;
+};
+
// Task
type TaskTypeGeneral = "bytebase.general";
@@ -121,6 +126,7 @@ export type TaskPatch = {
id: string;
name: string;
};
+ stageProgressList?: StageProgressPatch[];
payload?: any;
};
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index abad94f7bb..b0dce19a96 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -210,7 +210,7 @@ const TRANSITION_LIST: Transition[] = [
actionType: ActionType.NORMAL,
from: {
taskStatus: ["DONE", "CANCELED"],
- stageStatus: ["PENDING", "FAILED"],
+ stageStatus: ["PENDING", "DONE", "FAILED", "CANCELED"],
},
to: (from: WorkflowStatus) => {
return {
@@ -362,6 +362,12 @@ export default {
}
patchTask({
status: targetStatus.taskStatus,
+ stageProgressList: [
+ {
+ id: activeStage(state.task as Task).id,
+ status: targetStatus.stageStatus,
+ },
+ ],
});
};