Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Add output field list to the resolve form
天舟37aae5920b29
diff --git a/frontend/src/components/TaskStatusTransitionForm.vue b/frontend/src/components/TaskStatusTransitionForm.vueindex 36ca70fb68..3ae5ebefb0 100644--- a/frontend/src/components/TaskStatusTransitionForm.vue+++ b/frontend/src/components/TaskStatusTransitionForm.vue@@ -1,15 +1,37 @@<template><div class="px-4 space-y-6 divide-y divide-gray-200">- <div class="mt-4 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6">- <div class="sm:col-span-6">- <label for="about" class="block text-sm font-medium text-gray-700">- Note- </label>+ <div class="mt-2 grid grid-cols-1 gap-x-4 sm:grid-cols-4">+ <template v-if="transition.type == 'RESOLVE'">+ <template v-for="(field, index) in outputFieldList" :key="index">+ <div class="sm:col-span-1">+ <label class="textlabel">+ {{ field.name+ }}<span v-if="field.required" class="text-red-600">*</span>+ </label>+ </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"+ />+ </div>+ </div>+ <div v-if="index == outputFieldList.length - 1" class="mt-4" />+ </template>+ </template>++ <div class="sm:col-span-4 w-112 min-w-full">+ <label for="about" class="textlabel"> Note </label><div class="mt-1"><textarearef="commentTextArea"rows="3"- class="textarea block w-full resize-none mt-1 text-sm text-control whitespace-pre-wrap"+ class="textarea block w-full resize-none mt-1 text-sm text-control rounded-md whitespace-pre-wrap"placeholder="Add an optional note..."v-model="state.comment"@input="@@ -40,7 +62,8 @@type="button"class="ml-3 px-4 py-2"v-bind:class="submitButtonStyle"- @click.prevent="$emit('submit', state.comment)"+ :disabled="!allowSubmit"+ @click.prevent="$emit('submit', state.outputValueList, state.comment)">{{ okText }}</button>@@ -49,11 +72,14 @@</template><script lang="ts">-import { computed, reactive, ref, PropType } from "vue";+import { computed, onMounted, reactive, ref, PropType } from "vue";+import cloneDeep from "lodash-es/cloneDeep";import { Task, TaskStatusTransition } from "../types";+import { TaskField } from "../plugins";interface LocalState {comment: string;+ outputValueList: string[];}export default {@@ -65,20 +91,30 @@ export default {default: "OK",},task: {- // Can be false when create is true- required: false,+ required: true,type: Object as PropType<Task>,},transition: {required: true,type: Object as PropType<TaskStatusTransition>,},+ outputFieldList: {+ required: true,+ type: Object as PropType<TaskField[]>,+ },},setup(props, ctx) {const commentTextArea = ref("");const state = reactive<LocalState>({comment: "",+ outputValueList: [],+ });++ onMounted(() => {+ for (const field of props.outputFieldList) {+ state.outputValueList.push(cloneDeep(props.task.payload[field.id]));+ }});const submitButtonStyle = computed(() => {@@ -92,10 +128,24 @@ export default {}});+ const allowSubmit = computed(() => {+ if (props.transition.type != "RESOLVE") {+ return true;+ }+ for (let i = 0; i < props.outputFieldList.length; i++) {+ const field = props.outputFieldList[i];+ if (field.required && field.isEmpty(state.outputValueList[i])) {+ return false;+ }+ }+ return true;+ });+return {state,commentTextArea,submitButtonStyle,+ allowSubmit,};},};diff --git a/frontend/src/plugins/task/DatabaseRequestTemplate.ts b/frontend/src/plugins/task/DatabaseRequestTemplate.tsindex 8b68eec994..be185f886e 100644--- a/frontend/src/plugins/task/DatabaseRequestTemplate.ts+++ b/frontend/src/plugins/task/DatabaseRequestTemplate.ts@@ -6,7 +6,7 @@ import {DatabaseFieldPayload,} from "../types";-import { TaskNew } from "../../types";+import { TaskNew, EnvironmentId } from "../../types";const template: TaskTemplate = {type: "bytebase.database.request",@@ -49,6 +49,9 @@ const template: TaskTemplate = {name: "Environment",type: "Environment",required: true,+ isEmpty: (value: EnvironmentId): boolean => {+ return isEmpty(value);+ },},{category: "INPUT",@@ -72,6 +75,9 @@ const template: TaskTemplate = {name: "Data Source URL",type: "String",required: true,+ isEmpty: (value: string): boolean => {+ return isEmpty(value?.trim());+ },},],};diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.tsindex 0d1eb6c246..5f27303b85 100644--- a/frontend/src/plugins/types.ts+++ b/frontend/src/plugins/types.ts@@ -44,8 +44,7 @@ export type TaskField = {required: boolean;// Whether the value is empty, one use case is together with "required" field to validate// whether it's ready to submit the data.- // If not present, we will use the loadash/isEmpty check.- isEmpty?: (value: any) => boolean;+ isEmpty: (value: any) => boolean;// Placeholder displayed on UI.placeholder?: string;};diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vueindex 7f27c22597..1e4228d586 100644--- a/frontend/src/views/TaskDetail.vue+++ b/frontend/src/views/TaskDetail.vue@@ -128,10 +128,15 @@:okText="updateStatusModalState.okText":task="state.task":transition="updateStatusModalState.payload.transition"+ :outputFieldList="outputFieldList"@submit="- (comment) => {+ (outputValueList, comment) => {updateStatusModalState.show = false;- doTaskStatusTransition(updateStatusModalState.payload, comment);+ doTaskStatusTransition(+ updateStatusModalState.payload,+ outputValueList,+ comment+ );}"@cancel="@@ -399,13 +404,24 @@ export default {const doTaskStatusTransition = (payload: UpdateStatusModalStatePayload,+ outputValueList: string[],comment?: string) => {+ let payloadChanged = false;+ for (let i = 0; i < outputValueList.length; i++) {+ const field = outputFieldList.value[i];+ if (state.task.payload[field.id] != outputValueList[i]) {+ state.task.payload[field.id] = outputValueList[i];+ payloadChanged = true;+ }+ }+const theComment = comment ? comment.trim() : undefined;patchTask({status: payload.transition.to,comment: theComment ? theComment : undefined,+ payload: payloadChanged ? state.task.payload : undefined,},() => {payload.didTransit();@@ -493,8 +509,7 @@ export default {if (field.type != "Switch" && // Switch is boolean value which always presentsfield.required &&- ((field.isEmpty && field.isEmpty(state.task.payload[field.id])) ||- isEmpty(state.task.payload[field.id]))+ isEmpty(state.task.payload[field.id])) {return false;}diff --git a/frontend/src/views/TaskOutputPanel.vue b/frontend/src/views/TaskOutputPanel.vueindex e4dea3f913..1a25ce6123 100644--- a/frontend/src/views/TaskOutputPanel.vue+++ b/frontend/src/views/TaskOutputPanel.vue@@ -18,9 +18,10 @@<inputtype="text"class="flex-1 min-w-0 block w-full px-3 py-2 border border-r border-control-border focus:mr-0.5 focus:ring-control focus:border-control sm:text-sm disabled:bg-gray-50"- :disabled="!isAssignee"+ :disabled="!allowEdit":name="field.id":value="task.payload[field.id]"+ autocomplete="off"@input="$emit('update-custom-field', field, $event.target.value)"/><!-- Disallow tabbing since the focus ring is partially covered by the text field due to overlaying -->@@ -107,6 +108,13 @@ export default {return currentUser.value.id === props.task.assignee?.id;});+ const allowEdit = computed(() => {+ return (+ currentUser.value.id === props.task.assignee?.id &&+ props.task.status == "OPEN"+ );+ });+const isValidLink = (link: string) => {return link?.trim().length > 0;};@@ -135,7 +143,7 @@ export default {}};- return { state, isAssignee, isValidLink, copyText, goToLink };+ return { state, allowEdit, isValidLink, copyText, goToLink };},};</script>