Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): byt-920 allow to edit sql statement in tenant mode isue (#2018)
Liu Jifd1449d37dbe
diff --git a/frontend/src/components/Issue/logic/TenantModeProvider.ts b/frontend/src/components/Issue/logic/TenantModeProvider.tsindex acb0190022..fd54e2ff8c 100644--- a/frontend/src/components/Issue/logic/TenantModeProvider.ts+++ b/frontend/src/components/Issue/logic/TenantModeProvider.ts@@ -1,9 +1,10 @@import { computed, defineComponent } from "vue";import { cloneDeep } from "lodash-es";-import { useDatabaseStore } from "@/store";+import { useDatabaseStore, useTaskStore } from "@/store";import {Issue,IssueCreate,+ Task,TaskCreate,TaskDatabaseSchemaUpdatePayload,UpdateSchemaContext,@@ -11,6 +12,7 @@ import {import {errorAssertion,flattenTaskList,+ isTaskEditable,maybeFormatStatementOnSave,useCommonLogic,} from "./common";@@ -19,15 +21,16 @@ import { provideIssueLogic, useIssueLogic } from "./index";export default defineComponent({name: "TenantModeProvider",setup() {- const { create, issue, createIssue } = useIssueLogic();+ const { create, issue, createIssue, onStatusChanged } = useIssueLogic();const databaseStore = useDatabaseStore();+ const taskStore = useTaskStore();const allowEditStatement = computed(() => {if (create.value) {return true;}- // Once a tenant-mode issue created, its statement can never be changed.- return false;+ const tasks = flattenTaskList<Task>(issue.value);+ return tasks.every((task) => isTaskEditable(task));});// In tenant mode, the entire issue shares only one SQL statement@@ -44,7 +47,10 @@ export default defineComponent({}});- const updateStatement = (newStatement: string) => {+ const updateStatement = (+ newStatement: string,+ postUpdated?: (updatedTask: Task) => void+ ) => {if (create.value) {// For tenant deploy mode, we apply the statement to all stages and all tasksconst allTaskList = flattenTaskList<TaskCreate>(issue.value);@@ -59,8 +65,21 @@ export default defineComponent({(detail) => (detail.statement = newStatement));} else {- // But not editable in non-create mode- errorAssertion();+ const issueEntity = issue.value as Issue;+ taskStore+ .patchAllTasksInIssue({+ issueId: issueEntity.id,+ pipelineId: issueEntity.pipeline.id,+ taskPatch: {+ statement: newStatement,+ },+ })+ .then(() => {+ onStatusChanged(true);+ if (postUpdated) {+ postUpdated(issueEntity.pipeline.stageList[0].taskList[0]);+ }+ });}};diff --git a/frontend/src/store/modules/task.ts b/frontend/src/store/modules/task.tsindex d86efd4c49..a6cd7173d3 100644--- a/frontend/src/store/modules/task.ts+++ b/frontend/src/store/modules/task.ts@@ -276,6 +276,24 @@ export const useTaskStore = defineStore("task", {return task;},+ async patchAllTasksInIssue({+ issueId,+ pipelineId,+ taskPatch,+ }: {+ issueId: IssueId;+ pipelineId: PipelineId;+ taskPatch: TaskPatch;+ }) {+ await axios.patch(`/api/pipeline/${pipelineId}/task/all`, {+ data: {+ type: "taskPatch",+ attributes: taskPatch,+ },+ });++ useIssueStore().fetchIssueById(issueId);+ },async runChecks({issueId,pipelineId,diff --git a/frontend/src/types/pipeline/task.ts b/frontend/src/types/pipeline/task.tsindex 1f688b20ff..981e395fc8 100644--- a/frontend/src/types/pipeline/task.ts+++ b/frontend/src/types/pipeline/task.ts@@ -153,15 +153,14 @@ export type TaskPatch = {statement?: string;earliestAllowedTs?: number;- updatedTs: number;+ updatedTs?: number;};-export type TaskStatusPatch = {// Domain specific fieldsstatus: TaskStatus;comment?: string;- updatedTs: number;+ updatedTs?: number;};// TaskRun is one run of a particular task