Skip to content

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

Support the Step and Stage with the real model object from their respective tables.

天舟e7eeb341ad46
diff --git a/frontend/src/miragejs/factories/index.js b/frontend/src/miragejs/factories/index.js
index 201ce93c7c..4550d0b2a1 100644
--- a/frontend/src/miragejs/factories/index.js
+++ b/frontend/src/miragejs/factories/index.js
@@ -7,6 +7,8 @@ import dataSource from "./dataSource";
import dataSourceMember from "./dataSourceMember";
import database from "./database";
import task from "./task";
+import stage from "./stage";
+import step from "./step";
import activity from "./activity";
import message from "./message";
import workspace from "./workspace";
@@ -33,6 +35,8 @@ export default {
...database,
...message,
...task,
+ ...stage,
+ ...step,
...activity,
...workspace,
diff --git a/frontend/src/miragejs/factories/stage.js b/frontend/src/miragejs/factories/stage.js
new file mode 100644
index 0000000000..ba1688b872
--- /dev/null
+++ b/frontend/src/miragejs/factories/stage.js
@@ -0,0 +1,32 @@
+import { Factory } from "miragejs";
+import faker from "faker";
+import { UNKNOWN_ID } from "../../types";
+
+export default {
+ stage: Factory.extend({
+ creatorId() {
+ return UNKNOWN_ID;
+ },
+ createdTs(i) {
+ return Date.now() - (i + 1) * 1800 * 1000;
+ },
+ updaterId() {
+ return UNKNOWN_ID;
+ },
+ lastUpdatedTs(i) {
+ return Date.now() - i * 3600 * 1000;
+ },
+ name(i) {
+ return faker.fake("{{lorem.sentence}}");
+ },
+ type() {
+ return "bytebase.stage.general";
+ },
+ status() {
+ return "PENDING";
+ },
+ databaseId() {
+ return UNKNOWN_ID;
+ },
+ }),
+};
diff --git a/frontend/src/miragejs/factories/step.js b/frontend/src/miragejs/factories/step.js
new file mode 100644
index 0000000000..561c43bf36
--- /dev/null
+++ b/frontend/src/miragejs/factories/step.js
@@ -0,0 +1,32 @@
+import { Factory } from "miragejs";
+import faker from "faker";
+import { UNKNOWN_ID } from "../../types";
+
+export default {
+ step: Factory.extend({
+ creatorId() {
+ return UNKNOWN_ID;
+ },
+ createdTs(i) {
+ return Date.now() - (i + 1) * 1800 * 1000;
+ },
+ updaterId() {
+ return UNKNOWN_ID;
+ },
+ lastUpdatedTs(i) {
+ return Date.now() - i * 3600 * 1000;
+ },
+ name(i) {
+ return faker.fake("{{lorem.sentence}}");
+ },
+ type() {
+ return "bytebase.step.unknown";
+ },
+ status() {
+ return "PENDING";
+ },
+ payload() {
+ return undefined;
+ },
+ }),
+};
diff --git a/frontend/src/miragejs/models/index.js b/frontend/src/miragejs/models/index.js
index 4aa12b42b1..c1dfcf1d4c 100644
--- a/frontend/src/miragejs/models/index.js
+++ b/frontend/src/miragejs/models/index.js
@@ -26,6 +26,8 @@ export default {
project: hasMany(),
projectMember: hasMany(),
task: hasMany(),
+ stage: hasMany(),
+ step: hasMany(),
environment: hasMany(),
instance: hasMany(),
database: hasMany(),
@@ -80,10 +82,27 @@ export default {
task: Model.extend({
workspace: belongsTo(),
project: belongsTo(),
+ stage: hasMany(),
+ step: hasMany(),
}),
taskNew: Model,
taskPatch: Model,
+ // Stage
+ stage: Model.extend({
+ workspace: belongsTo(),
+ task: belongsTo(),
+ }),
+ stagePatch: Model,
+
+ // Step
+ step: Model.extend({
+ workspace: belongsTo(),
+ task: belongsTo(),
+ stage: belongsTo(),
+ }),
+ stepPatch: Model,
+
// Environment
environment: Model.extend({
workspace: belongsTo(),
diff --git a/frontend/src/miragejs/seeds/index.ts b/frontend/src/miragejs/seeds/index.ts
index 1a52c47a04..8430b33320 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 from "../../store/modules/environment";
import {
Database,
Environment,
@@ -15,6 +16,9 @@ import {
StageId,
DatabaseId,
ProjectId,
+ PrincipalId,
+ TaskId,
+ StepStatus,
} from "../../types";
import { databaseSlug, taskSlug } from "../../utils";
@@ -167,6 +171,13 @@ const workspacesSeeder = (server: any) => {
}).models[0]
);
+ const databaseList2 = [];
+ databaseList2.push(
+ server.schema.databases.where((item: any) => {
+ return item.name != "*" && item.instanceId == instanceList2[0].id;
+ }).models[0]
+ );
+
// Task
let task = server.create("task", {
type: "bytebase.general",
@@ -179,15 +190,6 @@ const workspacesSeeder = (server: any) => {
updaterId: ws1Dev1.id,
assigneeId: ws1Owner.id,
subscriberIdList: [ws1DBA.id, ws1Dev2.id, ws1Dev1.id, ws1Owner.id],
- stageList: [
- {
- id: "1",
- name: "Request",
- type: "bytebase.stage.general",
- status: "PENDING",
- databaseId: databaseList1[0].id,
- },
- ],
payload: {
5: projectList1[0].id,
6: environmentList1[0].id,
@@ -197,6 +199,28 @@ const workspacesSeeder = (server: any) => {
workspace: workspace1,
});
+ let stage = server.create("stage", {
+ creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
+ name: "Stage 1",
+ type: "bytebase.stage.general",
+ status: "PENDING",
+ databaseId: databaseList1[0].id,
+ task,
+ workspace: workspace1,
+ });
+
+ server.create("step", {
+ creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
+ name: "Waiting approval",
+ type: "bytebase.step.approve",
+ status: "PENDING",
+ task,
+ stage,
+ workspace: workspace1,
+ });
+
const createdActivity = server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
@@ -356,15 +380,6 @@ const workspacesSeeder = (server: any) => {
updaterId: ws1Dev1.id,
assigneeId: ws1Owner.id,
subscriberIdList: [ws1DBA.id, ws1Dev2.id],
- stageList: [
- {
- id: "1",
- name: "Create database",
- type: "bytebase.stage.database.create",
- status: "PENDING",
- databaseId: databaseList1[1].id,
- },
- ],
payload: {
5: projectList1[1].id,
6: environmentList1[1].id,
@@ -374,6 +389,28 @@ const workspacesSeeder = (server: any) => {
workspace: workspace1,
});
+ stage = server.create("stage", {
+ creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
+ name: "Create database",
+ type: "bytebase.stage.database.create",
+ status: "PENDING",
+ databaseId: databaseList1[1].id,
+ task,
+ workspace: workspace1,
+ });
+
+ server.create("step", {
+ creatorId: ws1Dev1.id,
+ updaterId: ws1Dev1.id,
+ name: "Waiting approval",
+ type: "bytebase.step.approve",
+ status: "PENDING",
+ task,
+ stage,
+ workspace: workspace1,
+ });
+
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
@@ -439,8 +476,42 @@ const workspacesSeeder = (server: any) => {
return list[Math.floor(Math.random() * list.length)];
};
+ const statusSetList: {
+ taskStatus: TaskStatus;
+ stageStatusList: StageStatus[];
+ stepStatusList: StepStatus[];
+ }[] = [
+ {
+ taskStatus: "OPEN",
+ stageStatusList: ["PENDING"],
+ stepStatusList: ["PENDING"],
+ },
+ {
+ taskStatus: "OPEN",
+ stageStatusList: ["DONE", "DONE", "RUNNING", "PENDING"],
+ stepStatusList: ["DONE", "DONE", "RUNNING", "PENDING"],
+ },
+ {
+ taskStatus: "DONE",
+ stageStatusList: ["DONE", "SKIPPED", "DONE", "DONE"],
+ stepStatusList: ["DONE", "CANCELED", "DONE", "DONE"],
+ },
+ {
+ taskStatus: "OPEN",
+ stageStatusList: ["DONE", "FAILED", "PENDING", "PENDING"],
+ stepStatusList: ["DONE", "FAILED", "PENDING", "PENDING"],
+ },
+ {
+ taskStatus: "CANCELED",
+ stageStatusList: ["DONE", "SKIPPED", "DONE", "PENDING"],
+ stepStatusList: ["DONE", "CANCELED", "DONE", "PENDING"],
+ },
+ ];
+
for (let i = 0; i < 3; i++) {
const data = randomUpdateSchemaTaskName();
+ const statusSet =
+ statusSetList[Math.floor(Math.random() * statusSetList.length)];
task = server.create("task", {
name: data.title,
type: "bytebase.database.schema.update",
@@ -449,11 +520,22 @@ const workspacesSeeder = (server: any) => {
assigneeId: ws1Owner.id,
sql: data.sql,
subscriberIdList: [ws1DBA.id, ws1Dev2.id],
- ...fillTaskAndStageStatus(environmentList1, databaseList1),
+ status: statusSet.taskStatus,
project: projectList1[i],
workspace: workspace1,
});
+ createUpdateSchemaStage(
+ server,
+ workspace1.id,
+ task.id,
+ ws1Dev1.id,
+ environmentList1,
+ databaseList1,
+ statusSet.stageStatusList,
+ statusSet.stepStatusList
+ );
+
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
@@ -477,6 +559,8 @@ const workspacesSeeder = (server: any) => {
for (let i = 0; i < 3; i++) {
const data = randomUpdateSchemaTaskName();
+ const statusSet =
+ statusSetList[Math.floor(Math.random() * statusSetList.length)];
task = server.create("task", {
name: data.title,
type: "bytebase.database.schema.update",
@@ -485,11 +569,22 @@ const workspacesSeeder = (server: any) => {
assigneeId: ws1DBA.id,
sql: data.sql,
subscriberIdList: [ws1Dev2.id],
- ...fillTaskAndStageStatus(environmentList1, databaseList1),
+ status: statusSet.taskStatus,
project: projectList1[i],
workspace: workspace1,
});
+ createUpdateSchemaStage(
+ server,
+ workspace1.id,
+ task.id,
+ ws1Owner.id,
+ environmentList1,
+ databaseList1,
+ statusSet.stageStatusList,
+ statusSet.stepStatusList
+ );
+
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
@@ -513,6 +608,8 @@ const workspacesSeeder = (server: any) => {
for (let i = 0; i < 3; i++) {
const data = randomUpdateSchemaTaskName();
+ const statusSet =
+ statusSetList[Math.floor(Math.random() * statusSetList.length)];
task = server.create("task", {
name: data.title,
type: "bytebase.database.schema.update",
@@ -521,11 +618,22 @@ const workspacesSeeder = (server: any) => {
assigneeId: ws1DBA.id,
sql: data.sql,
subscriberIdList: [ws1Owner.id, ws1Dev1.id],
- ...fillTaskAndStageStatus(environmentList1, databaseList1),
+ status: statusSet.taskStatus,
project: projectList1[i],
workspace: workspace1,
});
+ createUpdateSchemaStage(
+ server,
+ workspace1.id,
+ task.id,
+ ws1Dev2.id,
+ environmentList1,
+ databaseList1,
+ statusSet.stageStatusList,
+ statusSet.stepStatusList
+ );
+
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
@@ -548,6 +656,8 @@ const workspacesSeeder = (server: any) => {
}
const data = randomUpdateSchemaTaskName();
+ const statusSet =
+ statusSetList[Math.floor(Math.random() * statusSetList.length)];
task = server.create("task", {
name: data.title,
type: "bytebase.database.schema.update",
@@ -555,11 +665,22 @@ const workspacesSeeder = (server: any) => {
updaterId: ws2Dev.id,
assigneeId: ws2DBA.id,
sql: data.sql,
- ...fillTaskAndStageStatus(environmentList2, databaseList1),
+ status: statusSet.taskStatus,
project: projectList2[0],
workspace: workspace2,
});
+ createUpdateSchemaStage(
+ server,
+ workspace2.id,
+ task.id,
+ ws2Dev.id,
+ environmentList2,
+ databaseList2,
+ ["PENDING"],
+ ["PENDING"]
+ );
+
server.create("activity", {
actionType: "bytebase.task.create",
containerId: task.id,
@@ -669,179 +790,49 @@ const createInstanceList = (
return instanceList;
};
-type TaskPartial = {
- status: TaskStatus;
- stageList: {
- id: StageId;
- name: string;
- type: StageType;
- databaseId: DatabaseId;
- status: StageStatus;
- }[];
-};
-
-const fillTaskAndStageStatus = (
+const createUpdateSchemaStage = (
+ server: any,
+ workspaceId: string,
+ taskId: TaskId,
+ creatorId: PrincipalId,
environmentList: Environment[],
- databaseList: Database[]
-): TaskPartial => {
- const type: StageType = "bytebase.stage.schema.update";
- const i = Math.floor(Math.random() * 5);
- if (i % 5 == 0) {
- return {
- status: "OPEN",
- stageList: [
- {
- id: "1",
- name: environmentList[0].name,
- type,
- databaseId: databaseList[0].id,
- status: "PENDING",
- },
- {
- id: "2",
- name: environmentList[1].name,
- type,
- databaseId: databaseList[1].id,
- status: "PENDING",
- },
- ],
- };
- } else if (i % 5 == 1) {
- return {
- status: "OPEN",
- stageList: [
- {
- id: "1",
- name: environmentList[0].name,
- type,
- databaseId: databaseList[0].id,
- status: "DONE",
- },
- {
- id: "2",
- name: environmentList[1].name,
- type,
- databaseId: databaseList[1].id,
- status: "DONE",
- },
- {
- id: "3",
- name: environmentList[2].name,
- type,
- databaseId: databaseList[2].id,
- status: "RUNNING",
- },
- {
- id: "4",
- name: environmentList[3].name,
- type,
- databaseId: databaseList[3].id,
- status: "PENDING",
- },
- ],
- };
- } else if (i % 5 == 2) {
- return {
- status: "DONE",
- stageList: [
- {
- id: "1",
- name: environmentList[0].name,
- type,
- databaseId: databaseList[0].id,
- status: "DONE",
- },
- {
- id: "2",
- name: environmentList[1].name,
- type,
- databaseId: databaseList[1].id,
- status: "SKIPPED",
- },
- {
- id: "3",
- name: environmentList[2].name,
- type,
- databaseId: databaseList[2].id,
- status: "DONE",
- },
- {
- id: "4",
- name: environmentList[3].name,
- type,
- databaseId: databaseList[3].id,
- status: "DONE",
- },
- ],
- };
- } else if (i % 5 == 3) {
- return {
- status: "OPEN",
- stageList: [
- {
- id: "1",
- name: environmentList[0].name,
- type,
- databaseId: databaseList[0].id,
- status: "DONE",
- },
- {
- id: "2",
- name: environmentList[1].name,
- type,
- databaseId: databaseList[1].id,
- status: "FAILED",
- },
- {
- id: "3",
- name: environmentList[2].name,
- type,
- databaseId: databaseList[2].id,
- status: "PENDING",
- },
- {
- id: "4",
- name: environmentList[3].name,
- type,
- databaseId: databaseList[3].id,
- status: "PENDING",
- },
- ],
- };
- } else {
- return {
- status: "CANCELED",
- stageList: [
- {
- id: "1",
- name: environmentList[0].name,
- type,
- databaseId: databaseList[0].id,
- status: "DONE",
- },
- {
- id: "2",
- name: environmentList[1].name,
- type,
- databaseId: databaseList[1].id,
- status: "SKIPPED",
- },
- {
- id: "3",
- name: environmentList[2].name,
- type,
- databaseId: databaseList[2].id,
- status: "DONE",
- },
- {
- id: "4",
- name: environmentList[3].name,
- type,
- databaseId: databaseList[3].id,
- status: "PENDING",
- },
- ],
- };
+ databaseList: Database[],
+ stageStatusList: StageStatus[],
+ stepStatusList: StepStatus[]
+) => {
+ for (let i = 0; i < stageStatusList.length; i++) {
+ const stage = server.create("stage", {
+ creatorId: creatorId,
+ updaterId: creatorId,
+ name: `${environmentList[i].name}`,
+ type: "bytebase.stage.schema.update",
+ status: stageStatusList[i],
+ databaseId: databaseList[i].id,
+ taskId,
+ workspaceId,
+ });
+
+ server.create("step", {
+ creatorId: creatorId,
+ updaterId: creatorId,
+ name: "Waiting approval",
+ type: "bytebase.step.approve",
+ status: stepStatusList[i],
+ taskId,
+ stage,
+ workspaceId,
+ });
+
+ server.create("step", {
+ creatorId: creatorId,
+ updaterId: creatorId,
+ name: `Update ${databaseList[i].name} schema`,
+ type: "bytebase.step.schema.udpate",
+ status: stepStatusList[i],
+ taskId,
+ stage,
+ workspaceId,
+ });
}
};
diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts
index b039c4f03a..72dbcfde3a 100644
--- a/frontend/src/store/index.ts
+++ b/frontend/src/store/index.ts
@@ -14,6 +14,8 @@ import principal from "./modules/principal";
import plan from "./modules/plan";
import auth from "./modules/auth";
import task from "./modules/task";
+import stage from "./modules/stage";
+import step from "./modules/step";
// Following states are persisted in local storage
import uistate from "./modules/uistate";
@@ -40,6 +42,8 @@ export const store: Store<any> = createStore({
plan,
auth,
task,
+ stage,
+ step,
uistate,
router,
command,
diff --git a/frontend/src/store/modules/stage.ts b/frontend/src/store/modules/stage.ts
new file mode 100644
index 0000000000..e10879e92e
--- /dev/null
+++ b/frontend/src/store/modules/stage.ts
@@ -0,0 +1,77 @@
+import { root } from "postcss";
+import {
+ ResourceIdentifier,
+ ResourceObject,
+ Stage,
+ StageState,
+ Step,
+} from "../../types";
+
+const state: () => StageState = () => ({});
+
+function convertPartial(
+ stage: ResourceObject,
+ includedList: ResourceObject[],
+ rootGetters: any
+): Omit<Stage, "Task"> {
+ const creator = rootGetters["principal/principalById"](
+ stage.attributes.creatorId
+ );
+ const updater = rootGetters["principal/principalById"](
+ stage.attributes.updaterId
+ );
+
+ const database = rootGetters["database/databaseById"](
+ stage.attributes.databaseId
+ );
+
+ const stepList: Step[] = [];
+ for (const item of includedList || []) {
+ if (
+ item.type == "step" &&
+ (item.relationships!.stage.data as ResourceIdentifier).id == stage.id
+ ) {
+ const step = rootGetters["step/convertPartial"](item);
+ stepList.push(step);
+ }
+ }
+
+ return {
+ ...(stage.attributes as Omit<
+ Stage,
+ "id" | "creator" | "updater" | "task" | "database" | "stepList"
+ >),
+ id: stage.id,
+ creator,
+ updater,
+ database,
+ stepList,
+ };
+}
+
+const getters = {
+ convertPartial: (
+ state: StageState,
+ getters: any,
+ rootState: any,
+ rootGetters: any
+ ) => (
+ stage: ResourceObject,
+ includedList: ResourceObject[]
+ ): Omit<Stage, "Task"> => {
+ // It's only called when task tries to convert itself. So we pass empty includedList here to avoid circular dependency.
+ return convertPartial(stage, includedList, rootGetters);
+ },
+};
+
+const actions = {};
+
+const mutations = {};
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ actions,
+ mutations,
+};
diff --git a/frontend/src/store/modules/step.ts b/frontend/src/store/modules/step.ts
new file mode 100644
index 0000000000..f42fe5f172
--- /dev/null
+++ b/frontend/src/store/modules/step.ts
@@ -0,0 +1,66 @@
+import {
+ ResourceIdentifier,
+ ResourceObject,
+ StepState,
+ Step,
+ Task,
+ Stage,
+} from "../../types";
+
+const state: () => StepState = () => ({});
+
+function convertPartial(
+ step: ResourceObject,
+ rootGetters: any
+): Omit<Step, "task" | "stage"> {
+ const creator = rootGetters["principal/principalById"](
+ step.attributes.creatorId
+ );
+ const updater = rootGetters["principal/principalById"](
+ step.attributes.updaterId
+ );
+
+ return {
+ ...(step.attributes as Omit<
+ Step,
+ "id" | "creator" | "updater" | "task" | "stage"
+ >),
+ id: step.id,
+ creator,
+ updater,
+ };
+}
+
+function convert(step: ResourceObject, rootGetters: any): Step {
+ const task: Task = rootGetters["task/taskById"](step.attributes.taskId);
+ const stage: Stage = rootGetters["stage/stageById"](step.attributes.stageId);
+ return {
+ ...convertPartial(step, rootGetters),
+ task,
+ stage,
+ };
+}
+
+const getters = {
+ convertPartial: (
+ state: StepState,
+ getters: any,
+ rootState: any,
+ rootGetters: any
+ ) => (step: ResourceObject): Omit<Step, "task" | "stage"> => {
+ // It's only called when task/stage tries to convert themselves. So we pass empty includedList here to avoid circular dependency.
+ return convertPartial(step, rootGetters);
+ },
+};
+
+const actions = {};
+
+const mutations = {};
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ actions,
+ mutations,
+};
diff --git a/frontend/src/store/modules/task.ts b/frontend/src/store/modules/task.ts
index e748f21dfa..df245de41c 100644
--- a/frontend/src/store/modules/task.ts
+++ b/frontend/src/store/modules/task.ts
@@ -34,15 +34,6 @@ function convert(
);
}
- const stageList: Stage[] = (task.attributes.stageList as any[])!.map(
- (item) => {
- return {
- ...item,
- database: rootGetters["database/databaseById"](item.databaseId),
- };
- }
- );
-
const subscriberList = (task.attributes.subscriberIdList as Principal[]).map(
(principalId) => {
return rootGetters["principal/principalById"](principalId);
@@ -53,9 +44,14 @@ function convert(
let project: Project = unknown("PROJECT") as Project;
project.id = projectId;
+ const stageList: Stage[] = [];
for (const item of includedList || []) {
- if (item.type == "project" && item.id == projectId) {
- project = rootGetters["project/convert"](item);
+ if (
+ item.type == "stage" &&
+ (item.relationships!.task.data as ResourceIdentifier).id == task.id
+ ) {
+ const stage = rootGetters["stage/convertPartial"](item, includedList);
+ stageList.push(stage);
}
}
@@ -97,19 +93,23 @@ const getters = {
const actions = {
async fetchTaskListForUser({ commit, rootGetters }: any, userId: UserId) {
- const data = (await axios.get(`/api/task?user=${userId}&include=project`))
- .data;
+ const data = (
+ await axios.get(`/api/task?user=${userId}&include=project,stage,step`)
+ ).data;
const taskList = data.data.map((task: ResourceObject) => {
return convert(task, data.included, rootGetters);
});
commit("setTaskListForUser", { userId, taskList });
+ console.log(taskList);
return taskList;
},
async fetchTaskListForProject({ rootGetters }: any, projectId: ProjectId) {
const data = (
- await axios.get(`/api/task?project=${projectId}&include=project`)
+ await axios.get(
+ `/api/task?project=${projectId}&include=project,stage,step`
+ )
).data;
const taskList = data.data.map((task: ResourceObject) => {
return convert(task, data.included, rootGetters);
@@ -120,7 +120,9 @@ const actions = {
},
async fetchTaskById({ commit, rootGetters }: any, taskId: TaskId) {
- const data = (await axios.get(`/api/task/${taskId}?include=project`)).data;
+ const data = (
+ await axios.get(`/api/task/${taskId}?include=project,stage,step`)
+ ).data;
const task = convert(data.data, data.included, rootGetters);
commit("setTaskById", {
taskId,
@@ -131,7 +133,7 @@ const actions = {
async createTask({ commit, rootGetters }: any, newTask: TaskNew) {
const data = (
- await axios.post(`/api/task?include=project`, {
+ await axios.post(`/api/task?include=project,stage,step`, {
data: {
type: "tasknew",
attributes: newTask,
@@ -159,7 +161,7 @@ const actions = {
}
) {
const data = (
- await axios.patch(`/api/task/${taskId}?include=project`, {
+ await axios.patch(`/api/task/${taskId}?include=project,stage,step`, {
data: {
type: "taskpatch",
attributes: taskPatch,
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 9da8e37606..d67c1bec6c 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -175,6 +175,10 @@ export const unknown = (
const UNKNOWN_STAGE: Stage = {
id: UNKNOWN_ID,
+ creator: UNKNOWN_PRINCIPAL,
+ createdTs: 0,
+ updater: UNKNOWN_PRINCIPAL,
+ lastUpdatedTs: 0,
name: "<<Unknown stage>>",
type: "bytebase.stage.general",
status: "PENDING",
@@ -184,6 +188,7 @@ export const unknown = (
const UNKNOWN_STEP: Step = {
id: UNKNOWN_ID,
+ task: UNKNOWN_TASK,
stage: UNKNOWN_STAGE,
creator: UNKNOWN_PRINCIPAL,
createdTs: 0,
@@ -695,6 +700,14 @@ export type StageRunnable = {
// THus stage can access both instance and environment info.
export type Stage = {
id: StageId;
+
+ // Standard fields
+ creator: Principal;
+ createdTs: number;
+ updater: Principal;
+ lastUpdatedTs: number;
+
+ // Domain specific fields
name: string;
type: StageType;
status: StageStatus;
@@ -786,6 +799,7 @@ export type Step = {
id: StepId;
// Related fields
+ task: Task;
stage: Stage;
// Standard fields
@@ -1361,6 +1375,10 @@ export interface TaskState {
taskById: Map<TaskId, Task>;
}
+export interface StageState {}
+
+export interface StepState {}
+
export interface ProjectState {
projectById: Map<ProjectId, Project>;
}