Skip to content

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

chore: update plan utils (#16133)

boojack162e5a7714a6
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue b/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue
index 2b2a860d5e..080b08d23d 100644
--- a/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue
+++ b/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue
@@ -23,7 +23,8 @@
import { NEmpty } from "naive-ui";
import { computed, watch } from "vue";
import DatabaseInfo from "@/components/DatabaseInfo.vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import NoPermissionPlaceholder from "@/components/misc/NoPermissionPlaceholder.vue";
import { useDatabaseV1Store } from "@/store";
import { isValidDatabaseName } from "@/types";
@@ -39,7 +40,7 @@ const stageList = computed(() => {
});
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const placeholder = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
index 623507efc2..cb0e86c703 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
@@ -27,15 +27,23 @@
/>
<SQLCheckPanel
- v-if="showSQLCheckResultPanel && databaseForTask(issue, selectedTask)"
+ v-if="
+ showSQLCheckResultPanel &&
+ databaseForTask(issue.projectEntity, selectedTask)
+ "
:project="issue.project"
- :database="databaseForTask(issue, selectedTask)"
- :advices="checkResultMap[databaseForTask(issue, selectedTask).name].advices"
+ :database="databaseForTask(issue.projectEntity, selectedTask)"
+ :advices="
+ checkResultMap[databaseForTask(issue.projectEntity, selectedTask).name]
+ .advices
+ "
:affected-rows="
- checkResultMap[databaseForTask(issue, selectedTask).name].affectedRows
+ checkResultMap[databaseForTask(issue.projectEntity, selectedTask).name]
+ .affectedRows
"
:risk-level="
- checkResultMap[databaseForTask(issue, selectedTask).name].riskLevel
+ checkResultMap[databaseForTask(issue.projectEntity, selectedTask).name]
+ .riskLevel
"
:confirm="sqlCheckConfirmDialog"
:override-title="$t('issue.sql-check.sql-review-violations')"
@@ -53,13 +61,13 @@ import { getValidIssueLabels } from "@/components/IssueV1/components/IssueLabelS
import { ErrorList } from "@/components/IssueV1/components/common";
import {
databaseEngineForSpec,
- databaseForTask,
getLocalSheetByName,
isValidStage,
useIssueContext,
} from "@/components/IssueV1/logic";
import formatSQL from "@/components/MonacoEditor/sqlFormatter";
import { isValidSpec } from "@/components/Plan";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { SQLCheckPanel } from "@/components/SQLCheck";
import { STATEMENT_SKIP_CHECK_THRESHOLD } from "@/components/SQLCheck/common";
import {
@@ -308,7 +316,7 @@ const runSQLCheckForIssue = async () => {
}
if (!sheet) continue;
const statement = getSheetStatement(sheet);
- const database = databaseForTask(issue.value, task);
+ const database = databaseForTask(issue.value.projectEntity, task);
if (!statement) {
continue;
}
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue
index a8989d0efc..3244067fe1 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue
@@ -5,7 +5,7 @@
class="font-medium text-main hover:border-b hover:border-b-main"
@click="toTop"
>
- <span>{{ databaseForTask(issue, task).databaseName }}</span>
+ <span>{{ databaseForTask(issue.projectEntity, task).databaseName }}</span>
<template v-if="schemaVersion">
<span class="ml-1 text-control-placeholder">(</span>
<span class="lowercase text-control-placeholder">{{
@@ -20,7 +20,8 @@
<script lang="ts" setup>
import scrollIntoView from "scroll-into-view-if-needed";
import { computed } from "vue";
-import { databaseForTask, stageForTask } from "@/components/IssueV1/logic";
+import { stageForTask } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import type { ComposedIssue } from "@/types";
import type { Task } from "@/types/proto/v1/rollout_service";
diff --git a/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue
index 38f1a9c5a4..30e1ea666b 100644
--- a/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue
@@ -107,10 +107,10 @@ import {
issueReviewActionButtonProps,
issueReviewActionDisplayName,
planCheckRunSummaryForIssue,
- databaseForTask,
} from "@/components/IssueV1/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
import RequiredStar from "@/components/RequiredStar.vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { issueServiceClient } from "@/grpcweb";
import { Issue_Approver_Status } from "@/types/proto/v1/issue_service";
import { ErrorList } from "../common";
@@ -148,7 +148,7 @@ const title = computed(() => {
});
const database = computed(() =>
- databaseForTask(issue.value, selectedTask.value)
+ databaseForTask(issue.value.projectEntity, selectedTask.value)
);
const showPerformActionAnyway = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/Panel/RolloutTaskDatabaseName.vue b/frontend/src/components/IssueV1/components/Panel/RolloutTaskDatabaseName.vue
index 5ecb4fe428..c54a0227bf 100644
--- a/frontend/src/components/IssueV1/components/Panel/RolloutTaskDatabaseName.vue
+++ b/frontend/src/components/IssueV1/components/Panel/RolloutTaskDatabaseName.vue
@@ -18,9 +18,10 @@
<script setup lang="ts">
import { NPerformantEllipsis } from "naive-ui";
import { computed } from "vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { InstanceV1Name } from "@/components/v2";
import type { Task } from "@/types/proto/v1/rollout_service";
-import { databaseForTask, useIssueContext } from "../../logic";
+import { useIssueContext } from "../../logic";
const props = defineProps<{
task: Task;
@@ -29,6 +30,6 @@ const props = defineProps<{
const { issue } = useIssueContext();
const db = computed(() => {
- return databaseForTask(issue.value, props.task);
+ return databaseForTask(issue.value.projectEntity, props.task);
});
</script>
diff --git a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
index 28174c3eaa..670dd25605 100644
--- a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
@@ -164,7 +164,6 @@ import { computed, reactive, ref } from "vue";
import { useI18n } from "vue-i18n";
import type { TaskRolloutAction } from "@/components/IssueV1/logic";
import {
- databaseForTask,
semanticTaskType,
stageForTask,
taskRolloutActionButtonProps,
@@ -175,6 +174,7 @@ import {
} from "@/components/IssueV1/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { rolloutServiceClient } from "@/grpcweb";
import { pushNotification, useEnvironmentV1Store } from "@/store";
import type { Task, TaskRun } from "@/types/proto/v1/rollout_service";
@@ -216,7 +216,7 @@ const title = computed(() => {
});
const database = computed(() =>
- databaseForTask(issue.value, selectedTask.value)
+ databaseForTask(issue.value.projectEntity, selectedTask.value)
);
const stage = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
index dcc77f7edf..01189dd6f4 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
@@ -12,12 +12,12 @@
<script lang="ts" setup>
import { computed } from "vue";
import {
- databaseForTask,
planSpecHasPlanChecks,
specForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { useCurrentUserV1, extractUserId } from "@/store";
import { hasProjectPermissionV2, isValidTaskName } from "@/utils";
@@ -33,7 +33,7 @@ const show = computed(() => {
});
const database = computed(() =>
- databaseForTask(issue.value, selectedTask.value)
+ databaseForTask(issue.value.projectEntity, selectedTask.value)
);
const allowRunChecks = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
index efd9e893e0..7404b59410 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
@@ -35,10 +35,11 @@
import { CheckIcon, TriangleAlertIcon, CircleAlertIcon } from "lucide-vue-next";
import { NTag } from "naive-ui";
import { computed, ref } from "vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { SQLCheckPanel } from "@/components/SQLCheck";
import type { Advice } from "@/types/proto/v1/sql_service";
import { Advice_Status } from "@/types/proto/v1/sql_service";
-import { databaseForTask, useIssueContext } from "../../logic";
+import { useIssueContext } from "../../logic";
import { TaskSpinner } from "../common";
const props = defineProps<{
@@ -54,7 +55,7 @@ const { issue, selectedTask } = useIssueContext();
const showDetailPanel = ref(false);
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const status = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckButton.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckButton.vue
index 5e49f3270d..952d73302b 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckButton.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckButton.vue
@@ -54,6 +54,7 @@ import { v4 as uuidv4 } from "uuid";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBSpin } from "@/bbkit";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { SQLCheckPanel } from "@/components/SQLCheck";
import { STATEMENT_SKIP_CHECK_THRESHOLD } from "@/components/SQLCheck/common";
import ErrorList from "@/components/misc/ErrorList.vue";
@@ -65,7 +66,7 @@ import {
import { Advice, Advice_Status } from "@/types/proto/v1/sql_service";
import type { Defer, VueStyle } from "@/utils";
import { defer } from "@/utils";
-import { databaseForTask, useIssueContext } from "../../logic";
+import { useIssueContext } from "../../logic";
import { useTaskSheet } from "../StatementSection/useTaskSheet";
import { getTaskChangeType } from "./common";
import { useIssueSQLCheckContext } from "./context";
@@ -97,7 +98,7 @@ const advices = computed(() => {
});
const database = computed(() =>
- databaseForTask(issue.value, selectedTask.value)
+ databaseForTask(issue.value.projectEntity, selectedTask.value)
);
const statement = computed(() => sheetStatement.value);
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
index 688f41e968..99dac0345d 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
@@ -38,7 +38,8 @@
<script lang="ts" setup>
import { NTag, NTooltip } from "naive-ui";
import { computed } from "vue";
-import { useIssueContext, databaseForTask } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { TaskTypeListWithStatement } from "@/types";
import { Task_Type } from "@/types/proto/v1/rollout_service";
import SQLCheckBadge from "./SQLCheckBadge.vue";
@@ -50,7 +51,7 @@ const { issue, selectedTask } = useIssueContext();
const { enabled, resultMap } = useIssueSQLCheckContext();
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const show = computed(() => {
@@ -68,7 +69,10 @@ const show = computed(() => {
});
const checkResult = computed(() => {
- const database = databaseForTask(issue.value, selectedTask.value);
+ const database = databaseForTask(
+ issue.value.projectEntity,
+ selectedTask.value
+ );
return resultMap.value[database.name] || undefined;
});
</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostFlagsPanel.vue b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostFlagsPanel.vue
index ed3b56b998..5d15cc54a5 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostFlagsPanel.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostFlagsPanel.vue
@@ -73,13 +73,13 @@ import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import {
chooseUpdateTarget,
- databaseForTask,
notifyNotEditableLegacyIssue,
specForTask,
stageForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import ErrorList from "@/components/misc/ErrorList.vue";
import { Drawer, DrawerContent, RichDatabaseName } from "@/components/v2";
import { planServiceClient } from "@/grpcweb";
@@ -111,7 +111,7 @@ const stage = computed(() => {
return stageForTask(issue.value, task.value);
});
const database = computed(() => {
- return databaseForTask(issue.value, task.value);
+ return databaseForTask(issue.value.projectEntity, task.value);
});
const title = computed(() => {
return t("task.online-migration.configure-ghost-parameters");
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
index 440673a5c3..370e091728 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
@@ -49,8 +49,9 @@
import { NTooltip } from "naive-ui";
import { computed } from "vue";
import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { isDatabaseChangeRelatedIssue } from "@/utils";
import GhostConfigButton from "./GhostConfigButton.vue";
import GhostFlagsPanel from "./GhostFlagsPanel.vue";
@@ -80,6 +81,7 @@ const shouldShowGhostSection = computed(() => {
});
const instance = computed(() => {
- return databaseForTask(issue.value, selectedTask.value).instanceResource;
+ return databaseForTask(issue.value.projectEntity, selectedTask.value)
+ .instanceResource;
});
</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue
index bf07d642e1..0a9b15f335 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue
@@ -35,11 +35,11 @@ import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import InstanceAssignment from "@/components/InstanceAssignment.vue";
import {
- databaseForTask,
notifyNotEditableLegacyIssue,
specForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import type { ErrorItem } from "@/components/misc/ErrorList.vue";
import { default as ErrorList } from "@/components/misc/ErrorList.vue";
import { planServiceClient } from "@/grpcweb";
@@ -80,7 +80,10 @@ const errors = computed(() => {
t("subscription.instance-assignment.missing-license-attention")
);
}
- const database = databaseForTask(issue.value, selectedTask.value);
+ const database = databaseForTask(
+ issue.value.projectEntity,
+ selectedTask.value
+ );
// As we use the same database from backup to save temp tables in gh-ost, check if backup is available.
if (!database.backupAvailable) {
errors.push(
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
index 96f23b18f6..afaee6a8b7 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
@@ -4,13 +4,13 @@ import type { InjectionKey, Ref } from "vue";
import { computed, inject, provide, ref } from "vue";
import { useI18n } from "vue-i18n";
import {
- databaseForTask,
getLocalSheetByName,
isGroupingChangeTaskV1,
sheetNameForSpec,
specForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import {
useCurrentUserV1,
useStorageStore,
@@ -106,7 +106,8 @@ export const provideIssueGhostContext = () => {
const showMissingInstanceLicense = computed(() => {
const instances = uniqBy(
flattenTaskV1List(issue.value.rolloutEntity).map(
- (task) => databaseForTask(issue.value, task).instanceResource
+ (task) =>
+ databaseForTask(issue.value.projectEntity, task).instanceResource
),
(instance) => instance.name
);
@@ -198,7 +199,7 @@ export const allowGhostForSpec = (spec: Plan_Spec | undefined) => {
export const allowGhostForTask = (issue: ComposedIssue, task: Task) => {
return (
allowGhostForSpec(specForTask(issue.planEntity, task)) &&
- allowGhostForDatabase(databaseForTask(issue, task))
+ allowGhostForDatabase(databaseForTask(issue.projectEntity, task))
);
};
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
index 99eaf8e638..7dca719a96 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
@@ -6,14 +6,14 @@
<script lang="ts" setup>
import { computed } from "vue";
import {
- databaseForTask,
latestTaskRunForTask,
specForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
import { PreBackupSection } from "@/components/Plan/components/Sidebar";
import { providePreBackupSettingContext } from "@/components/Plan/components/Sidebar/PreBackupSection/context";
-import type { Plan, Plan_Spec } from "@/types/proto/v1/plan_service";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
+import type { Plan } from "@/types/proto/v1/plan_service";
import { TaskRun_Status } from "@/types/proto/v1/rollout_service";
import TaskRollbackSection from "./TaskRollbackSection.vue";
import { ROLLBACK_AVAILABLE_ENGINES } from "./common";
@@ -24,16 +24,19 @@ const {
enabled: preBackupEnabled,
events: preBackupEvents,
} = providePreBackupSettingContext({
+ isCreating,
project: computed(() => issue.value.projectEntity),
plan: computed(() => issue.value.planEntity as Plan),
- selectedSpec: computed(
- () => specForTask(issue.value.planEntity, selectedTask.value) as Plan_Spec
+ selectedSpec: computed(() =>
+ specForTask(issue.value.planEntity, selectedTask.value)
),
- isCreating,
+ selectedTask,
+ issue,
+ rollout: computed(() => issue.value.rolloutEntity),
});
const database = computed(() =>
- databaseForTask(issue.value, selectedTask.value)
+ databaseForTask(issue.value.projectEntity, selectedTask.value)
);
const latestTaskRun = computed(() =>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/utils.ts b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/utils.ts
index 0bf325c0fe..63f8b6a154 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/utils.ts
+++ b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/utils.ts
@@ -1,7 +1,8 @@
import { uniq } from "lodash-es";
import { computed, inject, provide } from "vue";
import type { InjectionKey, Ref } from "vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { useSubscriptionV1Store, useInstanceResourceByName } from "@/store";
import { isValidDatabaseName } from "@/types";
@@ -23,7 +24,7 @@ export const provideIssueIntanceContext = () => {
const instances =
issue.value.rolloutEntity?.stages.flatMap((stage) => {
return stage.tasks
- .map((task) => databaseForTask(issue.value, task))
+ .map((task) => databaseForTask(issue.value.projectEntity, task))
.filter((db) => isValidDatabaseName(db.name))
.map((db) => db.instance);
}) ?? [];
diff --git a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue
index d224389609..6c1ba67442 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/AffectedRowsView.vue
@@ -24,7 +24,7 @@
@click="onClickTask(task)"
>
<span class="group-hover:underline truncate">
- {{ databaseForTask(issue, task).databaseName }}
+ {{ databaseForTask(issue.projectEntity, task).databaseName }}
</span>
<span
class="shrink-0"
@@ -43,7 +43,8 @@
<script setup lang="ts">
import { NTag, NPopover } from "naive-ui";
import { computed } from "vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { type PlanCheckRun } from "@/types/proto/v1/plan_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import { flattenTaskV1List } from "@/utils";
diff --git a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue
index 18955245b3..5bf3cbb83f 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/TaskCheckSummarySection/FailedTasksView.vue
@@ -19,7 +19,7 @@
@click="onClickTask(task)"
>
<p class="group-hover:underline truncate">
- {{ databaseForTask(issue, task).databaseName }}
+ {{ databaseForTask(issue.projectEntity, task).databaseName }}
</p>
<p class="text-xs leading-4 text-error line-clamp-2">
{{ failedMessageOfTask(task.name) }}
@@ -33,7 +33,8 @@
<script setup lang="ts">
import { NTag, NPopover } from "naive-ui";
import { computed } from "vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1";
+import { useIssueContext } from "@/components/IssueV1";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import {
PlanCheckRun_Result_Status,
type PlanCheckRun,
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorActionPopover.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorActionPopover.vue
index 7dfcabef88..ee484c15f4 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorActionPopover.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorActionPopover.vue
@@ -22,7 +22,8 @@
import { EllipsisVerticalIcon } from "lucide-vue-next";
import { NPopover, NButton, NDivider } from "naive-ui";
import { computed } from "vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { Engine } from "@/types/proto/v1/common";
import { Task_Type } from "@/types/proto/v1/rollout_service";
import { useInstanceV1EditorLanguage } from "@/utils";
@@ -32,7 +33,7 @@ import InstanceRoleSelect from "./InstanceRoleSelect.vue";
const { formatOnSave, issue, selectedTask } = useIssueContext();
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const language = useInstanceV1EditorLanguage(
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
index dbb578ee83..c4c6624fd6 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
@@ -201,7 +201,6 @@ import { BBAttention, BBModal } from "@/bbkit";
import { FeatureModal } from "@/components/FeatureGuard";
import { ErrorList } from "@/components/IssueV1/components/common";
import {
- databaseForTask,
useIssueContext,
allowUserToEditStatementForTask,
stageForTask,
@@ -214,6 +213,7 @@ import {
} from "@/components/IssueV1/logic";
import { MonacoEditor } from "@/components/MonacoEditor";
import { extensionNameOfLanguage } from "@/components/MonacoEditor/utils";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import DownloadSheetButton from "@/components/Sheet/DownloadSheetButton.vue";
import SQLUploadButton from "@/components/misc/SQLUploadButton.vue";
import { planServiceClient } from "@/grpcweb";
@@ -274,7 +274,7 @@ const state = reactive<LocalState>({
});
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const language = useInstanceV1EditorLanguage(
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/InstanceRoleSelect.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/InstanceRoleSelect.vue
index 77924467b7..6f371ed486 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/InstanceRoleSelect.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/InstanceRoleSelect.vue
@@ -18,7 +18,8 @@
<script setup lang="tsx">
import { NSelect, type SelectOption } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { instanceRoleServiceClient } from "@/grpcweb";
import { DEFAULT_PAGE_SIZE } from "@/store/modules/common";
import type { InstanceRole } from "@/types/proto/v1/instance_role_service";
@@ -45,7 +46,7 @@ const { issue, selectedTask } = useIssueContext();
const state = reactive<LocalState>({});
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const instanceRoles = ref<InstanceRole[]>([]);
diff --git a/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue b/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue
index 1c4f7915d2..5415ae15c2 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue
@@ -15,10 +15,11 @@ import { computed, nextTick, ref } from "vue";
import { useI18n } from "vue-i18n";
import { onBeforeRouteLeave } from "vue-router";
import { useRouter } from "vue-router";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { TaskTypeListWithStatement } from "@/types";
import { Task_Type } from "@/types/proto/v1/rollout_service";
import { isValidTaskName } from "@/utils";
-import { databaseForTask, useIssueContext } from "../../logic";
+import { useIssueContext } from "../../logic";
import { useIssueSQLCheckContext } from "../SQLCheckSection/context";
import EditorView from "./EditorView";
import SDLView from "./SDLView";
@@ -31,7 +32,10 @@ const { resultMap } = useIssueSQLCheckContext();
const editorViewRef = ref<InstanceType<typeof EditorView>>();
const advices = computed(() => {
- const database = databaseForTask(issue.value, selectedTask.value);
+ const database = databaseForTask(
+ issue.value.projectEntity,
+ selectedTask.value
+ );
return resultMap.value[database.name]?.advices || [];
});
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue b/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue
index c54528264e..3a9da23969 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue
@@ -11,7 +11,8 @@
<template
v-if="
database &&
- formatEnvironmentName(instanceEnvironment.id) !== database.effectiveEnvironment
+ formatEnvironmentName(instanceEnvironment.id) !==
+ database.effectiveEnvironment
"
#prefix
>
@@ -78,14 +79,19 @@
import { computedAsync } from "@vueuse/core";
import { ChevronRightIcon, DatabaseIcon } from "lucide-vue-next";
import { computed } from "vue";
-import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { useIssueContext } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import {
DatabaseV1Name,
EnvironmentV1Name,
InstanceV1Name,
} from "@/components/v2";
import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
-import { formatEnvironmentName, isValidDatabaseName, unknownEnvironment } from "@/types";
+import {
+ formatEnvironmentName,
+ isValidDatabaseName,
+ unknownEnvironment,
+} from "@/types";
import { Task_Status, Task_Type } from "@/types/proto/v1/rollout_service";
import { extractInstanceResourceName } from "@/utils";
@@ -103,7 +109,7 @@ withDefaults(
const { issue, selectedTask } = useIssueContext();
const coreDatabaseInfo = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return databaseForTask(issue.value.projectEntity, selectedTask.value);
});
const databaseCreationStatus = computed((): DatabaseCreationStatus => {
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue b/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue
index 43c12f632a..6fbbe1afb2 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/TaskCard.vue
@@ -56,18 +56,14 @@ import { ExternalLinkIcon } from "lucide-vue-next";
import { NTag, NTooltip } from "naive-ui";
import { twMerge } from "tailwind-merge";
import { computed } from "vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { InstanceV1Name } from "@/components/v2";
import { isValidDatabaseName } from "@/types";
import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto/v1/plan_service";
import { Task } from "@/types/proto/v1/rollout_service";
import { Task_Type, task_StatusToJSON } from "@/types/proto/v1/rollout_service";
import { databaseV1Url, extractSchemaVersionFromTask, isDev } from "@/utils";
-import {
- databaseForTask,
- useInstanceForTask,
- specForTask,
- useIssueContext,
-} from "../../logic";
+import { useInstanceForTask, specForTask, useIssueContext } from "../../logic";
import TaskStatusIcon from "../TaskStatusIcon.vue";
import TaskExtraActionsButton from "./TaskExtraActionsButton.vue";
@@ -112,7 +108,9 @@ const taskClass = computed(() => {
return classes;
});
-const database = computed(() => databaseForTask(issue.value, props.task));
+const database = computed(() =>
+ databaseForTask(issue.value.projectEntity, props.task)
+);
const { instance } = useInstanceForTask(props.task);
const onClickTask = (task: Task) => {
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue b/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue
index 6d9bd08c94..5ef4aa54b6 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue
@@ -64,13 +64,14 @@ import { useDebounceFn } from "@vueuse/core";
import { NButton } from "naive-ui";
import { computed, ref, reactive, watch } from "vue";
import { BBSpin } from "@/bbkit";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { useVerticalScrollState } from "@/composables/useScrollState";
import { batchGetOrFetchDatabases } from "@/store";
import { DEBOUNCE_SEARCH_DELAY } from "@/types";
import type { Task_Status } from "@/types/proto/v1/rollout_service";
import type { Advice_Status } from "@/types/proto/v1/sql_service";
import { isDev } from "@/utils";
-import { useIssueContext, databaseForTask } from "../../logic";
+import { useIssueContext } from "../../logic";
import { useIssueSQLCheckContext } from "../SQLCheckSection/context";
import CurrentTaskSection from "./CurrentTaskSection.vue";
import TaskCard from "./TaskCard.vue";
@@ -167,7 +168,7 @@ const loadMore = useDebounceFn(async () => {
const databaseNames = filteredTaskList.value
.slice(fromIndex, toIndex)
- .map((task) => databaseForTask(issue.value, task).name);
+ .map((task) => databaseForTask(issue.value.projectEntity, task).name);
try {
await batchGetOrFetchDatabases(databaseNames);
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
index e241ecb9ed..0717f7164a 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
@@ -29,6 +29,7 @@ import { last } from "lodash-es";
import { NEllipsis } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { getProjectIdRolloutUidStageUidTaskUid } from "@/store/modules/v1/common";
import {
unknownTask,
@@ -40,7 +41,7 @@ import {
import { TaskRun_Status, Task_Type } from "@/types/proto/v1/rollout_service";
import { databaseV1Url, extractTaskUID, flattenTaskV1List } from "@/utils";
import { extractChangelogUID } from "@/utils/v1/changelog";
-import { databaseForTask, specForTask, useIssueContext } from "../../logic";
+import { specForTask, useIssueContext } from "../../logic";
import { displayTaskRunLogEntryType } from "./TaskRunLogTable/common";
export type CommentLink = {
@@ -163,7 +164,7 @@ const commentLink = computed((): CommentLink => {
link: "",
};
}
- const db = databaseForTask(issue.value, task);
+ const db = databaseForTask(issue.value.projectEntity, task);
const link = `${databaseV1Url(
db
)}/changelogs/${extractChangelogUID(taskRun.changelog)}`;
@@ -174,7 +175,7 @@ const commentLink = computed((): CommentLink => {
}
}
} else if (taskRun.status === TaskRun_Status.FAILED) {
- const db = databaseForTask(issue.value, task);
+ const db = databaseForTask(issue.value.projectEntity, task);
// Cast a wide net to catch migration version error
if (comment.value.includes("version")) {
return {
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
index 3463c9ae82..af952edc02 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
@@ -27,10 +27,11 @@ import { uniqueId } from "lodash-es";
import { RefreshCcwIcon } from "lucide-vue-next";
import { NButton, NTabs, NTabPane } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { useSheetV1Store } from "@/store";
import { Engine } from "@/types/proto/v1/common";
import { TaskRun_Status, type TaskRun } from "@/types/proto/v1/rollout_service";
-import { databaseForTask, useIssueContext } from "../../logic";
+import { useIssueContext } from "../../logic";
import TaskRunLogTable from "./TaskRunLogTable";
import TaskRunSession from "./TaskRunSession";
@@ -68,7 +69,7 @@ const showRefreshButton = computed(
);
const database = computed(() =>
- databaseForTask(issue.value, selectedTask.value)
+ databaseForTask(issue.value.projectEntity, selectedTask.value)
);
watch(
diff --git a/frontend/src/components/IssueV1/components/TaskStatusIcon.vue b/frontend/src/components/IssueV1/components/TaskStatusIcon.vue
index 4edc679510..d725086dd4 100644
--- a/frontend/src/components/IssueV1/components/TaskStatusIcon.vue
+++ b/frontend/src/components/IssueV1/components/TaskStatusIcon.vue
@@ -58,15 +58,12 @@
import { CircleAlertIcon, TriangleAlertIcon } from "lucide-vue-next";
import { computed } from "vue";
import { SkipIcon } from "@/components/Icon";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { PlanCheckRun_Result_Status } from "@/types/proto/v1/plan_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import { Task_Status } from "@/types/proto/v1/rollout_service";
import { Advice_Status } from "@/types/proto/v1/sql_service";
-import {
- databaseForTask,
- planCheckStatusForTask,
- useIssueContext,
-} from "../logic";
+import { planCheckStatusForTask, useIssueContext } from "../logic";
import { useIssueSQLCheckContext } from "./SQLCheckSection/context";
const props = defineProps<{
@@ -83,7 +80,9 @@ const checkStatus = computed(() => {
if (!props.task) return undefined;
if (isCreating.value) {
const checkResult =
- resultMap.value[databaseForTask(issue.value, props.task).name];
+ resultMap.value[
+ databaseForTask(issue.value.projectEntity, props.task).name
+ ];
if (!checkResult) return undefined;
if (
diff --git a/frontend/src/components/IssueV1/logic/plan-check.ts b/frontend/src/components/IssueV1/logic/plan-check.ts
index 35fbdd56bc..c9fc7ceb90 100644
--- a/frontend/src/components/IssueV1/logic/plan-check.ts
+++ b/frontend/src/components/IssueV1/logic/plan-check.ts
@@ -1,4 +1,5 @@
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import type { ComposedIssue } from "@/types";
import {
PlanCheckRun_Result_Status,
@@ -6,12 +7,7 @@ import {
} from "@/types/proto/v1/plan_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import { Task_Status } from "@/types/proto/v1/rollout_service";
-import {
- databaseForTask,
- sheetNameForSpec,
- specForTask,
- useIssueContext,
-} from ".";
+import { sheetNameForSpec, specForTask, useIssueContext } from ".";
export const planSpecHasPlanChecks = (spec: Plan_Spec) => {
if (spec.createDatabaseConfig) {
@@ -27,7 +23,7 @@ export const planSpecHasPlanChecks = (spec: Plan_Spec) => {
};
export const planCheckRunListForTask = (issue: ComposedIssue, task: Task) => {
- const target = databaseForTask(issue, task).name;
+ const target = databaseForTask(issue.projectEntity, task).name;
const spec = specForTask(issue.planEntity, task);
const sheet = spec ? sheetNameForSpec(spec) : "";
return issue.planCheckRunList.filter((check) => {
diff --git a/frontend/src/components/IssueV1/logic/poll.ts b/frontend/src/components/IssueV1/logic/poll.ts
index bc466d6c89..de4baf6595 100644
--- a/frontend/src/components/IssueV1/logic/poll.ts
+++ b/frontend/src/components/IssueV1/logic/poll.ts
@@ -1,6 +1,6 @@
import { isEqual } from "lodash-es";
import { watch } from "vue";
-import { databaseForTask } from "@/components/IssueV1/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { useProgressivePoll } from "@/composables/useProgressivePoll";
import {
experimentalFetchIssueByUID,
@@ -21,7 +21,7 @@ const clearCache = (issue: ComposedIssue) => {
const tasks = flattenTaskV1List(issue.rolloutEntity);
for (const task of tasks) {
- const database = databaseForTask(issue, task);
+ const database = databaseForTask(issue.projectEntity, task);
switch (task.type) {
case Task_Type.DATABASE_CREATE:
useInstanceV1Store()
diff --git a/frontend/src/components/IssueV1/logic/utils.ts b/frontend/src/components/IssueV1/logic/utils.ts
index 17a8356bf6..828ae08519 100644
--- a/frontend/src/components/IssueV1/logic/utils.ts
+++ b/frontend/src/components/IssueV1/logic/utils.ts
@@ -87,31 +87,6 @@ export const mockDatabase = (
return db;
};
-export const databaseForTask = (issue: ComposedIssue, task: Task) => {
- switch (task.type) {
- case Task_Type.DATABASE_CREATE:
- // The database is not created yet.
- // extract database info from the task's and payload's properties.
- return extractCoreDatabaseInfoFromDatabaseCreateTask(
- issue.projectEntity,
- task
- );
- case Task_Type.DATABASE_SCHEMA_BASELINE:
- case Task_Type.DATABASE_SCHEMA_UPDATE:
- case Task_Type.DATABASE_SCHEMA_UPDATE_SDL:
- case Task_Type.DATABASE_SCHEMA_UPDATE_GHOST:
- case Task_Type.DATABASE_DATA_UPDATE:
- case Task_Type.DATABASE_DATA_EXPORT:
- const db = useDatabaseV1Store().getDatabaseByName(task.target);
- if (!isValidDatabaseName(db.name)) {
- return mockDatabase(issue.projectEntity, task.target);
- }
- return db;
- default:
- return unknownDatabase();
- }
-};
-
export const extractCoreDatabaseInfoFromDatabaseCreateTask = (
project: ComposedProject,
task: Task
diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
index 8a1335210c..94713f6c79 100644
--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
+++ b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
@@ -5,7 +5,7 @@
<NSwitch
:value="enabled"
:disabled="!allowChange"
- @update:value="toggle"
+ @update:value="(on) => handleToggle(on)"
/>
</template>
<template #default>
@@ -26,6 +26,7 @@ import { NSwitch, NTooltip } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
+import { pushNotification } from "@/store";
import { usePreBackupSettingContext } from "./context";
const { t } = useI18n();
@@ -50,4 +51,13 @@ const disallowPreBackupLink = computed(() => {
}
return undefined;
});
+
+const handleToggle = async (on: boolean) => {
+ await toggle(on);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+};
</script>
diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts
index 25dfcb8eb2..406d9cbe75 100644
--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts
+++ b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts
@@ -8,20 +8,26 @@ import {
type InjectionKey,
type Ref,
} from "vue";
-import { useI18n } from "vue-i18n";
import { databaseForSpec, isDatabaseChangeSpec } from "@/components/Plan/logic";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { planServiceClient } from "@/grpcweb";
-import { pushNotification, useCurrentUserV1, extractUserId } from "@/store";
-import type { ComposedProject } from "@/types";
+import { useCurrentUserV1, extractUserId } from "@/store";
+import { unknownDatabase, type ComposedProject } from "@/types";
import { Engine } from "@/types/proto/v1/common";
-import type { Issue } from "@/types/proto/v1/issue_service";
+import { IssueStatus, type Issue } from "@/types/proto/v1/issue_service";
import {
Plan_ChangeDatabaseConfig_Type,
type Plan,
type Plan_Spec,
} from "@/types/proto/v1/plan_service";
+import {
+ Task,
+ Task_Status,
+ type Rollout,
+} from "@/types/proto/v1/rollout_service";
import {
flattenSpecList,
+ flattenTaskV1List,
hasProjectPermissionV2,
isNullOrUndefined,
} from "@/utils";
@@ -44,34 +50,50 @@ export const usePreBackupSettingContext = () => {
};
export const providePreBackupSettingContext = (refs: {
+ isCreating: Ref<boolean>;
project: Ref<ComposedProject>;
plan: Ref<Plan>;
- selectedSpec: Ref<Plan_Spec>;
- isCreating: Ref<boolean>;
- issue?: Ref<Issue>;
+ selectedSpec: Ref<Plan_Spec | undefined>;
+ selectedTask: Ref<Task | undefined>;
+ issue?: Ref<Issue | undefined>;
+ rollout?: Ref<Rollout | undefined>;
}) => {
- const { t } = useI18n();
- const currentUserV1 = useCurrentUserV1();
- const { project, plan, selectedSpec, isCreating } = refs;
+ const currentUser = useCurrentUserV1();
+ const {
+ isCreating,
+ project,
+ plan,
+ selectedSpec,
+ selectedTask,
+ issue,
+ rollout,
+ } = refs;
const events = new Emittery<{
update: boolean;
}>();
- const database = computed(() =>
- databaseForSpec(project.value, selectedSpec.value)
- );
+ const database = computed(() => {
+ if (selectedTask.value) {
+ return databaseForTask(project.value, selectedTask.value);
+ } else if (selectedSpec.value) {
+ return databaseForSpec(project.value, selectedSpec.value);
+ }
+ return unknownDatabase();
+ });
const shouldShow = computed((): boolean => {
- if (!isDatabaseChangeSpec(selectedSpec.value)) {
- return false;
- }
if (
+ !selectedSpec.value ||
selectedSpec.value.changeDatabaseConfig?.type !==
- Plan_ChangeDatabaseConfig_Type.DATA
+ Plan_ChangeDatabaseConfig_Type.DATA
) {
return false;
}
+ // Always show pre-backup for database change spec.
+ if (isDatabaseChangeSpec(selectedSpec.value)) {
+ return true;
+ }
const { engine } = database.value.instanceResource;
if (!PRE_BACKUP_AVAILABLE_ENGINES.includes(engine)) {
return false;
@@ -90,8 +112,30 @@ export const providePreBackupSettingContext = (refs: {
return true;
}
+ // If issue is not open, disallow.
+ if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
+ return false;
+ }
+
+ // If task of the spec is running/done/etc..., disallow.
+ if (rollout?.value) {
+ const tasks = flattenTaskV1List(rollout.value);
+ const task = tasks.find((t) => t.specId === selectedSpec.value?.id);
+ if (
+ task &&
+ [
+ Task_Status.PENDING,
+ Task_Status.RUNNING,
+ Task_Status.DONE,
+ Task_Status.SKIPPED,
+ ].includes(task.status)
+ ) {
+ return false;
+ }
+ }
+
// Allowed to the plan/issue creator.
- if (currentUserV1.value.email === extractUserId(unref(plan).creator)) {
+ if (currentUser.value.email === extractUserId(unref(plan).creator)) {
return true;
}
@@ -105,7 +149,7 @@ export const providePreBackupSettingContext = (refs: {
const enabled = computed((): boolean => {
const preBackupDatabase =
- selectedSpec.value.changeDatabaseConfig?.preUpdateBackupDetail?.database;
+ selectedSpec.value?.changeDatabaseConfig?.preUpdateBackupDetail?.database;
return !isNullOrUndefined(preBackupDatabase) && preBackupDatabase !== "";
});
@@ -129,7 +173,7 @@ export const providePreBackupSettingContext = (refs: {
} else {
const planPatch = cloneDeep(unref(plan));
const spec = flattenSpecList(planPatch).find((s) => {
- return s.id === selectedSpec.value.id;
+ return s.id === selectedSpec.value?.id;
});
if (!planPatch || !spec || !spec.changeDatabaseConfig) {
// Should not reach here.
@@ -150,12 +194,6 @@ export const providePreBackupSettingContext = (refs: {
plan: planPatch,
updateMask: ["steps"],
});
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
}
// Emit the update event.
diff --git a/frontend/src/components/Plan/components/Sidebar/Sidebar.vue b/frontend/src/components/Plan/components/Sidebar/Sidebar.vue
index 3774e4a271..0c17cfb0b4 100644
--- a/frontend/src/components/Plan/components/Sidebar/Sidebar.vue
+++ b/frontend/src/components/Plan/components/Sidebar/Sidebar.vue
@@ -18,6 +18,7 @@ const { shouldShow: shouldShowPreBackupSection, events: preBackupEvents } =
project: computed(() => plan.value.projectEntity),
plan: plan,
selectedSpec: selectedSpec,
+ selectedTask: computed(() => undefined),
isCreating,
});
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index fad505c700..71c9831610 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -16,6 +16,7 @@ export type PlanContext = {
isCreating: Ref<boolean>;
ready: Ref<boolean>;
plan: Ref<ComposedPlan>;
+ // TODO(steven): save related issue/rollout for checking if the plan is changable.
selectedSpec: Ref<Plan_Spec>;
formatOnSave: Ref<boolean>;
diff --git a/frontend/src/components/Rollout/RolloutDetail/index.ts b/frontend/src/components/Rollout/RolloutDetail/index.ts
index 4db34e1616..efc28d8531 100644
--- a/frontend/src/components/Rollout/RolloutDetail/index.ts
+++ b/frontend/src/components/Rollout/RolloutDetail/index.ts
@@ -1,3 +1,5 @@
import RolloutDetail from "./RolloutDetail.vue";
export default RolloutDetail;
+
+export * from "./utils";
diff --git a/frontend/src/components/Rollout/RolloutDetail/utils.ts b/frontend/src/components/Rollout/RolloutDetail/utils.ts
index 66835621d9..69e9760337 100644
--- a/frontend/src/components/Rollout/RolloutDetail/utils.ts
+++ b/frontend/src/components/Rollout/RolloutDetail/utils.ts
@@ -9,23 +9,23 @@ import {
import { Task_Type, type Task } from "@/types/proto/v1/rollout_service";
export const databaseForTask = (project: ComposedProject, task: Task) => {
- if (task.type === Task_Type.DATABASE_CREATE) {
- // The database is not created yet.
- // extract database info from the task's and payload's properties.
- return extractCoreDatabaseInfoFromDatabaseCreateTask(project, task);
- } else {
- if (
- task.databaseDataUpdate ||
- task.databaseSchemaUpdate ||
- task.databaseDataExport ||
- task.type === Task_Type.DATABASE_SCHEMA_BASELINE
- ) {
+ switch (task.type) {
+ case Task_Type.DATABASE_CREATE:
+ // The database is not created yet.
+ // extract database info from the task's and payload's properties.
+ return extractCoreDatabaseInfoFromDatabaseCreateTask(project, task);
+ case Task_Type.DATABASE_SCHEMA_BASELINE:
+ case Task_Type.DATABASE_SCHEMA_UPDATE:
+ case Task_Type.DATABASE_SCHEMA_UPDATE_SDL:
+ case Task_Type.DATABASE_SCHEMA_UPDATE_GHOST:
+ case Task_Type.DATABASE_DATA_UPDATE:
+ case Task_Type.DATABASE_DATA_EXPORT:
const db = useDatabaseV1Store().getDatabaseByName(task.target);
if (!isValidDatabaseName(db.name)) {
return mockDatabase(project, task.target);
}
return db;
- }
+ default:
+ return unknownDatabase();
}
- return unknownDatabase();
};
diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts
index 2ff0c26e80..45c6f31e9b 100644
--- a/frontend/src/types/issue.ts
+++ b/frontend/src/types/issue.ts
@@ -1,21 +1,10 @@
-type IssueTypeGeneral = "bb.issue.general";
-
-type IssueTypeDataSource = "bb.issue.data-source.request";
-
type IssueTypeDatabase =
- | "bb.issue.database.general" // For V1 API compatibility
| "bb.issue.database.create"
| "bb.issue.database.grant"
| "bb.issue.database.schema.update"
| "bb.issue.database.data.update"
- | "bb.issue.database.rollback"
- | "bb.issue.database.schema.update.ghost"
| "bb.issue.database.data.export";
type IssueTypeGrantRequest = "bb.issue.grant.request";
-export type IssueType =
- | IssueTypeGeneral
- | IssueTypeDataSource
- | IssueTypeDatabase
- | IssueTypeGrantRequest;
+export type IssueType = IssueTypeDatabase | IssueTypeGrantRequest;
diff --git a/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue b/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue
index 5d901283dc..dbe64a6f68 100644
--- a/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue
+++ b/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue
@@ -22,11 +22,11 @@ import { computed, watch, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import DatabaseInfo from "@/components/DatabaseInfo.vue";
-import { databaseForTask } from "@/components/IssueV1";
import IssueLabelSelector, {
getValidIssueLabels,
} from "@/components/IssueV1/components/IssueLabelSelector.vue";
import IssueStatusIconWithTaskSummary from "@/components/IssueV1/components/IssueStatusIconWithTaskSummary.vue";
+import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
import { emitWindowEvent } from "@/plugins";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
@@ -191,7 +191,7 @@ const issueRelatedDatabase = (issue: ComposedIssue) => {
if (!task) {
return;
}
- return databaseForTask(issue, task);
+ return databaseForTask(issue.projectEntity, task);
};
const issueRelatedStatement = (issue: ComposedIssue) => {