Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add the modal to confirm the status transition.

天舟f0fc434eb9c6
diff --git a/frontend/src/components/TaskStatusTransitionForm.vue b/frontend/src/components/TaskStatusTransitionForm.vue
new file mode 100644
index 0000000000..36ca70fb68
--- /dev/null
+++ b/frontend/src/components/TaskStatusTransitionForm.vue
@@ -0,0 +1,102 @@
+<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-1">
+ <textarea
+ ref="commentTextArea"
+ rows="3"
+ class="textarea block w-full resize-none mt-1 text-sm text-control whitespace-pre-wrap"
+ placeholder="Add an optional note..."
+ v-model="state.comment"
+ @input="
+ (e) => {
+ sizeToFit(e.target);
+ }
+ "
+ @focus="
+ (e) => {
+ sizeToFit(e.target);
+ }
+ "
+ ></textarea>
+ </div>
+ </div>
+ </div>
+
+ <!-- Update button group -->
+ <div class="flex justify-end items-center pt-5">
+ <button
+ type="button"
+ class="btn-normal mt-3 px-4 py-2 sm:mt-0 sm:w-auto"
+ @click.prevent="$emit('cancel')"
+ >
+ No
+ </button>
+ <button
+ type="button"
+ class="ml-3 px-4 py-2"
+ v-bind:class="submitButtonStyle"
+ @click.prevent="$emit('submit', state.comment)"
+ >
+ {{ okText }}
+ </button>
+ </div>
+ </div>
+</template>
+
+<script lang="ts">
+import { computed, reactive, ref, PropType } from "vue";
+import { Task, TaskStatusTransition } from "../types";
+
+interface LocalState {
+ comment: string;
+}
+
+export default {
+ name: "TaskStatusTransitionForm",
+ emits: ["submit", "cancel"],
+ props: {
+ okText: {
+ type: String,
+ default: "OK",
+ },
+ task: {
+ // Can be false when create is true
+ required: false,
+ type: Object as PropType<Task>,
+ },
+ transition: {
+ required: true,
+ type: Object as PropType<TaskStatusTransition>,
+ },
+ },
+ setup(props, ctx) {
+ const commentTextArea = ref("");
+
+ const state = reactive<LocalState>({
+ comment: "",
+ });
+
+ const submitButtonStyle = computed(() => {
+ switch (props.transition.to) {
+ case "OPEN":
+ return "btn-primary";
+ case "DONE":
+ return "btn-success";
+ case "CANCELED":
+ return "btn-danger";
+ }
+ });
+
+ return {
+ state,
+ commentTextArea,
+ submitButtonStyle,
+ };
+ },
+};
+</script>
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index ee8a358c1c..7f27c22597 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -41,7 +41,9 @@
: 'btn-primary'
: 'btn-normal mr-2'
"
- @click.prevent="tryStartTaskStatusTransition(transition.type)"
+ @click.prevent="
+ tryStartTaskStatusTransition(transition.type, () => {})
+ "
>
{{ transition.actionName }}
</button>
@@ -117,22 +119,28 @@
</div>
</main>
</div>
- <BBAlert
+ <BBModal
v-if="updateStatusModalState.show"
- :style="updateStatusModalState.style"
- :okText="updateStatusModalState.okText"
- :cancelText="'No'"
:title="updateStatusModalState.title"
- :payload="updateStatusModalState.payload"
- @ok="
- (payload) => {
- updateStatusModalState.show = false;
- doTaskStatusTransition(payload);
- }
- "
- @cancel="updateStatusModalState.show = false"
+ @close="updateStatusModalState.show = false"
>
- </BBAlert>
+ <TaskStatusTransitionForm
+ :okText="updateStatusModalState.okText"
+ :task="state.task"
+ :transition="updateStatusModalState.payload.transition"
+ @submit="
+ (comment) => {
+ updateStatusModalState.show = false;
+ doTaskStatusTransition(updateStatusModalState.payload, comment);
+ }
+ "
+ @cancel="
+ () => {
+ updateStatusModalState.show = false;
+ }
+ "
+ />
+ </BBModal>
</template>
<script lang="ts">
@@ -156,6 +164,7 @@ import TaskOutputPanel from "../views/TaskOutputPanel.vue";
import TaskDescription from "../views/TaskDescription.vue";
import TaskActivityPanel from "../views/TaskActivityPanel.vue";
import TaskSidebar from "../views/TaskSidebar.vue";
+import TaskStatusTransitionForm from "../components/TaskStatusTransitionForm.vue";
import {
Task,
TaskNew,
@@ -228,6 +237,7 @@ export default {
TaskDescription,
TaskActivityPanel,
TaskSidebar,
+ TaskStatusTransitionForm,
},
setup(props, ctx) {
@@ -387,10 +397,15 @@ export default {
updateStatusModalState.show = true;
};
- const doTaskStatusTransition = (payload: UpdateStatusModalStatePayload) => {
+ const doTaskStatusTransition = (
+ payload: UpdateStatusModalStatePayload,
+ comment?: string
+ ) => {
+ const theComment = comment ? comment.trim() : undefined;
patchTask(
{
status: payload.transition.to,
+ comment: theComment ? theComment : undefined,
},
() => {
payload.didTransit();