Skip to content

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

chore: disallow edit task for grouping issue (#6538)

boojackbc7c2d66a1a3
diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vue
index a73749e7bd..4a029aa12a 100644
--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue
+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue
@@ -22,7 +22,7 @@
>
🎈{{ $t("sql-review.unlock-full-feature") }}
</button>
- <span v-if="sqlHint" class="ml-1 text-accent">{{
+ <span v-if="sqlHint && !readonly" class="ml-1 text-accent">{{
`(${sqlHint})`
}}</span>
</div>
@@ -38,7 +38,7 @@
</div>
<div class="space-x-2 flex items-center">
- <template v-if="create || state.editing">
+ <template v-if="(create || state.editing) && !readonly">
<label
v-if="allowFormatOnSave"
class="mt-0.5 mr-2 inline-flex items-center gap-1"
@@ -131,7 +131,7 @@ import {
useSheetV1Store,
useDatabaseV1Store,
} from "@/store";
-import { useIssueLogic } from "./logic";
+import { isGroupingChangeIssue, useIssueLogic } from "./logic";
import {
ComposedDatabase,
dialectOfEngineV1,
@@ -319,7 +319,10 @@ const getOrFetchSheetStatementByName = async (
const readonly = computed(() => {
return (
- !state.editing || !allowEditStatement.value || isTaskSheetOversize.value
+ !state.editing ||
+ !allowEditStatement.value ||
+ isTaskSheetOversize.value ||
+ isGroupingChangeIssue(issue.value as Issue)
);
});
@@ -366,6 +369,9 @@ const shouldShowStatementEditButtonForUI = computed(() => {
if (create.value) {
return false;
}
+ if (readonly.value) {
+ return false;
+ }
// For those task sheet oversized, it's readonly.
if (isTaskSheetOversize.value) {
return false;
diff --git a/frontend/src/components/Issue/logic/TenantModeProvider.ts b/frontend/src/components/Issue/logic/TenantModeProvider.ts
index d55a01347b..b41ddc9efe 100644
--- a/frontend/src/components/Issue/logic/TenantModeProvider.ts
+++ b/frontend/src/components/Issue/logic/TenantModeProvider.ts
@@ -16,6 +16,7 @@ import {
MigrationContext,
SheetId,
UNKNOWN_ID,
+ MigrationDetail,
} from "@/types";
import {
errorAssertion,
@@ -61,7 +62,7 @@ export default defineComponent({
const selectedStatement = computed(() => {
if (create.value) {
if (isGroupingIssue.value) {
- return selectedTask.value.statement;
+ return selectedTask.value.statement || "";
}
const issueCreate = issue.value as IssueCreate;
@@ -171,14 +172,19 @@ export default defineComponent({
const taskList = flattenTaskList(issueCreate);
context.detailList = [];
for (const task of taskList) {
- context.detailList.push({
+ const migrationDetail: MigrationDetail = {
migrationType: detail.migrationType,
earliestAllowedTs: detail.earliestAllowedTs,
databaseGroupName: route.query.databaseGroupName as string,
databaseId: (task as any).databaseId,
statement: (task as any).statement,
sheetId: (task as any).sheetId,
- });
+ };
+ const payload = (task as Task).payload;
+ if (payload && (payload as any).schemaGroupName) {
+ migrationDetail.schemaGroupName = (payload as any).schemaGroupName;
+ }
+ context.detailList.push(migrationDetail);
}
createIssue(issueCreate);
return;
diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.ts
index ea0f616d62..5f15253011 100644
--- a/frontend/src/components/Issue/logic/common.ts
+++ b/frontend/src/components/Issue/logic/common.ts
@@ -47,6 +47,7 @@ import {
Sheet_Source,
Sheet_Type,
} from "@/types/proto/v1/sheet_service";
+import { IssuePayload } from "@/types/proto/store/issue";
export const useCommonLogic = () => {
const {
@@ -402,6 +403,17 @@ export const isTaskEditable = (task: Task): boolean => {
return false;
};
+export const isGroupingChangeIssue = (issue: Issue): boolean => {
+ const route = useRoute();
+ if (route.query.databaseGroupName !== "") {
+ return true;
+ }
+ if ((issue.payload as IssuePayload).grouping?.databaseGroupName !== "") {
+ return true;
+ }
+ return false;
+};
+
export const getPatchingTaskList = async (
issue: Issue,
task: Task,
diff --git a/frontend/src/plugins/issue/logic/initialize/helper.ts b/frontend/src/plugins/issue/logic/initialize/helper.ts
index 64c32eeee7..ea0eec3c7e 100644
--- a/frontend/src/plugins/issue/logic/initialize/helper.ts
+++ b/frontend/src/plugins/issue/logic/initialize/helper.ts
@@ -121,6 +121,7 @@ export class IssueCreateHelper {
statement,
sheetId: UNKNOWN_ID,
earliestAllowedTs: task.earliestAllowedTs,
+ payload: task.payload,
};
}),
})),
@@ -149,7 +150,7 @@ const defaultStatementOfTask = (task: Task) => {
if (task.type === "bb.task.database.schema.baseline") {
return ESTABLISH_BASELINE_SQL;
}
- if (task.statement) {
+ if (task.statement && task.statement !== VALIDATE_ONLY_SQL) {
return task.statement;
}
diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts
index e9c9d60ec3..31a3eeea6d 100644
--- a/frontend/src/types/issue.ts
+++ b/frontend/src/types/issue.ts
@@ -14,6 +14,7 @@ import { Project } from "./project";
import { MigrationType } from "./instance";
import { Expr } from "./proto/google/type/expr";
import { DatabaseResource } from "@/components/Issue/form/SelectDatabaseResourceForm/common";
+import { IssuePayload as IssueProtoPayload } from "./proto/store/issue";
type IssueTypeGeneral = "bb.issue.general";
@@ -59,6 +60,7 @@ export type MigrationDetail = {
earliestAllowedTs: number;
databaseId?: DatabaseId;
databaseGroupName?: string;
+ schemaGroupName?: string;
rollbackEnabled?: boolean;
rollbackDetail?: RollbackDetail;
};
@@ -116,12 +118,7 @@ export interface GrantRequestPayload {
condition: Expr;
}
-export type IssuePayload =
- | {
- approval: any;
- grantRequest: GrantRequestPayload;
- }
- | { [key: string]: any };
+export type IssuePayload = IssueProtoPayload | { [key: string]: any };
export type Issue = {
id: IssueId;
diff --git a/frontend/src/types/pipeline/task.ts b/frontend/src/types/pipeline/task.ts
index d06be27876..667ef30c9c 100644
--- a/frontend/src/types/pipeline/task.ts
+++ b/frontend/src/types/pipeline/task.ts
@@ -71,6 +71,7 @@ export type TaskDatabaseSchemaUpdatePayload = {
skippedReason: string;
statement: string;
sheetId: SheetId;
+ schemaGroupName?: string;
pushEvent?: VCSPushEvent;
};
@@ -121,6 +122,7 @@ export type TaskDatabaseDataUpdatePayload = {
skippedReason: string;
statement: string;
sheetId: SheetId;
+ schemaGroupName?: string;
pushEvent?: VCSPushEvent;
rollbackEnabled: boolean;
rollbackSqlStatus?: RollbackSQLStatus;
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index ab11b335d3..8e293ab059 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -397,7 +397,7 @@ const saveEdit = async () => {
if (userPatch.email !== user.value.email) {
updateMask.push("email");
}
- if (userPatch.phone !== user.value.phone) {
+ if (userPatch.phone && userPatch.phone !== user.value.phone) {
updateMask.push("phone");
}
if (userPatch.password !== user.value.email) {