Skip to content

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

chore: improve rollout time editing logic and UX (#8093)

Liu Jicfa76e97c8ea
diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue
index edb2dea455..ba971511c6 100644
--- a/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/EarliestAllowedTime.vue
@@ -21,13 +21,13 @@
</div>
</h2>
<div class="w-[12rem]">
- <NTooltip :disabled="allowEditEarliestAllowedTime">
+ <NTooltip :disabled="disallowEditReasons.length === 0">
<template #trigger>
<NDatePicker
:value="earliestAllowedTime"
:is-date-disabled="isDayPassed"
:placeholder="$t('task.earliest-allowed-time-unset')"
- :disabled="!allowEditEarliestAllowedTime || isUpdating"
+ :disabled="disallowEditReasons.length > 0 || isUpdating"
:loading="isUpdating"
:actions="['clear', 'confirm']"
type="datetime"
@@ -36,9 +36,7 @@
/>
</template>
<template #default>
- <div class="w-48">
- {{ $t("task.earliest-allowed-time-no-modify") }}
- </div>
+ <ErrorList :errors="disallowEditReasons" />
</template>
</NTooltip>
</div>
@@ -62,6 +60,8 @@ import { useI18n } from "vue-i18n";
import FeatureBadge from "@/components/FeatureGuard/FeatureBadge.vue";
import FeatureModal from "@/components/FeatureGuard/FeatureModal.vue";
import {
+ isGroupingChangeTaskV1,
+ latestTaskRunForTask,
notifyNotEditableLegacyIssue,
specForTask,
useIssueContext,
@@ -69,8 +69,13 @@ import {
import { rolloutServiceClient } from "@/grpcweb";
import { hasFeature, pushNotification, useCurrentUserV1 } from "@/store";
import { IssueStatus } from "@/types/proto/v1/issue_service";
-import { Task_Status } from "@/types/proto/v1/rollout_service";
+import {
+ TaskRun_Status,
+ Task_Status,
+ task_StatusToJSON,
+} from "@/types/proto/v1/rollout_service";
import { extractUserResourceName } from "@/utils";
+import { ErrorList } from "../../common";
dayjs.extend(isSameOrAfter);
@@ -85,6 +90,9 @@ const shouldShowEarliestAllowedTime = computed(() => {
if (isTenantMode.value) {
return false;
}
+ if (isGroupingChangeTaskV1(issue.value, selectedTask.value)) {
+ return false;
+ }
return true;
});
@@ -94,26 +102,53 @@ const earliestAllowedTime = computed(() => {
return spec?.earliestAllowedTime ? spec.earliestAllowedTime.getTime() : null;
});
-const allowEditEarliestAllowedTime = computed(() => {
- if (isTenantMode.value) {
- return false;
- }
+const disallowEditReasons = computed(() => {
if (isCreating.value) {
- return true;
+ return [];
}
- // only the assignee is allowed to modify EarliestAllowedTime
- const task = selectedTask.value;
+ const errors: string[] = [];
if (issue.value.status !== IssueStatus.OPEN) {
- return false;
+ if (issue.value.status === IssueStatus.DONE) {
+ errors.push(t("issue.disallow-edit-reasons.issue-is-done"));
+ }
+ if (issue.value.status === IssueStatus.CANCELED) {
+ errors.push(t("issue.disallow-edit-reasons.issue-is-canceled"));
+ }
+ return errors;
}
- if (![Task_Status.NOT_STARTED, Task_Status.PENDING].includes(task.status)) {
- return false;
+
+ if (
+ extractUserResourceName(issue.value.creator) !== currentUser.value.email
+ ) {
+ errors.push(t("issue.you-are-not-allowed-to-change-this-value"));
+ }
+
+ const task = selectedTask.value;
+ if (
+ task.status === Task_Status.RUNNING ||
+ task.status === Task_Status.PENDING
+ ) {
+ const latestTaskRun = latestTaskRunForTask(issue.value, selectedTask.value);
+ if (latestTaskRun) {
+ if (
+ latestTaskRun.status === TaskRun_Status.PENDING ||
+ latestTaskRun.status === TaskRun_Status.RUNNING
+ ) {
+ errors.push(
+ t("issue.disallow-edit-reasons.task-is-running-cancel-first")
+ );
+ }
+ }
+ } else if ([Task_Status.DONE, Task_Status.SKIPPED].includes(task.status)) {
+ errors.push(
+ t("issue.disallow-edit-reasons.task-is-x-status", {
+ status: task_StatusToJSON(task.status).toLowerCase(),
+ })
+ );
}
- return (
- extractUserResourceName(issue.value.creator) === currentUser.value.email
- );
+ return errors;
});
const handleUpdateEarliestAllowedTime = async (timestampMS: number | null) => {
diff --git a/frontend/src/components/IssueV1/logic/task-run.ts b/frontend/src/components/IssueV1/logic/task-run.ts
index 7f9be1352d..976d0fd6c1 100644
--- a/frontend/src/components/IssueV1/logic/task-run.ts
+++ b/frontend/src/components/IssueV1/logic/task-run.ts
@@ -1,3 +1,4 @@
+import { first, orderBy } from "lodash-es";
import { ComposedIssue } from "@/types";
import { Task } from "@/types/proto/v1/rollout_service";
import { extractTaskUID } from "@/utils";
@@ -7,3 +8,8 @@ export const taskRunListForTask = (issue: ComposedIssue, task: Task) => {
(taskRun) => extractTaskUID(taskRun.name) === task.uid
);
};
+
+export const latestTaskRunForTask = (issue: ComposedIssue, task: Task) => {
+ const taskRunList = taskRunListForTask(issue, task);
+ return first(orderBy(taskRunList, (taskRun) => Number(taskRun.uid), "desc"));
+};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index df889c8fea..89e23aee7d 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -920,7 +920,14 @@
"current-change-will-apply-to-all-tasks-in-batch-mode": "In batch mode, current change will be applied to all tasks."
},
"not-editable-legacy-issue": "This issue is not editable because it was created in an old version of Bytebase",
- "action-anyway": "{action} anyway"
+ "action-anyway": "{action} anyway",
+ "disallow-edit-reasons": {
+ "issue-is-done": "The issue is done",
+ "issue-is-canceled": "The issue is canceled",
+ "task-is-x-status": "The task is {status}",
+ "task-is-running-cancel-first": "The task is running, cancel task before changing this value"
+ },
+ "you-are-not-allowed-to-change-this-value": "You are not allowed to change this value"
},
"alter-schema": {
"vcs-enabled": "This project has enabled VCS based version control and selecting database below will navigate you to the corresponding Git repository to initiate the change process.",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 06271228b3..d37612574e 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -919,7 +919,14 @@
"current-change-will-apply-to-all-tasks-in-batch-mode": "En el modo por lotes, el cambio actual se aplicará a todas las tareas."
},
"not-editable-legacy-issue": "Este problema no es editable porque se creó en una versión anterior de Bytebase",
- "action-anyway": "{action} de todos modos"
+ "action-anyway": "{action} de todos modos",
+ "disallow-edit-reasons": {
+ "issue-is-done": "La cuestión está hecha",
+ "issue-is-canceled": "La emisión está cancelada.",
+ "task-is-x-status": "La tarea es {status}",
+ "task-is-running-cancel-first": "La tarea se está ejecutando, cancele la tarea antes de cambiar este valor"
+ },
+ "you-are-not-allowed-to-change-this-value": "No tienes permitido cambiar este valor."
},
"alter-schema": {
"vcs-enabled": "Este proyecto ha habilitado el control de versiones basado en VCS y seleccionar la base de datos a continuación lo llevará al repositorio Git correspondiente para iniciar el proceso de cambio.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 0798063886..e0349119a3 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -917,7 +917,14 @@
"current-change-will-apply-to-all-tasks-in-batch-mode": "在批量模式下,当前更改将应用​​于所有任务。"
},
"not-editable-legacy-issue": "这个工单不可编辑,因为它是在旧版本的 Bytebase 中创建的。",
- "action-anyway": "仍要{action}"
+ "action-anyway": "仍要{action}",
+ "disallow-edit-reasons": {
+ "issue-is-done": "工单已完成",
+ "issue-is-canceled": "工单已取消",
+ "task-is-x-status": "任务状态是{status}",
+ "task-is-running-cancel-first": "任务运行中,需要取消任务才能修改这项值"
+ },
+ "you-are-not-allowed-to-change-this-value": "您无权更改这项值"
},
"alter-schema": {
"vcs-enabled": "该项目开启了基于 VCS 的版本管理,选择下面的数据库会将您导航到相应的 Git 仓库以发起变更流程。",