Skip to content

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

TaskOutputPanel basic

Tianzhou Chen05c77110b191
diff --git a/frontend/src/plugins/task/template.ts b/frontend/src/plugins/task/template.ts
index ad78c12b18..b7ddd4d403 100644
--- a/frontend/src/plugins/task/template.ts
+++ b/frontend/src/plugins/task/template.ts
@@ -1,8 +1,25 @@
-import { TaskTemplate } from "../types";
+import { TaskTemplate, TemplateContext, Stage } from "../types";
export const taskTemplateList: TaskTemplate[] = [
{
type: "bytebase.datasource.create",
+ outputFieldList: [
+ {
+ id: 1,
+ name: "Data Source URL1",
+ required: true,
+ },
+ {
+ id: 2,
+ name: "Hello world",
+ required: true,
+ },
+ {
+ id: 3,
+ name: "Data Source URL3",
+ required: true,
+ },
+ ],
fieldList: [
{
id: 1,
@@ -18,5 +35,13 @@ export const taskTemplateList: TaskTemplate[] = [
},
},
],
+ stageListBuilder: (ctx: TemplateContext): Stage[] => {
+ return [
+ {
+ name: "Request Data Source",
+ type: "SIMPLE",
+ },
+ ];
+ },
},
];
diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.ts
index 91db14b0c1..9251148941 100644
--- a/frontend/src/plugins/types.ts
+++ b/frontend/src/plugins/types.ts
@@ -1,3 +1,12 @@
+import { Environment } from "../types";
+
+// Stage
+export type Stage = {
+ name: string;
+ type: "SIMPLE" | "ENVIRONMENT";
+};
+
+// Task
export type TaskFieldType = "String";
export type TaskField = {
@@ -24,7 +33,21 @@ export type TaskField = {
placeholder?: string;
};
+// Template
+export type TemplateContext = {
+ environmentList: Environment[];
+};
+
+export type TemplateOutput = {
+ // Similar to TaskField.id above
+ id: number;
+ name: string;
+ required: boolean;
+};
+
export type TaskTemplate = {
type: string;
+ outputFieldList: TemplateOutputField[];
fieldList: TaskField[];
+ stageListBuilder: (ctx: TemplateContext) => Stage[];
};
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index 680128f1bc..907ba59c1d 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -4,7 +4,7 @@
class="flex-1 overflow-auto focus:outline-none"
tabindex="0"
>
- <!-- Page header -->
+ <!-- Highlight Panel -->
<div class="bg-white">
<TaskHighlightPanel
:task="state.task"
@@ -13,12 +13,14 @@
/>
</div>
- <!-- Flow -->
+ <!-- Flow Bar -->
<TaskFlow
v-if="state.task.stageProgressList?.length > 0"
:task="state.task"
/>
- <div v-else class="border-t border-block-border" />
+
+ <!-- Output Panel -->
+ <TaskOutputPanel v-if="!state.new" :task="state.task" />
<!-- Main Content -->
<main
@@ -63,11 +65,12 @@ import cloneDeep from "lodash-es/cloneDeep";
import isEmpty from "lodash-es/isEmpty";
import { UserStateSymbol } from "../components/ProvideUser.vue";
import { humanize, idFromSlug, taskSlug } from "../utils";
-import TaskActivityPanel from "../views/TaskActivityPanel.vue";
-import TaskFlow from "../views/TaskFlow.vue";
import TaskHighlightPanel from "../views/TaskHighlightPanel.vue";
-import TaskContent from "../views/TaskContent.vue";
+import TaskFlow from "../views/TaskFlow.vue";
+import TaskOutputPanel from "../views/TaskOutputPanel.vue";
import TaskContentBar from "../views/TaskContentBar.vue";
+import TaskContent from "../views/TaskContent.vue";
+import TaskActivityPanel from "../views/TaskActivityPanel.vue";
import TaskSidebar from "../views/TaskSidebar.vue";
import { User, Task, TaskNew } from "../types";
import { taskTemplateList, TaskField } from "../plugins";
@@ -86,11 +89,12 @@ export default {
},
},
components: {
- TaskActivityPanel,
- TaskContent,
- TaskContentBar,
- TaskFlow,
TaskHighlightPanel,
+ TaskFlow,
+ TaskOutputPanel,
+ TaskContentBar,
+ TaskContent,
+ TaskActivityPanel,
TaskSidebar,
},
diff --git a/frontend/src/views/TaskOutputPanel.vue b/frontend/src/views/TaskOutputPanel.vue
new file mode 100644
index 0000000000..976c306170
--- /dev/null
+++ b/frontend/src/views/TaskOutputPanel.vue
@@ -0,0 +1,94 @@
+<template>
+ <div class="">
+ <div
+ class="px-2 py-4 md:flex md:flex-col lg:border-t lg:border-b lg:border-block-border"
+ >
+ <h3 class="px-4 text-lg leading-6 font-medium text-main">Result</h3>
+
+ <div v-if="template" class="my-2 mx-4 space-y-2">
+ <template
+ v-for="(field, index) in template.outputFieldList"
+ :key="index"
+ >
+ <div class="flex">
+ <span
+ class="z-0 whitespace-nowrap inline-flex items-center px-3 rounded-l-md border border-l border-r-0 border-control-border bg-gray-50 text-control-light sm:text-sm"
+ >
+ {{ field.name }}
+ </span>
+ <input
+ type="text"
+ :name="field.id"
+ class="z-10 flex-1 min-w-0 block w-full px-3 py-2 border border-r border-control-border focus:ring-control focus:border-control sm:text-sm"
+ />
+ <button
+ class="z-0 -ml-px px-2 py-2 border border-gray-300 text-sm font-medium text-control-light bg-gray-50 hover:bg-gray-100 focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-1"
+ >
+ <svg
+ class="w-6 h-6"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
+ ></path>
+ </svg>
+ </button>
+ <button
+ class="z-0 -ml-px px-2 py-2 border border-gray-300 text-sm font-medium rounded-r-md text-control-light bg-gray-50 hover:bg-gray-100 focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-1"
+ >
+ <svg
+ class="w-6 h-6"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
+ ></path>
+ </svg>
+ </button>
+ </div>
+ </template>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts">
+import { PropType, reactive } from "vue";
+import { taskTemplateList } from "../plugins";
+import { Task } from "../types";
+
+interface LocalState {}
+
+export default {
+ name: "TaskOutputPanel",
+ emits: ["update-field"],
+ props: {
+ task: {
+ required: true,
+ type: Object as PropType<Task>,
+ },
+ },
+ components: {},
+ setup(props, ctx) {
+ const state = reactive<LocalState>({});
+
+ const template = taskTemplateList.find(
+ (template) => template.type == props.task.attributes.type
+ );
+
+ return { state, template };
+ },
+};
+</script>