Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Show environment info in the task table if the task extension field contains Environment field
Tianzhou Chende4796ad503b
diff --git a/frontend/src/components/TaskTable.vue b/frontend/src/components/TaskTable.vueindex 2544a80555..a60a72910b 100644--- a/frontend/src/components/TaskTable.vue+++ b/frontend/src/components/TaskTable.vue@@ -21,11 +21,7 @@</span></BBTableCell><BBTableCell class="w-24 table-cell">- {{- activeEnvironmentId(task)- ? environmentName(activeEnvironmentId(task))- : ""- }}+ {{ activeEnvironmentName(task) }}</BBTableCell><BBTableCell :leftPadding="1" class="w-auto">{{ task.attributes.name }}@@ -108,8 +104,13 @@ export default {dataSource: [],});- const environmentName = function (id: EnvironmentId) {- return store.getters["environment/environmentById"](id)?.attributes.name;+ const activeEnvironmentName = function (task: Task) {+ const id = activeEnvironmentId(task);+ if (id) {+ return store.getters["environment/environmentById"](id)?.attributes+ .name;+ }+ return "";};const router = useRouter();@@ -155,10 +156,9 @@ export default {return {state,- environmentName,+ activeEnvironmentName,stageList,humanize,- activeEnvironmentId,activeStage,clickTask,};diff --git a/frontend/src/miragejs/seeds/index.js b/frontend/src/miragejs/seeds/index.jsindex 0011e7e909..12527720d9 100644--- a/frontend/src/miragejs/seeds/index.js+++ b/frontend/src/miragejs/seeds/index.js@@ -60,6 +60,7 @@ const workspacesSeeder = (server) => {server.create("task", {type: "bytebase.general",+ name: "General Task",creator: {id: ws1Dev1.id,name: ws1Dev1.name,@@ -80,6 +81,34 @@ const workspacesSeeder = (server) => {workspace: workspace1,});+ server.create("task", {+ type: "bytebase.datasource.create",+ name: "Request data source for environment - " + environmentList1[1].name,+ creator: {+ id: ws1Dev1.id,+ name: ws1Dev1.name,+ },+ assignee: {+ id: ws1Owner.id,+ name: ws1Owner.name,+ },+ subscriberIdList: [ws1DBA.id, ws1Dev2.id],+ stageProgressList: [+ {+ id: "1",+ name: "Request data source",+ type: "ENVIRONMENT",+ status: "PENDING",+ environmentId: environmentList1[1].id,+ },+ ],+ payload: {+ 1: "db1",+ 2: environmentList1[1].id,+ },+ workspace: workspace1,+ });+for (let i = 0; i < 5; i++) {server.create("task", {creator: {diff --git a/frontend/src/plugins/task/template.ts b/frontend/src/plugins/task/template.tsindex 34147cf5dc..f2f8409708 100644--- a/frontend/src/plugins/task/template.ts+++ b/frontend/src/plugins/task/template.ts@@ -1,5 +1,5 @@import { TaskTemplate, TemplateContext } from "../types";-import { EnvironmentId, TaskNew } from "../../types";+import { EnvironmentId, TaskType, TaskNew } from "../../types";const allTaskTemplateList: TaskTemplate[] = [{@@ -41,7 +41,7 @@ const allTaskTemplateList: TaskTemplate[] = [{id: "1",name: "Request Data Source",- type: "ENVIRONMENT",+ type: "SIMPLE",status: "PENDING",},],@@ -142,6 +142,6 @@ const allTaskTemplateList: TaskTemplate[] = [},];-export function templateForType(type: string): TaskTemplate | undefined {+export function templateForType(type: TaskType): TaskTemplate | undefined {return allTaskTemplateList.find((template) => template.type === type);}diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.tsindex 90296ff3ae..e9847c66d3 100644--- a/frontend/src/types/bytebase.ts+++ b/frontend/src/types/bytebase.ts@@ -103,7 +103,7 @@ export type Task = ResourceObject & {export type TaskNew = Omit<ResourceObject, "id"> & {attributes: {name: string;- type: string;+ type: TaskType;content: string;stageProgressList: StageProgress[];creator: {diff --git a/frontend/src/utils/task.ts b/frontend/src/utils/task.tsindex 0b4228a33e..dad8e57894 100644--- a/frontend/src/utils/task.ts+++ b/frontend/src/utils/task.ts@@ -1,4 +1,5 @@import { Task, StageProgress, EnvironmentId } from "../types";+import { templateForType } from "../plugins";export function activeStage(task: Task): StageProgress {for (const stageProgress of task.attributes.stageProgressList) {@@ -26,5 +27,15 @@ export function activeEnvironmentId(task: Task): EnvironmentId | null {if (stageProgress.type === "ENVIRONMENT") {return stageProgress.environmentId!;}+ const taskTemplate = templateForType(task.attributes.type);+ if (taskTemplate) {+ const inputFieldList =+ taskTemplate.fieldList?.filter((item) => item.category === "INPUT") || [];+ for (const field of inputFieldList) {+ if (field.type === "Environment") {+ return task.attributes.payload[field.id];+ }+ }+ }return null;}diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vueindex dbff326bcb..1c6d76a3d0 100644--- a/frontend/src/views/Home.vue+++ b/frontend/src/views/Home.vue@@ -35,7 +35,7 @@ import TaskTable from "../components/TaskTable.vue";import { useStore } from "vuex";import { useRouter } from "vue-router";import { UserStateSymbol } from "../components/ProvideUser.vue";-import { activeStage } from "../utils";+import { activeEnvironmentId } from "../utils";import { User, Environment, Task } from "../types";interface LocalState {@@ -113,11 +113,7 @@ export default {}return list.filter((task) => {if (state.selectedEnvironment) {- const stage = activeStage(task);- return (- stage.type === "ENVIRONMENT" &&- stage.environmentId == state.selectedEnvironment.id- );+ return activeEnvironmentId(task) === state.selectedEnvironment.id;}return false;});diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vueindex 1f05578b30..999ec4fa71 100644--- a/frontend/src/views/TaskDetail.vue+++ b/frontend/src/views/TaskDetail.vue@@ -124,6 +124,7 @@ import {User,Task,TaskNew,+ TaskType,TaskPatch,TaskStatus,StageStatus,@@ -250,7 +251,7 @@ export default {});const newTaskemplateName =- (router.currentRoute.value.query.template as string) ||+ (router.currentRoute.value.query.template as TaskType) ||"bytebase.general";const newTaskTemplate = templateForType(newTaskemplateName);if (!newTaskTemplate) {