Skip to content

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

feat: use rollout policy checkers in task rollout panel (#17506)

boojackbf1a5eda9dd0
diff --git a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
index 75d6d59755..8fe55e4dfd 100644
--- a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
@@ -11,16 +11,41 @@
v-if="action"
class="flex flex-col gap-y-4 h-full overflow-y-hidden px-1"
>
+ <!-- Error Alert -->
+ <NAlert
+ v-if="validationErrors.length > 0"
+ type="error"
+ :title="$t('rollout.task-execution-errors')"
+ >
+ <ul class="list-disc list-inside space-y-1">
+ <li
+ v-for="(error, index) in validationErrors"
+ :key="index"
+ class="text-sm"
+ >
+ {{ error }}
+ </li>
+ </ul>
+ </NAlert>
+
+ <!-- Warning Alert -->
+ <NAlert
+ v-if="validationWarnings.length > 0"
+ type="warning"
+ :title="$t('rollout.task-execution-notices')"
+ >
+ <ul class="list-disc list-inside space-y-1">
+ <li
+ v-for="(warning, index) in validationWarnings"
+ :key="index"
+ class="text-sm"
+ >
+ {{ warning }}
+ </li>
+ </ul>
+ </NAlert>
+
<template v-if="stage">
- <NAlert
- v-if="hasPreviousUnrolledStages"
- :title="
- t(
- 'issue.status-transition.warning.some-previous-stages-are-not-done'
- )
- "
- type="warning"
- />
<div
class="flex flex-row gap-x-2 shrink-0 overflow-y-hidden justify-start items-center"
>
@@ -83,16 +108,6 @@
:database="database"
/>
- <div v-if="planCheckErrors.length > 0" class="flex flex-col">
- <ErrorList :errors="planCheckErrors" :bullets="false" class="text-sm">
- <template #prefix>
- <heroicons:exclamation-triangle
- class="text-warning w-4 h-4 inline-block mr-1 mb-px"
- />
- </template>
- </ErrorList>
- </div>
-
<div class="flex flex-col gap-y-1 shrink-0">
<p class="font-medium text-control">
{{ $t("common.comment") }}
@@ -189,6 +204,7 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
+import dayjs from "dayjs";
import { head, uniqBy } from "lodash-es";
import {
NAlert,
@@ -220,7 +236,13 @@ import {
pushNotification,
useEnvironmentV1Store,
useCurrentProjectV1,
+ usePolicyByParentAndType,
} from "@/store";
+import { Issue_Approver_Status } from "@/types/proto-es/v1/issue_service_pb";
+import {
+ PolicyType,
+ RolloutPolicy_Checkers_PlanCheckEnforcement,
+} from "@/types/proto-es/v1/org_policy_service_pb";
import {
BatchRunTasksRequestSchema,
BatchSkipTasksRequestSchema,
@@ -263,6 +285,49 @@ const comment = ref("");
const runTimeInMS = ref<number | undefined>(undefined);
const performActionAnyway = ref(false);
+// Check issue approval status
+const issueApprovalStatus = computed(() => {
+ if (!issue?.value || !props.action) {
+ return { isApproved: true, hasIssue: false };
+ }
+
+ const currentIssue = issue.value;
+ const approvalTemplate = head(currentIssue.approvalTemplates);
+
+ // Check if issue has approval template
+ if (!approvalTemplate || (approvalTemplate.flow?.steps || []).length === 0) {
+ return { isApproved: true, hasIssue: true };
+ }
+
+ // Simple check based on all approvers being approved (no rejections)
+ const hasRejections = currentIssue.approvers.some(
+ (app) => app.status === Issue_Approver_Status.REJECTED
+ );
+
+ if (hasRejections) {
+ return { isApproved: false, hasIssue: true, status: "rejected" };
+ }
+
+ // Check if all required approvals are present
+ const approvedCount = currentIssue.approvers.filter(
+ (app) => app.status === Issue_Approver_Status.APPROVED
+ ).length;
+
+ const requiredApprovalsCount =
+ approvalTemplate.flow?.steps?.reduce(
+ (count, step) => count + step.nodes.length,
+ 0
+ ) || 0;
+
+ const isApproved = approvedCount >= requiredApprovalsCount;
+
+ return {
+ isApproved,
+ hasIssue: true,
+ status: isApproved ? "approved" : "pending",
+ };
+});
+
const title = computed(() => {
if (!props.action) return "";
@@ -277,6 +342,20 @@ const database = computed(() =>
databaseForTask(project.value, selectedTask.value)
);
+// Get rollout policy for the environment
+const { policy: rolloutPolicy } = usePolicyByParentAndType(
+ computed(() => {
+ const env = database.value?.effectiveEnvironment;
+ if (!env) {
+ return { parentPath: "", policyType: PolicyType.ROLLOUT_POLICY };
+ }
+ return {
+ parentPath: env,
+ policyType: PolicyType.ROLLOUT_POLICY,
+ };
+ })
+);
+
const stage = computed(() => {
const firstTask = head(props.taskList);
if (!firstTask) return undefined;
@@ -341,7 +420,10 @@ const hasPreviousUnrolledStages = computed(() => {
});
const showPerformActionAnyway = computed(() => {
- return planCheckErrors.value.length > 0 || hasPreviousUnrolledStages.value;
+ // Only show bypass option when there are warnings but NO errors
+ return (
+ validationWarnings.value.length > 0 && validationErrors.value.length === 0
+ );
});
const planCheckRunList = computed(() => {
@@ -349,51 +431,243 @@ const planCheckRunList = computed(() => {
return uniqBy(list, (checkRun) => checkRun.name);
});
-const planCheckErrors = computed(() => {
+// Plan check error validation based on rollout policy checkers
+const planCheckError = computed(() => {
+ if (
+ !(
+ props.action === "ROLLOUT" ||
+ props.action === "RETRY" ||
+ props.action === "RESTART"
+ )
+ ) {
+ return undefined;
+ }
+
+ const summary = planCheckRunSummaryForCheckRunList(planCheckRunList.value);
+
+ // Get the plan check enforcement level from the rollout policy
+ const planCheckEnforcement =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredStatusChecks
+ ?.planCheckEnforcement
+ : undefined;
+
+ // If no enforcement is specified, default to no validation
+ if (!planCheckEnforcement) {
+ return undefined;
+ }
+
+ if (summary.runningCount > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"
+ );
+ }
+ // ERROR_ONLY enforcement: only block on errors
+ if (
+ planCheckEnforcement ===
+ RolloutPolicy_Checkers_PlanCheckEnforcement.ERROR_ONLY
+ ) {
+ if (summary.errorCount > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
+ );
+ }
+ }
+ // STRICT enforcement: block on both errors and warnings
+ if (
+ planCheckEnforcement === RolloutPolicy_Checkers_PlanCheckEnforcement.STRICT
+ ) {
+ if (summary.errorCount > 0 || summary.warnCount > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
+ );
+ }
+ }
+ return undefined;
+});
+
+// Plan check warning validation for non-blocking plan check results
+const planCheckWarning = computed(() => {
+ if (
+ !(
+ props.action === "ROLLOUT" ||
+ props.action === "RETRY" ||
+ props.action === "RESTART"
+ )
+ ) {
+ return undefined;
+ }
+
+ const summary = planCheckRunSummaryForCheckRunList(planCheckRunList.value);
+ if (
+ summary.successCount +
+ summary.warnCount +
+ summary.errorCount +
+ summary.runningCount ===
+ 0
+ ) {
+ return undefined;
+ }
+
+ // Get the plan check enforcement level from the rollout policy
+ const planCheckEnforcement =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredStatusChecks
+ ?.planCheckEnforcement
+ : undefined;
+
+ // If there's no enforcement policy, show any plan check issues as warnings
+ if (!planCheckEnforcement) {
+ if (summary.runningCount > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"
+ );
+ }
+ if (summary.errorCount > 0 || summary.warnCount > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
+ );
+ }
+ }
+
+ // Show warnings for plan check results that don't violate enforcement policy
+ if (
+ planCheckEnforcement ===
+ RolloutPolicy_Checkers_PlanCheckEnforcement.ERROR_ONLY
+ ) {
+ // Show warnings as non-blocking when ERROR_ONLY policy allows them
+ if (summary.warnCount > 0) {
+ return t("rollout.task-execution-notices");
+ }
+ }
+
+ return undefined;
+});
+
+// Collect blocking validation errors
+const validationErrors = computed(() => {
+ if (!props.action) return [];
+
const errors: string[] = [];
+
+ // Permission errors - always block rollout
+ if (filteredTasks.value.length > 0) {
+ // Check basic task permissions here if needed
+ }
+
+ // No active tasks to cancel - blocking error
+ if (
+ props.action === "CANCEL" &&
+ filteredTasks.value.length > 0 &&
+ !filteredTasks.value.some(
+ (task) =>
+ task.status === Task_Status.PENDING ||
+ task.status === Task_Status.RUNNING
+ )
+ ) {
+ errors.push(t("rollout.no-active-task-to-cancel"));
+ }
+
if (
props.action === "ROLLOUT" ||
props.action === "RETRY" ||
props.action === "RESTART"
) {
- const summary = planCheckRunSummaryForCheckRunList(planCheckRunList.value);
- if (summary.errorCount > 0 || summary.warnCount) {
+ // Issue approval errors (only if policy requires it) - HARD BLOCK
+ const requiresIssueApproval =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredIssueApproval
+ : false;
+
+ if (
+ requiresIssueApproval &&
+ issueApprovalStatus.value.hasIssue &&
+ !issueApprovalStatus.value.isApproved
+ ) {
+ const isRejected = issueApprovalStatus.value.status === "rejected";
errors.push(
- t(
- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
- )
+ isRejected
+ ? t("issue.approval.rejected-error")
+ : t("issue.approval.pending-error")
);
}
- if (summary.runningCount > 0) {
- errors.push(
- t(
- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"
- )
- );
+
+ // Plan check errors (based on rollout policy) - HARD BLOCK
+ if (planCheckError.value) {
+ errors.push(planCheckError.value);
}
}
return errors;
});
-const confirmErrors = computed(() => {
- const errors: string[] = [];
- if (!performActionAnyway.value) {
- if (planCheckErrors.value.length > 0) {
- errors.push(...planCheckErrors.value);
+// Collect validation warnings that don't block rollout
+const validationWarnings = computed(() => {
+ if (!props.action) return [];
+
+ const warnings: string[] = [];
+
+ // Basic validation warnings
+ if (filteredTasks.value.length === 0) {
+ warnings.push(t("common.no-data"));
+ }
+
+ if (
+ props.action === "ROLLOUT" ||
+ props.action === "RETRY" ||
+ props.action === "RESTART"
+ ) {
+ // Validate scheduled time if not running immediately
+ if (runTimeInMS.value !== undefined && runTimeInMS.value <= Date.now()) {
+ warnings.push(t("task.error.scheduled-time-must-be-in-the-future"));
+ }
+
+ // Plan check warnings (non-blocking plan check results)
+ if (planCheckWarning.value) {
+ warnings.push(planCheckWarning.value);
}
+
+ // Issue approval warnings (when not required by policy but issue is not approved)
+ const requiresIssueApproval =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredIssueApproval
+ : false;
+
+ if (
+ !requiresIssueApproval &&
+ issueApprovalStatus.value.hasIssue &&
+ !issueApprovalStatus.value.isApproved
+ ) {
+ const isRejected = issueApprovalStatus.value.status === "rejected";
+ warnings.push(
+ isRejected
+ ? t("issue.approval.rejected-error")
+ : t("issue.approval.pending-error")
+ );
+ }
+
+ // Previous stages incomplete warning
if (hasPreviousUnrolledStages.value) {
- errors.push(
+ warnings.push(
t("issue.status-transition.warning.some-previous-stages-are-not-done")
);
}
}
- // 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 warnings;
+});
+
+const confirmErrors = computed(() => {
+ const errors: string[] = [];
+
+ // Always block on validation errors
+ if (validationErrors.value.length > 0) {
+ errors.push(...validationErrors.value);
+ }
+
+ // Block on warnings unless bypassed
+ if (!performActionAnyway.value && validationWarnings.value.length > 0) {
+ errors.push(...validationWarnings.value);
}
return errors;
diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
index ac6223fb89..3483963b55 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
@@ -214,7 +214,7 @@ import {
} from "@/utils";
import { usePlanContextWithRollout } from "../../logic";
import StageActions from "./StageActions.vue";
-import { useTaskActionPermissions } from "./taskPermissions";
+import { canRolloutTasks } from "./taskPermissions";
const props = defineProps<{
rollout: Rollout;
@@ -231,9 +231,7 @@ const emit = defineEmits<{
const router = useRouter();
const { project } = useCurrentProjectV1();
const environmentStore = useEnvironmentV1Store();
-const { readonly, issue } = usePlanContextWithRollout();
-
-const { canPerformTaskAction } = useTaskActionPermissions();
+const { readonly } = usePlanContextWithRollout();
const isCreated = computed(() => {
return props.rollout.stages.some(
@@ -296,12 +294,7 @@ const canRunTasks = computed(() => {
if (readonly.value) {
return false;
}
- return canPerformTaskAction(
- filteredTasks.value,
- props.rollout,
- project.value,
- issue.value
- );
+ return canRolloutTasks(filteredTasks.value);
});
const canCreateRollout = computed(() => {
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue b/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue
index 53dbf69565..84730be693 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue
@@ -55,7 +55,6 @@ 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,
@@ -64,7 +63,7 @@ import type {
} from "@/types/proto-es/v1/rollout_service_pb";
import { usePlanContextWithRollout } from "../../logic";
import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";
-import { useTaskActionPermissions } from "./taskPermissions";
+import { canRolloutTasks } from "./taskPermissions";
interface TaskAction {
icon: VNode;
@@ -96,9 +95,7 @@ const state = reactive<LocalState>({
});
const { t } = useI18n();
-const { project } = useCurrentProjectV1();
-const { readonly, issue } = usePlanContextWithRollout();
-const { canPerformTaskAction } = useTaskActionPermissions();
+const { readonly } = usePlanContextWithRollout();
// Action target for the panel
const actionTarget = computed(() => {
@@ -154,12 +151,7 @@ const canPerformTaskActions = computed(() => {
if (readonly.value) {
return false;
}
- return canPerformTaskAction(
- props.tasks,
- props.rollout,
- project.value,
- issue.value
- );
+ return canRolloutTasks(props.tasks);
});
const getDisabledTooltip = (_action: string) => {
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
index ebb720733f..32be106844 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
@@ -8,19 +8,36 @@
>
<template #default>
<div class="flex flex-col gap-y-4 h-full overflow-y-hidden px-1">
- <!-- Consolidated Alert -->
+ <!-- Error Alert -->
<NAlert
- v-if="validationMessages.length > 0"
+ v-if="validationErrors.length > 0"
+ type="error"
+ :title="$t('rollout.task-execution-errors')"
+ >
+ <ul class="list-disc list-inside space-y-1">
+ <li
+ v-for="(error, index) in validationErrors"
+ :key="index"
+ class="text-sm"
+ >
+ {{ error }}
+ </li>
+ </ul>
+ </NAlert>
+
+ <!-- Warning Alert -->
+ <NAlert
+ v-if="validationWarnings.length > 0"
type="warning"
:title="$t('rollout.task-execution-notices')"
>
<ul class="list-disc list-inside space-y-1">
<li
- v-for="(message, index) in validationMessages"
+ v-for="(warning, index) in validationWarnings"
:key="index"
class="text-sm"
>
- {{ message }}
+ {{ warning }}
</li>
</ul>
</NAlert>
@@ -194,10 +211,13 @@
</template>
<template #footer>
<div class="w-full flex flex-row justify-between items-center gap-x-2">
- <!-- Force rollout checkbox -->
- <div v-if="shouldShowForceRollout" class="flex items-center">
- <NCheckbox v-model:checked="forceRollout" :disabled="state.loading">
- {{ $t("rollout.force-rollout") }}
+ <!-- Bypass stage requirements checkbox -->
+ <div v-if="shouldShowBypassOption" class="flex items-center">
+ <NCheckbox
+ v-model:checked="bypassPolicyChecks"
+ :disabled="state.loading"
+ >
+ {{ $t("rollout.bypass-stage-requirements") }}
</NCheckbox>
</div>
<div v-else />
@@ -207,10 +227,13 @@
{{ $t("common.close") }}
</NButton>
- <NTooltip :disabled="validationMessages.length === 0" placement="top">
+ <NTooltip :disabled="validationErrors.length === 0" placement="top">
<template #trigger>
<NButton
- :disabled="shouldShowForceRollout && !forceRollout"
+ :disabled="
+ validationErrors.length > 0 ||
+ (validationWarnings.length > 0 && !bypassPolicyChecks)
+ "
type="primary"
@click="handleConfirm"
>
@@ -226,7 +249,7 @@
</NButton>
</template>
<template #default>
- <ErrorList :errors="validationMessages" />
+ <ErrorList :errors="validationErrors" />
</template>
</NTooltip>
</div>
@@ -262,12 +285,14 @@ import { EnvironmentV1Name } from "@/components/v2";
import { rolloutServiceClientConnect } from "@/grpcweb";
import {
pushNotification,
- useCurrentProjectV1,
useEnvironmentV1Store,
usePolicyByParentAndType,
} from "@/store";
import { Issue_Approver_Status } from "@/types/proto-es/v1/issue_service_pb";
-import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
+import {
+ PolicyType,
+ RolloutPolicy_Checkers_PlanCheckEnforcement,
+} from "@/types/proto-es/v1/org_policy_service_pb";
import {
BatchRunTasksRequestSchema,
BatchSkipTasksRequestSchema,
@@ -281,17 +306,12 @@ import type {
Task,
} from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status, Task_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import {
- extractStageUID,
- hasProjectPermissionV2,
- hasWorkspacePermissionV2,
- isNullOrUndefined,
-} from "@/utils";
+import { extractStageUID, isNullOrUndefined } from "@/utils";
import { usePlanContextWithRollout, usePlanCheckStatus } from "../../logic";
import { useIssueReviewContext } from "../../logic/issue-review";
import PlanCheckStatusCount from "../PlanCheckStatusCount.vue";
import TaskDatabaseName from "./TaskDatabaseName.vue";
-import { useTaskActionPermissions } from "./taskPermissions";
+import { canRolloutTasks } from "./taskPermissions";
// Default delay for running tasks if not scheduled immediately.
// 1 hour in milliseconds
@@ -315,17 +335,15 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-const { project } = useCurrentProjectV1();
const { issue, rollout, plan, taskRuns } = 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);
+const bypassPolicyChecks = ref(false);
const { statusSummary: planCheckStatus } = usePlanCheckStatus(plan);
// Check issue approval status using the review context
@@ -362,143 +380,209 @@ const issueApprovalStatus = computed(() => {
};
});
-// Check if all previous stages are complete (done or skipped)
-const previousStagesStatus = computed(() => {
- if (!rollout.value || !targetStage.value) {
- return { allComplete: true, hasIncomplete: false };
+const shouldShowComment = computed(() => !isNullOrUndefined(issue?.value));
+
+// Plan check error validation based on rollout policy checkers
+const planCheckError = computed(() => {
+ if (props.action !== "RUN") {
+ return undefined;
}
- const stages = rollout.value.stages;
- const currentStageIndex = stages.findIndex(
- (stage) => stage.environment === targetStage.value.environment
- );
+ // Get the plan check enforcement level from the rollout policy
+ const planCheckEnforcement =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredStatusChecks
+ ?.planCheckEnforcement
+ : undefined;
- if (currentStageIndex <= 0) {
- // This is the first stage or stage not found
- return { allComplete: true, hasIncomplete: false };
+ // If no enforcement is specified, default to no validation
+ if (!planCheckEnforcement) {
+ return undefined;
}
- // Check all previous stages
- for (let i = 0; i < currentStageIndex; i++) {
- const stage = stages[i];
- const hasIncompleteTasks = stage.tasks.some(
- (task) =>
- task.status !== Task_Status.DONE && task.status !== Task_Status.SKIPPED
+ if (planCheckStatus.value.running > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"
);
- if (hasIncompleteTasks) {
- return { allComplete: false, hasIncomplete: true };
+ }
+ // ERROR_ONLY enforcement: only block on errors
+ if (
+ planCheckEnforcement ===
+ RolloutPolicy_Checkers_PlanCheckEnforcement.ERROR_ONLY
+ ) {
+ if (planCheckStatus.value.error > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
+ );
}
}
-
- return { allComplete: true, hasIncomplete: false };
+ // STRICT enforcement: block on both errors and warnings
+ if (
+ planCheckEnforcement === RolloutPolicy_Checkers_PlanCheckEnforcement.STRICT
+ ) {
+ if (planCheckStatus.value.error > 0 || planCheckStatus.value.warning > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
+ );
+ }
+ }
+ return undefined;
});
-const shouldShowComment = computed(() => !isNullOrUndefined(issue?.value));
+// Plan check warning validation for non-blocking plan check results
+const planCheckWarning = computed(() => {
+ if (props.action !== "RUN" || planCheckStatus.value.total === 0) {
+ return undefined;
+ }
-// Plan check error validation
-const planCheckError = computed(() => {
- if (props.action === "RUN") {
- // Only consider plan check errors for RUN action.
- if (planCheckStatus.value.error > 0) {
+ // Get the plan check enforcement level from the rollout policy
+ const planCheckEnforcement =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredStatusChecks
+ ?.planCheckEnforcement
+ : undefined;
+
+ // If there's no enforcement policy, show any plan check issues as warnings
+ if (!planCheckEnforcement) {
+ if (planCheckStatus.value.running > 0) {
+ return t(
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"
+ );
+ }
+ if (planCheckStatus.value.error > 0 || planCheckStatus.value.warning > 0) {
return t(
"custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
);
}
- if (planCheckStatus.value.running > 0) {
+ }
+
+ // Show warnings for plan check results that don't violate enforcement policy
+ if (
+ planCheckEnforcement ===
+ RolloutPolicy_Checkers_PlanCheckEnforcement.ERROR_ONLY
+ ) {
+ // Show warnings as non-blocking when ERROR_ONLY policy allows them
+ if (planCheckStatus.value.warning > 0) {
return t(
- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"
+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
);
}
}
+
return undefined;
});
-// Collect all validation messages for both display and error checking
-const validationMessages = computed(() => {
- const messages: string[] = [];
+// Collect blocking validation errors
+const validationErrors = computed(() => {
+ const errors: string[] = [];
- // Basic validation errors
- if (eligibleTasks.value.length === 0) {
- messages.push(t("common.no-data"));
+ // Permission errors - always block rollout
+ if (!canRolloutTasks(eligibleTasks.value)) {
+ errors.push(t("task.no-permission"));
}
+ // No active tasks to cancel - blocking error
if (
- !canPerformTaskAction(
- eligibleTasks.value,
- rollout.value,
- project.value,
- issue?.value
+ props.action === "CANCEL" &&
+ eligibleTasks.value.length > 0 &&
+ !eligibleTasks.value.some(
+ (task) =>
+ task.status === Task_Status.PENDING ||
+ task.status === Task_Status.RUNNING
)
) {
- messages.push(t("task.no-permission"));
+ errors.push(t("rollout.no-active-task-to-cancel"));
}
if (props.action === "RUN") {
- // Validate scheduled time if not running immediately
- if (runTimeInMS.value !== undefined && runTimeInMS.value <= Date.now()) {
- messages.push(t("task.error.scheduled-time-must-be-in-the-future"));
- }
+ // Issue approval errors (only if policy requires it) - HARD BLOCK
+ const requiresIssueApproval =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredIssueApproval
+ : false;
- // Issue approval messages (only if not forcing rollout)
if (
+ requiresIssueApproval &&
issueApprovalStatus.value.hasIssue &&
!issueApprovalStatus.value.isApproved
) {
const isRejected = issueApprovalStatus.value.status === "rejected";
- messages.push(
+ errors.push(
isRejected
? t("issue.approval.rejected-error")
: t("issue.approval.pending-error")
);
}
- // Previous stages incomplete (only if not forcing rollout)
- if (previousStagesStatus.value.hasIncomplete) {
- messages.push(
- t("rollout.message.pervious-stages-incomplete.description")
- );
+ // Plan check errors (based on rollout policy) - HARD BLOCK
+ if (planCheckError.value) {
+ errors.push(planCheckError.value);
}
+ }
- // Plan check errors (only if not forcing rollout)
- if (planCheckError.value) {
- messages.push(planCheckError.value);
+ return errors;
+});
+
+// Collect validation warnings that don't block rollout
+const validationWarnings = computed(() => {
+ const warnings: string[] = [];
+
+ // Basic validation warnings
+ if (eligibleTasks.value.length === 0) {
+ warnings.push(t("common.no-data"));
+ }
+
+ if (props.action === "RUN") {
+ // Validate scheduled time if not running immediately
+ if (runTimeInMS.value !== undefined && runTimeInMS.value <= Date.now()) {
+ warnings.push(t("task.error.scheduled-time-must-be-in-the-future"));
}
- // Automatic rollout info (only show for non-export tasks with no task runs)
+ // Plan check warnings (non-blocking plan check results)
+ if (planCheckWarning.value) {
+ warnings.push(planCheckWarning.value);
+ }
+
+ // Issue approval warnings (when not required by policy but issue is not approved)
+ const requiresIssueApproval =
+ rolloutPolicy.value?.policy?.case === "rolloutPolicy"
+ ? rolloutPolicy.value.policy.value.checkers?.requiredIssueApproval
+ : false;
+
+ if (
+ !requiresIssueApproval &&
+ issueApprovalStatus.value.hasIssue &&
+ !issueApprovalStatus.value.isApproved
+ ) {
+ const isRejected = issueApprovalStatus.value.status === "rejected";
+ warnings.push(
+ isRejected
+ ? t("issue.approval.rejected-error")
+ : t("issue.approval.pending-error")
+ );
+ }
+
+ // Automatic rollout info (always show as warning for non-export tasks with no task runs)
if (
isAutomaticRollout.value &&
!isDatabaseExportTask.value &&
!hasTaskRuns.value
) {
- messages.push(t("rollout.automatic-rollout.description"));
+ warnings.push(t("rollout.automatic-rollout.description"));
}
}
- if (
- props.action === "CANCEL" &&
- eligibleTasks.value.some(
- (task) =>
- task.status !== Task_Status.PENDING &&
- task.status !== Task_Status.RUNNING
- )
- ) {
- messages.push(t("rollout.no-active-task-to-cancel"));
- }
-
- return messages;
+ return warnings;
});
-const shouldShowForceRollout = computed(() => {
- // Show force rollout checkbox for RUN action when:
- // 1. Issue approval is not complete, OR
- // 2. Plan check has errors
- return Boolean(
- props.action === "RUN" &&
- (hasWorkspacePermissionV2("bb.taskRuns.create") ||
- hasProjectPermissionV2(project.value, "bb.taskRuns.create")) &&
- ((issueApprovalStatus.value.hasIssue &&
- !issueApprovalStatus.value.isApproved) ||
- planCheckError.value)
+const shouldShowBypassOption = computed(() => {
+ if (props.action !== "RUN") {
+ return false;
+ }
+
+ // Only show bypass option when there are warnings but NO errors
+ return (
+ validationWarnings.value.length > 0 && validationErrors.value.length === 0
);
});
@@ -821,6 +905,6 @@ const handleConfirm = async () => {
const resetState = () => {
comment.value = "";
runTimeInMS.value = undefined;
- forceRollout.value = false;
+ bypassPolicyChecks.value = false;
};
</script>
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue b/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
index dc39d26c26..156cc1578c 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
@@ -38,7 +38,6 @@ import { EllipsisVerticalIcon } from "lucide-vue-next";
import { NButton, NDropdown } from "naive-ui";
import { computed, ref } 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,
@@ -48,7 +47,7 @@ import type {
} from "@/types/proto-es/v1/rollout_service_pb";
import { usePlanContextWithRollout } from "../../logic";
import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";
-import { useTaskActionPermissions } from "./taskPermissions";
+import { canRolloutTasks } from "./taskPermissions";
type TaskStatusAction =
// NOT_STARTED -> PENDING
@@ -71,9 +70,7 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-const { project } = useCurrentProjectV1();
-const { readonly, issue } = usePlanContextWithRollout();
-const { canPerformTaskAction } = useTaskActionPermissions();
+const { readonly } = usePlanContextWithRollout();
const showActionPanel = ref(false);
const selectedAction = ref<TaskStatusAction>();
@@ -132,12 +129,7 @@ const canPerformTaskActions = computed(() => {
if (!props.rollout || readonly.value) {
return false;
}
- return canPerformTaskAction(
- [props.task],
- props.rollout,
- project.value,
- issue.value
- );
+ return canRolloutTasks([props.task]);
});
const primaryAction = computed((): TaskStatusAction | null => {
diff --git a/frontend/src/components/Plan/components/RolloutView/taskPermissions.ts b/frontend/src/components/Plan/components/RolloutView/taskPermissions.ts
index e7bab67877..265d36c2ca 100644
--- a/frontend/src/components/Plan/components/RolloutView/taskPermissions.ts
+++ b/frontend/src/components/Plan/components/RolloutView/taskPermissions.ts
@@ -1,14 +1,13 @@
-import { uniq } from "lodash-es";
import {
useCurrentUserV1,
useCurrentProjectV1,
useProjectIamPolicyStore,
+ useDatabaseV1Store,
+ usePolicyV1Store,
} from "@/store";
import { userNamePrefix, roleNamePrefix } from "@/store/modules/v1/common";
-import { Issue_Type, type Issue } from "@/types/proto-es/v1/issue_service_pb";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import type { Task } from "@/types/proto-es/v1/rollout_service_pb";
-import type { Rollout } from "@/types/proto-es/v1/rollout_service_pb";
import {
hasWorkspacePermissionV2,
hasProjectPermissionV2,
@@ -16,84 +15,72 @@ import {
} from "@/utils";
/**
- * Check if the current user can perform task actions for the given tasks
+ * Check if the current user can rollout the given tasks
+ * - If user has bb.taskRuns.create permission → always allow
+ * - If user lacks bb.taskRuns.create permission → check environment rollout policy roles
+ * @param tasks - Array of tasks to check
+ * @returns true if user can rollout, false otherwise
*/
-export const useTaskActionPermissions = () => {
- const currentUser = useCurrentUserV1();
- const { project } = useCurrentProjectV1();
- const projectIamPolicyStore = useProjectIamPolicyStore();
- const formatedCurrentUser = `${userNamePrefix}${currentUser.value.email}`;
-
- /**
- * Get releaser candidates for an issue (similar to releaserCandidatesForIssue)
- */
- const getReleaserCandidatesForIssue = (issue: Issue): string[] => {
- const policy = projectIamPolicyStore.getProjectIamPolicy(
- project.value.name
- );
- const projectMembersMap = memberMapToRolesInProjectIAM(policy);
- const users: string[] = [];
-
- for (let i = 0; i < issue.releasers.length; i++) {
- const releaserRole = issue.releasers[i];
- if (releaserRole.startsWith(roleNamePrefix)) {
- for (const [user, roleSet] of projectMembersMap.entries()) {
- if (roleSet.has(releaserRole)) {
- users.push(user);
- }
- }
- } else if (releaserRole.startsWith(userNamePrefix)) {
- users.push(releaserRole);
- }
- }
+export const canRolloutTasks = (tasks: Task[]): boolean => {
+ if (tasks.length === 0) {
+ return false;
+ }
- return uniq(users);
- };
+ const { project } = useCurrentProjectV1();
- /**
- * Check if user can perform task actions based on issue releaser roles
- */
- const canPerformTaskActionForIssue = (issue: Issue): boolean => {
- // For data export issues, only the creator can run tasks
- if (issue.type === Issue_Type.DATABASE_EXPORT) {
- return issue.creator === formatedCurrentUser;
- }
+ // First check: if user has bb.taskRuns.create permission, always allow rollout
+ const hasCreatePermission =
+ hasWorkspacePermissionV2("bb.taskRuns.create") ||
+ hasProjectPermissionV2(project.value, "bb.taskRuns.create");
+ if (hasCreatePermission) {
+ return true;
+ }
- const releaserCandidates = getReleaserCandidatesForIssue(issue);
- // Check if current user is in releaser candidates
- return releaserCandidates.includes(formatedCurrentUser);
- };
+ // Second check: if no permission, check if user matches environment rollout policy roles
+ const currentUser = useCurrentUserV1();
+ const projectIamPolicyStore = useProjectIamPolicyStore();
+ const databaseStore = useDatabaseV1Store();
+ const policyStore = usePolicyV1Store();
+ const formatedCurrentUser = `${userNamePrefix}${currentUser.value.email}`;
- /**
- * Main function to check if user can perform task actions
- */
- const canPerformTaskAction = (
- tasks: Task[],
- rollout: Rollout,
- project: Project,
- issue?: Issue
- ): boolean => {
- if (tasks.length === 0) {
+ return tasks.every((task) => {
+ // Get database from task target
+ const database = databaseStore.getDatabaseByName(task.target);
+ if (!database || !database.effectiveEnvironment) {
return false;
}
- // Users with bb.taskRuns.create can always create task runs
+ // Get rollout policy for the environment
+ const rolloutPolicy = policyStore.getPolicyByParentAndType({
+ parentPath: database.effectiveEnvironment,
+ policyType: PolicyType.ROLLOUT_POLICY,
+ });
+
+ // If no rollout policy is defined, allow rollout (permission check already passed)
if (
- hasWorkspacePermissionV2("bb.taskRuns.create") ||
- hasProjectPermissionV2(project, "bb.taskRuns.create")
+ !rolloutPolicy?.policy ||
+ rolloutPolicy.policy.case !== "rolloutPolicy"
) {
return true;
}
- // If there's an issue, check issue-based permissions.
- if (issue) {
- return canPerformTaskActionForIssue(issue);
+ const policy = rolloutPolicy.policy.value;
+
+ // Check if current user has any of the required roles in the rollout policy
+ for (const requiredRole of policy.roles) {
+ if (requiredRole.startsWith(roleNamePrefix)) {
+ // Check if user has this role (includes both project and workspace level roles)
+ const projectIamPolicy = projectIamPolicyStore.getProjectIamPolicy(
+ project.value.name
+ );
+ const memberRoles = memberMapToRolesInProjectIAM(projectIamPolicy);
+ const userRoles = memberRoles.get(formatedCurrentUser);
+ if (userRoles?.has(requiredRole)) {
+ return true;
+ }
+ }
}
return false;
- };
-
- return {
- canPerformTaskAction,
- };
+ });
};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index e90c73a831..e8c4c20bfe 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1180,11 +1180,12 @@
},
"rollout": {
"rollouts": "Rollouts",
- "force-rollout": "Force run",
+ "bypass-stage-requirements": "Bypass warnings",
"task-execution-notices": "Task execution notices",
+ "task-execution-errors": "Task execution errors",
"no-active-task-to-cancel": "No active task to cancel.",
"automatic-rollout": {
- "description": "This environment has automatic rollout enabled. Tasks will execute automatically when all conditions are met."
+ "description": "This environment has automatic rollout enabled."
},
"stage": {
"self": "Stage | Stages",
@@ -1195,9 +1196,7 @@
}
},
"message": {
- "pervious-stages-incomplete": {
- "description": "Some previous stages are not completed."
- }
+ "pervious-stages-incomplete": {}
}
},
"quick-action": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 366b790e53..2603e06e4f 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1081,8 +1081,8 @@
"under-review": "Bajo revisión"
},
"approval": {
- "rejected-error": "Se ha rechazado la aprobación del problema. Habilite la implementación forzada para continuar.",
- "pending-error": "La aprobación del problema está pendiente. Habilite la implementación forzada para continuar.",
+ "rejected-error": "Se ha rechazado la aprobación del problema.",
+ "pending-error": "La aprobación del problema está pendiente.",
"approved-and-waiting-for-rollout": "Este problema ha sido aprobado y está listo para implementarse."
},
"new-layout": "Nuevo diseño de CI/CD"
@@ -1180,11 +1180,12 @@
},
"rollout": {
"rollouts": "Despliegues",
- "force-rollout": "Ejecución forzada",
+ "bypass-stage-requirements": "Advertencias de bypass",
"task-execution-notices": "Avisos de ejecución de tareas",
+ "task-execution-errors": "Errores de ejecución de tareas",
"no-active-task-to-cancel": "No hay ninguna tarea activa para cancelar.",
"automatic-rollout": {
- "description": "Este entorno tiene habilitada la implementación automática. Las tareas se ejecutarán automáticamente cuando se cumplan todas las condiciones."
+ "description": "Este entorno tiene habilitada la implementación automática."
},
"stage": {
"self": "Escenario | Escenarios",
@@ -1195,9 +1196,7 @@
}
},
"message": {
- "pervious-stages-incomplete": {
- "description": "Algunas etapas anteriores no se han completado. Activa la ejecución forzada para continuar."
- }
+ "pervious-stages-incomplete": {}
}
},
"quick-action": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 3e1d34e3a3..3bda1f52c6 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1081,8 +1081,8 @@
"under-review": "審査中"
},
"approval": {
- "rejected-error": "問題の承認が拒否されました。続行するには強制ロールアウトを有効にしてください。",
- "pending-error": "問題の承認が保留中です。続行するには強制ロールアウトを有効にしてください。",
+ "rejected-error": "問題の承認が拒否されました。",
+ "pending-error": "問題の承認が保留中です。",
"approved-and-waiting-for-rollout": "この問題は承認されており、展開する準備ができています。"
},
"new-layout": "新しいCI/CDレイアウト"
@@ -1180,11 +1180,12 @@
},
"rollout": {
"rollouts": "ロールアウト",
- "force-rollout": "強制実行",
+ "bypass-stage-requirements": "バイパス警告",
"task-execution-notices": "タスク実行通知",
+ "task-execution-errors": "タスク実行エラー",
"no-active-task-to-cancel": "キャンセルするアクティブなタスクはありません。",
"automatic-rollout": {
- "description": "この環境では自動ロールアウトが有効になっています。すべての条件が満たされると、タスクは自動的に実行されます。"
+ "description": "この環境では自動ロールアウトが有効になっています。"
},
"stage": {
"self": "ステージ | ステージ",
@@ -1195,9 +1196,7 @@
}
},
"message": {
- "pervious-stages-incomplete": {
- "description": "前のステージの一部が完了していません。続行するには強制実行を有効にしてください。"
- }
+ "pervious-stages-incomplete": {}
}
},
"quick-action": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 8ee8506d92..62a970c2fc 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1081,8 +1081,8 @@
"under-review": "Đang xem xét"
},
"approval": {
- "rejected-error": "Đã từ chối phê duyệt vấn đề. Vui lòng bật triển khai bắt buộc để tiếp tục.",
- "pending-error": "Đang chờ phê duyệt vấn đề. Vui lòng bật triển khai bắt buộc để tiếp tục.",
+ "rejected-error": "Đã từ chối phê duyệt vấn đề.",
+ "pending-error": "Đang chờ phê duyệt vấn đề.",
"approved-and-waiting-for-rollout": "Phiên bản này đã được chấp thuận và sẵn sàng triển khai."
},
"new-layout": "Bố cục CI/CD mới"
@@ -1180,11 +1180,12 @@
},
"rollout": {
"rollouts": "Triển khai",
- "force-rollout": "Chạy bắt buộc",
+ "bypass-stage-requirements": "Bỏ qua cảnh báo",
"task-execution-notices": "Thông báo thực hiện nhiệm vụ",
+ "task-execution-errors": "Lỗi thực hiện tác vụ",
"no-active-task-to-cancel": "Không có tác vụ nào đang hoạt động để hủy.",
"automatic-rollout": {
- "description": "Môi trường này đã bật tính năng triển khai tự động. Các tác vụ sẽ tự động thực thi khi đáp ứng tất cả các điều kiện."
+ "description": "Môi trường này đã bật tính năng triển khai tự động."
},
"stage": {
"self": "Giai đoạn | Các giai đoạn",
@@ -1195,9 +1196,7 @@
}
},
"message": {
- "pervious-stages-incomplete": {
- "description": "Một số giai đoạn trước chưa hoàn tất. Vui lòng bật chế độ chạy bắt buộc để tiếp tục."
- }
+ "pervious-stages-incomplete": {}
}
},
"quick-action": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index b45e1982b6..8066e400e3 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1081,8 +1081,8 @@
"under-review": "等待审批"
},
"approval": {
- "rejected-error": "此工单已被退回。请确认并勾选强制运行才能继续。",
- "pending-error": "此工单正在等待审批。请确认并勾选强制运行才能继续。",
+ "rejected-error": "此工单已被退回。",
+ "pending-error": "此工单正在等待审批。",
"approved-and-waiting-for-rollout": "该工单已批准,等待发布。"
},
"new-layout": "使用新版 CI/CD 页面"
@@ -1180,11 +1180,12 @@
},
"rollout": {
"rollouts": "发布任务",
- "force-rollout": "强制运行",
+ "bypass-stage-requirements": "绕过提醒",
"task-execution-notices": "任务执行提醒",
+ "task-execution-errors": "任务执行警告",
"no-active-task-to-cancel": "没有要取消的任务。",
"automatic-rollout": {
- "description": "此环境已启用自动部署。当所有条件满足时,任务将自动执行。"
+ "description": "此环境已启用自动部署。"
},
"stage": {
"self": "阶段 | 阶段",
@@ -1195,9 +1196,7 @@
}
},
"message": {
- "pervious-stages-incomplete": {
- "description": "存在未完成的前置阶段。请确认并勾选强制运行才能继续。"
- }
+ "pervious-stages-incomplete": {}
}
},
"quick-action": {
diff --git a/frontend/src/views/project/RolloutDetailLayout.vue b/frontend/src/views/project/RolloutDetailLayout.vue
index 4054081ac3..138adb0718 100644
--- a/frontend/src/views/project/RolloutDetailLayout.vue
+++ b/frontend/src/views/project/RolloutDetailLayout.vue
@@ -34,7 +34,7 @@
<script lang="ts" setup>
import { NBreadcrumb, NBreadcrumbItem } from "naive-ui";
-import { computed } from "vue";
+import { computed, watchEffect } from "vue";
import { useRoute, useRouter } from "vue-router";
import { usePlanContextWithRollout } from "@/components/Plan";
import { provideRolloutViewContext } from "@/components/Plan/components/RolloutView/context";
@@ -43,7 +43,12 @@ import {
PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
} from "@/router/dashboard/projectV1";
-import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
+import {
+ useCurrentProjectV1,
+ useEnvironmentV1Store,
+ usePolicyV1Store,
+} from "@/store";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { extractProjectResourceName } from "@/utils";
const route = useRoute();
@@ -51,6 +56,7 @@ const router = useRouter();
const { rollout } = usePlanContextWithRollout();
const { project } = useCurrentProjectV1();
const environmentStore = useEnvironmentV1Store();
+const policyStore = usePolicyV1Store();
const { mergedStages } = provideRolloutViewContext();
// Route parameters
@@ -61,6 +67,31 @@ const stage = computed(() =>
mergedStages.value.find((s) => s.name.endsWith(`/${stageId.value}`))
);
+// Prepare rollout policies for all stages in the rollout.
+watchEffect(() => {
+ if (!rollout.value) return;
+
+ const environmentNames = new Set<string>();
+ // Collect all unique environment names from stages
+ for (const stage of rollout.value.stages) {
+ if (stage.environment) {
+ environmentNames.add(stage.environment);
+ }
+ }
+
+ // Fetch rollout policies for each environment
+ for (const environmentName of environmentNames) {
+ policyStore
+ .getOrFetchPolicyByParentAndType({
+ parentPath: environmentName,
+ policyType: PolicyType.ROLLOUT_POLICY,
+ })
+ .catch(() => {
+ // Silently ignore errors as policies might not exist
+ });
+ }
+});
+
// Navigation handlers
const navigateToRollout = () => {
router.push({