Skip to content

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

fix: disable next button when no database will be deployed (#401)

Liu Ji009918cd33df
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 10417cf66d..18793a7532 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -159,6 +159,7 @@ export default defineComponent({
selectedDatabaseIdForEnvironment: new Map(),
tenantProjectId: undefined,
selectedDatabaseName: undefined,
+ deployingTenantDatabaseList: [],
});
const isTenantProject = computed((): boolean => {
@@ -232,7 +233,9 @@ export default defineComponent({
const allowGenerateTenant = computed(() => {
if (!state.selectedDatabaseName) return false;
- // TODO: return false when database list filtered by deployment config is empty
+ // not allowed when database list filtered by deployment config is empty
+ // which means no database will be deployed
+ if (state.deployingTenantDatabaseList.length === 0) return false;
return true;
});
diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
index ecf84e0bc1..90e142ec65 100644
--- a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
@@ -95,6 +95,7 @@ import {
import { useStore } from "vuex";
import {
Database,
+ DatabaseId,
DeploymentConfig,
Environment,
Label,
@@ -105,9 +106,11 @@ import {
import { NCollapse, NCollapseItem } from "naive-ui";
import { groupBy } from "lodash-es";
import { DeployDatabaseTable } from "../TenantDatabaseTable";
+import { getPipelineFromDeploymentSchedule } from "../../utils";
export type State = {
selectedDatabaseName: string | undefined;
+ deployingTenantDatabaseList: DatabaseId[];
};
const props = defineProps<{
@@ -170,6 +173,31 @@ watch(
},
{ immediate: true }
);
+
+watchEffect(() => {
+ if (!deployment.value) return;
+ const name = props.state.selectedDatabaseName;
+ if (!name) {
+ props.state.deployingTenantDatabaseList = [];
+ } else {
+ // find the selected database list group by name
+ const databaseGroup = databaseListGroupByName.value.find(
+ (group) => group.name === name
+ );
+ const databaseList = databaseGroup?.list || [];
+
+ // calculate the deployment matching to preview the pipeline
+ const stages = getPipelineFromDeploymentSchedule(
+ databaseList,
+ deployment.value.schedule
+ );
+
+ // flatten all stages' database id list
+ // these databases are to be deployed
+ const databaseIdList = stages.flatMap((stage) => stage.map((db) => db.id));
+ props.state.deployingTenantDatabaseList = databaseIdList;
+ }
+});
</script>
<style scoped lang="postcss">
diff --git a/frontend/src/store/modules/deployment.ts b/frontend/src/store/modules/deployment.ts
index a559718d75..8e53d04da3 100644
--- a/frontend/src/store/modules/deployment.ts
+++ b/frontend/src/store/modules/deployment.ts
@@ -25,6 +25,13 @@ function convert(
).schedule;
try {
schedule = JSON.parse(deployment.attributes.payload as string);
+ schedule.deployments.forEach((deployment) => {
+ deployment.spec.selector.matchExpressions.forEach((rule) => {
+ if (!rule.values) {
+ rule.values = []; // empty values polyfill
+ }
+ });
+ });
} catch {
// nothing
}
diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.ts
index c8078f086b..aae2815fa6 100644
--- a/frontend/src/types/store.ts
+++ b/frontend/src/types/store.ts
@@ -1,5 +1,6 @@
import {
AuthProvider,
+ DeploymentConfig,
EnvironmentId,
MigrationHistoryId,
Policy,
@@ -204,3 +205,7 @@ export interface EditorSelectorState {
export type EditorSelectorGetters = typeof editorSelectorStore.getters;
export type EditorSelectorActions = typeof editorSelectorStore.actions;
export type EditorSelectorMutations = typeof editorSelectorStore.mutations;
+
+export interface DeploymentState {
+ deploymentConfigByProjectId: Map<ProjectId, DeploymentConfig>;
+}