Skip to content

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

Change stageProgress to stage, and stageProgressList to stageList

天舟ac9a7037b9d2
diff --git a/frontend/src/components/TaskTable.vue b/frontend/src/components/TaskTable.vue
index 9fa939e4e1..d8da782ab1 100644
--- a/frontend/src/components/TaskTable.vue
+++ b/frontend/src/components/TaskTable.vue
@@ -144,11 +144,11 @@ export default {
const router = useRouter();
const stageList = function (task: Task): BBStep[] {
- return task.stageProgressList.map((stageProgress) => {
+ return task.stageList.map((stage) => {
let stepStatus: BBStepStatus = "PENDING";
- switch (stageProgress.status) {
+ switch (stage.status) {
case "PENDING":
- if (activeStage(task).id === stageProgress.id) {
+ if (activeStage(task).id === stage.id) {
stepStatus = "PENDING_ACTIVE";
} else {
stepStatus = "PENDING";
@@ -168,7 +168,7 @@ export default {
break;
}
return {
- title: stageProgress.name,
+ title: stage.name,
status: stepStatus,
link: (): string => {
return `/task/${task.id}`;
diff --git a/frontend/src/miragejs/factories/task.js b/frontend/src/miragejs/factories/task.js
index 835a53aec0..f7855779c1 100644
--- a/frontend/src/miragejs/factories/task.js
+++ b/frontend/src/miragejs/factories/task.js
@@ -21,7 +21,7 @@ export default {
description() {
return faker.fake("{{lorem.paragraphs}}");
},
- stageProgressList() {
+ stageList() {
return [
{
id: "1",
diff --git a/frontend/src/miragejs/factories/taskPatch.js b/frontend/src/miragejs/factories/taskPatch.js
index 1ea223e9f4..27d215476b 100644
--- a/frontend/src/miragejs/factories/taskPatch.js
+++ b/frontend/src/miragejs/factories/taskPatch.js
@@ -18,7 +18,7 @@ export default {
assigneeId() {
return "200";
},
- stageProgress() {
+ stage() {
return [
{
id: "1",
diff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.js
index 488485bb14..2cfa9840f1 100644
--- a/frontend/src/miragejs/routes/index.js
+++ b/frontend/src/miragejs/routes/index.js
@@ -264,18 +264,18 @@ export default function routes() {
}
}
- if (attrs.stageProgress !== undefined) {
- const stage = task.stageProgressList.find(
- (item) => item.id == attrs.stageProgress.id
+ if (attrs.stage !== undefined) {
+ const stage = task.stageList.find(
+ (item) => item.id == attrs.stage.id
);
if (stage) {
changeList.push({
fieldId: [TaskBuiltinFieldId.STAGE, stage.id].join("."),
oldValue: stage.status,
- newValue: attrs.stageProgress.status,
+ newValue: attrs.stage.status,
});
- stage.status = attrs.stageProgress.status;
- attrs.stageProgressList = task.stageProgressList;
+ stage.status = attrs.stage.status;
+ attrs.stageList = task.stageList;
}
}
diff --git a/frontend/src/miragejs/seeds/index.ts b/frontend/src/miragejs/seeds/index.ts
index 21a118deac..e86271b51c 100644
--- a/frontend/src/miragejs/seeds/index.ts
+++ b/frontend/src/miragejs/seeds/index.ts
@@ -1,4 +1,5 @@
import faker from "faker";
+import { Environment, Stage, Task } from "../../types";
import { instanceSlug, databaseSlug, taskSlug } from "../../utils";
/*
@@ -70,7 +71,7 @@ const workspacesSeeder = (server: any) => {
creatorId: ws1Dev1.id,
assigneeId: ws1Owner.id,
subscriberIdList: [ws1DBA.id, ws1Dev2.id],
- stageProgressList: [
+ stageList: [
{
id: "1",
name: "Request",
@@ -111,12 +112,18 @@ const workspacesSeeder = (server: any) => {
creatorId: ws1Dev1.id,
assigneeId: ws1Owner.id,
subscriberIdList: [ws1DBA.id, ws1Dev2.id],
- stageProgressList: [
+ stageList: [
{
id: "1",
name: "Request data source",
type: "SIMPLE",
status: "PENDING",
+ stepList: [
+ {
+ name: "Database name",
+ type: "DATABASE",
+ },
+ ],
},
],
payload: {
@@ -161,7 +168,7 @@ const workspacesSeeder = (server: any) => {
name: ws1Dev1.name,
},
subscriberIdList: [ws1DBA.id, ws1Dev2.id],
- ...fillStage(environmentList1),
+ ...fillTaskAndStageStatus(environmentList1),
workspace: workspace1,
});
@@ -190,7 +197,7 @@ const workspacesSeeder = (server: any) => {
creatorId: ws1Owner.id,
assigneeId: ws1DBA.id,
subscriberIdList: [ws1Dev2.id],
- ...fillStage(environmentList1),
+ ...fillTaskAndStageStatus(environmentList1),
workspace: workspace1,
});
@@ -222,7 +229,7 @@ const workspacesSeeder = (server: any) => {
creatorId: ws1Dev2.id,
assigneeId: ws1DBA.id,
subscriberIdList: [ws1Owner.id, ws1Dev1.id],
- ...fillStage(environmentList1),
+ ...fillTaskAndStageStatus(environmentList1),
workspace: workspace1,
});
@@ -249,7 +256,7 @@ const workspacesSeeder = (server: any) => {
type: "bytebase.database.schema.update",
creatorId: ws2Dev.id,
assigneeId: ws2DBA.id,
- ...fillStage(environmentList2),
+ ...fillTaskAndStageStatus(environmentList2),
workspace: workspace2,
});
@@ -273,12 +280,14 @@ const workspacesSeeder = (server: any) => {
});
};
-const fillStage = (environmentList: any[]) => {
+const fillTaskAndStageStatus = (
+ environmentList: Environment[]
+): Pick<Task, "status" | "stageList"> => {
const i = Math.floor(Math.random() * 5);
if (i % 5 == 0) {
return {
status: "OPEN",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: environmentList[0].name,
@@ -289,6 +298,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "PENDING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[0].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "2",
@@ -300,13 +315,19 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "PENDING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[1].name,
+ type: "EXECUTION",
+ },
+ ],
},
],
};
} else if (i % 5 == 1) {
return {
status: "OPEN",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: environmentList[0].name,
@@ -317,6 +338,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[0].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "2",
@@ -328,6 +355,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[1].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "3",
@@ -339,6 +372,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "RUNNING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[2].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "4",
@@ -350,13 +389,19 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "PENDING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[3].name,
+ type: "EXECUTION",
+ },
+ ],
},
],
};
} else if (i % 5 == 2) {
return {
status: "DONE",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: environmentList[0].name,
@@ -367,6 +412,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[0].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "2",
@@ -378,6 +429,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "SKIPPED",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[1].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "3",
@@ -389,6 +446,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[2].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "4",
@@ -400,13 +463,19 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[3].name,
+ type: "EXECUTION",
+ },
+ ],
},
],
};
} else if (i % 5 == 3) {
return {
status: "OPEN",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: environmentList[0].name,
@@ -417,6 +486,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[0].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "2",
@@ -428,6 +503,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "FAILED",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[1].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "3",
@@ -439,6 +520,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "PENDING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[2].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "4",
@@ -450,13 +537,19 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "PENDING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[3].name,
+ type: "EXECUTION",
+ },
+ ],
},
],
};
} else {
return {
status: "CANCELED",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: environmentList[0].name,
@@ -467,6 +560,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[0].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "2",
@@ -478,6 +577,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "SKIPPED",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[1].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "3",
@@ -489,6 +594,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "DONE",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[2].name,
+ type: "EXECUTION",
+ },
+ ],
},
{
id: "4",
@@ -500,6 +611,12 @@ const fillStage = (environmentList: any[]) => {
run: () => {},
},
status: "PENDING",
+ stepList: [
+ {
+ name: "Apply to " + environmentList[3].name,
+ type: "EXECUTION",
+ },
+ ],
},
],
};
diff --git a/frontend/src/plugins/task/DatabaseRequestTemplate.ts b/frontend/src/plugins/task/DatabaseRequestTemplate.ts
index cdfce08e76..4bf9d5252d 100644
--- a/frontend/src/plugins/task/DatabaseRequestTemplate.ts
+++ b/frontend/src/plugins/task/DatabaseRequestTemplate.ts
@@ -30,7 +30,7 @@ const template: TaskTemplate = {
name: "Request new database",
type: "bytebase.database.request",
description: "Estimated QPS: 10",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: "Request database",
diff --git a/frontend/src/plugins/task/DatabaseSchemaUpdateTemplate.ts b/frontend/src/plugins/task/DatabaseSchemaUpdateTemplate.ts
index 6342235e50..1b20e94391 100644
--- a/frontend/src/plugins/task/DatabaseSchemaUpdateTemplate.ts
+++ b/frontend/src/plugins/task/DatabaseSchemaUpdateTemplate.ts
@@ -18,7 +18,7 @@ const template: TaskTemplate = {
name: "Update Schema",
type: "bytebase.database.schema.update",
description: "DDL: ",
- stageProgressList: ctx.environmentList.map((env) => {
+ stageList: ctx.environmentList.map((env) => {
return {
id: env.id,
name: env.name,
diff --git a/frontend/src/plugins/task/template.ts b/frontend/src/plugins/task/template.ts
index 8fb0e3925f..d937b98c6e 100644
--- a/frontend/src/plugins/task/template.ts
+++ b/frontend/src/plugins/task/template.ts
@@ -18,7 +18,7 @@ const DEFAULT_TEMPLATE = {
name: "New General Task",
type: "bytebase.general",
description: "",
- stageProgressList: [
+ stageList: [
{
id: "1",
name: "Request",
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 55d7a3c780..6360ab7823 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -89,7 +89,7 @@ export const unknown = (
status: "OPEN",
type: "bytebase.general",
description: "",
- stageProgressList: [],
+ stageList: [],
creator: UNKNOWN_PRINCIPAL,
subscriberList: [],
payload: {},
@@ -246,14 +246,11 @@ export type Stage = {
id: StageId;
name: string;
type: StageType;
+ status: StageStatus;
environmentId?: EnvironmentId;
runnable?: StageRunnable;
};
-export type StageProgress = Stage & {
- status: StageStatus;
-};
-
export type StageProgressPatch = {
id: StageId;
status: StageStatus;
@@ -282,7 +279,7 @@ export type Task = {
status: TaskStatus;
type: TaskType;
description: string;
- stageProgressList: StageProgress[];
+ stageList: Stage[];
creator: Principal;
assignee?: Principal;
subscriberList: Principal[];
@@ -293,7 +290,7 @@ export type TaskNew = {
name: string;
type: TaskType;
description: string;
- stageProgressList: StageProgress[];
+ stageList: Stage[];
creatorId: PrincipalId;
assigneeId?: PrincipalId;
subscriberIdList: PrincipalId[];
@@ -305,7 +302,7 @@ export type TaskPatch = {
status?: TaskStatus;
description?: string;
assigneeId?: PrincipalId;
- stageProgress?: StageProgressPatch;
+ stage?: StageProgressPatch;
payload?: TaskPayload;
comment?: string;
};
diff --git a/frontend/src/utils/task.ts b/frontend/src/utils/task.ts
index d8095678be..b91080b2f4 100644
--- a/frontend/src/utils/task.ts
+++ b/frontend/src/utils/task.ts
@@ -1,28 +1,28 @@
-import { Task, StageId, StageProgress, EnvironmentId } from "../types";
+import { Task, StageId, Stage, EnvironmentId } from "../types";
import { templateForType } from "../plugins";
export function stageName(task: Task, stageId: StageId): string {
- for (const stageProgress of task.stageProgressList) {
- if (stageProgress.id == stageId) {
- return stageProgress.name;
+ for (const stage of task.stageList) {
+ if (stage.id == stageId) {
+ return stage.name;
}
}
return "<<Unknown stage>>";
}
-export function activeStage(task: Task): StageProgress {
- for (const stageProgress of task.stageProgressList) {
+export function activeStage(task: Task): Stage {
+ for (const stage of task.stageList) {
if (
- stageProgress.status === "PENDING" ||
- stageProgress.status === "RUNNING" ||
+ stage.status === "PENDING" ||
+ stage.status === "RUNNING" ||
// "FAILED" is also a transient stage status, which requires user
// to take further action (e.g. Cancel, Skip, Retry)
- stageProgress.status === "FAILED"
+ stage.status === "FAILED"
) {
- return stageProgress;
+ return stage;
}
}
- return task.stageProgressList[task.stageProgressList.length - 1];
+ return task.stageList[task.stageList.length - 1];
}
export function activeStageIsRunning(task: Task): boolean {
@@ -30,9 +30,9 @@ export function activeStageIsRunning(task: Task): boolean {
}
export function activeEnvironmentId(task: Task): EnvironmentId | null {
- const stageProgress = activeStage(task);
- if (stageProgress.type === "ENVIRONMENT") {
- return stageProgress.environmentId!;
+ const stage = activeStage(task);
+ if (stage.type === "ENVIRONMENT") {
+ return stage.environmentId!;
}
const taskTemplate = templateForType(task.type);
if (taskTemplate) {
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index 38b3304908..13c90f1857 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -508,12 +508,9 @@ export default {
});
};
- const changeStageStatus = (
- stageProgress: StageProgressPatch,
- comment?: string
- ) => {
+ const changeStageStatus = (stage: StageProgressPatch, comment?: string) => {
patchTask({
- stageProgress,
+ stage,
comment,
});
};
@@ -568,7 +565,7 @@ export default {
});
const showTaskStageFlowBar = computed(() => {
- return !state.new && state.task.stageProgressList.length > 1;
+ return !state.new && state.task.stageList.length > 1;
});
const showTaskOutputPanel = computed(() => {
diff --git a/frontend/src/views/TaskStageFlow.vue b/frontend/src/views/TaskStageFlow.vue
index 63f783f688..45baa0875d 100644
--- a/frontend/src/views/TaskStageFlow.vue
+++ b/frontend/src/views/TaskStageFlow.vue
@@ -322,11 +322,11 @@ export default {
const currentUser = computed(() => store.getters["auth/currentUser"]());
const stageList = computed<FlowItem[]>(() => {
- return props.task.stageProgressList.map((stageProgress) => {
+ return props.task.stageList.map((stage) => {
return {
- id: stageProgress.id,
- title: stageProgress.name,
- status: stageProgress.status,
+ id: stage.id,
+ title: stage.name,
+ status: stage.status,
link: (): string => {
return `/task/${props.task.id}`;
},