Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Support database field type in output panel and task status transition form
天舟b5e14679e407
diff --git a/frontend/src/components/TaskStatusTransitionForm.vue b/frontend/src/components/TaskStatusTransitionForm.vueindex b558714ed9..d0699344b4 100644--- a/frontend/src/components/TaskStatusTransitionForm.vue+++ b/frontend/src/components/TaskStatusTransitionForm.vue@@ -10,26 +10,33 @@}}<span v-if="field.required" class="text-red-600">*</span></label></div>- <template v-if="fieldProvider(field)">- <router-link- :to="fieldProvider(field).link"- class="ml-2 normal-link"- >- {{ fieldProvider(field).title }}- </router-link>- </template></div><div class="sm:col-span-4 sm:col-start-1">- <div class="mt-1 flex rounded-md shadow-sm">- <input- type="text"- :name="field.id"- :id="field.id"- v-model="state.outputValueList[index]"- autocomplete="off"- class="w-full textfield"+ <template v-if="field.type == 'String'">+ <div class="mt-1 flex rounded-md shadow-sm">+ <input+ type="text"+ :name="field.id"+ :id="field.id"+ v-model="state.outputValueList[index]"+ autocomplete="off"+ class="w-full textfield"+ />+ </div>+ </template>+ <template v-if="field.type == 'Database'">+ <DatabaseSelect+ class="mt-1 w-64"+ :mode="'ENVIRONMENT'"+ :environmentId="environmentId"+ :selectedId="state.outputValueList[index]"+ @select-database-id="+ (databaseId) => {+ state.outputValueList[index] = databaseId;+ }+ "/>- </div>+ </template></div><div v-if="index == outputFieldList.length - 1" class="mt-4" /></template>@@ -82,13 +89,16 @@</template><script lang="ts">-import { computed, onMounted, reactive, ref, PropType } from "vue";+import { computed, onMounted, reactive, ref, watch, PropType } from "vue";import cloneDeep from "lodash-es/cloneDeep";-import { Task, TaskStatusTransition } from "../types";+import isEqual from "lodash-es/isEqual";+import DatabaseSelect from "../components/DatabaseSelect.vue";+import { DatabaseId, Task, TaskStatusTransition } from "../types";import {TaskField,TaskFieldReferenceProvider,TaskFieldReferenceProviderContext,+ TaskBuiltinFieldId,} from "../plugins";interface LocalState {@@ -117,18 +127,19 @@ export default {type: Object as PropType<TaskField[]>,},},- setup(props, ctx) {+ components: { DatabaseSelect },+ setup(props, { emit }) {const commentTextArea = ref("");const state = reactive<LocalState>({comment: "",- outputValueList: [],+ outputValueList: props.outputFieldList.map((field) =>+ cloneDeep(props.task.payload[field.id])+ ),});- onMounted(() => {- for (const field of props.outputFieldList) {- state.outputValueList.push(cloneDeep(props.task.payload[field.id]));- }+ const environmentId = computed(() => {+ return props.task.payload[TaskBuiltinFieldId.ENVIRONMENT];});const submitButtonStyle = computed(() => {@@ -155,24 +166,12 @@ export default {return true;});- const fieldProvider = (- field: TaskField- ): TaskFieldReferenceProvider | undefined => {- if (field.provider) {- return field.provider({- task: props.task,- field,- });- }- return undefined;- };-return {state,+ environmentId,commentTextArea,submitButtonStyle,allowSubmit,- fieldProvider,};},};diff --git a/frontend/src/plugins/task/DatabaseRequestTemplate.ts b/frontend/src/plugins/task/DatabaseRequestTemplate.tsindex 8a2b726463..cdfce08e76 100644--- a/frontend/src/plugins/task/DatabaseRequestTemplate.ts+++ b/frontend/src/plugins/task/DatabaseRequestTemplate.ts@@ -80,53 +80,6 @@ const template: TaskTemplate = {isEmpty: (value: string): boolean => {return isEmpty(value?.trim());},- provider: ({ task, field }: { task: Task; field: TaskField }) => {- const currentValue = task.payload[field.id];- console.log(currentValue);- if (!isEmpty(currentValue)) {- return {- title: "view database",- link: linkfy("DATABASE", currentValue),- };- }-- let title = "create database";- let link = "/db/new";- const databasePayload: DatabaseFieldPayload =- task.payload[TaskBuiltinFieldId.DATABASE];- if (!databasePayload.isNew) {- title = "assign database";- }-- const queryParamList: string[] = [];-- const environmentId = task.payload[TaskBuiltinFieldId.ENVIRONMENT];- if (environmentId) {- queryParamList.push(`environment=${environmentId}`);- }-- if (databasePayload.name) {- queryParamList.push(`name=${databasePayload.name}`);- }-- // If we are creating a new database, we always assign RW to the owner.- if (!databasePayload.isNew && databasePayload.readOnly) {- queryParamList.push(`readonly=true`);- }-- queryParamList.push(`owner=${task.creator.id}`);-- queryParamList.push(`task=${task.id}`);-- queryParamList.push(`from=${task.type}`);-- link += "?" + queryParamList.join("&");-- return {- title,- link,- };- },},],};diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.tsindex c36c361c18..5d95d05fdd 100644--- a/frontend/src/plugins/types.ts+++ b/frontend/src/plugins/types.ts@@ -64,13 +64,6 @@ export type TaskField = {isEmpty: (value: any) => boolean;// Placeholder displayed on UI.placeholder?: string;- // Provides the reference to the place where the field originates. e.g. the request database- // task requires to fill the data source field when resolving the task, while the data source value- // can be found in the data source / database page. This provider can return the relevant link to- // be displayed on the UI, which helps user navigate to the place to acquire the required info.- provider?: (- ctx: TaskFieldReferenceProviderContext- ) => TaskFieldReferenceProvider;};export const UNKNOWN_FIELD: TaskField = {diff --git a/frontend/src/views/TaskOutputPanel.vue b/frontend/src/views/TaskOutputPanel.vueindex 9b04873ffe..8b41da9a95 100644--- a/frontend/src/views/TaskOutputPanel.vue+++ b/frontend/src/views/TaskOutputPanel.vue@@ -12,13 +12,15 @@<div class="textlabel">{{ field.name }}<span v-if="field.required" class="text-red-600">*</span>- <template v-if="fieldProvider(field)">- <router-link- :to="fieldProvider(field).link"- class="ml-2 normal-link"- >- {{ fieldProvider(field).title }}- </router-link>+ <template v-if="allowEdit">+ <template v-if="field.type == 'Database'">+ <router-link+ :to="createDatabaseLink(field)"+ class="ml-2 normal-link"+ >+ (Create database)+ </router-link>+ </template></template></div><template v-if="field.type == 'String'">@@ -77,7 +79,10 @@</button></div></template>- <template v-if="field.type == 'Database'">+ <div+ v-if="field.type == 'Database'"+ class="flex flex-row items-center space-x-2"+ ><DatabaseSelectclass="mt-1 w-64":disabled="!allowEdit"@@ -90,7 +95,15 @@}"/>- </template>+ <template v-if="databaseLink(field)">+ <router-link+ :to="databaseLink(field)"+ class="ml-2 normal-link text-sm"+ >+ View+ </router-link>+ </template>+ </div></div></template></div>@@ -103,10 +116,12 @@ import { useRouter } from "vue-router";import isEqual from "lodash-es/isEqual";import { toClipboard } from "@soerenmartius/vue3-clipboard";import DatabaseSelect from "../components/DatabaseSelect.vue";+import { fullDatabaseUrl } from "../utils";import {TaskField,TaskFieldReferenceProvider,TaskBuiltinFieldId,+ DatabaseFieldPayload,} from "../plugins";import { DatabaseId, Task } from "../types";@@ -134,22 +149,14 @@ export default {const currentUser = computed(() => store.getters["auth/currentUser"]());+ const environmentId = computed(() => {+ return props.task.payload[TaskBuiltinFieldId.ENVIRONMENT];+ });+const fieldValue = (field: TaskField): string => {return props.task.payload[field.id];};- const fieldProvider = (- field: TaskField- ): TaskFieldReferenceProvider | undefined => {- if (field.provider) {- return field.provider({- task: props.task,- field,- });- }- return undefined;- };-const allowEdit = computed(() => {return (currentUser.value.id === props.task.assignee?.id &&@@ -161,9 +168,44 @@ export default {return link?.trim().length > 0;};- const environmentId = computed(() => {- return props.task.payload[TaskBuiltinFieldId.ENVIRONMENT];- });+ const createDatabaseLink = (field: TaskField) => {+ const queryParamList: string[] = [];++ if (environmentId.value) {+ queryParamList.push(`environment=${environmentId.value}`);+ }++ // The created database info is stored in the predefined field with id TaskBuiltinFieldId.DATABASE+ const databasePayload: DatabaseFieldPayload =+ props.task.payload[TaskBuiltinFieldId.DATABASE];+ if (databasePayload.name) {+ queryParamList.push(`name=${databasePayload.name}`);+ }++ // If we are creating a new database, we always assign RW to the owner.+ if (!databasePayload.isNew && databasePayload.readOnly) {+ queryParamList.push(`readonly=true`);+ }++ queryParamList.push(`owner=${props.task.creator.id}`);++ queryParamList.push(`task=${props.task.id}`);++ queryParamList.push(`from=${props.task.type}`);++ return "/db/new?" + queryParamList.join("&");+ };++ const databaseLink = (field: TaskField) => {+ const databaseId = fieldValue(field);+ if (databaseId) {+ const database = store.getters["database/databaseById"](databaseId);+ if (database) {+ return fullDatabaseUrl(database);+ }+ }+ return "";+ };const copyText = (field: TaskField) => {toClipboard(props.task.payload[field.id]).then(() => {@@ -200,11 +242,12 @@ export default {return {state,+ environmentId,fieldValue,- fieldProvider,allowEdit,isValidLink,- environmentId,+ createDatabaseLink,+ databaseLink,copyText,goToLink,trySaveCustomField,