Skip to content

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

feat(frontend): auto select active task when pipeline moves forward (#1330)

Liu Ji66747f085501
diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vue
index 8016d24341..cf7a53c2d1 100644
--- a/frontend/src/components/Issue/IssueDetailLayout.vue
+++ b/frontend/src/components/Issue/IssueDetailLayout.vue
@@ -109,9 +109,9 @@ import { useRoute } from "vue-router";
import {
pipelineType,
PipelineType,
- activeStage,
+ activeStage as activeStageOfPipeline,
activeTaskInStage,
- activeTask,
+ activeTask as activeTaskOfPipeline,
} from "@/utils";
import IssueBanner from "./IssueBanner.vue";
import IssueHighlightPanel from "./IssueHighlightPanel.vue";
@@ -317,8 +317,35 @@ watch(
}
);
+// When activeTask is changed, we automatically select it.
+// This enables users to know the pipeline status has changed and we may move forward.
+const autoSelectWhenStatusChanged = () => {
+ const activeTask = computed((): Task | undefined => {
+ if (create.value) return undefined;
+ const { pipeline } = issue.value as Issue;
+ if (!pipeline) return undefined;
+ const task = activeTaskOfPipeline(pipeline);
+ return task;
+ });
+
+ watch(
+ // Watch the task.id instead of the task object itself, Since the object might
+ // sometimes drift to another object reference when polling the issue.
+ () => activeTask.value?.id,
+ () => {
+ const task = activeTask.value;
+ if (!task) return;
+ selectTask(task);
+ },
+ // Also triggered when the first time the page is loaded.
+ { immediate: true }
+ );
+};
+
const onStatusChanged = (eager: boolean) => emit("status-changed", eager);
+autoSelectWhenStatusChanged();
+
provideIssueLogic(
{
create,
@@ -332,8 +359,8 @@ provideIssueLogic(
isPITRMode,
isValidStage,
taskStatusOfStage,
- activeStageOfPipeline: activeStage,
- activeTaskOfPipeline: activeTask,
+ activeStageOfPipeline,
+ activeTaskOfPipeline,
activeTaskOfStage: activeTaskInStage,
selectStageOrTask,
selectTask,
diff --git a/frontend/src/components/Issue/logic/base.ts b/frontend/src/components/Issue/logic/base.ts
index fa4284f5be..0cde90317a 100644
--- a/frontend/src/components/Issue/logic/base.ts
+++ b/frontend/src/components/Issue/logic/base.ts
@@ -113,10 +113,11 @@ export const useBaseIssueLogic = (params: {
};
const selectTask = (task: Task) => {
- if (!create.value) return;
+ if (create.value) return;
+ // Find the stage which the task belongs to
const stage = (issue.value as Issue).pipeline?.stageList.find(
- (t) => t.id === task.id
+ (s) => s.taskList.findIndex((t) => t.id === task.id) >= 0
);
if (!stage) {
return;