Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Expose templateForType method instead of all template list
Tianzhou Chenbc15b112d70a
diff --git a/frontend/src/plugins/task/template.ts b/frontend/src/plugins/task/template.tsindex 55712b5808..34147cf5dc 100644--- a/frontend/src/plugins/task/template.ts+++ b/frontend/src/plugins/task/template.ts@@ -1,7 +1,7 @@import { TaskTemplate, TemplateContext } from "../types";import { EnvironmentId, TaskNew } from "../../types";-export const taskTemplateList: TaskTemplate[] = [+const allTaskTemplateList: TaskTemplate[] = [{type: "bytebase.general",buildTask: (ctx: TemplateContext): TaskNew => {@@ -141,3 +141,7 @@ export const taskTemplateList: TaskTemplate[] = [],},];++export function templateForType(type: string): TaskTemplate | undefined {+ return allTaskTemplateList.find((template) => template.type === type);+}diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vueindex b81cedbebe..1f05578b30 100644--- a/frontend/src/views/TaskDetail.vue+++ b/frontend/src/views/TaskDetail.vue@@ -128,7 +128,7 @@ import {TaskStatus,StageStatus,} from "../types";-import { taskTemplateList, TaskField, TaskTemplate } from "../plugins";+import { templateForType, TaskField, TaskTemplate } from "../plugins";type StageTransitionType = "RUN" | "RETRY" | "CANCEL" | "SKIP";@@ -250,16 +250,16 @@ export default {});const newTaskemplateName =- router.currentRoute.value.query.template || "bytebase.general";- const newTaskTemplate = taskTemplateList.find(- (template) => template.type === newTaskemplateName- )!;+ (router.currentRoute.value.query.template as string) ||+ "bytebase.general";+ const newTaskTemplate = templateForType(newTaskemplateName);if (!newTaskTemplate) {store.dispatch("notification/pushNotification", {module: "bytebase",style: "CRITICAL",title: `Unknown template '${newTaskTemplate}'.`,});+ return;}const environmentList = computed(() => {@@ -289,9 +289,7 @@ export default {title: "",});- const taskTemplate = taskTemplateList.find(- (template) => template.type == state.task.attributes.type- )!;+ const taskTemplate = templateForType(state.task.attributes.type)!;const outputFieldList =taskTemplate.fieldList?.filter((item) => item.category == "OUTPUT") || [];