Skip to content

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

fix: plan check runs for task (#13420)

boojack5babc50cbc14
diff --git a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
index 6585a28ba5..7492813428 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
@@ -91,7 +91,8 @@ dayjs.extend(isSameOrAfter);
const { t } = useI18n();
const currentUser = useCurrentUserV1();
-const { isCreating, issue, selectedTask, events } = useIssueContext();
+const { isCreating, issue, selectedTask, events, getPlanCheckRunsForTask } =
+ useIssueContext();
const isUpdating = ref(false);
const showFeatureModal = ref(false);
const dialog = useDialog();
@@ -175,11 +176,11 @@ const chooseUpdateStatementTarget = () => {
TASK: [selectedTask.value],
STAGE: (stageForTask(issue.value, selectedTask.value)?.tasks ?? []).filter(
(task) => {
- return isTaskEditable(task).length === 0;
+ return isTaskEditable(task, getPlanCheckRunsForTask(task)).length === 0;
}
),
ALL: flattenTaskV1List(issue.value.rolloutEntity).filter((task) => {
- return isTaskEditable(task).length === 0;
+ return isTaskEditable(task, getPlanCheckRunsForTask(task)).length === 0;
}),
};
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
index c649afd9f1..c24ee67f78 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
@@ -275,7 +275,14 @@ const props = defineProps<{
const { t } = useI18n();
const route = useRoute();
const context = useIssueContext();
-const { events, isCreating, issue, selectedTask, formatOnSave } = context;
+const {
+ events,
+ isCreating,
+ issue,
+ selectedTask,
+ formatOnSave,
+ getPlanCheckRunsForTask,
+} = context;
const project = computed(() => issue.value.projectEntity);
const dialog = useDialog();
const editorContainerElRef = ref<HTMLElement>();
@@ -427,14 +434,14 @@ const chooseUpdateStatementTarget = () => {
(task) => {
return (
TaskTypeListWithStatement.includes(task.type) &&
- isTaskEditable(task).length === 0
+ isTaskEditable(task, getPlanCheckRunsForTask(task)).length === 0
);
}
),
ALL: flattenTaskV1List(issue.value.rolloutEntity).filter((task) => {
return (
TaskTypeListWithStatement.includes(task.type) &&
- isTaskEditable(task).length === 0
+ isTaskEditable(task, getPlanCheckRunsForTask(task)).length === 0
);
}),
};
diff --git a/frontend/src/components/IssueV1/logic/rollout.ts b/frontend/src/components/IssueV1/logic/rollout.ts
index 5799877ff5..8c98f557cf 100644
--- a/frontend/src/components/IssueV1/logic/rollout.ts
+++ b/frontend/src/components/IssueV1/logic/rollout.ts
@@ -3,6 +3,7 @@ import { t } from "@/plugins/i18n";
import { useCurrentUserV1 } from "@/store";
import type { ComposedIssue } from "@/types";
import { IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";
+import type { PlanCheckRun } from "@/types/proto/v1/plan_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import {
Task_Status,
@@ -32,6 +33,7 @@ export const allowUserToEditStatementForTask = (
task: Task
): string[] => {
const user = useCurrentUserV1();
+ const { getPlanCheckRunsForTask } = useIssueContext();
const denyReasons: string[] = [];
if (isTaskV1TriggeredByVCS(issue, task)) {
@@ -63,7 +65,7 @@ export const allowUserToEditStatementForTask = (
// - user is the creator
// - OR user has plans.update permission in the project
- denyReasons.push(...isTaskEditable(task));
+ denyReasons.push(...isTaskEditable(task, getPlanCheckRunsForTask(task)));
if (extractUserResourceName(issue.creator) !== user.value.email) {
if (!hasProjectPermissionV2(issue.projectEntity, "bb.plans.update")) {
@@ -75,8 +77,10 @@ export const allowUserToEditStatementForTask = (
return denyReasons;
};
-export const isTaskEditable = (task: Task): string[] => {
- const { getPlanCheckRunsForTask } = useIssueContext();
+export const isTaskEditable = (
+ task: Task,
+ planCheckRuns: PlanCheckRun[]
+): string[] => {
if (
task.status === Task_Status.NOT_STARTED ||
task.status === Task_Status.FAILED ||
@@ -91,9 +95,7 @@ export const isTaskEditable = (task: Task): string[] => {
// the scheduler.
// Editing a queued task's SQL statement is dangerous with kinds of race
// condition risks.
- const summary = planCheckRunSummaryForCheckRunList(
- getPlanCheckRunsForTask(task)
- );
+ const summary = planCheckRunSummaryForCheckRunList(planCheckRuns);
if (summary.errorCount > 0) {
return [];
}