Skip to content

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

refactor: remove confusing task selection in database export view (#17484)

boojack6d2f44b31376
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
index b47328cc05..e9c62c7647 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
@@ -45,7 +45,7 @@ interface LocalState {
const props = defineProps<{
taskRun: TaskRun;
- database: Database;
+ database?: Database;
}>();
const sheetStore = useSheetV1Store();
@@ -62,7 +62,7 @@ const sheet = computed(() =>
const showTaskRunSessionTab = computed(
() =>
- props.database.instanceResource &&
+ props.database?.instanceResource &&
TASK_RUN_SESSION_SUPPORTED_ENGINES.includes(
props.database.instanceResource.engine
)
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue
index 287b8c6219..3385caf291 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue
@@ -3,6 +3,9 @@
<!-- Tasks Section -->
<TasksSection />
+ <!-- Execution History Section -->
+ <ExecutionHistorySection v-if="taskRuns.length > 0" />
+
<!-- Export Options Section -->
<OptionsSection />
@@ -15,14 +18,20 @@
import { computed, watchEffect } from "vue";
import { useDatabaseV1Store, useSheetV1Store } from "@/store";
import type { Plan_ExportDataConfig } from "@/types/proto-es/v1/plan_service_pb";
+import { usePlanContextWithRollout } from "../../logic";
import { useSelectedSpec } from "../SpecDetailView/context";
import StatementSection from "../StatementSection";
-import { TasksSection, OptionsSection } from "./DatabaseExportView";
+import {
+ TasksSection,
+ OptionsSection,
+ ExecutionHistorySection,
+} from "./DatabaseExportView";
const databaseStore = useDatabaseV1Store();
const sheetStore = useSheetV1Store();
const selectedSpec = useSelectedSpec();
+const { taskRuns } = usePlanContextWithRollout();
const exportDataConfig = computed(() => {
return selectedSpec.value.config.value as Plan_ExportDataConfig;
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/ExecutionHistorySection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/ExecutionHistorySection.vue
new file mode 100644
index 0000000000..6d5bd8625b
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/ExecutionHistorySection.vue
@@ -0,0 +1,69 @@
+<template>
+ <div class="space-y-4">
+ <!-- Execution History Section -->
+ <div class="space-y-3">
+ <div class="flex items-center justify-between">
+ <h3 class="text-base font-medium">
+ {{ $t("task-run.history") }}
+ </h3>
+ </div>
+
+ <!-- Task Runs Table -->
+ <div v-if="allTaskRuns.length > 0">
+ <TaskRunTable :task-runs="allTaskRuns" :show-database-column="true" />
+ </div>
+
+ <!-- No task runs message -->
+ <div v-else class="text-center text-control-light py-8">
+ {{ $t("common.no-data") }}
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import TaskRunTable from "@/components/Plan/components/RolloutView/TaskRunTable.vue";
+import type { TaskRun } from "@/types/proto-es/v1/rollout_service_pb";
+import { extractTaskUID } from "@/utils";
+import { usePlanContext } from "../../../logic";
+import { usePlanContextWithRollout } from "../../../logic";
+
+const { plan, rollout } = usePlanContext();
+const { taskRuns } = usePlanContextWithRollout();
+
+// Get the export data spec
+const exportDataSpec = computed(() => {
+ return plan.value.specs.find(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+});
+
+// Find export tasks related to this spec
+const exportTasks = computed(() => {
+ if (!rollout.value || !exportDataSpec.value) return [];
+
+ const tasks = [];
+ for (const stage of rollout.value.stages) {
+ for (const task of stage.tasks) {
+ if (task.specId === exportDataSpec.value.id) {
+ tasks.push(task);
+ }
+ }
+ }
+ return tasks;
+});
+
+// Get all task runs for export tasks
+const allTaskRuns = computed((): TaskRun[] => {
+ if (exportTasks.value.length === 0) return [];
+
+ const exportTaskUIDs = new Set(
+ exportTasks.value.map((task) => extractTaskUID(task.name))
+ );
+
+ return taskRuns.value.filter((taskRun) =>
+ exportTaskUIDs.has(extractTaskUID(taskRun.name))
+ );
+});
+</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
index dca78b57e6..994ef0b153 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
@@ -14,17 +14,12 @@
</div>
</div>
- <!-- Flattened task list -->
+ <!-- Task status display -->
<div v-if="exportTasks.length > 0" class="flex flex-wrap gap-2">
<div
v-for="task in exportTasks"
:key="task.name"
- class="inline-flex items-center gap-2 px-2 py-1.5 border rounded transition-colors min-w-0 cursor-pointer"
- :class="{
- 'bg-blue-50 border-blue-300': selectedTask?.name === task.name,
- 'hover:bg-gray-50': selectedTask?.name !== task.name,
- }"
- @click="handleTaskClick(task)"
+ class="inline-flex items-center gap-2 px-2 py-1.5 border rounded transition-colors min-w-0"
>
<!-- Task Status -->
<div class="flex-shrink-0">
@@ -42,17 +37,6 @@
</div>
</div>
- <!-- Task Runs for Selected Task -->
- <div
- v-if="selectedTask && selectedTaskRuns.length > 0"
- class="mt-4 space-y-2"
- >
- <div class="text-sm font-medium text-control">
- {{ $t("task-run.history") }}
- </div>
- <TaskRunTable :task="selectedTask" :task-runs="selectedTaskRuns" />
- </div>
-
<!-- No tasks message -->
<div
v-else-if="exportTasks.length === 0"
@@ -65,34 +49,12 @@
</template>
<script lang="ts" setup>
-import { computed, ref, watchEffect } from "vue";
-import TaskRunTable from "@/components/Plan/components/RolloutView/TaskRunTable.vue";
+import { computed } from "vue";
import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
-import {
- Task_Status,
- type Task,
- type TaskRun,
-} from "@/types/proto-es/v1/rollout_service_pb";
-import { extractTaskUID } from "@/utils";
import { usePlanContext } from "../../../logic";
-import { usePlanContextWithRollout } from "../../../logic";
const { plan, rollout } = usePlanContext();
-const { taskRuns } = usePlanContextWithRollout();
-
-// Track selected task for showing task runs
-const selectedTask = ref<Task | null>(null);
-
-// Get task runs for the selected task
-const selectedTaskRuns = computed((): TaskRun[] => {
- if (!selectedTask.value) return [];
-
- const taskUID = extractTaskUID(selectedTask.value.name);
- return taskRuns.value.filter(
- (taskRun) => extractTaskUID(taskRun.name) === taskUID
- );
-});
// Get the export data spec
const exportDataSpec = computed(() => {
@@ -115,55 +77,4 @@ const exportTasks = computed(() => {
}
return tasks;
});
-
-// Auto-select the most relevant task
-const autoSelectTask = () => {
- if (exportTasks.value.length === 0) {
- selectedTask.value = null;
- return;
- }
-
- // Priority order: Failed > Not started (Pending) > First task
- const failedTasks = exportTasks.value.filter(
- (task) => task.status === Task_Status.FAILED
- );
- const pendingTasks = exportTasks.value.filter(
- (task) =>
- task.status === Task_Status.PENDING ||
- task.status === Task_Status.NOT_STARTED ||
- task.status === Task_Status.RUNNING
- );
-
- let taskToSelect: Task | null = null;
-
- if (failedTasks.length > 0) {
- // Select first failed task
- taskToSelect = failedTasks[0];
- } else if (pendingTasks.length > 0) {
- // Select first not started (pending) task
- taskToSelect = pendingTasks[0];
- } else {
- // Fallback to first task
- taskToSelect = exportTasks.value[0];
- }
-
- selectedTask.value = taskToSelect;
-};
-
-// Handle task selection
-const handleTaskClick = (task: Task) => {
- if (selectedTask.value?.name === task.name) {
- selectedTask.value = null; // Deselect if clicking the same task
- } else {
- selectedTask.value = task; // Select the new task
- }
-};
-
-// Auto-select task when tasks change
-watchEffect(() => {
- // Only auto-select if no task is currently selected
- if (!selectedTask.value && exportTasks.value.length > 0) {
- autoSelectTask();
- }
-});
</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts
index dc879e1e00..dc7d9df8d0 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts
@@ -1,2 +1,3 @@
export { default as TasksSection } from "./TasksSection.vue";
export { default as OptionsSection } from "./OptionsSection.vue";
+export { default as ExecutionHistorySection } from "./ExecutionHistorySection.vue";
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue b/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue
index 3bac15d5fd..d42270fdce 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue
@@ -3,7 +3,7 @@
size="small"
:row-key="rowKey"
:columns="columnList"
- :data="taskRuns"
+ :data="sortedTaskRuns"
:striped="true"
:bordered="true"
/>
@@ -17,7 +17,7 @@
v-if="taskRunDetailContext.taskRun"
:key="taskRunDetailContext.taskRun.name"
:task-run="taskRunDetailContext.taskRun"
- :database="database"
+ :database="getDatabaseForTaskRun(taskRunDetailContext.taskRun)"
/>
</DrawerContent>
</Drawer>
@@ -33,6 +33,7 @@ import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import TaskRunDetail from "@/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue";
import TaskRunStatusIcon from "@/components/IssueV1/components/TaskRunSection/TaskRunStatusIcon.vue";
+import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
import HumanizeDate from "@/components/misc/HumanizeDate.vue";
import { Drawer, DrawerContent } from "@/components/v2";
import { useCurrentProjectV1 } from "@/store";
@@ -43,20 +44,48 @@ import {
import type { Task, TaskRun } from "@/types/proto-es/v1/rollout_service_pb";
import { TaskRun_Status } from "@/types/proto-es/v1/rollout_service_pb";
import { databaseForTask } from "@/utils";
-import { humanizeDurationV1 } from "@/utils";
+import { humanizeDurationV1, extractTaskUID } from "@/utils";
+import { usePlanContextWithRollout } from "../../logic";
import TaskRunComment from "./TaskRunComment.vue";
const props = defineProps<{
- task: Task;
taskRuns: TaskRun[];
+ showDatabaseColumn?: boolean; // Whether to show database column
}>();
+// Sort task runs by creation time descending (newest first)
+const sortedTaskRuns = computed(() => {
+ return [...props.taskRuns].sort((a, b) => {
+ const timeA = a.createTime ? Number(a.createTime.seconds) : 0;
+ const timeB = b.createTime ? Number(b.createTime.seconds) : 0;
+ return timeB - timeA; // Descending order
+ });
+});
+
const { t } = useI18n();
const { project } = useCurrentProjectV1();
+const { rollout } = usePlanContextWithRollout();
-const database = computed(() => {
- return databaseForTask(project.value, props.task);
-});
+// Helper function to get task for a given task run
+const getTaskForTaskRun = (taskRun: TaskRun): Task | undefined => {
+ if (!rollout.value) return undefined;
+
+ // Search through all stages and tasks in the rollout
+ for (const stage of rollout.value.stages) {
+ for (const task of stage.tasks) {
+ if (extractTaskUID(task.name) === extractTaskUID(taskRun.name)) {
+ return task;
+ }
+ }
+ }
+ return undefined;
+};
+
+// Helper function to get database for a task run
+const getDatabaseForTaskRun = (taskRun: TaskRun) => {
+ const task = getTaskForTaskRun(taskRun);
+ return task ? databaseForTask(project.value, task) : undefined;
+};
const taskRunDetailContext = ref<{
show: boolean;
@@ -78,6 +107,23 @@ const columnList = computed((): DataTableColumn<TaskRun>[] => {
return <TaskRunStatusIcon status={taskRun.status} />;
},
},
+ ...(props.showDatabaseColumn
+ ? [
+ {
+ key: "database",
+ title: t("common.database"),
+ width: 200,
+ render: (taskRun: TaskRun) => {
+ const db = getDatabaseForTaskRun(taskRun);
+ return db ? (
+ <DatabaseDisplay database={db.name} showEnvironment={true} />
+ ) : (
+ "-"
+ );
+ },
+ },
+ ]
+ : []),
{
key: "detail",
title: t("common.detail"),
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskView.vue b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
index 147f9dfefd..24977ece34 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
@@ -80,7 +80,7 @@
<div class="flex items-center justify-between mb-2">
<span class="text-base font-medium">{{ $t("task-run.history") }}</span>
</div>
- <TaskRunTable :task="task" :task-runs="taskRuns" />
+ <TaskRunTable :task-runs="taskRuns" />
</div>
<!-- Sheet Statement -->