Skip to content

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

Initial Task info wiring for creation

Tianzhou Chen747f19e7ac21
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index 39c9d26b6c..21a5dc2e4d 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -112,7 +112,7 @@
v-if="quickActionList.includes('datasource.add')"
class="flex flex-col items-center w-28"
>
- <router-link to="/datasource/new" class="">
+ <router-link to="/task/new" class="">
<span class="btn-icon-primary inline-flex p-3">
<svg
class="w-6 h-6"
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 35ac88f784..1fe6efb8e3 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -245,27 +245,16 @@ const routes: Array<RouteRecordRaw> = [
},
props: { content: true },
},
- {
- path: "datasource/new",
- name: "workspace.datasource.detail",
- meta: {
- title: () => "Request DB",
- },
- components: {
- content: defineAsyncComponent(
- () => import("../views/TaskDetail.vue")
- ),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
{
path: "task/:taskId",
name: "workspace.task.detail",
meta: {
title: (route: RouteLocationNormalized) => {
- return store.getters["task/taskById"](route.params.taskId)
- .attributes.name;
+ const taskId = route.params.taskId as string;
+ if (taskId.toUpperCase() == "NEW") {
+ return "New";
+ }
+ return store.getters["task/taskById"](taskId).attributes.name;
},
},
components: {
@@ -328,7 +317,6 @@ router.beforeEach((to, from, next) => {
to.name === "workspace.inbox" ||
to.name === "workspace.environment" ||
to.name === "workspace.instance" ||
- to.name === "workspace.datasource.detail" ||
to.name?.toString().startsWith("setting")
) {
next();
@@ -342,6 +330,10 @@ router.beforeEach((to, from, next) => {
console.log("RouterSlug:", routerSlug);
if (taskId) {
+ if (taskId.toUpperCase() == "NEW") {
+ next();
+ return;
+ }
store
.dispatch("task/fetchTaskById", taskId)
.then((task) => {
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 390c068880..af881f6a1f 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -35,7 +35,7 @@ export type ActivityNew = Omit<Activity, "id">;
export type Task = ResourceObject & {
attributes: {
- title: string;
+ name: string;
createdTs: number;
lastUpdatedTs: number;
status: "PENDING" | "RUNNING" | "DONE" | "FAILED" | "CANCELED";
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index 038da902b6..5945704ff7 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -6,11 +6,12 @@
>
<!-- Page header -->
<div class="bg-white">
- <TaskHighlightPanel :task="task" />
+ <TaskHighlightPanel :task="state.task" />
</div>
<!-- Flow -->
- <TaskFlow :task="task" />
+ <TaskFlow v-if="!state.new" :task="state.task" />
+ <div v-else class="border-t border-block-border" />
<!-- Main Content -->
<main
@@ -23,15 +24,15 @@
>
<div class="lg:col-span-2 lg:pr-8 lg:border-r lg:border-gray-200">
<div>
- <TaskContentBar v-if="false" :task="task" />
- <TaskSidebar class="lg:hidden" :task="task" />
- <TaskContent :task="task" />
+ <TaskContentBar v-if="false" :task="state.task" />
+ <TaskSidebar class="lg:hidden" :task="state.task" />
+ <TaskContent :task="state.task" />
</div>
<section aria-labelledby="activity-title" class="mt-8 lg:mt-10">
- <TaskActivityPanel :task="task" />
+ <TaskActivityPanel :task="state.task" />
</section>
</div>
- <TaskSidebar class="hidden lg:block lg:pl-8" :task="task" />
+ <TaskSidebar class="hidden lg:block lg:pl-8" :task="state.task" />
</div>
</div>
</main>
@@ -39,8 +40,9 @@
</template>
<script lang="ts">
-import { computed, onMounted } from "vue";
+import { onMounted, reactive, inject } from "vue";
import { useStore } from "vuex";
+import { UserStateSymbol } from "../components/ProvideUser.vue";
import { humanize } from "../utils";
import TaskActivityPanel from "../views/TaskActivityPanel.vue";
import TaskFlow from "../views/TaskFlow.vue";
@@ -48,6 +50,12 @@ import TaskHighlightPanel from "../views/TaskHighlightPanel.vue";
import TaskContent from "../views/TaskContent.vue";
import TaskContentBar from "../views/TaskContentBar.vue";
import TaskSidebar from "../views/TaskSidebar.vue";
+import { User, Task } from "../types";
+
+interface LocalState {
+ new: boolean;
+ task: Task;
+}
export default {
name: "TaskDetail",
@@ -69,6 +77,39 @@ export default {
setup(props, ctx) {
const store = useStore();
+ const currentUser = inject<User>(UserStateSymbol);
+
+ const state = reactive<LocalState>({
+ new: props.taskId.toLowerCase() == "new",
+ task:
+ props.taskId.toLowerCase() == "new"
+ ? {
+ type: "task",
+ attributes: {
+ name: "New Task",
+ status: "PENDING",
+ content: "Need a new database",
+ currentStageId: "1",
+ stageProgressList: [
+ {
+ stageId: "1",
+ stageName: "Request Database",
+ status: "CREATED",
+ },
+ ],
+ creator: {
+ id: currentUser!.id,
+ name: currentUser!.attributes.name,
+ },
+ assignee: {
+ id: currentUser!.id,
+ name: currentUser!.attributes.name,
+ },
+ },
+ }
+ : store.getters["task/taskById"](props.taskId),
+ });
+
onMounted(() => {
// Always scroll to top, the scrollBehavior doesn't seem to work.
// The hypothesis is that because the scroll bar is in the nested
@@ -77,9 +118,7 @@ export default {
document.getElementById("task-detail-top")!.scrollIntoView();
});
- const task = computed(() => store.getters["task/taskById"](props.taskId));
-
- return { task, humanize };
+ return { state, humanize };
},
};
</script>
diff --git a/frontend/src/views/TaskHighlightPanel.vue b/frontend/src/views/TaskHighlightPanel.vue
index a735f86e91..6b40c7c987 100644
--- a/frontend/src/views/TaskHighlightPanel.vue
+++ b/frontend/src/views/TaskHighlightPanel.vue
@@ -15,7 +15,7 @@
{{ task.attributes.name }}
</p>
</div>
- <div>
+ <div v-if="!state.new">
<p class="mt-2 text-sm text-gray-500">
#{{ task.id }} opened by
<span href="#" class="font-medium text-control">{{
@@ -31,17 +31,27 @@
</div>
</div>
<div class="mt-6 flex space-x-3 md:mt-0 md:ml-4">
- <button type="button" class="btn-normal px-4 py-2">Add money</button>
- <button type="button" class="btn-primary px-4 py-2">Send money</button>
+ <template v-if="state.new">
+ <button type="button" class="btn-primary px-4 py-2">Create</button>
+ </template>
+ <template v-else>
+ <button type="button" class="btn-normal px-4 py-2">Close</button>
+ <button type="button" class="btn-primary px-4 py-2">Resolve</button>
+ </template>
</div>
</div>
</div>
</template>
<script lang="ts">
-import { PropType } from "vue";
+import { PropType, reactive } from "vue";
+import isEmpty from "lodash-es/isEmpty";
import { Task } from "../types";
+interface LocalState {
+ new: boolean;
+}
+
export default {
name: "TaskHighlightPanel",
props: {
@@ -51,6 +61,12 @@ export default {
},
},
components: {},
- setup(props, ctx) {},
+ setup(props, ctx) {
+ const state = reactive<LocalState>({
+ new: isEmpty(props.task.id),
+ });
+
+ return { state };
+ },
};
</script>
diff --git a/frontend/src/views/TaskSidebar.vue b/frontend/src/views/TaskSidebar.vue
index 3f6fcd5ee0..b12d6280fa 100644
--- a/frontend/src/views/TaskSidebar.vue
+++ b/frontend/src/views/TaskSidebar.vue
@@ -24,14 +24,16 @@
<input
type="text"
name="db"
- id="db"
class="textfield w-64"
placeholder="Your DB Name"
/>
</div>
</div>
</div>
- <div class="mt-6 border-t border-block-border py-6 space-y-4">
+ <div
+ v-if="!state.new"
+ class="mt-6 border-t border-block-border py-6 space-y-4"
+ >
<div class="flex items-center space-x-2">
<!-- Heroicon name: solid/lock-open -->
<svg
@@ -81,9 +83,14 @@
</template>
<script lang="ts">
-import { PropType } from "vue";
+import { PropType, reactive } from "vue";
+import isEmpty from "lodash-es/isEmpty";
import { Task } from "../types";
+interface LocalState {
+ new: boolean;
+}
+
export default {
name: "TaskSidebar",
props: {
@@ -93,6 +100,12 @@ export default {
},
},
components: {},
- setup(props, ctx) {},
+ setup(props, ctx) {
+ const state = reactive<LocalState>({
+ new: isEmpty(props.task.id),
+ });
+
+ return { state };
+ },
};
</script>