Skip to content

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

feat: update rollout time now can apply to more tasks (#11775)

Liu Ji6e23d2aeed2e
diff --git a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
index ba92637de2..d4aa001dab 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
@@ -54,17 +54,19 @@ import { useNow } from "@vueuse/core";
import dayjs from "dayjs";
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
import { cloneDeep } from "lodash-es";
-import { NDatePicker, NTooltip } from "naive-ui";
-import { computed, ref } from "vue";
+import { NButton, NDatePicker, NTooltip, useDialog } from "naive-ui";
+import { computed, h, ref } from "vue";
import { useI18n } from "vue-i18n";
import FeatureBadge from "@/components/FeatureGuard/FeatureBadge.vue";
import FeatureModal from "@/components/FeatureGuard/FeatureModal.vue";
import {
isDeploymentConfigChangeTaskV1,
isGroupingChangeTaskV1,
+ isTaskEditable,
latestTaskRunForTask,
notifyNotEditableLegacyIssue,
specForTask,
+ stageForTask,
useIssueContext,
} from "@/components/IssueV1";
import ErrorList from "@/components/misc/ErrorList.vue";
@@ -73,12 +75,16 @@ import { emitWindowEvent } from "@/plugins";
import { hasFeature, pushNotification, useCurrentUserV1 } from "@/store";
import { IssueStatus } from "@/types/proto/v1/issue_service";
import {
+ type Plan_Spec,
+ type Task,
TaskRun_Status,
Task_Status,
task_StatusToJSON,
} from "@/types/proto/v1/rollout_service";
import {
+ defer,
extractUserResourceName,
+ flattenTaskV1List,
hasProjectPermissionV2,
isDatabaseChangeRelatedIssue,
} from "@/utils";
@@ -90,6 +96,7 @@ const currentUser = useCurrentUserV1();
const { isCreating, issue, selectedTask, events } = useIssueContext();
const isUpdating = ref(false);
const showFeatureModal = ref(false);
+const dialog = useDialog();
const shouldShowEarliestAllowedTime = computed(() => {
if (!isDatabaseChangeRelatedIssue(issue.value)) {
@@ -179,6 +186,97 @@ const disallowEditReasons = computed(() => {
return errors;
});
+const chooseUpdateStatementTarget = () => {
+ type Target = "CANCELED" | "TASK" | "STAGE" | "ALL";
+ const d = defer<{ target: Target; tasks: Task[] }>();
+
+ const targets: Record<Target, Task[]> = {
+ CANCELED: [],
+ TASK: [selectedTask.value],
+ STAGE: (stageForTask(issue.value, selectedTask.value)?.tasks ?? []).filter(
+ (task) => {
+ return isTaskEditable(issue.value, task).length === 0;
+ }
+ ),
+ ALL: flattenTaskV1List(issue.value.rolloutEntity).filter((task) => {
+ return isTaskEditable(issue.value, task).length === 0;
+ }),
+ };
+
+ if (targets.STAGE.length === 1 && targets.ALL.length === 1) {
+ d.resolve({ target: "TASK", tasks: targets.TASK });
+ return d.promise;
+ }
+
+ const $d = dialog.create({
+ title: t("issue.update-rollout-time.self"),
+ content: t("issue.update-statement.apply-current-change-to"),
+ type: "info",
+ autoFocus: false,
+ closable: false,
+ maskClosable: false,
+ closeOnEsc: false,
+ showIcon: false,
+ action: () => {
+ const finish = (target: Target) => {
+ d.resolve({ target, tasks: targets[target] });
+ $d.destroy();
+ };
+
+ const CANCEL = h(
+ NButton,
+ { size: "small", onClick: () => finish("CANCELED") },
+ {
+ default: () => t("common.cancel"),
+ }
+ );
+ const TASK = h(
+ NButton,
+ { size: "small", onClick: () => finish("TASK") },
+ {
+ default: () => t("issue.update-statement.target.selected-task"),
+ }
+ );
+ const buttons = [CANCEL, TASK];
+ if (targets.STAGE.length > 1) {
+ // More than one editable tasks in stage
+ // Add "Selected stage" option
+ const STAGE = h(
+ NButton,
+ { size: "small", onClick: () => finish("STAGE") },
+ {
+ default: () => t("issue.update-statement.target.selected-stage"),
+ }
+ );
+ buttons.push(STAGE);
+ }
+ if (targets.ALL.length > targets.STAGE.length) {
+ // More editable tasks in other stages
+ // Add "All tasks" option
+ const ALL = h(
+ NButton,
+ { size: "small", onClick: () => finish("ALL") },
+ {
+ default: () => t("issue.update-statement.target.all-tasks"),
+ }
+ );
+ buttons.push(ALL);
+ }
+
+ return h(
+ "div",
+ { class: "flex items-center justify-end gap-x-2" },
+ buttons
+ );
+ },
+ onClose() {
+ d.resolve({ target: "CANCELED", tasks: [] });
+ },
+ });
+
+ return d.promise;
+};
+
const handleUpdateEarliestAllowedTime = async (timestampMS: number | null) => {
if (!hasFeature("bb.feature.task-schedule-time")) {
showFeatureModal.value = true;
@@ -195,26 +293,52 @@ const handleUpdateEarliestAllowedTime = async (timestampMS: number | null) => {
spec.earliestAllowedTime.setTime(timestampMS);
}
} else {
+ const { target, tasks } = await chooseUpdateStatementTarget();
+
+ if (target === "CANCELED" || tasks.length === 0) {
+ return;
+ }
+
const planPatch = cloneDeep(issue.value.planEntity);
- const spec = specForTask(planPatch, selectedTask.value);
- if (!planPatch || !spec) {
+ if (!planPatch) {
notifyNotEditableLegacyIssue();
return;
}
isUpdating.value = true;
try {
- if (!timestampMS) {
- spec.earliestAllowedTime = undefined;
- } else {
- spec.earliestAllowedTime = new Date();
- spec.earliestAllowedTime.setTime(timestampMS);
+ const specs: Plan_Spec[] = [];
+ tasks.forEach((task) => {
+ const spec = specForTask(planPatch, task);
+ if (spec) {
+ specs.push(spec);
+ }
+ });
+ const distinctSpecIds = new Set(specs.map((s) => s.id));
+ if (distinctSpecIds.size === 0) {
+ notifyNotEditableLegacyIssue();
+ return;
+ }
+
+ const specsToPatch = planPatch.steps
+ .flatMap((step) => step.specs)
+ .filter((spec) => distinctSpecIds.has(spec.id));
+
+ for (let i = 0; i < specsToPatch.length; i++) {
+ const spec = specsToPatch[i];
+ if (!timestampMS) {
+ spec.earliestAllowedTime = undefined;
+ } else {
+ spec.earliestAllowedTime = new Date();
+ spec.earliestAllowedTime.setTime(timestampMS);
+ }
}
const updatedPlan = await rolloutServiceClient.updatePlan({
plan: planPatch,
updateMask: ["steps"],
});
+
issue.value.planEntity = updatedPlan;
events.emit("status-changed", { eager: true });
@@ -224,6 +348,7 @@ const handleUpdateEarliestAllowedTime = async (timestampMS: number | null) => {
style: "SUCCESS",
title: t("common.updated"),
});
+
emitWindowEvent("bb.pipeline-task-earliest-allowed-time-update");
} finally {
isUpdating.value = false;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 403a59fd2c..bdd9910984 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1190,6 +1190,9 @@
"format": "Format",
"encrypt": "Encrypt",
"file-downloaded": "File Downloaded"
+ },
+ "update-rollout-time": {
+ "self": "Update rollout time"
}
},
"alter-schema": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index ac2c9a93ee..e5a0a3e726 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1190,6 +1190,9 @@
"format": "Formato",
"encrypt": "Cifrar",
"file-downloaded": "Archivo Descargado"
+ },
+ "update-rollout-time": {
+ "self": "Hora de implementación de la actualización"
}
},
"alter-schema": {
@@ -3432,4 +3435,4 @@
"drop-partition-with-subpartitions-confirm": "También eliminará todas sus subparticiones."
}
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 0d95b7d893..213274ae04 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1190,6 +1190,9 @@
"format": "エクスポート形式",
"encrypt": "暗号化",
"file-downloaded": "ダウンロードされたファイル"
+ },
+ "update-rollout-time": {
+ "self": "更新のロールアウト時間"
}
},
"alter-schema": {
@@ -3432,4 +3435,4 @@
"drop-partition-with-subpartitions-confirm": "すべてのサブパーティションが同時に削除されます。"
}
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index a70de283e6..d9797f271b 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1190,6 +1190,9 @@
"format": "Định dạng",
"encrypt": "Mã hóa",
"file-downloaded": "Tệp đã được tải xuống"
+ },
+ "update-rollout-time": {
+ "self": "Cập nhật thời gian triển khai"
}
},
"alter-schema": {
@@ -3432,4 +3435,4 @@
"drop-partition-with-subpartitions-confirm": "Cũng sẽ bỏ tất cả các phân vùng của nó."
}
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 28326807af..2e8903351f 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1190,6 +1190,9 @@
"format": "导出格式",
"encrypt": "加密",
"file-downloaded": "文件已下载"
+ },
+ "update-rollout-time": {
+ "self": "修改指定发布时间"
}
},
"alter-schema": {
@@ -3432,4 +3435,4 @@
"drop-partition-with-subpartitions-confirm": "将会同时删除其所有子分区。"
}
}
-}
\ No newline at end of file
+}