Skip to content

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

chore: use selected task instead of active task in issue page (#14533)

boojack0f9cdec90e72
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue
index da41494192..34e5930590 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue
@@ -18,10 +18,10 @@ import { isDatabaseDataExportIssue } from "@/utils";
import { ExportArchiveDownloadButton } from "../request";
const currentUser = useCurrentUserV1();
-const { issue, activeTask } = useIssueContext();
+const { issue, selectedTask } = useIssueContext();
const taskRolloutActionList = computed(() => {
- return getApplicableTaskRolloutActionList(issue.value, activeTask.value);
+ return getApplicableTaskRolloutActionList(issue.value, selectedTask.value);
});
const primaryTaskRolloutActionList = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
index 99b170e898..dce572c06e 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
@@ -50,7 +50,7 @@ const currentUser = useCurrentUserV1();
const hideIssueReviewActions = useAppFeature(
"bb.feature.issue.hide-review-actions"
);
-const { issue, phase, reviewContext, events, activeTask, activeStage } =
+const { issue, phase, reviewContext, events, selectedTask, selectedStage } =
useIssueContext();
const { ready, status, done } = reviewContext;
@@ -128,11 +128,11 @@ const forceRolloutActionList = computed((): ExtraActionOption[] => {
const taskExtraActionOptions = getApplicableTaskRolloutActionList(
issue.value,
- activeTask.value
+ selectedTask.value
).map<ExtraActionOption>((action) => ({
type: "TASK",
action,
- target: activeTask.value,
+ target: selectedTask.value,
label: `${t("common.force-verb", {
verb: taskRolloutActionDisplayName(action).toLowerCase(),
})}`,
@@ -140,7 +140,7 @@ const forceRolloutActionList = computed((): ExtraActionOption[] => {
}));
const stageExtraActionOptions = getApplicableStageRolloutActionList(
issue.value,
- activeStage.value
+ selectedStage.value
).map<ExtraActionOption>(({ action, tasks }) => {
const taskActionName = taskRolloutActionDisplayName(action);
const stageActionName = t("issue.action-to-current-stage", {
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
index 50867666b7..8a5ad2d11a 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
@@ -59,8 +59,8 @@ import type { RolloutAction } from "./common";
const { t } = useI18n();
const {
issue,
- activeStage,
- activeTask,
+ selectedStage,
+ selectedTask,
events,
releaserCandidates,
reviewContext,
@@ -74,13 +74,13 @@ const issueStatusActionList = computed(() => {
});
const taskRolloutActionList = computed(() => {
- return getApplicableTaskRolloutActionList(issue.value, activeTask.value);
+ return getApplicableTaskRolloutActionList(issue.value, selectedTask.value);
});
const stageRolloutActionList = computed(() => {
return getApplicableStageRolloutActionList(
issue.value,
- activeStage.value,
+ selectedStage.value,
false /* !allowSkipPendingTasks */
);
});
@@ -141,7 +141,7 @@ const issueStatusButtonsDisplayMode = computed(() => {
const performRolloutAction = async (params: RolloutAction) => {
const { action, target } = params;
if (target === "TASK") {
- return performBatchTaskAction(action, [activeTask.value]);
+ return performBatchTaskAction(action, [selectedTask.value]);
}
if (target === "STAGE") {
const actionItem = stageRolloutActionList.value.find(
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue
index d23b308c0e..b2bd8b1534 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue
@@ -48,14 +48,14 @@ defineEmits<{
}>();
const { t } = useI18n();
-const { issue, activeTask, releaserCandidates } = useIssueContext();
+const { issue, selectedTask, releaserCandidates } = useIssueContext();
const errors = asyncComputed(async () => {
const errors: ErrorItem[] = [];
if (
!(await allowUserToApplyTaskRolloutAction(
issue.value,
- activeTask.value,
+ selectedTask.value,
props.action,
releaserCandidates.value
))
@@ -88,7 +88,7 @@ const errors = asyncComputed(async () => {
const actionList = computed(() => {
const { action } = props;
- const text = taskRolloutActionDisplayName(action, activeTask.value);
+ const text = taskRolloutActionDisplayName(action, selectedTask.value);
const actionProps: RolloutButtonAction["props"] = {
...taskRolloutActionButtonProps(action),
tag: "div",
diff --git a/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue
index 77fef7bf50..e7ac2466f9 100644
--- a/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue
@@ -123,7 +123,7 @@ const { t } = useI18n();
const state = reactive<LocalState>({
loading: false,
});
-const { events, issue, activeTask } = useIssueContext();
+const { events, issue, selectedTask } = useIssueContext();
const comment = ref("");
const performActionAnyway = ref(false);
@@ -140,7 +140,7 @@ const title = computed(() => {
});
const database = computed(() =>
- databaseForTask(issue.value, activeTask.value)
+ databaseForTask(issue.value, selectedTask.value)
);
const planCheckErrors = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
index e14e7274ec..7eddb39c42 100644
--- a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
@@ -177,7 +177,7 @@ const { t } = useI18n();
const state = reactive<LocalState>({
loading: false,
});
-const { issue, activeTask, events, getPlanCheckRunsForTask } =
+const { issue, selectedTask, events, getPlanCheckRunsForTask } =
useIssueContext();
const comment = ref("");
const performActionAnyway = ref(false);
@@ -185,14 +185,16 @@ const performActionAnyway = ref(false);
const title = computed(() => {
if (!props.action) return "";
- const action = taskRolloutActionDisplayName(props.action, activeTask.value);
+ const action = taskRolloutActionDisplayName(props.action, selectedTask.value);
if (props.taskList.length > 1) {
return t("task.action-all-tasks-in-current-stage", { action });
}
return action;
});
-const database = computed(() => databaseForTask(issue.value, activeTask.value));
+const database = computed(() =>
+ databaseForTask(issue.value, selectedTask.value)
+);
const stage = computed(() => {
const firstTask = head(props.taskList);
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue
index 58ea9a193a..02b6cb4f32 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue
@@ -26,7 +26,7 @@ const props = defineProps<{
}>();
const { t } = useI18n();
-const { isCreating, issue, activeTask } = useIssueContext();
+const { isCreating, issue, selectedTask } = useIssueContext();
const code = computed(() => {
return props.row.checkResult.sqlReviewReport?.code;
@@ -39,10 +39,10 @@ const advise = computed(() => {
if (!code.value) {
return undefined;
}
- if (isGroupingChangeTaskV1(issue.value, activeTask.value)) {
+ if (isGroupingChangeTaskV1(issue.value, selectedTask.value)) {
return undefined;
}
- if (!allowGhostForTask(issue.value, activeTask.value)) {
+ if (!allowGhostForTask(issue.value, selectedTask.value)) {
return undefined;
}
if (code.value === 1801) {
diff --git a/frontend/src/components/IssueV1/components/Sidebar/useActiveTaskSheet.ts b/frontend/src/components/IssueV1/components/Sidebar/useActiveTaskSheet.ts
deleted file mode 100644
index f894237b06..0000000000
--- a/frontend/src/components/IssueV1/components/Sidebar/useActiveTaskSheet.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { computed, ref, watch } from "vue";
-import { useIssueContext } from "@/components/IssueV1/logic";
-import { useSheetV1Store } from "@/store";
-import { extractSheetUID, sheetNameOfTaskV1 } from "@/utils";
-
-export const useActiveTaskSheet = () => {
- const sheetStore = useSheetV1Store();
- const { isCreating, activeTask } = useIssueContext();
-
- const sheetName = computed(() => {
- return sheetNameOfTaskV1(activeTask.value);
- });
- const sheetReady = ref(false);
- const sheet = computed(() => {
- if (isCreating.value) {
- return undefined;
- }
- const name = sheetName.value;
- // Use any (basic or full) view of sheets here to save data size
- return sheetStore.getSheetByName(name);
- });
- watch(
- [sheetName, isCreating],
- ([sheetName, isCreating]) => {
- if (isCreating) {
- sheetReady.value = true;
- return;
- }
- const uid = extractSheetUID(sheetName);
- if (!uid) return;
- sheetReady.value = false;
- // Use any (basic or full) view of sheets here to save data size
- sheetStore.getOrFetchSheetByName(sheetName).finally(() => {
- sheetReady.value = true;
- });
- },
- { immediate: true }
- );
-
- return {
- sheet,
- sheetName,
- sheetReady,
- };
-};
diff --git a/frontend/src/components/IssueV1/components/StageSection/StageCard.vue b/frontend/src/components/IssueV1/components/StageSection/StageCard.vue
index 9a17634f65..a5317a2f6e 100644
--- a/frontend/src/components/IssueV1/components/StageSection/StageCard.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/StageCard.vue
@@ -89,7 +89,7 @@ const props = defineProps<{
const { t } = useI18n();
const {
isCreating,
- activeTask,
+ selectedTask,
selectedStage,
events,
getPlanCheckRunsForTask,
@@ -109,12 +109,11 @@ const isSelectedStage = computed(() => {
const isActiveStage = computed(() => {
if (isCreating.value) {
- // In create mode we don't have an ActiveStage
return false;
}
const taskFound = props.stage.tasks.find(
- (t) => t.name === activeTask.value.name
+ (t) => t.name === selectedTask.value.name
);
if (taskFound && !isTaskFinished(taskFound)) {
// A stage is "Active" if the ActiveTaskOfPipeline is inside this stage
diff --git a/frontend/src/components/IssueV1/components/StageSection/StageInfo/StageSelect.vue b/frontend/src/components/IssueV1/components/StageSection/StageInfo/StageSelect.vue
index 8444a004fd..099f3764a2 100644
--- a/frontend/src/components/IssueV1/components/StageSection/StageInfo/StageSelect.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/StageInfo/StageSelect.vue
@@ -29,7 +29,7 @@ type StageSelectOption = SelectOption & {
};
const { t } = useI18n();
-const { isCreating, issue, activeStage, selectedStage, events } =
+const { isCreating, issue, selectedStage, events } =
useIssueContext();
const stageList = computed(() => issue.value.rolloutEntity?.stages || []);
@@ -46,7 +46,7 @@ const renderLabel = (option: SelectOption) => {
const { stage } = option as StageSelectOption;
const text =
- !isCreating.value && stage === activeStage.value
+ !isCreating.value && stage === selectedStage.value
? t("issue.stage-select.current", { name: stage.title })
: stage.title;
return h("div", { class: "flex items-center gap-x-1" }, [
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue b/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue
index 296ddb7074..fc6c77bbc4 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue
@@ -10,7 +10,6 @@
<div class="flex items-center flex-1 gap-x-1">
<TaskStatusIcon
:create="isCreating"
- :active="active"
:status="task.status"
:task="task"
class="transform scale-75"
@@ -18,7 +17,6 @@
<div
class="name flex-1 inline-flex gap-x-1 items-center flex-wrap overflow-x-hidden"
>
- <ArrowRightIcon v-if="active" class="w-4 h-4 inline-block" />
<span>{{ databaseForTask(issue, task).databaseName }}</span>
<NTag v-if="schemaVersion" class="font-normal" size="small" round>
{{ schemaVersion }}
@@ -50,7 +48,6 @@
</template>
<script setup lang="ts">
-import { ArrowRightIcon } from "lucide-vue-next";
import { NTag } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
@@ -59,7 +56,7 @@ import { Workflow } from "@/types/proto/v1/project_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import { Task_Type, task_StatusToJSON } from "@/types/proto/v1/rollout_service";
import { extractSchemaVersionFromTask, isDev } from "@/utils";
-import { databaseForTask, isTaskFinished, useIssueContext } from "../../logic";
+import { databaseForTask, useIssueContext } from "../../logic";
import TaskStatusIcon from "../TaskStatusIcon.vue";
import TaskExtraActionsButton from "./TaskExtraActionsButton.vue";
@@ -70,15 +67,8 @@ const props = defineProps<{
}>();
const { t } = useI18n();
-const { isCreating, issue, activeTask, selectedTask, events } =
- useIssueContext();
+const { isCreating, issue, selectedTask, events } = useIssueContext();
const project = computed(() => issue.value.projectEntity);
-const active = computed(
- () =>
- !isCreating.value &&
- props.task === activeTask.value &&
- !isTaskFinished(props.task)
-);
const selected = computed(() => props.task === selectedTask.value);
const secondaryViewMode = computed((): SecondaryViewMode => {
@@ -116,7 +106,6 @@ const taskClass = computed(() => {
const { task } = props;
const classes: string[] = [];
if (selected.value) classes.push("selected");
- if (active.value) classes.push("active");
if (isCreating.value) classes.push("create");
classes.push(`status_${task_StatusToJSON(task.status).toLowerCase()}`);
return classes;
@@ -145,9 +134,6 @@ const onClickTask = (task: Task) => {
.task .name {
@apply whitespace-pre-wrap break-all;
}
-.task.active .name {
- @apply font-bold;
-}
.task.status_done .name {
@apply text-control;
}
@@ -155,10 +141,6 @@ const onClickTask = (task: Task) => {
.task.status_not_started .name {
@apply text-control;
}
-.task.active.status_pending .name,
-.task.active.status_not_started .name {
- @apply text-info;
-}
.task.status_running .name {
@apply text-info;
}
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue b/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue
index 3bb6867360..cf54d2bec0 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue
@@ -46,7 +46,7 @@ const props = defineProps<{
}>();
const { t } = useI18n();
-const { events, isCreating, activeTask, issue, releaserCandidates } =
+const { events, isCreating, selectedTask, issue, releaserCandidates } =
useIssueContext();
const actionList = computed(() => {
@@ -71,7 +71,7 @@ const options = computed((): ExtraTaskRolloutActionDropdownOption[] => {
return [];
}
const { task } = props;
- if (task.name !== activeTask.value.name) {
+ if (task.name !== selectedTask.value.name) {
return [];
}
const SKIP = actionList.value.includes("SKIP");
diff --git a/frontend/src/components/IssueV1/components/TaskStatusIcon.vue b/frontend/src/components/IssueV1/components/TaskStatusIcon.vue
index b2337475c7..59a6a4966d 100644
--- a/frontend/src/components/IssueV1/components/TaskStatusIcon.vue
+++ b/frontend/src/components/IssueV1/components/TaskStatusIcon.vue
@@ -20,16 +20,7 @@
<heroicons-outline:user class="w-4 h-4" />
</template>
<template v-else-if="status === Task_Status.PENDING">
- <span
- v-if="active"
- class="h-2 w-2 bg-info rounded-full"
- aria-hidden="true"
- />
- <span
- v-else
- class="h-1.5 w-1.5 bg-control rounded-full"
- aria-hidden="true"
- />
+ <span class="h-1.5 w-1.5 bg-control rounded-full" aria-hidden="true" />
</template>
<template v-else-if="status === Task_Status.RUNNING">
<div class="flex h-2.5 w-2.5 relative overflow-visible">
@@ -74,7 +65,6 @@ import { Task_Status } from "@/types/proto/v1/rollout_service";
import { planCheckStatusForTask, useIssueContext } from "../logic";
const props = defineProps<{
- active: boolean;
status: Task_Status;
task?: Task;
ignorePlanCheckStatus?: boolean;
@@ -101,12 +91,12 @@ const classes = computed((): string => {
switch (props.status) {
case Task_Status.NOT_STARTED:
case Task_Status.STATUS_UNSPECIFIED:
- if (!isCreating.value && props.active) {
+ if (!isCreating.value) {
return "bg-white border-2 border-info text-info";
}
return "bg-white border-2 border-control";
case Task_Status.PENDING:
- if (!isCreating.value && props.active) {
+ if (!isCreating.value) {
return "bg-white border-2 border-info text-info ";
}
return "bg-white border-2 border-control";
diff --git a/frontend/src/components/IssueV1/logic/base.ts b/frontend/src/components/IssueV1/logic/base.ts
index 7d4e28dad8..85758919ac 100644
--- a/frontend/src/components/IssueV1/logic/base.ts
+++ b/frontend/src/components/IssueV1/logic/base.ts
@@ -6,28 +6,24 @@ import { useRoute, useRouter } from "vue-router";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import { useUIStateStore } from "@/store";
import { emptyStage, emptyTask } from "@/types";
-import type { Plan_Spec, PlanCheckRun } from "@/types/proto/v1/plan_service";
+import type { PlanCheckRun } from "@/types/proto/v1/plan_service";
import { Task_Type, Stage, Task } from "@/types/proto/v1/rollout_service";
-import { emptyPlanSpec } from "@/types/v1/issue/plan";
import {
activeStageInRollout,
- activeTaskInRollout,
activeTaskInStageV1,
flattenTaskV1List,
uidFromSlug,
indexOrUIDFromSlug,
stageV1Slug,
taskV1Slug,
- flattenSpecList,
extractTaskUID,
- isValidTaskName,
extractStageUID,
} from "@/utils";
import type { IssueContext, IssueEvents, IssuePhase } from "./context";
import { planCheckRunListForTask } from "./plan-check";
import { releaserCandidatesForIssue } from "./releaser";
import { extractReviewContext } from "./review";
-import { specForTask, stageForTask } from "./utils";
+import { stageForTask } from "./utils";
const state = {
uid: -101,
@@ -47,44 +43,9 @@ export const useBaseIssueContext = (
const events: IssueEvents = new Emittery();
- const plan = computed(() => issue.value.planEntity);
const rollout = computed(() => issue.value.rolloutEntity);
- const specs = computed(() => flattenSpecList(plan.value));
const tasks = computed(() => flattenTaskV1List(rollout.value));
- const activeStage = computed((): Stage => {
- return activeStageInRollout(rollout.value);
- });
- const activeTask = computed((): Task => {
- return activeTaskInRollout(rollout.value);
- });
-
- const selectedSpec = computed((): Plan_Spec => {
- // Check if spec is selected from URL. (Not use yet)
- const specSlug = route.query.spec as string;
- if (specSlug) {
- const indexOrId = indexOrUIDFromSlug(specSlug);
- if (isCreating.value) {
- if (indexOrId < specs.value.length) {
- return specs.value[indexOrId];
- }
- } else {
- const specFound = specs.value.find(
- (spec) => spec.id === String(indexOrId)
- );
- if (specFound) {
- return specFound;
- }
- }
- }
-
- // Otherwise, fallback to selected task's spec.
- if (selectedTask.value && isValidTaskName(selectedTask.value.name)) {
- return specForTask(plan.value, selectedTask.value) || emptyPlanSpec();
- }
- // Fallback to first spec.
- return first(specs.value) || emptyPlanSpec();
- });
const selectedStage = computed((): Stage => {
const stageSlug = route.query.stage as string;
const taskSlug = route.query.task as string;
@@ -116,11 +77,11 @@ export const useBaseIssueContext = (
}
}
}
+
// fallback
if (isCreating.value) {
return first(stageList) ?? emptyStage();
}
-
return activeStageInRollout(rollout.value);
});
const selectedTask = computed((): Task => {
@@ -230,11 +191,8 @@ export const useBaseIssueContext = (
events,
releaserCandidates,
reviewContext,
- activeStage,
- activeTask,
selectedStage,
selectedTask,
- selectedSpec,
formatOnSave,
dialog,
getPlanCheckRunsForTask,
diff --git a/frontend/src/components/IssueV1/logic/context.ts b/frontend/src/components/IssueV1/logic/context.ts
index 32a3f3ee81..90d27fc0bc 100644
--- a/frontend/src/components/IssueV1/logic/context.ts
+++ b/frontend/src/components/IssueV1/logic/context.ts
@@ -6,7 +6,7 @@ import { inject, provide } from "vue";
import type { ComposedIssue, ReviewFlow } from "@/types";
import { type User } from "@/types/proto/v1/auth_service";
import type { Issue_Approver_Status } from "@/types/proto/v1/issue_service";
-import type { Plan_Spec, PlanCheckRun } from "@/types/proto/v1/plan_service";
+import type { PlanCheckRun } from "@/types/proto/v1/plan_service";
import type { Stage, Task } from "@/types/proto/v1/rollout_service";
import type {
IssueReviewAction,
@@ -54,14 +54,9 @@ export type IssueContext = {
// review status
reviewContext: ReviewContext;
- // rollout status
- activeStage: Ref<Stage>;
- activeTask: Ref<Task>;
-
// UI status
selectedStage: Ref<Stage>;
selectedTask: Ref<Task>;
- selectedSpec: Ref<Plan_Spec>;
formatOnSave: Ref<boolean>;
// UI events
diff --git a/frontend/src/components/IssueV1/logic/poll.ts b/frontend/src/components/IssueV1/logic/poll.ts
index fd71930b7c..d1ca814a78 100644
--- a/frontend/src/components/IssueV1/logic/poll.ts
+++ b/frontend/src/components/IssueV1/logic/poll.ts
@@ -11,11 +11,7 @@ import { useListCache } from "@/store/modules/v1/cache";
import type { ComposedIssue } from "@/types";
import { IssueStatus } from "@/types/proto/v1/issue_service";
import { Task_Type } from "@/types/proto/v1/rollout_service";
-import {
- extractIssueUID,
- extractProjectResourceName,
- isValidTaskName,
-} from "@/utils";
+import { extractIssueUID, extractProjectResourceName } from "@/utils";
import { flattenTaskV1List } from "@/utils";
import { useIssueContext } from "./context";
@@ -50,7 +46,7 @@ const clearCache = (issue: ComposedIssue) => {
};
export const usePollIssue = () => {
- const { isCreating, ready, issue, events, activeTask } = useIssueContext();
+ const { isCreating, ready, issue, events } = useIssueContext();
const refreshIssue = () => {
if (isCreating.value || !ready.value) return;
@@ -98,11 +94,4 @@ export const usePollIssue = () => {
poller.restart();
}
});
-
- watch(activeTask, (curr, prev) => {
- if (!isValidTaskName(curr.name)) return;
- if (curr.name !== prev.name) {
- events.emit("select-task", { task: curr });
- }
- });
};
diff --git a/frontend/src/utils/v1/issue/rollout.ts b/frontend/src/utils/v1/issue/rollout.ts
index 1f8f9bd069..944822457a 100644
--- a/frontend/src/utils/v1/issue/rollout.ts
+++ b/frontend/src/utils/v1/issue/rollout.ts
@@ -69,11 +69,16 @@ export const taskV1Slug = (task: Task): string => {
};
export const activeTaskInTaskList = (tasks: Task[]): Task => {
- for (const task of tasks) {
- if (
+ // Focus on the running task first.
+ const runningTask = tasks.find((task) => task.status === Task_Status.RUNNING);
+ if (runningTask) {
+ return runningTask;
+ }
+
+ const maybeActiveTask = tasks.find(
+ (task) =>
task.status === Task_Status.NOT_STARTED ||
task.status === Task_Status.PENDING ||
- task.status === Task_Status.RUNNING ||
// "FAILED" is also a transient task status, which requires user
// to take further action (e.g. Skip, Retry)
task.status === Task_Status.FAILED ||
@@ -81,11 +86,12 @@ export const activeTaskInTaskList = (tasks: Task[]): Task => {
// So it should be an "active" task
task.status === Task_Status.CANCELED ||
task.status === Task_Status.STATUS_UNSPECIFIED // compatibility for preview phase
- ) {
- return task;
- }
+ );
+ if (maybeActiveTask) {
+ return maybeActiveTask;
}
+ // fallback
return last(tasks) ?? emptyTask();
};