Skip to content

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

chore: show tasks in stage card (#16862)

boojackc8cab9182ca5
diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
index 3fde477c85..c34599f8e6 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
@@ -12,9 +12,9 @@
"
@click="isCreated && handleClickStageTitle()"
>
- <div class="flex items-center justify-between gap-4">
+ <div class="flex items-start justify-between gap-4">
<!-- Left side: Stage title and status counts -->
- <div class="flex items-center gap-2">
+ <div class="flex items-start gap-2">
<div class="flex items-start gap-2">
<TaskStatus :status="stageStatus" size="medium" />
<div class="flex flex-col">
@@ -31,38 +31,87 @@
</div>
</div>
- <!-- Task status counts -->
- <div class="flex items-center gap-2 flex-wrap">
- <template v-for="status in TASK_STATUS_FILTERS" :key="status">
+ <!-- Tasks and task status counts -->
+ <div v-if="isCreated" class="flex-1 flex flex-col">
+ <!-- Task status counts -->
+ <div class="flex items-center gap-2 flex-wrap">
+ <template v-for="status in TASK_STATUS_FILTERS" :key="status">
+ <NTag
+ v-if="getTaskCount(status) > 0"
+ round
+ size="medium"
+ :type="
+ status === Task_Status.RUNNING
+ ? 'info'
+ : status === Task_Status.FAILED
+ ? 'error'
+ : status === Task_Status.PENDING
+ ? 'warning'
+ : 'default'
+ "
+ class="cursor-pointer hover:opacity-80 transition-opacity"
+ @click.stop="handleTaskStatusClick(status)"
+ >
+ <template #avatar>
+ <TaskStatus :status="status" size="small" disabled />
+ </template>
+ <div class="flex flex-row items-center gap-2">
+ <span class="select-none text-base">{{
+ stringifyTaskStatus(status)
+ }}</span>
+ <span class="select-none text-base font-medium">{{
+ getTaskCount(status)
+ }}</span>
+ </div>
+ </NTag>
+ </template>
+ <!-- Toggle button for tasks -->
+ <NButton
+ v-if="filteredTasks.length > 0"
+ quaternary
+ round
+ size="small"
+ class="!px-2"
+ @click.stop="showTasks = !showTasks"
+ >
+ <template #icon>
+ <ChevronDownIcon v-if="!showTasks" class="text-gray-500" />
+ <ChevronUpIcon v-else class="text-gray-500" />
+ </template>
+ </NButton>
+ </div>
+ <!-- Tasks -->
+ <div
+ v-if="filteredTasks.length > 0 && showTasks"
+ class="mt-2 flex flex-row gap-2 flex-wrap"
+ >
<NTag
- v-if="getTaskCount(status) > 0"
+ v-for="task in displayedTasks"
+ :key="task.name"
round
- size="medium"
- :type="
- status === Task_Status.RUNNING
- ? 'info'
- : status === Task_Status.FAILED
- ? 'error'
- : status === Task_Status.PENDING
- ? 'warning'
- : 'default'
- "
- class="cursor-pointer hover:opacity-80 transition-opacity"
- @click.stop="handleTaskStatusClick(status)"
+ size="small"
+ :bordered="false"
+ :class="isCreated && 'cursor-pointer hover:opacity-80'"
+ @click.stop="handleTaskClick(task)"
>
<template #avatar>
- <TaskStatus :status="status" size="small" disabled />
+ <TaskStatus :status="task.status" size="tiny" disabled />
</template>
- <div class="flex flex-row items-center gap-2">
- <span class="select-none text-base">{{
- stringifyTaskStatus(status)
- }}</span>
- <span class="select-none text-base font-medium">{{
- getTaskCount(status)
- }}</span>
- </div>
+ <DatabaseDisplay :database="task.target" />
</NTag>
- </template>
+ <NTag
+ v-if="remainingTaskCount > 0"
+ round
+ size="small"
+ type="default"
+ :bordered="false"
+ class="opacity-80"
+ :class="isCreated && 'cursor-pointer hover:opacity-100'"
+ @click.stop="handleClickStageTitle()"
+ >
+ +{{ remainingTaskCount }} more
+ </NTag>
+ </div>
</div>
</div>
@@ -71,6 +120,7 @@
<RunTasksButton
v-if="isCreated"
:stage="stage"
+ :size="'small'"
:disabled="!canRunTasks || runableTasks.length === 0"
@run-tasks="handleRunAllTasks"
/>
@@ -83,7 +133,7 @@
<template #trigger>
<NTooltip>
<template #trigger>
- <NButton size="medium">
+ <NButton :size="'small'">
<template #icon>
<CircleFadingPlusIcon class="w-5 h-5" />
</template>
@@ -102,13 +152,21 @@
</template>
<script setup lang="ts">
-import { CircleFadingPlusIcon } from "lucide-vue-next";
+import {
+ CircleFadingPlusIcon,
+ ChevronDownIcon,
+ ChevronUpIcon,
+} from "lucide-vue-next";
import { NTooltip, NButton, NPopconfirm, NTag } from "naive-ui";
import { twMerge } from "tailwind-merge";
-import { computed } from "vue";
+import { computed, ref } from "vue";
import { useRouter } from "vue-router";
+import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
-import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL } from "@/router/dashboard/projectV1";
+import {
+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
+} from "@/router/dashboard/projectV1";
import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
import { getTimeForPbTimestampProtoEs } from "@/types";
import type {
@@ -144,13 +202,13 @@ const emit = defineEmits<{
const { canPerformTaskAction } = useTaskActionPermissions();
const TASK_STATUS_FILTERS: Task_Status[] = [
- Task_Status.DONE,
Task_Status.RUNNING,
- Task_Status.PENDING,
Task_Status.FAILED,
Task_Status.CANCELED,
- Task_Status.NOT_STARTED,
+ Task_Status.DONE,
+ Task_Status.PENDING,
Task_Status.SKIPPED,
+ Task_Status.NOT_STARTED,
];
const isCreated = computed(() => {
@@ -159,13 +217,65 @@ const isCreated = computed(() => {
);
});
+// Determine if this is an active stage (has running tasks) or first unfinished stage
+const isActiveOrFirstUnfinished = computed(() => {
+ // Check if stage has running tasks
+ const hasRunningTasks = props.stage.tasks.some(
+ (task) => task.status === Task_Status.RUNNING
+ );
+ if (hasRunningTasks) return true;
+
+ // Find first stage with unfinished tasks
+ for (const stage of props.rollout.stages) {
+ const hasUnfinishedTasks = stage.tasks.some(
+ (task) =>
+ task.status !== Task_Status.DONE &&
+ task.status !== Task_Status.SKIPPED &&
+ task.status !== Task_Status.CANCELED
+ );
+ if (hasUnfinishedTasks) {
+ return stage.environment === props.stage.environment;
+ }
+ }
+
+ return false;
+});
+
+// Toggle state for showing/hiding tasks - default based on stage state
+const showTasks = ref(isActiveOrFirstUnfinished.value);
+
const filteredTasks = computed(() => {
- if (!props.taskStatusFilter || props.taskStatusFilter.length === 0) {
- return props.stage.tasks;
+ let tasks = props.stage.tasks;
+
+ // Apply status filter if provided
+ if (props.taskStatusFilter && props.taskStatusFilter.length > 0) {
+ tasks = tasks.filter((task) =>
+ props.taskStatusFilter!.includes(task.status)
+ );
}
- return props.stage.tasks.filter((task) =>
- props.taskStatusFilter!.includes(task.status)
- );
+
+ // Sort tasks by status order defined in TASK_STATUS_FILTERS
+ const statusOrder = new Map<Task_Status, number>();
+ TASK_STATUS_FILTERS.forEach((status, index) => {
+ statusOrder.set(status, index);
+ });
+
+ return tasks.slice().sort((a, b) => {
+ const aOrder = statusOrder.get(a.status) ?? Number.MAX_SAFE_INTEGER;
+ const bOrder = statusOrder.get(b.status) ?? Number.MAX_SAFE_INTEGER;
+ return aOrder - bOrder;
+ });
+});
+
+// Limit displayed tasks to approximately 2 rows worth
+const MAX_DISPLAYED_TASKS = 6; // Adjust based on typical tag width
+
+const displayedTasks = computed(() => {
+ return filteredTasks.value.slice(0, MAX_DISPLAYED_TASKS);
+});
+
+const remainingTaskCount = computed(() => {
+ return Math.max(0, filteredTasks.value.length - MAX_DISPLAYED_TASKS);
});
const runableTasks = computed(() => {
@@ -268,4 +378,26 @@ const handleTaskStatusClick = (status: Task_Status) => {
},
});
};
+
+const handleTaskClick = (task: Task) => {
+ // Only navigate if the stage is created
+ if (!isCreated.value) return;
+
+ const rolloutId = props.rollout.name.split("/").pop();
+ const stageId = props.stage.name.split("/").pop();
+ const taskId = task.name.split("/").pop();
+
+ if (!rolloutId || !stageId || !taskId) return;
+
+ // Navigate to the task detail route
+ router.push({
+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(project.value.name),
+ rolloutId,
+ stageId,
+ taskId,
+ },
+ });
+};
</script>
diff --git a/frontend/src/components/Plan/components/common/DatabaseDisplay.vue b/frontend/src/components/Plan/components/common/DatabaseDisplay.vue
index bfd1e6c44f..3caaa685c6 100644
--- a/frontend/src/components/Plan/components/common/DatabaseDisplay.vue
+++ b/frontend/src/components/Plan/components/common/DatabaseDisplay.vue
@@ -9,9 +9,9 @@
{{ instanceDisplayName }}
</span>
<ChevronRightIcon
- class="inline opacity-60 text-gray-600 w-4 h-4 shrink-0"
+ class="inline opacity-60 text-gray-500 w-4 h-4 shrink-0"
/>
- <span class="truncate text-gray-800">
+ <span class="truncate text-gray-700">
{{ databaseDisplayName }}
</span>
</div>
diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.ts
index d20aa4dce9..1385928a7a 100644
--- a/frontend/src/components/Plan/logic/poller/poller.ts
+++ b/frontend/src/components/Plan/logic/poller/poller.ts
@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from "uuid";
import {
computed,
inject,
+ nextTick,
provide,
ref,
watch,
@@ -54,8 +55,11 @@ export const provideResourcePoller = () => {
const { isCreating, plan, planCheckRuns, issue, rollout, events } =
usePlanContext();
- // Track refreshing state
- const isRefreshing = ref(false);
+ // Track refreshing state per resource
+ const refreshingResources = ref(new Set<ResourceType>());
+
+ // Computed overall refreshing state
+ const isRefreshing = computed(() => refreshingResources.value.size > 0);
const enhancedPollingResources = ref<ResourceType[]>([]);
@@ -105,7 +109,7 @@ export const provideResourcePoller = () => {
// Issue-specific pages
if (includes([PROJECT_V1_ROUTE_ISSUE_DETAIL_V1], routeName)) {
- return ["issue", "issueComments", "plan"];
+ return ["issue", "issueComments"];
}
// Rollout-specific pages
@@ -123,7 +127,7 @@ export const provideResourcePoller = () => {
}
// Default to polling all resources
- return ["plan", "issue", "issueComments", "rollout"];
+ return ["plan", "planCheckRuns", "issue", "issueComments", "rollout"];
});
const resourcesToPolled = computed<ResourceType[]>(() => {
@@ -168,7 +172,7 @@ export const provideResourcePoller = () => {
resource: ResourceType
) => {
return async () => {
- isRefreshing.value = true;
+ refreshingResources.value.add(resource);
resourceBeingRefreshed.value = resource;
try {
await refreshFn();
@@ -178,7 +182,7 @@ export const provideResourcePoller = () => {
isManual: false,
});
} finally {
- isRefreshing.value = false;
+ nextTick(() => refreshingResources.value.delete(resource));
resourceBeingRefreshed.value = null;
}
};
@@ -292,6 +296,11 @@ export const provideResourcePoller = () => {
const activeResources = resourcesToPolled.value;
const refreshPromises = [];
+ // Mark all resources as refreshing at once
+ activeResources.forEach((resource) =>
+ refreshingResources.value.add(resource)
+ );
+
if (activeResources.includes("plan"))
refreshPromises.push(refreshPlanOnly());
if (activeResources.includes("planCheckRuns"))
@@ -303,7 +312,6 @@ export const provideResourcePoller = () => {
if (activeResources.includes("rollout"))
refreshPromises.push(refreshRolloutOnly());
- isRefreshing.value = true;
try {
await Promise.all(refreshPromises);
// Emit event after successful refresh
@@ -312,7 +320,11 @@ export const provideResourcePoller = () => {
isManual,
});
} finally {
- isRefreshing.value = false;
+ nextTick(() =>
+ activeResources.forEach((resource) =>
+ refreshingResources.value.delete(resource)
+ )
+ );
}
};
@@ -424,7 +436,7 @@ export const provideResourcePoller = () => {
refreshAllManual,
requestEnhancedPolling,
restartActivePollers,
- isRefreshing: computed(() => isRefreshing.value),
+ isRefreshing,
activeResources: resourcesToPolled,
};
diff --git a/frontend/src/components/Rollout/kits/TaskStatus.vue b/frontend/src/components/Rollout/kits/TaskStatus.vue
index 7789e1bff7..4643506804 100644
--- a/frontend/src/components/Rollout/kits/TaskStatus.vue
+++ b/frontend/src/components/Rollout/kits/TaskStatus.vue
@@ -70,13 +70,16 @@ import { stringifyTaskStatus } from "@/utils";
const props = defineProps<{
status: Task_Status;
- size?: "small" | "medium" | "large";
+ size?: "tiny" | "small" | "medium" | "large";
disabled?: boolean;
}>();
const classes = computed((): string => {
let sizeClass = "";
switch (props.size) {
+ case "tiny":
+ sizeClass = "w-4 h-4";
+ break;
case "small":
sizeClass = "w-5 h-5";
break;