Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Make fieldFromId return UNKNOWN_FIELD if not found in the field list.
天舟58d6b80f8d2d
diff --git a/frontend/src/plugins/task/template.ts b/frontend/src/plugins/task/template.tsindex 4b8d63069a..1a89631157 100644--- a/frontend/src/plugins/task/template.ts+++ b/frontend/src/plugins/task/template.ts@@ -5,6 +5,7 @@ import {TemplateContext,TaskBuiltinFieldId,DatabaseFieldPayload,+ UNKNOWN_FIELD,} from "../types";import { EnvironmentId, TaskType, TaskNew } from "../../types";import DatabaseRequestTemplate from "./DatabaseRequestTemplate";@@ -49,9 +50,11 @@ export function templateForType(type: TaskType): TaskTemplate | undefined {export function fieldFromId(template: TaskTemplate,fieldId: TaskFieldId-): TaskField | undefined {+): TaskField {if (template.fieldList) {- return template.fieldList.find((field) => field.id == fieldId);+ return (+ template.fieldList.find((field) => field.id == fieldId) || UNKNOWN_FIELD+ );}- return undefined;+ return UNKNOWN_FIELD;}diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.tsindex 3c3b0e00cc..c36c361c18 100644--- a/frontend/src/plugins/types.ts+++ b/frontend/src/plugins/types.ts@@ -1,4 +1,11 @@-import { Environment, Principal, TaskNew, Task, DatabaseId } from "../types";+import {+ Environment,+ Principal,+ TaskNew,+ Task,+ DatabaseId,+ UNKNOWN_ID,+} from "../types";// Taskexport type TaskFieldId = string;@@ -66,6 +73,16 @@ export type TaskField = {) => TaskFieldReferenceProvider;};+export const UNKNOWN_FIELD: TaskField = {+ category: "INPUT",+ id: UNKNOWN_ID,+ slug: "",+ name: "<<Unknown field>>",+ type: "String",+ required: false,+ isEmpty: () => true,+};+// Field payload for "Database" and "NewDatabase" fieldexport type DatabaseFieldPayload = {isNew: boolean;diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vueindex d520391a12..69563834ed 100644--- a/frontend/src/views/TaskActivityPanel.vue+++ b/frontend/src/views/TaskActivityPanel.vue@@ -484,31 +484,29 @@ export default {newValue = update.newValue;} else {const field = fieldFromId(props.taskTemplate, update.fieldId);- if (field) {- name = field.name;- if (field.type === "String") {- oldValue = update.oldValue;- newValue = update.newValue;- } else if (field.type === "Environment") {- if (update.oldValue) {- const environment: Environment = store.getters[- "environment/environmentById"- ](update.oldValue);- if (environment) {- oldValue = environment.name;- } else {- oldValue = "Unknown Environment";- }+ name = field.name;+ if (field.type === "String") {+ oldValue = update.oldValue;+ newValue = update.newValue;+ } else if (field.type === "Environment") {+ if (update.oldValue) {+ const environment: Environment = store.getters[+ "environment/environmentById"+ ](update.oldValue);+ if (environment) {+ oldValue = environment.name;+ } else {+ oldValue = "Unknown Environment";}- if (update.newValue) {- const environment: Environment = store.getters[- "environment/environmentById"- ](update.newValue);- if (environment) {- newValue = environment.name;- } else {- newValue = "Unknown Environment";- }+ }+ if (update.newValue) {+ const environment: Environment = store.getters[+ "environment/environmentById"+ ](update.newValue);+ if (environment) {+ newValue = environment.name;+ } else {+ newValue = "Unknown Environment";}}}