Skip to content

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

feat: rollouts in project sidebar (#16688)

boojack8b385ccb7c4b
diff --git a/frontend/src/components/IssueV1/logic/rollout.ts b/frontend/src/components/IssueV1/logic/rollout.ts
index 53f879b5dd..65ac930b1b 100644
--- a/frontend/src/components/IssueV1/logic/rollout.ts
+++ b/frontend/src/components/IssueV1/logic/rollout.ts
@@ -1,3 +1,4 @@
+import { head, includes } from "lodash-es";
import { t } from "@/plugins/i18n";
import { extractUserId, useCurrentUserV1 } from "@/store";
import type { ComposedIssue } from "@/types";
@@ -9,7 +10,6 @@ import {
Task_Type,
} from "@/types/proto/v1/rollout_service";
import { extractDatabaseGroupName, hasProjectPermissionV2 } from "@/utils";
-import { head, includes } from "lodash-es";
import { projectOfIssue, specForTask } from ".";
export const isGroupingChangeTaskV1 = (issue: ComposedIssue, task: Task) => {
@@ -94,6 +94,8 @@ export const semanticTaskType = (type: Task_Type) => {
return "DDL";
case Task_Type.DATABASE_SCHEMA_UPDATE_GHOST:
return "gh-ost";
+ case Task_Type.DATABASE_EXPORT:
+ return "Export";
}
- return "";
+ return type.toString();
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index e4fea9f0b1..be9263d9d4 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -24,10 +24,6 @@
@close="pendingStatusAction = undefined"
/>
</template>
- <RolloutActionPanel
- :action="pendingRolloutAction"
- @close="pendingRolloutAction = undefined"
- />
</template>
</template>
@@ -51,7 +47,6 @@ import { CreateButton } from "./create";
import {
IssueReviewActionPanel,
IssueStatusActionPanel,
- RolloutActionPanel,
IssueCreationActionPanel,
} from "./panels";
import {
@@ -62,7 +57,7 @@ import {
type UnifiedAction,
} from "./unified";
-const { isCreating, plan, issue } = usePlanContext();
+const { isCreating, issue } = usePlanContext();
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
@@ -72,7 +67,6 @@ const reviewContext = provideIssueReviewContext(issue);
// Panel visibility state
const pendingReviewAction = ref<IssueReviewAction | undefined>(undefined);
const pendingStatusAction = ref<IssueStatusAction | undefined>(undefined);
-const pendingRolloutAction = ref<"CREATE" | undefined>(undefined);
const pendingIssueCreationAction = ref<"CREATE" | undefined>(undefined);
// Compute available actions based on issue state and user permissions
@@ -167,16 +161,7 @@ const availableActions = computed(() => {
actions.push("CLOSE");
}
- // Check for rollout creation action
- if (reviewContext.done.value && !plan.value.rollout) {
- const canCreateRollout = hasProjectPermissionV2(
- project.value,
- "bb.rollouts.create"
- );
- if (canCreateRollout) {
- actions.push("CREATE_ROLLOUT");
- }
- }
+ // No separate rollout creation - handled when creating issue
return actions;
});
@@ -189,11 +174,6 @@ const primaryAction = computed((): ActionConfig | undefined => {
return { action: "CREATE_ISSUE" };
}
- // CREATE_ROLLOUT is the highest priority when available
- if (actions.includes("CREATE_ROLLOUT")) {
- return { action: "CREATE_ROLLOUT" };
- }
-
// REOPEN is primary when issue is closed
if (actions.includes("REOPEN")) {
return { action: "REOPEN" };
@@ -236,9 +216,6 @@ const handlePerformAction = (action: UnifiedAction) => {
case "REOPEN":
pendingStatusAction.value = action as IssueStatusAction;
break;
- case "CREATE_ROLLOUT":
- pendingRolloutAction.value = "CREATE";
- break;
case "CREATE_ISSUE":
pendingIssueCreationAction.value = "CREATE";
break;
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
index 707b74ccb3..55554e20d6 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
@@ -79,22 +79,38 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";
import { ErrorList } from "@/components/Plan/components/common";
-import { planCheckRunListForSpec, usePlanContext } from "@/components/Plan/logic";
+import {
+ planCheckRunListForSpec,
+ usePlanContext,
+} from "@/components/Plan/logic";
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
-import { issueServiceClientConnect } from "@/grpcweb";
-import { PROJECT_V1_ROUTE_ISSUE_DETAIL_V1 } from "@/router/dashboard/projectV1";
-import { useCurrentProjectV1, useCurrentUserV1, usePolicyV1Store } from "@/store";
+import {
+ issueServiceClientConnect,
+ rolloutServiceClientConnect,
+ planServiceClientConnect,
+} from "@/grpcweb";
+import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
+import {
+ useCurrentProjectV1,
+ useCurrentUserV1,
+ usePolicyV1Store,
+} from "@/store";
import { emptyIssue } from "@/types";
import { CreateIssueRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
+import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
+import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
import { Issue, IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";
import { PolicyType } from "@/types/proto/v1/org_policy_service";
import { PlanCheckRun_Result_Status } from "@/types/proto/v1/plan_service";
import {
- extractIssueUID,
extractProjectResourceName,
hasProjectPermissionV2,
+ extractPlanUID,
} from "@/utils";
-import { convertNewIssueToOld, convertOldIssueToNew } from "@/utils/v1/issue-conversions";
+import {
+ convertNewIssueToOld,
+ convertOldIssueToNew,
+} from "@/utils/v1/issue-conversions";
type IssueCreationAction = "CREATE";
@@ -118,7 +134,7 @@ const state = reactive<LocalState>({
const { project } = useCurrentProjectV1();
const currentUser = useCurrentUserV1();
const policyV1Store = usePolicyV1Store();
-const { plan, planCheckRunList } = usePlanContext();
+const { plan, planCheckRunList, events } = usePlanContext();
const comment = ref("");
const restrictIssueCreationForSqlReviewPolicy = ref(false);
@@ -222,19 +238,46 @@ const doCreateIssue = async () => {
plan: plan.value.name,
};
const newIssue = convertOldIssueToNew(issueToCreate);
- const request = create(CreateIssueRequestSchema, {
+ const issueRequest = create(CreateIssueRequestSchema, {
parent: project.value.name,
issue: newIssue,
});
- const newCreatedIssue = await issueServiceClientConnect.createIssue(request);
- const createdIssue = convertNewIssueToOld(newCreatedIssue);
+ const newCreatedIssue =
+ await issueServiceClientConnect.createIssue(issueRequest);
+ convertNewIssueToOld(newCreatedIssue);
+
+ // Then create the rollout from the plan
+ const rolloutRequest = create(CreateRolloutRequestSchema, {
+ parent: project.value.name,
+ rollout: {
+ title: plan.value.title,
+ plan: plan.value.name,
+ },
+ });
+ const createdRollout = await rolloutServiceClientConnect.createRollout(rolloutRequest);
+
+ // Update the plan to include the rollout reference
+ const updatePlanRequest = create(UpdatePlanRequestSchema, {
+ plan: {
+ name: plan.value.name,
+ rollout: createdRollout.name,
+ },
+ updateMask: {
+ paths: ["rollout"],
+ },
+ });
+ await planServiceClientConnect.updatePlan(updatePlanRequest);
+
+ // Emit status changed to refresh the UI
+ events.emit("status-changed", { eager: true });
nextTick(() => {
+ // Stay on the plan page to see the rollout actions
router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
params: {
projectId: extractProjectResourceName(plan.value.name),
- issueId: extractIssueUID(createdIssue.name),
+ planId: extractPlanUID(plan.value.name),
},
});
});
@@ -257,4 +300,4 @@ const buildIssue = () => {
const resetState = () => {
comment.value = "";
};
-</script>
\ No newline at end of file
+</script>
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/RolloutActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/RolloutActionPanel.vue
deleted file mode 100644
index d0e409754b..0000000000
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/RolloutActionPanel.vue
+++ /dev/null
@@ -1,178 +0,0 @@
-<template>
- <CommonDrawer
- :show="action !== undefined"
- :title="title"
- :loading="state.loading"
- @show="resetState"
- @close="$emit('close')"
- >
- <template #default>
- <div v-if="action" class="flex flex-col gap-y-4 px-1">
- <div class="flex flex-col gap-y-1">
- <div class="font-medium text-control">Plan</div>
- <div class="textinfolabel">
- {{ plan.title }}
- </div>
- </div>
-
- <div class="flex flex-col gap-y-1">
- <div class="font-medium text-control">
- {{ $t("common.description") }}
- </div>
- <div class="textinfolabel">
- {{ plan.description || "No description" }}
- </div>
- </div>
-
- <div class="flex flex-col gap-y-1">
- <p class="font-medium text-control">
- {{ $t("common.comment") }}
- </p>
- <NInput
- v-model:value="comment"
- type="textarea"
- :placeholder="$t('issue.leave-a-comment')"
- :autosize="{
- minRows: 3,
- maxRows: 10,
- }"
- />
- </div>
- </div>
- </template>
- <template #footer>
- <div
- v-if="action"
- class="w-full flex flex-row justify-end items-center gap-2"
- >
- <div class="flex justify-end gap-x-3">
- <NButton @click="$emit('close')">
- {{ $t("common.cancel") }}
- </NButton>
-
- <NTooltip :disabled="confirmErrors.length === 0" placement="top">
- <template #trigger>
- <NButton
- type="primary"
- :disabled="confirmErrors.length > 0"
- @click="handleConfirm"
- >
- {{ $t("common.create") }}
- </NButton>
- </template>
- <template #default>
- <ErrorList :errors="confirmErrors" />
- </template>
- </NTooltip>
- </div>
- </div>
- </template>
- </CommonDrawer>
-</template>
-
-<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import { NButton, NInput, NTooltip } from "naive-ui";
-import { computed, nextTick, reactive, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";
-import { ErrorList } from "@/components/Plan/components/common";
-import { usePlanContext, useIssueReviewContext } from "@/components/Plan/logic";
-import { rolloutServiceClientConnect } from "@/grpcweb";
-import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL } from "@/router/dashboard/projectV1";
-import { useCurrentProjectV1 } from "@/store";
-import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
-import {
- extractProjectResourceName,
- extractRolloutUID,
- hasProjectPermissionV2,
-} from "@/utils";
-
-type RolloutAction = "CREATE";
-
-type LocalState = {
- loading: boolean;
-};
-
-const props = defineProps<{
- action?: RolloutAction;
-}>();
-const emit = defineEmits<{
- (event: "close"): void;
-}>();
-
-const { t } = useI18n();
-const router = useRouter();
-const state = reactive<LocalState>({
- loading: false,
-});
-const { project } = useCurrentProjectV1();
-const { plan } = usePlanContext();
-const reviewContext = useIssueReviewContext();
-const comment = ref("");
-
-const title = computed(() => {
- switch (props.action) {
- case "CREATE":
- return t("common.create") + " " + t("common.rollout");
- }
- return ""; // Make linter happy
-});
-
-const confirmErrors = computed(() => {
- const errors: string[] = [];
-
- if (!hasProjectPermissionV2(project.value, "bb.rollouts.create")) {
- errors.push(t("common.missing-required-permission"));
- }
-
- if (plan.value.rollout) {
- errors.push("Rollout already exists for this plan");
- }
-
- if (!reviewContext.done.value) {
- errors.push("Issue must pass approval review before creating rollout");
- }
-
- return errors;
-});
-
-const handleConfirm = async () => {
- const { action } = props;
- if (!action) return;
- state.loading = true;
-
- try {
- if (action === "CREATE") {
- const request = create(CreateRolloutRequestSchema, {
- parent: project.value.name,
- rollout: {
- plan: plan.value.name,
- title: plan.value.title,
- },
- });
-
- const createdRollout =
- await rolloutServiceClientConnect.createRollout(request);
-
- nextTick(() => {
- router.push({
- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
- params: {
- projectId: extractProjectResourceName(plan.value.name),
- rolloutId: extractRolloutUID(createdRollout.name),
- },
- });
- });
- }
- } finally {
- state.loading = false;
- emit("close");
- }
-};
-
-const resetState = () => {
- comment.value = "";
-};
-</script>
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts
index a58b9979e6..6fa7bee9b2 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts
@@ -1,4 +1,3 @@
export { default as IssueReviewActionPanel } from "./IssueReviewActionPanel.vue";
export { default as IssueStatusActionPanel } from "./IssueStatusActionPanel.vue";
-export { default as RolloutActionPanel } from "./RolloutActionPanel.vue";
export { default as IssueCreationActionPanel } from "./IssueCreationActionPanel.vue";
\ No newline at end of file
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/rollout/CreateRolloutButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/rollout/CreateRolloutButton.vue
deleted file mode 100644
index 0a8a809372..0000000000
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/rollout/CreateRolloutButton.vue
+++ /dev/null
@@ -1,60 +0,0 @@
-<template>
- <NTooltip :disabled="errors.length === 0" placement="top">
- <template #trigger>
- <NButton
- type="primary"
- size="medium"
- tag="div"
- :disabled="errors.length > 0"
- @click="handleCreateRollout"
- >
- {{ $t("common.create") }} {{ $t("common.rollout") }}
- </NButton>
- </template>
-
- <template #default>
- <ErrorList :errors="errors" />
- </template>
- </NTooltip>
-</template>
-
-<script setup lang="ts">
-import { NTooltip, NButton } from "naive-ui";
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
-import { ErrorList } from "@/components/Plan/components/common";
-import { usePlanContext, useIssueReviewContext } from "@/components/Plan/logic";
-import { useCurrentProjectV1 } from "@/store";
-import { hasProjectPermissionV2 } from "@/utils";
-
-const emit = defineEmits<{
- (event: "create-rollout"): void;
-}>();
-
-const { t } = useI18n();
-const { project } = useCurrentProjectV1();
-const { plan } = usePlanContext();
-const reviewContext = useIssueReviewContext();
-
-const errors = computed(() => {
- const errorList: string[] = [];
-
- if (!hasProjectPermissionV2(project.value, "bb.rollouts.create")) {
- errorList.push(t("common.missing-required-permission"));
- }
-
- if (plan.value.rollout) {
- errorList.push("Rollout already exists for this plan");
- }
-
- if (!reviewContext.done.value) {
- errorList.push("Issue must pass approval review before creating rollout");
- }
-
- return errorList;
-});
-
-const handleCreateRollout = () => {
- emit("create-rollout");
-};
-</script>
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/rollout/index.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/rollout/index.ts
deleted file mode 100644
index 1180545ff4..0000000000
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/rollout/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as CreateRolloutButton } from "./CreateRolloutButton.vue";
\ No newline at end of file
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue
index aee8fc4529..538f55a7ef 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue
@@ -38,8 +38,6 @@ const actionDisplayName = (action: UnifiedAction): string => {
return t("issue.batch-transition.close");
case "REOPEN":
return t("issue.batch-transition.reopen");
- case "CREATE_ROLLOUT":
- return t("common.create") + " " + t("common.rollout");
case "CREATE_ISSUE":
return t("common.create") + " " + t("common.issue");
}
@@ -48,7 +46,6 @@ const actionDisplayName = (action: UnifiedAction): string => {
const actionButtonProps = (action: UnifiedAction) => {
switch (action) {
case "APPROVE":
- case "CREATE_ROLLOUT":
case "CREATE_ISSUE":
return {
type: "primary" as const,
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
index b5f9e898ad..315efaa0e9 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
@@ -57,15 +57,11 @@ const actionDisplayName = (action: UnifiedAction): string => {
return t("issue.batch-transition.close");
case "REOPEN":
return t("issue.batch-transition.reopen");
- case "CREATE_ROLLOUT":
- return t("common.create") + " " + t("common.rollout");
case "CREATE_ISSUE":
return t("common.create") + " " + t("common.issue");
}
};
-// Removed unused interface - using inline types instead
-
const dropdownOptions = computed(() => {
return props.secondaryActions.map((config) => ({
key: config.action,
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts
index 0118877487..d1a8cf9a08 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts
@@ -2,11 +2,12 @@ export type IssueReviewAction = "APPROVE" | "REJECT" | "RE_REQUEST";
export type IssueStatusAction = "CLOSE" | "REOPEN";
-export type RolloutAction = "CREATE_ROLLOUT";
-
export type IssueCreationAction = "CREATE_ISSUE";
-export type UnifiedAction = IssueReviewAction | IssueStatusAction | RolloutAction | IssueCreationAction;
+export type UnifiedAction =
+ | IssueReviewAction
+ | IssueStatusAction
+ | IssueCreationAction;
export interface ActionConfig {
action: UnifiedAction;
diff --git a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue b/frontend/src/components/Plan/components/RolloutView/RolloutView.vue
index ba42aba43a..e66f733868 100644
--- a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/RolloutView.vue
@@ -31,7 +31,7 @@
<div class="flex-1 overflow-hidden">
<StageView
v-if="!isTableView"
- :rollout="rollout"
+ :merged-stages="mergedStages"
:task-status-filter="taskStatusFilter"
/>
<TaskTable
@@ -48,12 +48,13 @@ import { ListIcon, Columns3Icon } from "lucide-vue-next";
import { NButton, NButtonGroup } from "naive-ui";
import { ref } from "vue";
import { Task_Status } from "@/types/proto/v1/rollout_service";
-import { usePlanContextWithRollout } from "../../logic";
+import { provideRolloutViewContext } from "./context";
import StageView from "./StageView.vue";
import TaskFilter from "./TaskFilter.vue";
import TaskTable from "./TaskTable.vue";
-const { rollout } = usePlanContextWithRollout();
+// Provide the context and get its values directly
+const { rollout, mergedStages } = provideRolloutViewContext();
const isTableView = ref(false);
const taskStatusFilter = ref<Task_Status[]>([]);
diff --git a/frontend/src/components/Plan/components/RolloutView/RunTasksButton.vue b/frontend/src/components/Plan/components/RolloutView/RunTasksButton.vue
new file mode 100644
index 0000000000..b4cfc7e196
--- /dev/null
+++ b/frontend/src/components/Plan/components/RolloutView/RunTasksButton.vue
@@ -0,0 +1,37 @@
+<template>
+ <NButton v-if="hasRunnableTasks" size="small" @click="handleRunTasks">
+ <template #icon>
+ <PlayIcon class="w-4 h-4" />
+ </template>
+ {{ $t("common.rollout") }}
+ </NButton>
+</template>
+
+<script setup lang="ts">
+import { PlayIcon } from "lucide-vue-next";
+import { NButton } from "naive-ui";
+import { computed } from "vue";
+import type { Stage } from "@/types/proto/v1/rollout_service";
+import { Task_Status } from "@/types/proto/v1/rollout_service";
+
+const props = defineProps<{
+ stage: Stage;
+}>();
+
+const emit = defineEmits<{
+ (event: "run-tasks"): void;
+}>();
+
+const hasRunnableTasks = computed(() => {
+ return props.stage.tasks.some(
+ (task) =>
+ task.status === Task_Status.NOT_STARTED ||
+ task.status === Task_Status.PENDING ||
+ task.status === Task_Status.FAILED
+ );
+});
+
+const handleRunTasks = () => {
+ emit("run-tasks");
+};
+</script>
diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
index 091f9c460a..9c80468724 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
@@ -1,43 +1,43 @@
<template>
- <div class="!w-80 bg-white z-[1] rounded-lg p-1 hover:shadow">
+ <div
+ class="!w-80 bg-white z-[1] rounded-lg p-1"
+ :class="
+ twMerge(
+ isCreated ? 'bg-white shadow' : 'bg-zinc-50 border-2 border-dashed'
+ )
+ "
+ >
<div
class="w-full flex flex-row justify-between items-center gap-2 px-2 pt-2 pb-1"
>
- <p class="textlabel">
+ <p class="text-base font-medium">
{{ environmentStore.getEnvironmentByName(stage.environment).title }}
+ <NTag v-if="!isCreated" round size="tiny">Preview</NTag>
</p>
+ <div v-if="isCreated">
+ <RunTasksButton :stage="stage" @run-tasks="showRunTasksPanel = true" />
+ </div>
</div>
<NVirtualList
- style="max-height: 100vh"
+ style="max-height: 80vh"
:items="filteredTasks"
:item-size="56"
>
<template #default="{ item: task }: { item: Task }">
<div
:key="task.name"
- class="w-full border-t border-zinc-50 flex flex-col items-start justify-start truncate px-2 py-1 h-14"
+ class="w-full border-t border-zinc-50 flex items-center justify-start truncate px-2 py-3 min-h-[56px]"
>
- <div class="w-full flex flex-row items-center text-sm truncate">
- <TaskStatus :status="task.status" size="small" />
- <InstanceV1EngineIcon
- class="inline-block ml-2 mr-1"
- :instance="databaseForTask(project, task).instanceResource"
- />
- <span class="truncate">
- {{ databaseForTask(project, task).instanceResource.title }}
- </span>
- <ChevronRightIcon class="inline opacity-60 w-4 shrink-0" />
- <span class="truncate">
- {{ databaseForTask(project, task).databaseName }}
- </span>
- </div>
- <p class="space-x-1 mt-0.5 leading-4">
+ <TaskStatus :status="task.status" size="small" class="shrink-0" />
+ <TaskDatabaseName :task="task" class="ml-2 flex-1" />
+ <div class="ml-auto flex items-center space-x-1 shrink-0">
<NTooltip>
<template #trigger>
<NTag round size="tiny">{{ semanticTaskType(task.type) }}</NTag>
</template>
{{ $t("common.type") }}
</NTooltip>
+
<NTooltip v-if="extractSchemaVersionFromTask(task)">
<template #trigger>
<NTag round size="tiny">
@@ -46,38 +46,58 @@
</template>
{{ $t("common.version") }}
</NTooltip>
- </p>
+ </div>
</div>
</template>
</NVirtualList>
+
+ <!-- Task Rollout Action Panel -->
+ <TaskRolloutActionPanel
+ :action="showRunTasksPanel ? 'RUN_TASKS' : undefined"
+ :stage="stage"
+ @close="showRunTasksPanel = false"
+ />
</div>
</template>
<script setup lang="ts">
-import { ChevronRightIcon } from "lucide-vue-next";
-import { NTag, NVirtualList, NTooltip } from "naive-ui";
-import { computed } from "vue";
+import { NTag, NTooltip, NVirtualList } from "naive-ui";
+import { twMerge } from "tailwind-merge";
+import { computed, ref } from "vue";
+import { useI18n } from "vue-i18n";
import { semanticTaskType } from "@/components/IssueV1";
import TaskStatus from "@/components/Rollout/RolloutDetail/Panels/kits/TaskStatus.vue";
-import { databaseForTask } from "@/components/Rollout/RolloutDetail/utils";
-import { InstanceV1EngineIcon } from "@/components/v2";
-import { useEnvironmentV1Store, useCurrentProjectV1 } from "@/store";
+import { useEnvironmentV1Store } from "@/store";
import {
Stage,
type Task,
- type Rollout,
type Task_Status,
} from "@/types/proto/v1/rollout_service";
import { extractSchemaVersionFromTask } from "@/utils";
+import RunTasksButton from "./RunTasksButton.vue";
+import TaskDatabaseName from "./TaskDatabaseName.vue";
+import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";
+import { useRolloutViewContext } from "./context";
const props = defineProps<{
stage: Stage;
- rollout: Rollout;
taskStatusFilter: Task_Status[];
}>();
+const { t: $t } = useI18n();
const environmentStore = useEnvironmentV1Store();
-const { project } = useCurrentProjectV1();
+const { rollout } = useRolloutViewContext();
+
+const showRunTasksPanel = ref(false);
+
+const isCreated = computed(() => {
+ if (!rollout.value) {
+ return false;
+ }
+ return rollout.value.stages.some(
+ (stage) => stage.environment === props.stage.environment
+ );
+});
const filteredTasks = computed(() => {
if (props.taskStatusFilter.length === 0) {
diff --git a/frontend/src/components/Plan/components/RolloutView/StageView.vue b/frontend/src/components/Plan/components/RolloutView/StageView.vue
index 735ad60a53..f6caf769ae 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageView.vue
@@ -2,27 +2,25 @@
<div class="w-full h-full flex flex-col p-4">
<div class="w-full flex grow overflow-auto bg-zinc-50 p-6 rounded-lg">
<div
- class="relative w-auto flex flex-row items-start justify-start gap-6"
+ class="relative w-auto flex flex-row items-start justify-start gap-8"
>
- <div class="absolute top-5 border-2 w-full"></div>
- <StageCard
- v-for="stage in rollout.stages"
- :key="stage.name"
- :stage="stage"
- :rollout="rollout"
- :task-status-filter="taskStatusFilter"
- />
+ <!-- Connecting line -->
+ <div class="absolute top-5 border-t-2 border-gray-200 w-full z-0"></div>
+
+ <template v-for="stage in mergedStages" :key="stage.name">
+ <StageCard :stage="stage" :task-status-filter="taskStatusFilter" />
+ </template>
</div>
</div>
</div>
</template>
<script setup lang="ts">
-import type { Rollout, Task_Status } from "@/types/proto/v1/rollout_service";
+import type { Stage, Task_Status } from "@/types/proto/v1/rollout_service";
import StageCard from "./StageCard.vue";
defineProps<{
- rollout: Rollout;
+ mergedStages: Stage[];
taskStatusFilter: Task_Status[];
}>();
</script>
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskDatabaseName.vue b/frontend/src/components/Plan/components/RolloutView/TaskDatabaseName.vue
new file mode 100644
index 0000000000..e204ed9596
--- /dev/null
+++ b/frontend/src/components/Plan/components/RolloutView/TaskDatabaseName.vue
@@ -0,0 +1,59 @@
+<template>
+ <div class="flex items-center text-sm truncate">
+ <InstanceV1EngineIcon
+ class="inline-block mr-1"
+ :instance="database.instanceResource"
+ />
+ <span class="truncate text-gray-600">
+ {{ instanceDisplayName }}
+ </span>
+ <ChevronRightIcon
+ class="inline opacity-60 text-gray-600 w-4 h-4 shrink-0 mx-0.5"
+ />
+ <span class="truncate text-gray-800">
+ {{ databaseDisplayName }}
+ </span>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { ChevronRightIcon } from "lucide-vue-next";
+import { computed } from "vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail/utils";
+import { InstanceV1EngineIcon } from "@/components/v2";
+import { useCurrentProjectV1 } from "@/store";
+import { unknownInstance } from "@/types";
+import type { Task } from "@/types/proto/v1/rollout_service";
+import { extractInstanceResourceName } from "@/utils";
+
+const props = defineProps<{
+ task: Task;
+ environmentTitle?: string;
+}>();
+
+const { project } = useCurrentProjectV1();
+
+const database = computed(() => databaseForTask(project.value, props.task));
+
+const instanceDisplayName = computed(() => {
+ const title = database.value.instanceResource.title;
+ // Fallback for unknown instances - try to extract instance name from task target
+ if (!title || title === unknownInstance().title) {
+ return extractInstanceResourceName(props.task.target);
+ }
+ return title;
+});
+
+const databaseDisplayName = computed(() => {
+ const name = database.value.databaseName;
+ // Fallback for unknown databases - try to extract database name from task target
+ if (name === "<<Unknown database>>" || !name) {
+ const target = props.task.target;
+ if (target && target.includes("/databases/")) {
+ const databaseName = target.split("/databases/")[1];
+ return databaseName || name;
+ }
+ }
+ return name;
+});
+</script>
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue b/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue
index 0de4e49efd..83931ec389 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue
@@ -41,8 +41,9 @@ import { computed } from "vue";
import TaskStatus from "@/components/Rollout/RolloutDetail/Panels/kits/TaskStatus.vue";
import type { Rollout, Task_Status } from "@/types/proto/v1/rollout_service";
import { Task_Status as TaskStatusEnum } from "@/types/proto/v1/rollout_service";
+import { useRolloutViewContext } from "./context";
-const props = defineProps<{
+defineProps<{
rollout: Rollout;
taskStatusList: Task_Status[];
}>();
@@ -51,6 +52,8 @@ const emit = defineEmits<{
(event: "update:taskStatusList", taskStatusList: Task_Status[]): void;
}>();
+const { mergedStages } = useRolloutViewContext();
+
const TASK_STATUS_FILTERS: Task_Status[] = [
TaskStatusEnum.NOT_STARTED,
TaskStatusEnum.PENDING,
@@ -62,7 +65,7 @@ const TASK_STATUS_FILTERS: Task_Status[] = [
];
const allTasks = computed(() => {
- return flatten(props.rollout.stages.map((stage) => stage.tasks));
+ return flatten(mergedStages.value.map((stage) => stage.tasks));
});
const totalTaskCount = computed(() => allTasks.value.length);
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
new file mode 100644
index 0000000000..e34181deae
--- /dev/null
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
@@ -0,0 +1,270 @@
+<template>
+ <CommonDrawer
+ :show="action !== undefined"
+ :title="title"
+ :loading="state.loading"
+ @show="resetState"
+ @close="$emit('close')"
+ >
+ <template #default>
+ <div
+ v-if="action"
+ class="flex flex-col gap-y-4 h-full overflow-y-hidden px-1"
+ >
+ <div
+ class="flex flex-row gap-x-2 shrink-0 overflow-y-hidden justify-start items-center"
+ >
+ <label class="font-medium text-control">
+ {{ $t("common.stage") }}
+ </label>
+ <span class="break-all">
+ {{ environmentStore.getEnvironmentByName(stage.environment).title }}
+ </span>
+ </div>
+
+ <div
+ class="flex flex-col gap-y-1 shrink overflow-y-hidden justify-start"
+ >
+ <label class="font-medium text-control">
+ <template v-if="runnableTasks.length === 1">
+ {{ $t("common.task") }}
+ </template>
+ <template v-else>{{ $t("common.tasks") }}</template>
+ <span class="font-mono opacity-80" v-if="runnableTasks.length > 1"
+ >({{ runnableTasks.length }})</span
+ >
+ </label>
+ <div class="flex-1 overflow-y-auto">
+ <NScrollbar class="max-h-64">
+ <ul class="text-sm space-y-2">
+ <li
+ v-for="task in runnableTasks"
+ :key="task.name"
+ class="flex items-center"
+ >
+ <NTag
+ v-if="semanticTaskType(task.type)"
+ class="mr-2"
+ size="small"
+ >
+ <span class="inline-block text-center">
+ {{ semanticTaskType(task.type) }}
+ </span>
+ </NTag>
+ <TaskDatabaseName :task="task" />
+ </li>
+ </ul>
+ </NScrollbar>
+ </div>
+ </div>
+
+ <div class="flex flex-col gap-y-1 shrink-0">
+ <p class="font-medium text-control">
+ {{ $t("common.comment") }}
+ </p>
+ <NInput
+ v-model:value="comment"
+ type="textarea"
+ :placeholder="$t('issue.leave-a-comment')"
+ :autosize="{
+ minRows: 3,
+ maxRows: 10,
+ }"
+ />
+ </div>
+
+ <div
+ v-if="showScheduledTimePicker"
+ class="flex flex-col gap-y-3 shrink-0"
+ >
+ <div class="flex items-center">
+ <NCheckbox
+ :checked="runTimeInMS === undefined"
+ @update:checked="
+ (checked) =>
+ (runTimeInMS = checked
+ ? undefined
+ : Date.now() + DEFAULT_RUN_DELAY_MS)
+ "
+ >
+ {{ $t("task.run-immediately") }}
+ </NCheckbox>
+ </div>
+ <div v-if="runTimeInMS !== undefined" class="flex flex-col gap-y-1">
+ <p class="font-medium text-control">
+ {{ $t("task.scheduled-time", runnableTasks.length) }}
+ </p>
+ <NDatePicker
+ v-model:value="runTimeInMS"
+ type="datetime"
+ :placeholder="$t('task.select-scheduled-time')"
+ :is-date-disabled="
+ (date: number) => date < dayjs().startOf('day').valueOf()
+ "
+ format="yyyy-MM-dd HH:mm:ss"
+ clearable
+ />
+ </div>
+ </div>
+ </div>
+ </template>
+ <template #footer>
+ <div
+ v-if="action"
+ class="w-full flex flex-row justify-between items-center gap-x-2"
+ >
+ <div class="flex justify-end gap-x-3 w-full">
+ <NButton @click="$emit('close')">
+ {{ $t("common.cancel") }}
+ </NButton>
+
+ <NTooltip :disabled="confirmErrors.length === 0" placement="top">
+ <template #trigger>
+ <NButton
+ :disabled="confirmErrors.length > 0"
+ type="primary"
+ @click="handleConfirm"
+ >
+ {{ $t("common.rollout") }}
+ </NButton>
+ </template>
+ <template #default>
+ <ErrorList :errors="confirmErrors" />
+ </template>
+ </NTooltip>
+ </div>
+ </div>
+ </template>
+ </CommonDrawer>
+</template>
+
+<script setup lang="ts">
+import { create } from "@bufbuild/protobuf";
+import dayjs from "dayjs";
+import Long from "long";
+import {
+ NButton,
+ NCheckbox,
+ NDatePicker,
+ NInput,
+ NScrollbar,
+ NTag,
+ NTooltip,
+} from "naive-ui";
+import { computed, reactive, ref } from "vue";
+import { useI18n } from "vue-i18n";
+import { semanticTaskType } from "@/components/IssueV1";
+import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";
+import { ErrorList } from "@/components/IssueV1/components/common";
+import { rolloutServiceClientConnect } from "@/grpcweb";
+import { pushNotification, useEnvironmentV1Store } from "@/store";
+import { BatchRunTasksRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
+import type { Stage } from "@/types/proto/v1/rollout_service";
+import { Task_Status } from "@/types/proto/v1/rollout_service";
+import TaskDatabaseName from "./TaskDatabaseName.vue";
+
+// Default delay for running tasks if not scheduled immediately.
+const DEFAULT_RUN_DELAY_MS = 60000;
+
+type LocalState = {
+ loading: boolean;
+};
+
+const props = defineProps<{
+ action?: "RUN_TASKS";
+ stage: Stage;
+}>();
+
+const emit = defineEmits<{
+ (event: "close"): void;
+}>();
+
+const { t } = useI18n();
+const state = reactive<LocalState>({
+ loading: false,
+});
+const environmentStore = useEnvironmentV1Store();
+const comment = ref("");
+const runTimeInMS = ref<number | undefined>(undefined);
+
+const title = computed(() => {
+ if (!props.action) return "";
+ return t("common.rollout");
+});
+
+const runnableTasks = computed(() => {
+ return props.stage.tasks.filter(
+ (task) =>
+ task.status === Task_Status.NOT_STARTED ||
+ task.status === Task_Status.PENDING ||
+ task.status === Task_Status.FAILED
+ );
+});
+
+const showScheduledTimePicker = computed(() => {
+ return props.action === "RUN_TASKS";
+});
+
+const confirmErrors = computed(() => {
+ const errors: string[] = [];
+
+ if (runnableTasks.value.length === 0) {
+ errors.push(t("common.no-data"));
+ }
+
+ // Validate scheduled time if not running immediately
+ if (runTimeInMS.value !== undefined) {
+ if (runTimeInMS.value <= Date.now()) {
+ errors.push(t("task.error.scheduled-time-must-be-in-the-future"));
+ }
+ }
+
+ return errors;
+});
+
+const handleConfirm = async () => {
+ state.loading = true;
+ try {
+ // Prepare the request parameters
+ const requestParams: any = {
+ parent: props.stage.name,
+ tasks: runnableTasks.value.map((task) => task.name),
+ reason: comment.value,
+ };
+
+ if (runTimeInMS.value !== undefined) {
+ // Convert timestamp to protobuf Timestamp format
+ const runTimeSeconds = Math.floor(runTimeInMS.value / 1000);
+ const runTimeNanos = (runTimeInMS.value % 1000) * 1000000;
+ requestParams.runTime = {
+ seconds: Long.fromNumber(runTimeSeconds),
+ nanos: runTimeNanos,
+ };
+ }
+
+ const request = create(BatchRunTasksRequestSchema, requestParams);
+ await rolloutServiceClientConnect.batchRunTasks(request);
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.success"),
+ });
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("common.error"),
+ description: String(error),
+ });
+ } finally {
+ state.loading = false;
+ emit("close");
+ }
+};
+
+const resetState = () => {
+ comment.value = "";
+ runTimeInMS.value = undefined;
+};
+</script>
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskTable.vue b/frontend/src/components/Plan/components/RolloutView/TaskTable.vue
index 167d3e64f8..5fba471b9d 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskTable.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskTable.vue
@@ -25,6 +25,7 @@ import { InstanceV1EngineIcon } from "@/components/v2";
import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
import type { Task, Rollout, Task_Status } from "@/types/proto/v1/rollout_service";
import { extractSchemaVersionFromTask } from "@/utils";
+import { useRolloutViewContext } from "./context";
const props = defineProps<{
rollout: Rollout;
@@ -34,9 +35,10 @@ const props = defineProps<{
const { t } = useI18n();
const { project } = useCurrentProjectV1();
const environmentStore = useEnvironmentV1Store();
+const { mergedStages } = useRolloutViewContext();
const taskList = computed(() => {
- const allTasks = flatten(props.rollout.stages.map((stage) => stage.tasks));
+ const allTasks = flatten(mergedStages.value.map((stage) => stage.tasks));
if (props.taskStatusFilter.length === 0) {
return allTasks;
}
@@ -45,7 +47,7 @@ const taskList = computed(() => {
);
});
-const stages = computed(() => props.rollout.stages);
+const stages = computed(() => mergedStages.value);
const columnList = computed((): DataTableColumn<Task>[] => {
return [
diff --git a/frontend/src/components/Plan/components/RolloutView/context.ts b/frontend/src/components/Plan/components/RolloutView/context.ts
new file mode 100644
index 0000000000..c7111a9446
--- /dev/null
+++ b/frontend/src/components/Plan/components/RolloutView/context.ts
@@ -0,0 +1,98 @@
+import { create } from "@bufbuild/protobuf";
+import { createContextValues } from "@connectrpc/connect";
+import type { ComputedRef, InjectionKey, Ref } from "vue";
+import { computed, inject, provide, ref } from "vue";
+import { useProgressivePoll } from "@/composables/useProgressivePoll";
+import { rolloutServiceClientConnect } from "@/grpcweb";
+import { silentContextKey } from "@/grpcweb/context-key";
+import { useCurrentProjectV1 } from "@/store";
+import { PreviewRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
+import { Rollout, type Stage } from "@/types/proto/v1/rollout_service";
+import { convertNewRolloutToOld, convertOldPlanToNew } from "@/utils/v1/rollout-conversions";
+import { usePlanContextWithRollout } from "../../logic";
+
+export type RolloutViewContext = {
+ rollout: Ref<Rollout>;
+ rolloutPreview: Ref<Rollout | undefined>;
+ mergedStages: ComputedRef<Stage[]>;
+};
+
+export const KEY = Symbol(
+ "bb.plan.rollout-view"
+) as InjectionKey<RolloutViewContext>;
+
+export const useRolloutViewContext = () => {
+ return inject(KEY)!;
+};
+
+export const provideRolloutViewContext = () => {
+ const { plan, rollout } = usePlanContextWithRollout();
+ const { project } = useCurrentProjectV1();
+
+ const rolloutPreview = ref<Rollout>(Rollout.fromPartial({}));
+
+ const mergedStages = computed(() => {
+ // Merge preview stages with created rollout stages
+ const createdStages = rollout.value.stages;
+ const previewStages = rolloutPreview.value.stages;
+
+ // Start with created stages
+ const merged = [...createdStages];
+
+ // Add preview stages that don't exist in created stages
+ for (const previewStage of previewStages) {
+ const existingIndex = merged.findIndex(
+ (s) => s.environment === previewStage.environment
+ );
+ if (existingIndex === -1) {
+ merged.push(previewStage);
+ }
+ }
+
+ return merged;
+ });
+
+ const fetchRolloutPreview = async () => {
+ const request = create(PreviewRolloutRequestSchema, {
+ project: project.value.name,
+ plan: convertOldPlanToNew(plan.value),
+ });
+
+ try {
+ const rolloutPreviewNew = await rolloutServiceClientConnect.previewRollout(
+ request,
+ {
+ contextValues: createContextValues().set(silentContextKey, true),
+ }
+ );
+ rolloutPreview.value = convertNewRolloutToOld(rolloutPreviewNew);
+ } catch (error) {
+ // Handle preview errors gracefully
+ console.error("Failed to fetch rollout preview:", error);
+ rolloutPreview.value = Rollout.fromPartial({});
+ }
+ };
+
+ // Initial fetch
+ fetchRolloutPreview();
+
+ // Poll for updates
+ const poller = useProgressivePoll(fetchRolloutPreview, {
+ interval: {
+ min: 2000,
+ max: 10000,
+ growth: 2,
+ jitter: 500,
+ },
+ });
+ poller.start();
+
+ const context: RolloutViewContext = {
+ rollout,
+ rolloutPreview,
+ mergedStages,
+ };
+
+ provide(KEY, context);
+ return context;
+};
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 10b106fd1a..4555ba387f 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -70,4 +70,5 @@ export const providePlanContext = (
};
}
provide(KEY, context as PlanContext);
+ return context as PlanContext;
};
diff --git a/frontend/src/components/Plan/logic/poll.ts b/frontend/src/components/Plan/logic/poll.ts
index e82c216763..bf6e8fc6c9 100644
--- a/frontend/src/components/Plan/logic/poll.ts
+++ b/frontend/src/components/Plan/logic/poll.ts
@@ -1,21 +1,27 @@
import { create } from "@bufbuild/protobuf";
import { computed, watch } from "vue";
import { useProgressivePoll } from "@/composables/useProgressivePoll";
-import { issueServiceClientConnect, planServiceClientConnect } from "@/grpcweb";
+import {
+ issueServiceClientConnect,
+ planServiceClientConnect,
+ rolloutServiceClientConnect,
+} from "@/grpcweb";
import { useCurrentProjectV1 } from "@/store";
import { useIssueCommentStore } from "@/store";
import { usePlanStore } from "@/store/modules/v1/plan";
import { ListPlanCheckRunsRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
import { GetIssueRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
+import { GetRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
import { ListIssueCommentsRequest } from "@/types/proto/v1/issue_service";
import { hasProjectPermissionV2 } from "@/utils";
import { convertNewPlanCheckRunToOld } from "@/utils/v1/plan-conversions";
import { convertNewIssueToOld } from "@/utils/v1/issue-conversions";
+import { convertNewRolloutToOld } from "@/utils/v1/rollout-conversions";
import { usePlanContext } from "./context";
export const usePollPlan = () => {
const { project } = useCurrentProjectV1();
- const { isCreating, plan, planCheckRunList, issue, events } =
+ const { isCreating, plan, planCheckRunList, issue, rollout, events } =
usePlanContext();
const planStore = usePlanStore();
const issueCommentStore = useIssueCommentStore();
@@ -44,6 +50,19 @@ export const usePollPlan = () => {
convertNewPlanCheckRunToOld
);
}
+
+ // Refresh rollout if it exists
+ if (updatedPlan.rollout && rollout && hasProjectPermissionV2(project.value, "bb.rollouts.get")) {
+ try {
+ const rolloutRequest = create(GetRolloutRequestSchema, {
+ name: updatedPlan.rollout,
+ });
+ const newRollout = await rolloutServiceClientConnect.getRollout(rolloutRequest);
+ rollout.value = convertNewRolloutToOld(newRollout);
+ } catch {
+ // Rollout might not exist or we don't have permission
+ }
+ }
};
const refreshIssue = async () => {
diff --git a/frontend/src/components/Project/useProjectSidebar.ts b/frontend/src/components/Project/useProjectSidebar.ts
index f662a053a7..ba456ba01b 100644
--- a/frontend/src/components/Project/useProjectSidebar.ts
+++ b/frontend/src/components/Project/useProjectSidebar.ts
@@ -4,9 +4,10 @@ import {
Users,
Settings,
PencilRuler,
- SearchCodeIcon,
DownloadIcon,
PackageIcon,
+ LayoutList,
+ PlayCircle,
} from "lucide-vue-next";
import { computed, h, unref } from "vue";
import type { RouteLocationNormalizedLoaded } from "vue-router";
@@ -28,6 +29,7 @@ import projectV1Routes, {
PROJECT_V1_ROUTE_RELEASES,
PROJECT_V1_ROUTE_MASKING_EXEMPTION,
PROJECT_V1_ROUTE_PLANS,
+ PROJECT_V1_ROUTE_ROLLOUTS,
} from "@/router/dashboard/projectV1";
import { useAppFeature } from "@/store";
import type { ComposedProject, MaybeRef } from "@/types";
@@ -128,15 +130,23 @@ export const useProjectSidebar = (
databaseChangeMode.value === DatabaseChangeMode.EDITOR,
},
{
- // TODO(claude): rename title to "Plans".
- title: t("review-center.self"),
- icon: () => h(SearchCodeIcon),
+ title: t("plan.plans"),
+ icon: () => h(LayoutList),
path: PROJECT_V1_ROUTE_PLANS,
type: "div",
hide:
isDefaultProject.value ||
databaseChangeMode.value === DatabaseChangeMode.EDITOR,
},
+ {
+ title: t("rollout.rollouts"),
+ path: PROJECT_V1_ROUTE_ROLLOUTS,
+ icon: () => h(PlayCircle),
+ type: "div",
+ hide:
+ isDefaultProject.value ||
+ databaseChangeMode.value === DatabaseChangeMode.EDITOR,
+ },
{
title: t("export-center.self"),
icon: () => h(DownloadIcon),
diff --git a/frontend/src/components/Rollout/RolloutDataTable.vue b/frontend/src/components/Rollout/RolloutDataTable.vue
index 88efddd4d7..36a1d048f0 100644
--- a/frontend/src/components/Rollout/RolloutDataTable.vue
+++ b/frontend/src/components/Rollout/RolloutDataTable.vue
@@ -13,13 +13,22 @@
<script lang="tsx" setup>
import type { DataTableColumn } from "naive-ui";
-import { NDataTable } from "naive-ui";
+import { NDataTable, NTag } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { RouterLink, useRouter } from "vue-router";
import { BBAvatar } from "@/bbkit";
+import TaskStatus from "@/components/Rollout/RolloutDetail/Panels/kits/TaskStatus.vue";
+import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
import { getTimeForPbTimestamp, type ComposedRollout } from "@/types";
-import { extractIssueUID, humanizeTs } from "@/utils";
+import { Task_Status as TaskStatusEnum } from "@/types/proto/v1/rollout_service";
+import type { Task_Status } from "@/types/proto/v1/rollout_service";
+import {
+ extractPlanUID,
+ extractProjectResourceName,
+ humanizeTs,
+ stringifyTaskStatus,
+} from "@/utils";
const props = withDefaults(
defineProps<{
@@ -38,21 +47,38 @@ const props = withDefaults(
const { t } = useI18n();
const router = useRouter();
+const TASK_STATUS_FILTERS: Task_Status[] = [
+ TaskStatusEnum.NOT_STARTED,
+ TaskStatusEnum.PENDING,
+ TaskStatusEnum.RUNNING,
+ TaskStatusEnum.DONE,
+ TaskStatusEnum.FAILED,
+ TaskStatusEnum.CANCELED,
+ TaskStatusEnum.SKIPPED,
+];
+
+const getTaskCount = (rollout: ComposedRollout, status: Task_Status) => {
+ const allTasks = rollout.stages.flatMap((stage) => stage.tasks);
+ return allTasks.filter((task) => task.status === status).length;
+};
+
const columnList = computed(
(): (DataTableColumn<ComposedRollout> & { hide?: boolean })[] => {
const columns: (DataTableColumn<ComposedRollout> & { hide?: boolean })[] = [
{
- key: "issue",
- title: t("common.issue"),
+ key: "plan",
+ title: t("plan.self"),
width: 96,
render: (rollout) => {
- const uid = extractIssueUID(rollout.issue);
- if (!uid) return "-";
-
+ const uid = extractPlanUID(rollout.plan);
return (
<RouterLink
to={{
- path: `/${rollout.issue}`,
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(rollout.plan),
+ planId: uid,
+ },
}}
custom={true}
>
@@ -72,13 +98,34 @@ const columnList = computed(
},
},
{
- key: "title",
- title: t("common.title"),
+ key: "taskStatus",
+ title: t("common.tasks"),
render: (rollout) => {
return (
- <p class="inline-flex w-full">
- <span class="shrink truncate">{rollout.title}</span>
- </p>
+ <div class="flex flex-row gap-1 items-center">
+ {TASK_STATUS_FILTERS.map((status) => {
+ const count = getTaskCount(rollout, status);
+ if (count === 0) return null;
+
+ return (
+ <NTag key={status} round>
+ {{
+ avatar: () => <TaskStatus status={status} size="small" />,
+ default: () => (
+ <div class="flex flex-row items-center gap-1">
+ <span class="select-none text-sm">
+ {stringifyTaskStatus(status)}
+ </span>
+ <span class="select-none text-sm font-medium">
+ {count}
+ </span>
+ </div>
+ ),
+ }}
+ </NTag>
+ );
+ })}
+ </div>
);
},
},
diff --git a/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue b/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
index 8d2dc24f9d..2c99051e23 100644
--- a/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
+++ b/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
@@ -16,7 +16,7 @@ import AdvancedSearch from "@/components/AdvancedSearch";
import type { ScopeOption } from "@/components/AdvancedSearch/types";
import { formatEnvironmentName } from "@/types";
import { Task_Status } from "@/types/proto/v1/rollout_service";
-import { type SearchParams } from "@/utils";
+import { stringifyTaskStatus, type SearchParams } from "@/utils";
import { useRolloutDetailContext } from "../../context";
import { databaseForTask } from "../../utils";
@@ -107,32 +107,7 @@ const scopeOptions = computed((): ScopeOption[] => {
Task_Status.CANCELED,
Task_Status.SKIPPED,
].map((status) => {
- let statusTitle;
- switch (status) {
- case Task_Status.NOT_STARTED:
- statusTitle = t("task.status.not-started");
- break;
- case Task_Status.PENDING:
- statusTitle = t("task.status.pending");
- break;
- case Task_Status.RUNNING:
- statusTitle = t("task.status.running");
- break;
- case Task_Status.DONE:
- statusTitle = t("task.status.done");
- break;
- case Task_Status.FAILED:
- statusTitle = t("task.status.failed");
- break;
- case Task_Status.CANCELED:
- statusTitle = t("task.status.canceled");
- break;
- case Task_Status.SKIPPED:
- statusTitle = t("task.status.skipped");
- break;
- default:
- statusTitle = status;
- }
+ const statusTitle = stringifyTaskStatus(status);
return {
value: status,
keywords: [status],
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index ef9558521c..a5adf1e25a 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1033,6 +1033,8 @@
}
},
"plan": {
+ "self": "Plan",
+ "plans": "Plans",
"new-plan": "New Plan",
"add-spec": "Add Specification",
"change-type": "Change Type",
@@ -1106,6 +1108,9 @@
"click-to-run-checks": "Click \"Run Checks\" to validate this specification"
}
},
+ "rollout": {
+ "rollouts": "Rollouts"
+ },
"quick-action": {
"create-db": "Create database",
"new-db": "New DB",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 87369f9a76..40f1c99d4d 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1033,6 +1033,8 @@
}
},
"plan": {
+ "self": "Plan",
+ "plans": "Planes",
"new-plan": "Nuevo plan",
"add-spec": "Agregar especificación",
"change-type": "Cambiar tipo",
@@ -1106,6 +1108,9 @@
"click-to-run-checks": "Haga clic en \"Ejecutar comprobaciones\" para validar esta especificación"
}
},
+ "rollout": {
+ "rollouts": "Despliegues"
+ },
"quick-action": {
"create-db": "Crear base de datos",
"new-db": "Nueva BD",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 39b506a569..10df76fba3 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1033,6 +1033,8 @@
}
},
"plan": {
+ "self": "プラン",
+ "plans": "予定",
"new-plan": "新しい計画",
"add-spec": "仕様を追加",
"change-type": "変更タイプ",
@@ -1106,6 +1108,9 @@
"click-to-run-checks": "この仕様を検証するには、「チェックを実行」をクリックしてください"
}
},
+ "rollout": {
+ "rollouts": "ロールアウト"
+ },
"quick-action": {
"create-db": "データベースの作成",
"new-db": "データベースの作成",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index d6fe28ee2e..ee0c4f9006 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1033,6 +1033,8 @@
}
},
"plan": {
+ "self": "Kế hoạch",
+ "plans": "Kế hoạch",
"new-plan": "Kế hoạch mới",
"add-spec": "Thêm thông số kỹ thuật",
"change-type": "Thay đổi loại",
@@ -1106,6 +1108,9 @@
"click-to-run-checks": "Nhấp vào \"Chạy kiểm tra\" để xác thực thông số kỹ thuật này"
}
},
+ "rollout": {
+ "rollouts": "Triển khai"
+ },
"quick-action": {
"create-db": "Tạo cơ sở dữ liệu",
"new-db": "Cơ sở dữ liệu mới",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index fc987e64c4..8e37342b90 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1033,6 +1033,8 @@
}
},
"plan": {
+ "self": "变更计划",
+ "plans": "变更计划",
"new-plan": "创建变更计划",
"add-spec": "添加变更项",
"change-type": "变更类型",
@@ -1052,9 +1054,9 @@
},
"navigator": {
"specifications": "变更项",
- "checks": "检查",
- "review": "审查",
- "rollout": "推出",
+ "checks": "SQL 检查",
+ "review": "审批流",
+ "rollout": "发布任务",
"statement-empty": "变更语句为空"
},
"spec": {
@@ -1106,6 +1108,9 @@
"click-to-run-checks": "单击“运行检查”以验证此规范"
}
},
+ "rollout": {
+ "rollouts": "发布任务"
+ },
"quick-action": {
"create-db": "创建数据库",
"new-db": "创建数据库",
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 0f0b68c8db..a05bf5a093 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -40,55 +40,35 @@ export const PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL = `${PROJECT_V1_ROUTE_R
const cicdRoutes: RouteRecordRaw[] = [
{
path: "",
+ component: () => import("@/views/project/CICDLayout.vue"),
+ props: true,
children: [
{
- path: "plans",
+ path: "plans/:planId",
+ meta: {
+ requiredPermissionList: () => ["bb.plans.get"],
+ },
props: true,
children: [
{
path: "",
- name: PROJECT_V1_ROUTE_PLANS,
- meta: {
- // TODO(claude): rename title to "Plans" later.
- title: () => t("review-center.self"),
- requiredPermissionList: () => [
- "bb.databases.list",
- "bb.plans.list",
- ],
- },
- component: () => import("@/views/ReviewCenter/index.vue"),
- props: true,
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
+ component: () => import("@/views/project/PlanDetailView.vue"),
},
{
- path: ":planId",
- name: PROJECT_V1_ROUTE_PLAN_DETAIL,
- meta: {
- requiredPermissionList: () => ["bb.plans.get"],
- },
- component: () => import("@/views/project/ProjectPlanDetail.vue"),
- props: true,
- children: [
- {
- path: "specs",
- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
- component: () =>
- import("@/views/project/ProjectPlanDetail.vue"),
- children: [
- {
- path: ":specId",
- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
- component: () =>
- import("@/views/project/ProjectPlanDetail.vue"),
- },
- ],
- },
- {
- path: "planCheckRuns",
- name: PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,
- component: () =>
- import("@/views/project/ProjectPlanDetail.vue"),
- },
- ],
+ path: "specs",
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ component: () => import("@/views/project/PlanSpecDetailView.vue"),
+ },
+ {
+ path: "specs/:specId",
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ component: () => import("@/views/project/PlanSpecDetailView.vue"),
+ },
+ {
+ path: "planCheckRuns",
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,
+ component: () => import("@/views/project/PlanCheckRunsView.vue"),
},
],
},
@@ -98,11 +78,11 @@ const cicdRoutes: RouteRecordRaw[] = [
meta: {
requiredPermissionList: () => ["bb.issues.get"],
},
- component: () => import("@/views/project/ProjectPlanDetail.vue"),
+ component: () => import("@/views/project/IssueDetailView.vue"),
props: true,
},
{
- path: "rollouts",
+ path: "rollouts/:rolloutId",
meta: {
title: () => t("common.rollout"),
},
@@ -110,38 +90,21 @@ const cicdRoutes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: PROJECT_V1_ROUTE_ROLLOUTS,
+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
+ component: () => import("@/views/project/RolloutDetailView.vue"),
+ props: true,
meta: {
- requiredPermissionList: () => ["bb.rollouts.list"],
+ requiredPermissionList: () => ["bb.rollouts.get"],
},
- component: () =>
- import("@/views/project/ProjectRolloutDashboard.vue"),
- props: true,
- },
- {
- path: ":rolloutId",
- props: true,
- children: [
- {
- path: "",
- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
- component: () =>
- import("@/views/project/ProjectPlanDetail.vue"),
- props: true,
- meta: {
- requiredPermissionList: () => ["bb.rollouts.get"],
- },
- },
- // TODO(steven): Add more children routes for rollout detail.
- {
- path: "stages/:stageId/tasks/:taskId",
- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
- component: () =>
- import("@/components/Rollout/RolloutDetail/TaskDetail/"),
- props: true,
- },
- ],
},
+ // TODO(steven): Add more children routes for rollout detail.
+ // {
+ // path: "stages/:stageId/tasks/:taskId",
+ // name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
+ // component: () =>
+ // import("@/components/Rollout/RolloutDetail/TaskDetail/"),
+ // props: true,
+ // },
],
},
],
@@ -268,6 +231,26 @@ const projectV1Routes: RouteRecordRaw[] = [
},
],
},
+ {
+ path: "plans",
+ name: PROJECT_V1_ROUTE_PLANS,
+ meta: {
+ // TODO(claude): rename title to "Plans" later.
+ title: () => t("review-center.self"),
+ requiredPermissionList: () => ["bb.databases.list", "bb.plans.list"],
+ },
+ component: () => import("@/views/ReviewCenter/index.vue"),
+ props: true,
+ },
+ {
+ path: "rollouts",
+ name: PROJECT_V1_ROUTE_ROLLOUTS,
+ meta: {
+ requiredPermissionList: () => ["bb.rollouts.list"],
+ },
+ component: () => import("@/views/project/ProjectRolloutDashboard.vue"),
+ props: true,
+ },
{
path: "changelists",
meta: {
diff --git a/frontend/src/utils/v1/issue/rollout.ts b/frontend/src/utils/v1/issue/rollout.ts
index 286abd36aa..7ef0ff85bb 100644
--- a/frontend/src/utils/v1/issue/rollout.ts
+++ b/frontend/src/utils/v1/issue/rollout.ts
@@ -1,5 +1,6 @@
import { last } from "lodash-es";
import { stringify } from "qs";
+import { useI18n } from "vue-i18n";
import type { ComposedIssue } from "@/types";
import {
EMPTY_TASK_NAME,
@@ -198,3 +199,25 @@ export const buildIssueV1LinkWithTask = (
return url;
};
+
+export const stringifyTaskStatus = (status: Task_Status): string => {
+ const { t } = useI18n();
+ switch (status) {
+ case Task_Status.NOT_STARTED:
+ return t("task.status.not-started");
+ case Task_Status.PENDING:
+ return t("task.status.pending");
+ case Task_Status.RUNNING:
+ return t("task.status.running");
+ case Task_Status.DONE:
+ return t("task.status.done");
+ case Task_Status.FAILED:
+ return t("task.status.failed");
+ case Task_Status.CANCELED:
+ return t("task.status.canceled");
+ case Task_Status.SKIPPED:
+ return t("task.status.skipped");
+ default:
+ return status;
+ }
+};
diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vue
new file mode 100644
index 0000000000..bcb2a54a5d
--- /dev/null
+++ b/frontend/src/views/project/CICDLayout.vue
@@ -0,0 +1,279 @@
+<template>
+ <div class="relative overflow-x-hidden h-full">
+ <template v-if="ready">
+ <div class="h-full flex flex-col">
+ <HeaderSection />
+ <NTabs
+ type="line"
+ :value="tabKey"
+ tab-class="first:ml-4"
+ @update-value="handleTabChange"
+ >
+ <NTab
+ v-for="tab in availableTabs"
+ :key="tab"
+ :name="tab"
+ :tab="tabRender(tab)"
+ />
+
+ <!-- Suffix slot for Specifications tab -->
+ <template v-if="tabKey === TabKey.Specifications" #suffix>
+ <div class="pr-4 flex flex-row justify-end items-center">
+ <CurrentSpecSelector />
+ </div>
+ </template>
+ </NTabs>
+
+ <div class="flex-1 flex">
+ <router-view />
+ </div>
+ </div>
+ </template>
+ <div v-else class="w-full h-full flex flex-col items-center justify-center">
+ <NSpin />
+ </div>
+ </div>
+</template>
+
+<script lang="tsx" setup>
+import { useTitle } from "@vueuse/core";
+import { head } from "lodash-es";
+import { NSpin, NTab, NTabs } from "naive-ui";
+import { computed, toRef } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRoute, useRouter } from "vue-router";
+import {
+ providePlanContext,
+ useBasePlanContext,
+ useInitializePlan,
+} from "@/components/Plan";
+import { HeaderSection } from "@/components/Plan/components";
+import CurrentSpecSelector from "@/components/Plan/components/CurrentSpecSelector.vue";
+import { useSpecsValidation } from "@/components/Plan/components/common";
+import { gotoSpec } from "@/components/Plan/components/common/utils";
+import { provideIssueReviewContext } from "@/components/Plan/logic/issue-review";
+import { useBodyLayoutContext } from "@/layouts/common";
+import {
+ PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ PROJECT_V1_ROUTE_PLAN_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
+} from "@/router/dashboard/projectV1";
+import {
+ extractIssueUID,
+ extractPlanUID,
+ extractRolloutUID,
+ isNullOrUndefined,
+} from "@/utils";
+
+enum TabKey {
+ Overview = "overview",
+ Specifications = "specifications",
+ Checks = "checks",
+ Review = "review",
+ Rollout = "rollout",
+}
+
+const props = defineProps<{
+ projectId: string;
+ planId?: string;
+ issueId?: string;
+ rolloutId?: string;
+}>();
+
+const { t } = useI18n();
+const { isCreating, plan, planCheckRunList, issue, rollout, isInitializing } =
+ useInitializePlan(
+ toRef(props, "projectId"),
+ toRef(props, "planId"),
+ toRef(props, "issueId"),
+ toRef(props, "rolloutId")
+ );
+const planBaseContext = useBasePlanContext({
+ isCreating,
+ plan,
+});
+
+const ready = computed(() => {
+ return !isInitializing.value && !!plan.value;
+});
+
+const route = useRoute();
+const router = useRouter();
+
+providePlanContext(
+ {
+ isCreating,
+ plan,
+ planCheckRunList,
+ issue,
+ rollout,
+ ...planBaseContext,
+ },
+ true /* root */
+);
+
+provideIssueReviewContext(issue);
+
+const { isSpecEmpty } = useSpecsValidation(plan.value.specs);
+
+const planCheckRunCount = computed(() =>
+ Object.values(plan.value.planCheckRunStatusCount).reduce(
+ (sum, count) => sum + count,
+ 0
+ )
+);
+
+const tabKey = computed(() => {
+ const routeName = route.name?.toString() as string;
+ if (
+ [
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ ].includes(routeName)
+ ) {
+ return TabKey.Specifications;
+ } else if ([PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS].includes(routeName)) {
+ return TabKey.Checks;
+ } else if (routeName === PROJECT_V1_ROUTE_ISSUE_DETAIL_V1) {
+ return TabKey.Review;
+ } else if (routeName === PROJECT_V1_ROUTE_ROLLOUT_DETAIL) {
+ return TabKey.Rollout;
+ }
+ // Fallback to Overview if no specific tab is matched.
+ return TabKey.Overview;
+});
+
+const availableTabs = computed<TabKey[]>(() => {
+ const tabs: TabKey[] = [TabKey.Overview, TabKey.Specifications];
+ if (!isCreating.value) {
+ if (
+ plan.value.specs.some(
+ (spec) => !isNullOrUndefined(spec.changeDatabaseConfig)
+ )
+ ) {
+ tabs.push(TabKey.Checks);
+ }
+ if (plan.value.issue) {
+ tabs.push(TabKey.Review);
+ }
+ if (plan.value.rollout) {
+ tabs.push(TabKey.Rollout);
+ }
+ }
+ return tabs;
+});
+
+const tabRender = (tab: TabKey) => {
+ switch (tab) {
+ case TabKey.Overview:
+ return t("common.overview");
+ case TabKey.Specifications:
+ return (
+ <div>
+ {t("plan.navigator.specifications")}
+ {plan.value.specs.some(isSpecEmpty) && (
+ <span
+ class="text-error ml-0.5"
+ title={t("plan.navigator.statement-empty")}
+ >
+ *
+ </span>
+ )}
+ </div>
+ );
+ case TabKey.Checks:
+ return (
+ <div>
+ {t("plan.navigator.checks")}
+ {planCheckRunCount.value > 0 && (
+ <span class="text-gray-500">({planCheckRunCount.value})</span>
+ )}
+ </div>
+ );
+ case TabKey.Review:
+ return t("plan.navigator.review");
+ case TabKey.Rollout:
+ return t("plan.navigator.rollout");
+ default:
+ // Fallback to raw tab name.
+ return tab;
+ }
+};
+
+const handleTabChange = (tab: TabKey) => {
+ const params = route.params;
+ if (isCreating.value) {
+ params.planId = "create";
+ } else {
+ params.planId = extractPlanUID(plan.value.name);
+ if (plan.value.issue) {
+ params.issueId = extractIssueUID(plan.value.issue);
+ }
+ if (plan.value.rollout) {
+ params.rolloutId = extractRolloutUID(plan.value.rollout);
+ }
+ }
+
+ if (tab === TabKey.Overview) {
+ router.push({
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
+ params: params,
+ query: route.query,
+ });
+ } else if (tab === TabKey.Specifications) {
+ // Auto select the first spec when switching to Specifications tab.
+ const spec = head(plan.value.specs);
+ if (spec) {
+ gotoSpec(router, spec.id);
+ } else {
+ router.push({
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ params: params,
+ query: route.query,
+ });
+ }
+ } else if (tab === TabKey.Checks) {
+ router.push({
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,
+ params: params,
+ query: route.query,
+ });
+ } else if (tab === TabKey.Review) {
+ router.push({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ params: params,
+ query: route.query,
+ });
+ } else if (tab === TabKey.Rollout) {
+ router.push({
+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
+ params: params,
+ query: route.query,
+ });
+ }
+};
+
+const { overrideMainContainerClass } = useBodyLayoutContext();
+
+overrideMainContainerClass("!py-0 !px-0");
+
+const documentTitle = computed(() => {
+ if (isCreating.value) {
+ return t("plan.new-plan");
+ } else {
+ if (ready.value) {
+ if (issue.value) {
+ return issue.value.title;
+ }
+ if (plan.value) {
+ return plan.value.title;
+ }
+ }
+ }
+ return t("common.loading");
+});
+useTitle(documentTitle);
+</script>
diff --git a/frontend/src/views/project/IssueDetailView.vue b/frontend/src/views/project/IssueDetailView.vue
new file mode 100644
index 0000000000..5c15fed84a
--- /dev/null
+++ b/frontend/src/views/project/IssueDetailView.vue
@@ -0,0 +1,10 @@
+<template>
+ <IssueReviewView />
+</template>
+
+<script lang="ts" setup>
+import { usePollPlan } from "@/components/Plan";
+import { IssueReviewView } from "@/components/Plan/components/IssueReviewView";
+
+usePollPlan();
+</script>
diff --git a/frontend/src/views/project/PlanCheckRunsView.vue b/frontend/src/views/project/PlanCheckRunsView.vue
new file mode 100644
index 0000000000..ac691cabde
--- /dev/null
+++ b/frontend/src/views/project/PlanCheckRunsView.vue
@@ -0,0 +1,10 @@
+<template>
+ <ChecksView />
+</template>
+
+<script lang="ts" setup>
+import { usePollPlan } from "@/components/Plan";
+import { ChecksView } from "@/components/Plan/components";
+
+usePollPlan();
+</script>
diff --git a/frontend/src/views/project/PlanDetailView.vue b/frontend/src/views/project/PlanDetailView.vue
new file mode 100644
index 0000000000..d8e2362490
--- /dev/null
+++ b/frontend/src/views/project/PlanDetailView.vue
@@ -0,0 +1,10 @@
+<template>
+ <Overview />
+</template>
+
+<script lang="ts" setup>
+import { usePollPlan } from "@/components/Plan";
+import { Overview } from "@/components/Plan/components";
+
+usePollPlan();
+</script>
diff --git a/frontend/src/views/project/PlanSpecDetailView.vue b/frontend/src/views/project/PlanSpecDetailView.vue
new file mode 100644
index 0000000000..d66b147b2b
--- /dev/null
+++ b/frontend/src/views/project/PlanSpecDetailView.vue
@@ -0,0 +1,10 @@
+<template>
+ <SpecsView />
+</template>
+
+<script lang="ts" setup>
+import { usePollPlan } from "@/components/Plan";
+import SpecsView from "@/components/Plan/components/SpecsView.vue";
+
+usePollPlan();
+</script>
diff --git a/frontend/src/views/project/RolloutDetailView.vue b/frontend/src/views/project/RolloutDetailView.vue
new file mode 100644
index 0000000000..73661c443a
--- /dev/null
+++ b/frontend/src/views/project/RolloutDetailView.vue
@@ -0,0 +1,10 @@
+<template>
+ <RolloutView />
+</template>
+
+<script lang="ts" setup>
+import { usePollPlan } from "@/components/Plan";
+import { RolloutView } from "@/components/Plan/components/RolloutView";
+
+usePollPlan();
+</script>