Skip to content

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

chore: check issue status in rollout (#16819)

boojack3207880892bd
diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vue
index 20c1b6733f..5fa0e3b3d3 100644
--- a/frontend/src/components/Plan/components/Configuration/Configuration.vue
+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue
@@ -21,7 +21,7 @@ import PreBackupSection from "./PreBackupSection";
import { providePreBackupSettingContext } from "./PreBackupSection/context";
const { project } = useCurrentProjectV1();
-const { isCreating, plan, events, issue, rollout } = usePlanContext();
+const { isCreating, plan, events, issue, rollout, readonly } = usePlanContext();
const selectedSpec = useSelectedSpec();
const { shouldShow: shouldShowGhostSection, events: ghostEvents } =
@@ -32,6 +32,7 @@ const { shouldShow: shouldShowGhostSection, events: ghostEvents } =
isCreating,
issue,
rollout,
+ readonly,
});
const { shouldShow: shouldShowPreBackupSection, events: preBackupEvents } =
@@ -42,6 +43,7 @@ const { shouldShow: shouldShowPreBackupSection, events: preBackupEvents } =
isCreating,
issue,
rollout,
+ readonly,
});
const shouldShow = computed(() => {
diff --git a/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
index ede50c12c0..e77648e4c1 100644
--- a/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
@@ -36,6 +36,7 @@ export const provideGhostSettingContext = (refs: {
selectedTask?: Ref<Task | undefined>;
issue?: Ref<Issue | undefined>;
rollout?: Ref<Rollout | undefined>;
+ readonly?: Ref<boolean>;
}) => {
const currentUser = useCurrentUserV1();
const databaseStore = useDatabaseV1Store();
@@ -48,6 +49,7 @@ export const provideGhostSettingContext = (refs: {
selectedTask,
issue,
rollout,
+ readonly,
} = refs;
const events = new Emittery<{
@@ -75,6 +77,11 @@ export const provideGhostSettingContext = (refs: {
});
const allowChange = computed(() => {
+ // If readonly mode, disallow changes
+ if (readonly?.value) {
+ return false;
+ }
+
// Allow toggle pre-backup when creating.
if (isCreating.value) {
return true;
diff --git a/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
index ce4d03cd10..ce1bc20ceb 100644
--- a/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
@@ -50,10 +50,12 @@ export const providePreBackupSettingContext = (refs: {
selectedTask?: Ref<Task | undefined>;
issue?: Ref<Issue | undefined>;
rollout?: Ref<Rollout | undefined>;
+ readonly?: Ref<boolean>;
}) => {
const currentUser = useCurrentUserV1();
const databaseStore = useDatabaseV1Store();
- const { isCreating, project, plan, selectedSpec, issue, rollout } = refs;
+ const { isCreating, project, plan, selectedSpec, issue, rollout, readonly } =
+ refs;
const events = new Emittery<{
update: never;
@@ -91,6 +93,11 @@ export const providePreBackupSettingContext = (refs: {
});
const allowChange = computed((): boolean => {
+ // If readonly mode, disallow changes
+ if (readonly?.value) {
+ return false;
+ }
+
// Allow toggle pre-backup when creating.
if (isCreating.value) {
return true;
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index 65c20b96b0..0ac8bccdc0 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -57,7 +57,7 @@ import {
type UnifiedAction,
} from "./unified";
-const { isCreating, issue } = usePlanContext();
+const { isCreating, issue, rollout } = usePlanContext();
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
@@ -77,6 +77,10 @@ const availableActions = computed(() => {
// If no issue exists, show create issue action
if (!issue?.value) {
+ // If rollout exists, no actions are available.
+ if (rollout?.value) {
+ return actions;
+ }
const canCreateIssue = hasProjectPermissionV2(
project.value,
"bb.plans.create"
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vue
index 5b17225662..86203ffd67 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vue
@@ -51,9 +51,9 @@
}}
</NCheckbox>
</div>
- <div class="flex justify-end gap-x-3">
- <NButton @click="$emit('close')">
- {{ $t("common.cancel") }}
+ <div class="flex justify-end gap-x-2">
+ <NButton quaternary @click="$emit('close')">
+ {{ $t("common.close") }}
</NButton>
<NTooltip :disabled="confirmErrors.length === 0" placement="top">
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueStatusActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueStatusActionPanel.vue
index e5026b60fe..b169af98fc 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueStatusActionPanel.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueStatusActionPanel.vue
@@ -40,8 +40,8 @@
>
<div></div>
<div class="flex justify-end gap-x-3">
- <NButton @click="$emit('close')">
- {{ $t("common.cancel") }}
+ <NButton quaternary @click="$emit('close')">
+ {{ $t("common.close") }}
</NButton>
<NButton type="primary" @click="handleConfirm">
diff --git a/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue b/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
index fb881c4295..ab5313764c 100644
--- a/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
@@ -43,7 +43,7 @@ type ViewMode = "EDIT" | "VIEW";
const { t } = useI18n();
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, issue } = usePlanContext();
+const { isCreating, plan, issue, readonly } = usePlanContext();
const state = reactive({
isEditing: false,
@@ -83,6 +83,9 @@ const style = computed(() => {
});
const allowEdit = computed(() => {
+ if (readonly.value) {
+ return false;
+ }
if (isCreating.value) {
return true;
}
diff --git a/frontend/src/components/Plan/components/Overview.vue b/frontend/src/components/Plan/components/Overview.vue
index 4e5142d182..27e9e01336 100644
--- a/frontend/src/components/Plan/components/Overview.vue
+++ b/frontend/src/components/Plan/components/Overview.vue
@@ -6,84 +6,194 @@
<h2 class="text-2xl font-semibold mb-2">
{{ $t("common.overview") }}
</h2>
- <p class="text-control-light">
- {{ $t("plan.overview.description") }}
- </p>
</div>
<!-- Statistics Cards -->
- <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
- <div class="bg-white rounded-md border px-3 py-2">
- <div class="flex items-center justify-between">
- <div>
- <p class="text-sm text-control-light">
- {{ $t("plan.overview.total-specs") }}
- </p>
- <p class="text-xl font-medium mt-1">
- {{ statistics.totalSpecs }}
- </p>
+ <div
+ :class="
+ rollout && issue
+ ? 'grid grid-cols-1 lg:grid-cols-3 gap-4'
+ : rollout || issue
+ ? 'grid grid-cols-1 lg:grid-cols-2 gap-4'
+ : 'grid grid-cols-1 md:grid-cols-3 gap-4'
+ "
+ >
+ <!-- Plan Statistics Column -->
+ <div :class="issue || rollout ? 'space-y-4' : 'contents'">
+ <!-- Plan Statistics Grid -->
+ <div
+ :class="issue || rollout ? 'grid grid-cols-1 gap-4' : 'contents'"
+ >
+ <!-- Specs Card -->
+ <div class="bg-white rounded-md border px-3 py-2">
+ <div class="flex items-center justify-between">
+ <div>
+ <p class="textlabel">
+ {{ $t("plan.overview.total-specs") }}
+ </p>
+ <p class="text-xl font-medium mt-1">
+ {{ statistics.totalSpecs }}
+ </p>
+ </div>
+ <LayersIcon
+ class="w-8 h-8 text-control-light"
+ stroke-width="1"
+ />
+ </div>
+ </div>
+
+ <!-- Targets Card -->
+ <div class="bg-white rounded-md border px-3 py-2">
+ <div class="flex items-center justify-between">
+ <div>
+ <p class="textlabel">
+ {{ $t("plan.overview.total-targets") }}
+ </p>
+ <p class="text-xl font-medium mt-1">
+ {{ statistics.totalTargets }}
+ </p>
+ </div>
+ <DatabaseIcon
+ class="w-8 h-8 text-control-light"
+ stroke-width="1"
+ />
+ </div>
+ </div>
+
+ <!-- Checks Card -->
+ <div class="bg-white rounded-md border px-3 py-2">
+ <div class="flex items-center justify-between">
+ <div>
+ <p class="textlabel">
+ {{ $t("plan.navigator.checks") }}
+ </p>
+ <div class="flex items-center gap-3 mt-1">
+ <div
+ v-if="statistics.checkStatus.error > 0"
+ class="flex items-center gap-1"
+ >
+ <XCircleIcon class="w-5 h-5 text-error" />
+ <span class="text-xl font-medium text-error">{{
+ statistics.checkStatus.error
+ }}</span>
+ </div>
+ <div
+ v-if="statistics.checkStatus.warning > 0"
+ class="flex items-center gap-1"
+ >
+ <AlertCircleIcon class="w-5 h-5 text-warning" />
+ <span class="text-xl font-medium text-warning">{{
+ statistics.checkStatus.warning
+ }}</span>
+ </div>
+ <div
+ v-if="statistics.checkStatus.success > 0"
+ class="flex items-center gap-1"
+ >
+ <CheckCircleIcon class="w-5 h-5 text-success" />
+ <span class="text-xl font-medium text-success">{{
+ statistics.checkStatus.success
+ }}</span>
+ </div>
+ <span
+ v-if="statistics.checkStatus.total === 0"
+ class="text-xl text-control"
+ >
+ {{ $t("plan.overview.no-checks") }}
+ </span>
+ </div>
+ </div>
+ <ActivityIcon
+ class="w-8 h-8 text-control-light"
+ stroke-width="1"
+ />
+ </div>
</div>
- <LayersIcon class="w-8 h-8 text-control-light" stroke-width="1" />
</div>
</div>
- <div class="bg-white rounded-md border px-3 py-2">
- <div class="flex items-center justify-between">
- <div>
- <p class="text-sm text-control-light">
- {{ $t("plan.overview.total-targets") }}
- </p>
- <p class="text-xl font-medium mt-1">
- {{ statistics.totalTargets }}
- </p>
- </div>
- <DatabaseIcon class="w-8 h-8 text-control-light" stroke-width="1" />
+ <!-- Approval Flow Column -->
+ <div v-if="issue">
+ <div class="bg-white rounded-md border p-4">
+ <ApprovalFlowSection :issue="issue" @issue-updated="() => {}" />
</div>
</div>
- <div class="bg-white rounded-md border px-3 py-2">
- <div class="flex items-center justify-between">
- <div>
- <p class="text-sm text-control-light">
- {{ $t("plan.navigator.checks") }}
- </p>
- <div class="flex items-center gap-3 mt-1">
- <div
- v-if="statistics.checkStatus.error > 0"
- class="flex items-center gap-1"
- >
- <XCircleIcon class="w-5 h-5 text-error" />
- <span class="text-xl font-medium text-error">{{
- statistics.checkStatus.error
- }}</span>
- </div>
- <div
- v-if="statistics.checkStatus.warning > 0"
- class="flex items-center gap-1"
- >
- <AlertCircleIcon class="w-5 h-5 text-warning" />
- <span class="text-xl font-medium text-warning">{{
- statistics.checkStatus.warning
- }}</span>
- </div>
- <div
- v-if="statistics.checkStatus.success > 0"
- class="flex items-center gap-1"
- >
- <CheckCircleIcon class="w-5 h-5 text-success" />
- <span class="text-xl font-medium text-success">{{
- statistics.checkStatus.success
- }}</span>
- </div>
+ <!-- Rollout Statistics Column -->
+ <div v-if="rollout" class="space-y-4">
+ <!-- Stages Card -->
+ <div class="bg-white rounded-md border p-4">
+ <div class="flex items-center justify-between mb-3">
+ <h3 class="text-lg font-semibold">
+ {{ $t("rollout.stage.self", rollout?.stages.length || 0) }}
+ </h3>
+ <GitBranchIcon
+ class="w-6 h-6 text-control-light"
+ stroke-width="1"
+ />
+ </div>
+ <div
+ v-if="!rollout?.stages.length"
+ class="text-sm text-gray-400 italic"
+ >
+ {{ $t("common.no-data") }}
+ </div>
+ <div v-else class="flex flex-row gap-2 flex-wrap">
+ <div
+ v-for="(stage, index) in rollout.stages"
+ :key="stage.name"
+ class="flex items-center gap-2"
+ >
+ <TaskStatus :status="getStageStatus(stage)" size="small" />
<span
- v-if="statistics.checkStatus.total === 0"
- class="text-xl text-control"
+ class="text-sm font-medium text-gray-700 whitespace-nowrap"
>
- {{ $t("plan.overview.no-checks") }}
+ {{
+ environmentStore.getEnvironmentByName(stage.environment)
+ .title
+ }}
</span>
+ <span
+ v-if="index < (rollout?.stages.length || 0) - 1"
+ class="text-gray-400"
+ >→</span
+ >
</div>
</div>
- <ActivityIcon class="w-8 h-8 text-control-light" stroke-width="1" />
+ </div>
+
+ <!-- Task Status Card -->
+ <div class="bg-white rounded-md border p-4">
+ <div class="flex items-center justify-between mb-3">
+ <h3 class="text-lg font-semibold">
+ {{ $t("common.tasks") }}
+ </h3>
+ <ListChecksIcon
+ class="w-6 h-6 text-control-light"
+ stroke-width="1"
+ />
+ </div>
+ <div class="flex flex-wrap gap-2">
+ <NTag
+ v-for="status in TASK_STATUS_FILTERS"
+ :key="status"
+ v-show="getTaskCount(status) > 0"
+ round
+ size="medium"
+ >
+ <template #avatar>
+ <TaskStatus :status="status" size="small" />
+ </template>
+ <div class="flex flex-row items-center gap-2">
+ <span class="select-none text-sm">
+ {{ stringifyTaskStatus(status) }}
+ </span>
+ <span class="select-none text-sm font-medium">
+ {{ getTaskCount(status) }}
+ </span>
+ </div>
+ </NTag>
+ </div>
</div>
</div>
</div>
@@ -168,22 +278,57 @@ import {
AlertCircleIcon,
XCircleIcon,
FolderIcon,
+ GitBranchIcon,
+ ListChecksIcon,
} from "lucide-vue-next";
+import { NTag } from "naive-ui";
import { computed, watch } from "vue";
import { useI18n } from "vue-i18n";
+import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import { InstanceV1EngineIcon } from "@/components/v2/Model/Instance";
-import { useInstanceV1Store, useDBGroupStore } from "@/store";
+import {
+ useInstanceV1Store,
+ useDBGroupStore,
+ useEnvironmentV1Store,
+} from "@/store";
import type { ComposedDatabaseGroup, ComposedInstance } from "@/types";
import { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";
-import { instanceV1Name, extractDatabaseResourceName } from "@/utils";
+import { Task_Status as TaskStatusEnum } from "@/types/proto-es/v1/rollout_service_pb";
+import type { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
+import {
+ instanceV1Name,
+ extractDatabaseResourceName,
+ getStageStatus,
+ stringifyTaskStatus,
+} from "@/utils";
import { usePlanContext } from "../logic/context";
import { targetsForSpec } from "../logic/plan";
import DescriptionSection from "./DescriptionSection.vue";
+import ApprovalFlowSection from "./IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalFlowSection.vue";
const { t } = useI18n();
-const { plan } = usePlanContext();
+const { plan, issue, rollout } = usePlanContext();
const instanceStore = useInstanceV1Store();
const dbGroupStore = useDBGroupStore();
+const environmentStore = useEnvironmentV1Store();
+
+// Task status filters for rollout
+const TASK_STATUS_FILTERS: Task_Status[] = [
+ TaskStatusEnum.DONE,
+ TaskStatusEnum.RUNNING,
+ TaskStatusEnum.FAILED,
+ TaskStatusEnum.CANCELED,
+ TaskStatusEnum.SKIPPED,
+ TaskStatusEnum.PENDING,
+ TaskStatusEnum.NOT_STARTED,
+];
+
+// Get task count by status for rollout
+const getTaskCount = (status: Task_Status) => {
+ if (!rollout?.value) return 0;
+ const allTasks = rollout.value.stages.flatMap((stage) => stage.tasks);
+ return allTasks.filter((task) => task.status === status).length;
+};
// Calculate statistics
const statistics = computed(() => {
diff --git a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue b/frontend/src/components/Plan/components/RolloutView/RolloutView.vue
index de207c7353..595a65f806 100644
--- a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/RolloutView.vue
@@ -13,6 +13,7 @@
<StagesView
:rollout="rollout"
:merged-stages="mergedStages"
+ :readonly="readonly"
@run-tasks="handleRunTasks"
@create-rollout-to-stage="handleCreateRolloutToStage"
/>
@@ -45,7 +46,7 @@ import { useRolloutViewContext } from "./context";
const { t } = useI18n();
const { project } = useCurrentProjectV1();
-const { events } = usePlanContextWithRollout();
+const { events, readonly } = usePlanContextWithRollout();
const { rollout, mergedStages } = useRolloutViewContext();
const runTasksPanel = ref<{
diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
index c99d7fefd6..48435c511f 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
@@ -5,11 +5,12 @@
class="flex-1 bg-white rounded-lg border p-4 shadow-sm"
:class="
twMerge(
- isCreated ? 'border-gray-200' : 'border-gray-300 border-dashed',
- !readonly && 'cursor-pointer hover:shadow-md transition-shadow'
+ isCreated
+ ? 'border-gray-200 cursor-pointer hover:shadow-md transition-shadow'
+ : 'border-gray-300 border-dashed'
)
"
- @click="!readonly && isCreated && handleClickStageTitle()"
+ @click="isCreated && handleClickStageTitle()"
>
<div class="flex items-center justify-between gap-4">
<!-- Left side: Stage title and status counts -->
diff --git a/frontend/src/components/Plan/components/RolloutView/StageView.vue b/frontend/src/components/Plan/components/RolloutView/StageView.vue
index 44b77e69f8..cd916397a5 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageView.vue
@@ -22,7 +22,11 @@
<!-- Tasks Table View -->
<div class="flex-1 min-h-0">
- <TaskTableView :task-status-filter="taskStatusFilter" :stage="stage" />
+ <TaskTableView
+ :task-status-filter="taskStatusFilter"
+ :stage="stage"
+ :readonly="readonly"
+ />
</div>
</div>
</template>
@@ -45,7 +49,7 @@ const props = defineProps<{
const route = useRoute();
const environmentStore = useEnvironmentV1Store();
-const { rollout } = usePlanContextWithRollout();
+const { rollout, readonly } = usePlanContextWithRollout();
const stage = computed(() => {
return rollout.value.stages.find((s) => s.id === props.stageId) as Stage;
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue b/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue
index c3b71fbe12..34cdcb5647 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue
@@ -19,7 +19,7 @@
quaternary
size="small"
type="primary"
- :disabled="action.disabled"
+ :disabled="action.disabled || readonly"
@click="action.click"
>
<template #icon>
@@ -55,16 +55,13 @@ import { NButton, NScrollbar, NTooltip } from "naive-ui";
import type { VNode } from "vue";
import { computed, h, reactive } from "vue";
import { useI18n } from "vue-i18n";
-import { useCurrentProjectV1 } from "@/store";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import type {
Task,
Rollout,
Stage,
} from "@/types/proto-es/v1/rollout_service_pb";
-import { usePlanContext } from "../../logic";
import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";
-import { useTaskActionPermissions } from "./taskPermissions";
interface TaskAction {
icon: VNode;
@@ -83,6 +80,7 @@ const props = defineProps<{
tasks: Task[];
rollout: Rollout;
stage: Stage;
+ readonly?: boolean;
}>();
const emit = defineEmits<{
@@ -96,40 +94,6 @@ const state = reactive<LocalState>({
});
const { t } = useI18n();
-const { project } = useCurrentProjectV1();
-const planContext = usePlanContext();
-const { canPerformTaskAction } = useTaskActionPermissions();
-
-// Permission checks for each action
-const canRunTasks = computed(() => {
- if (props.tasks.length === 0) return false;
- return canPerformTaskAction(
- props.tasks,
- props.rollout,
- project.value,
- planContext.issue?.value
- );
-});
-
-const canSkipTasks = computed(() => {
- if (props.tasks.length === 0) return false;
- return canPerformTaskAction(
- props.tasks,
- props.rollout,
- project.value,
- planContext.issue?.value
- );
-});
-
-const canCancelTasks = computed(() => {
- if (props.tasks.length === 0) return false;
- return canPerformTaskAction(
- props.tasks,
- props.rollout,
- project.value,
- planContext.issue?.value
- );
-});
// Action target for the panel
const actionTarget = computed(() => {
@@ -190,8 +154,7 @@ const actions = computed((): TaskAction[] => {
resp.push({
icon: h(PlayIcon),
text: t("common.run"),
- disabled:
- props.tasks.length === 0 || !canRunTasks.value || !hasRunnableTasks.value,
+ disabled: props.tasks.length === 0 || !hasRunnableTasks.value,
click: () => {
state.selectedAction = "RUN";
state.showActionPanel = true;
@@ -200,9 +163,6 @@ const actions = computed((): TaskAction[] => {
if (props.tasks.length === 0) {
return getDisabledTooltip(action);
}
- if (!canRunTasks.value) {
- return t("task.no-permission");
- }
if (!hasRunnableTasks.value) {
return t("task.no-runnable-tasks");
}
@@ -214,10 +174,7 @@ const actions = computed((): TaskAction[] => {
resp.push({
icon: h(SkipForwardIcon),
text: t("common.skip"),
- disabled:
- props.tasks.length === 0 ||
- !canSkipTasks.value ||
- !hasSkippableTasks.value,
+ disabled: props.tasks.length === 0 || !hasSkippableTasks.value,
click: () => {
state.selectedAction = "SKIP";
state.showActionPanel = true;
@@ -226,9 +183,6 @@ const actions = computed((): TaskAction[] => {
if (props.tasks.length === 0) {
return getDisabledTooltip(action);
}
- if (!canSkipTasks.value) {
- return t("task.no-permission");
- }
if (!hasSkippableTasks.value) {
return t("task.no-skippable-tasks");
}
@@ -240,10 +194,7 @@ const actions = computed((): TaskAction[] => {
resp.push({
icon: h(XIcon),
text: t("common.cancel"),
- disabled:
- props.tasks.length === 0 ||
- !canCancelTasks.value ||
- !hasCancellableTasks.value,
+ disabled: props.tasks.length === 0 || !hasCancellableTasks.value,
click: () => {
state.selectedAction = "CANCEL";
state.showActionPanel = true;
@@ -252,9 +203,6 @@ const actions = computed((): TaskAction[] => {
if (props.tasks.length === 0) {
return getDisabledTooltip(action);
}
- if (!canCancelTasks.value) {
- return t("task.no-permission");
- }
if (!hasCancellableTasks.value) {
return t("task.no-cancellable-tasks");
}
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
index b7b85cefe5..a028f95c35 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
@@ -221,22 +221,26 @@ 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 {
+ pushNotification,
+ useCurrentProjectV1,
+ useEnvironmentV1Store,
+} from "@/store";
import { Issue_Approver_Status } from "@/types/proto-es/v1/issue_service_pb";
import {
BatchRunTasksRequestSchema,
BatchSkipTasksRequestSchema,
BatchCancelTaskRunsRequestSchema,
+ ListTaskRunsRequestSchema,
+ TaskRun_Status,
} from "@/types/proto-es/v1/rollout_service_pb";
-import type {
- Stage,
- Task,
- TaskRun,
-} from "@/types/proto-es/v1/rollout_service_pb";
+import type { Stage, Task } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
-import { usePlanContext } from "../../logic";
+import { hasWorkspacePermissionV2 } from "@/utils";
+import { usePlanContextWithRollout } from "../../logic";
import { useIssueReviewContext } from "../../logic/issue-review";
import TaskDatabaseName from "./TaskDatabaseName.vue";
+import { useTaskActionPermissions } from "./taskPermissions";
// Default delay for running tasks if not scheduled immediately.
const DEFAULT_RUN_DELAY_MS = 60000;
@@ -245,9 +249,7 @@ type LocalState = {
loading: boolean;
};
-export type TargetType =
- | { type: "tasks"; tasks?: Task[]; stage: Stage }
- | { type: "taskRuns"; taskRuns: TaskRun[]; stage: Stage };
+export type TargetType = { type: "tasks"; tasks?: Task[]; stage: Stage };
const props = defineProps<{
show: boolean;
@@ -261,12 +263,14 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-const { issue } = usePlanContext();
+const { project } = useCurrentProjectV1();
+const { issue, rollout } = usePlanContextWithRollout();
const reviewContext = useIssueReviewContext();
const state = reactive<LocalState>({
loading: false,
});
const environmentStore = useEnvironmentV1Store();
+const { canPerformTaskAction } = useTaskActionPermissions();
const comment = ref("");
const runTimeInMS = ref<number | undefined>(undefined);
const forceRollout = ref(false);
@@ -310,7 +314,8 @@ const shouldShowForceRollout = computed(() => {
return (
props.action === "RUN" &&
issueApprovalStatus.value.hasIssue &&
- !issueApprovalStatus.value.isApproved
+ !issueApprovalStatus.value.isApproved &&
+ hasWorkspacePermissionV2("bb.taskRuns.create")
);
});
@@ -327,14 +332,6 @@ const targetTasks = computed(() => {
return undefined;
});
-// Extract task runs if provided
-const targetTaskRuns = computed(() => {
- if (props.target.type === "taskRuns") {
- return props.target.taskRuns;
- }
- return undefined;
-});
-
const title = computed(() => {
switch (props.action) {
case "RUN":
@@ -407,6 +404,18 @@ const confirmErrors = computed(() => {
errors.push(t("common.no-data"));
}
+ if (
+ !canPerformTaskAction(
+ runnableTasks.value,
+ rollout.value,
+ project.value,
+ issue?.value
+ ) &&
+ !hasWorkspacePermissionV2("bb.taskRuns.create")
+ ) {
+ errors.push(t("task.no-permission"));
+ }
+
// Validate scheduled time if not running immediately (only for RUN)
if (props.action === "RUN" && runTimeInMS.value !== undefined) {
if (runTimeInMS.value <= Date.now()) {
@@ -428,12 +437,16 @@ const confirmErrors = computed(() => {
}
}
- // For CANCEL, we need task runs
if (
props.action === "CANCEL" &&
- (!targetTaskRuns.value || targetTaskRuns.value.length === 0)
+ runnableTasks.value.some(
+ (task) =>
+ task.status !== Task_Status.PENDING &&
+ task.status !== Task_Status.RUNNING
+ )
) {
- errors.push("No active task runs to cancel");
+ // Check task status.
+ errors.push("No active task to cancel");
}
return errors;
@@ -468,20 +481,39 @@ const handleConfirm = async () => {
});
await rolloutServiceClientConnect.batchSkipTasks(request);
} else if (props.action === "CANCEL") {
+ // Fetch task runs for the tasks to be canceled.
+ const taskRuns = (
+ await Promise.all(
+ runnableTasks.value.map(async (task) => {
+ const request = create(ListTaskRunsRequestSchema, {
+ parent: task.name,
+ pageSize: 10,
+ });
+ return rolloutServiceClientConnect
+ .listTaskRuns(request)
+ .then((response) => response.taskRuns || []);
+ })
+ )
+ ).flat();
+ const cancelableTaskRuns = taskRuns.filter(
+ (taskRun) =>
+ taskRun.status === TaskRun_Status.PENDING ||
+ taskRun.status === TaskRun_Status.RUNNING
+ );
const request = create(BatchCancelTaskRunsRequestSchema, {
parent: `${targetStage.value.name}/tasks/-`,
- taskRuns: targetTaskRuns.value?.map((taskRun) => taskRun.name) || [],
+ taskRuns: cancelableTaskRuns.map((taskRun) => taskRun.name),
reason: comment.value,
});
await rolloutServiceClientConnect.batchCancelTaskRuns(request);
}
+ emit("confirm");
pushNotification({
module: "bytebase",
style: "SUCCESS",
title: t("common.success"),
});
- emit("confirm");
} catch (error) {
pushNotification({
module: "bytebase",
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue b/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
index d2145b263c..33c347e8a9 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
@@ -1,7 +1,7 @@
<template>
<div>
<div
- v-if="primaryAction || dropdownOptions.length > 0"
+ v-if="!props.readonly && (primaryAction || dropdownOptions.length > 0)"
class="flex flex-row justify-end items-center gap-x-2"
>
<NButton
@@ -66,6 +66,7 @@ const props = defineProps<{
task: Task;
taskRuns: TaskRun[];
rollout?: Rollout;
+ readonly?: boolean;
}>();
const emit = defineEmits<{
@@ -97,22 +98,11 @@ const currentPanelAction = computed((): PanelAction => {
// Determine target based on action type
const actionTarget = computed(() => {
if (!currentPanelAction.value) return undefined;
-
- if (currentPanelAction.value === "CANCEL") {
- // For cancel actions, we need task runs
- return {
- type: "taskRuns" as const,
- taskRuns: props.taskRuns,
- stage: stage.value,
- };
- } else {
- // For run and skip actions, we use specific tasks
- return {
- type: "tasks" as const,
- tasks: [props.task],
- stage: stage.value,
- };
- }
+ return {
+ type: "tasks" as const,
+ tasks: [props.task],
+ stage: stage.value,
+ };
});
// Get the stage for the current task
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue b/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue
index 175e855a11..222b1d4d52 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue
@@ -5,6 +5,7 @@
:tasks="selectedTasks"
:rollout="rollout"
:stage="props.stage"
+ :readonly="props.readonly"
@refresh="handleRefresh"
@action-confirmed="handleTaskActionConfirmed"
/>
@@ -36,6 +37,7 @@ import TaskTable from "./TaskTable.vue";
const props = defineProps<{
taskStatusFilter: Task_Status[];
stage: Stage;
+ readonly?: boolean;
}>();
const { rollout, events } = usePlanContextWithRollout();
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskView.vue b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
index d5e0d9a585..bd43a64fc7 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
@@ -31,6 +31,7 @@
:task="task"
:task-runs="taskRuns"
:rollout="rollout"
+ :readonly="readonly"
@action-confirmed="handleTaskActionConfirmed"
/>
</div>
@@ -111,7 +112,7 @@ const props = defineProps<{
}>();
const { project } = useCurrentProjectV1();
-const { rollout } = usePlanContextWithRollout();
+const { rollout, readonly, events } = usePlanContextWithRollout();
const sheetStore = useSheetV1Store();
const taskRunsRef = ref<TaskRun[]>([]);
@@ -190,5 +191,6 @@ const handleTaskActionConfirmed = async () => {
console.error("Failed to refresh task runs:", error);
}
}
+ events.emit("status-changed", { eager: true });
};
</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
index 943cb6c72c..3e334532f1 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -153,7 +153,7 @@ const DEFAULT_VISIBLE_TARGETS = 20;
const { t } = useI18n();
const router = useRouter();
-const { plan, isCreating } = usePlanContext();
+const { plan, isCreating, readonly } = usePlanContext();
const selectedSpec = useSelectedSpec();
const instanceStore = useInstanceV1Store();
const databaseStore = useDatabaseV1Store();
@@ -179,10 +179,11 @@ const project = computed(() => {
return projectStore.getProjectByName(projectName);
});
-// Only allow editing in creation mode or if the plan is editable.
+// Only allow editing in creation mode or if the plan is editable and not readonly.
// An empty string for `plan.value.rollout` indicates that the plan is in a draft or uninitialized state,
// which allows edits to be made.
const allowEdit = computed(() => {
+ if (readonly.value) return false;
return (isCreating.value || plan.value.rollout === "") && selectedSpec.value;
});
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index 11f00ac767..482f131f2f 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -112,7 +112,7 @@
}"
@update:content="handleStatementChange"
/>
- <div class="absolute bottom-1 right-4">
+ <div v-if="!readonly" class="absolute bottom-1 right-4">
<NButton
size="small"
:quaternary="true"
@@ -216,7 +216,8 @@ type LocalState = {
const { t } = useI18n();
const dialog = useDialog();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, planCheckRuns, rollout, events } = usePlanContext();
+const { isCreating, plan, planCheckRuns, rollout, events, readonly } =
+ usePlanContext();
const selectedSpec = useSelectedSpec();
const monacoEditorRef = ref<InstanceType<typeof MonacoEditor>>();
@@ -261,6 +262,9 @@ const { markers } = useSQLAdviceMarkers(
* - Disallowed to edit statement
*/
const isEditorReadonly = computed(() => {
+ if (readonly.value) {
+ return true;
+ }
if (isCreating.value) {
return false;
}
@@ -286,6 +290,10 @@ const denyEditStatementReasons = computed(() => {
});
const shouldShowEditButton = computed(() => {
+ // Not allowed to edit if readonly.
+ if (readonly.value) {
+ return false;
+ }
// Need not to show "Edit" while the plan is still pending create.
if (isCreating.value) {
return false;
diff --git a/frontend/src/components/Plan/logic/base.ts b/frontend/src/components/Plan/logic/base.ts
index 9ee7725d43..0de4357e82 100644
--- a/frontend/src/components/Plan/logic/base.ts
+++ b/frontend/src/components/Plan/logic/base.ts
@@ -1,12 +1,25 @@
import Emittery from "emittery";
+import { computed } from "vue";
+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import type { PlanContext, PlanEvents } from "./context";
-export const useBasePlanContext = (
- _: Pick<PlanContext, "isCreating" | "plan">
-): Partial<PlanContext> => {
+export const useBasePlanContext = ({
+ issue,
+}: Pick<
+ PlanContext,
+ "isCreating" | "plan" | "issue"
+>): Partial<PlanContext> => {
const events: PlanEvents = new Emittery();
+ const readonly = computed(() => {
+ if (issue?.value) {
+ return issue.value.status !== IssueStatus.OPEN;
+ }
+ return false;
+ });
+
return {
+ readonly,
events,
};
};
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 664b16aeb9..3436120639 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -1,6 +1,6 @@
import type Emittery from "emittery";
import { v4 as uuidv4 } from "uuid";
-import type { InjectionKey, Ref } from "vue";
+import type { ComputedRef, InjectionKey, Ref } from "vue";
import { inject, provide } from "vue";
import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
import type { Plan, PlanCheckRun } from "@/types/proto-es/v1/plan_service_pb";
@@ -30,6 +30,8 @@ export type PlanContext = {
issue?: Ref<Issue | undefined>;
rollout?: Ref<Rollout | undefined>;
+ readonly: ComputedRef<boolean>;
+
// UI events
events: PlanEvents;
};
diff --git a/frontend/src/components/Rollout/RolloutDataTable.vue b/frontend/src/components/Rollout/RolloutDataTable.vue
index e77d5fb95b..674287cea2 100644
--- a/frontend/src/components/Rollout/RolloutDataTable.vue
+++ b/frontend/src/components/Rollout/RolloutDataTable.vue
@@ -2,7 +2,7 @@
<NDataTable
size="small"
:columns="columnList"
- :data="sortedRolloutList"
+ :data="rolloutList"
:striped="true"
:bordered="bordered"
:loading="loading"
@@ -36,7 +36,7 @@ import {
getStageStatus,
} from "@/utils";
-const props = withDefaults(
+withDefaults(
defineProps<{
rolloutList: ComposedRollout[];
bordered?: boolean;
@@ -127,7 +127,7 @@ const columnList = computed(
<>
<div key={stage.name} class="flex items-center gap-1">
<TaskStatus status={stageStatus} size="small" />
- <span class="text-sm font-medium text-gray-700">
+ <span class="text-sm font-medium text-gray-700 whitespace-nowrap">
{environment.title}
</span>
</div>
@@ -202,10 +202,6 @@ const columnList = computed(
}
);
-const sortedRolloutList = computed(() => {
- return props.rolloutList;
-});
-
const rowProps = (rollout: ComposedRollout) => {
return {
style: "cursor: pointer;",
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f8ff21c7e9..3e6e94fe8b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1062,7 +1062,6 @@
"select-targets": "Select Targets",
"ready-for-review": "Ready for Review",
"overview": {
- "description": "View and manage all specifications in this plan",
"total-specs": "Total Specs",
"total-targets": "Total Targets",
"no-checks": "No checks",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index dd33d9ee54..51ee412c10 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1062,7 +1062,6 @@
"select-targets": "Seleccionar objetivos",
"ready-for-review": "Listo para revisión",
"overview": {
- "description": "Ver y administrar todas las especificaciones de este plan",
"total-specs": "Especificaciones totales",
"total-targets": "Objetivos totales",
"no-checks": "Sin controles",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index a703e4b8b0..aedff004f7 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1062,7 +1062,6 @@
"select-targets": "ターゲットを選択",
"ready-for-review": "レビュー準備完了",
"overview": {
- "description": "このプランのすべての仕様を表示および管理します",
"total-specs": "合計スペック",
"total-targets": "合計ターゲット",
"no-checks": "チェックなし",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 4ebee8f474..9dd3cb14e8 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1062,7 +1062,6 @@
"select-targets": "Chọn mục tiêu",
"ready-for-review": "Sẵn sàng để xem xét",
"overview": {
- "description": "Xem và quản lý tất cả các thông số kỹ thuật trong kế hoạch này",
"total-specs": "Tổng số thông số kỹ thuật",
"total-targets": "Tổng số mục tiêu",
"no-checks": "Không kiểm tra",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f515cb1f3b..9ff9b72d44 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1062,7 +1062,6 @@
"select-targets": "选择变更对象",
"ready-for-review": "提交审批",
"overview": {
- "description": "查看和管理此变更计划中的所有变更项",
"total-specs": "变更项",
"total-targets": "变更对象",
"no-checks": "没有检查",
diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vue
index efe8baf7b5..c8638d8cdf 100644
--- a/frontend/src/views/project/CICDLayout.vue
+++ b/frontend/src/views/project/CICDLayout.vue
@@ -3,6 +3,22 @@
<template v-if="ready">
<PollerProvider>
<div class="h-full flex flex-col">
+ <!-- Banner Section -->
+ <div v-if="showBanner" class="banner-section">
+ <div
+ v-if="showClosedBanner"
+ class="h-8 w-full text-base font-medium bg-gray-400 text-white flex justify-center items-center"
+ >
+ {{ $t("common.closed") }}
+ </div>
+ <div
+ v-else-if="showSuccessBanner"
+ class="h-8 w-full text-base font-medium bg-success text-white flex justify-center items-center"
+ >
+ {{ $t("common.done") }}
+ </div>
+ </div>
+
<HeaderSection />
<NTabs
type="line"
@@ -68,6 +84,7 @@ import {
PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
} from "@/router/dashboard/projectV1";
+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import {
extractIssueUID,
extractPlanUID,
@@ -101,6 +118,7 @@ const { isCreating, plan, planCheckRuns, issue, rollout, isInitializing } =
const planBaseContext = useBasePlanContext({
isCreating,
plan,
+ issue,
});
const ready = computed(() => {
@@ -288,5 +306,19 @@ const documentTitle = computed(() => {
}
return t("common.loading");
});
+
+// Banner conditions
+const showClosedBanner = computed(() => {
+ return issue.value && issue.value.status === IssueStatus.CANCELED;
+});
+
+const showSuccessBanner = computed(() => {
+ return issue.value && issue.value.status === IssueStatus.DONE;
+});
+
+const showBanner = computed(() => {
+ return showClosedBanner.value || showSuccessBanner.value;
+});
+
useTitle(documentTitle);
</script>