Browse Source

feat: allow overwriting props of duplicated project

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5752/head
mertmit 1 year ago
parent
commit
ae1a1e0ca9
  1. 7
      packages/nc-gui/components/dlg/ProjectDuplicate.vue
  2. 2
      packages/nc-gui/components/dlg/TableDuplicate.vue
  3. 24
      packages/nocodb-sdk/src/lib/Api.ts
  4. 32
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  5. 77
      packages/nocodb/src/schema/swagger.json

7
packages/nc-gui/components/dlg/ProjectDuplicate.vue

@ -34,7 +34,12 @@ const isLoading = ref(false)
const _duplicate = async () => {
isLoading.value = true
try {
const jobData = await api.project.duplicate(props.project.id as string, optionsToExclude.value)
const jobData = await api.project.duplicate(props.project.id as string, {
options: optionsToExclude.value,
project: {
meta: props.project.meta,
},
})
props.onOk(jobData as any)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))

2
packages/nc-gui/components/dlg/TableDuplicate.vue

@ -34,7 +34,7 @@ const isLoading = ref(false)
const _duplicate = async () => {
isLoading.value = true
try {
const jobData = await api.dbTable.duplicate(props.table.project_id!, props.table.id!, optionsToExclude.value)
const jobData = await api.dbTable.duplicate(props.table.project_id!, props.table.id!, { options: optionsToExclude.value })
props.onOk(jobData as any)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))

24
packages/nocodb-sdk/src/lib/Api.ts

@ -4032,9 +4032,12 @@ export class Api<
baseDuplicate: (
projectId: IdType,
data: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
options?: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
};
project?: object;
},
baseId?: IdType,
params: RequestParams = {}
@ -4078,9 +4081,12 @@ export class Api<
duplicate: (
projectId: IdType,
data: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
options?: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
};
project?: object;
},
params: RequestParams = {}
) =>
@ -5118,8 +5124,10 @@ export class Api<
projectId: IdType,
tableId: IdType,
data: {
excludeData?: boolean;
excludeViews?: boolean;
options?: {
excludeData?: boolean;
excludeViews?: boolean;
};
},
params: RequestParams = {}
) =>

32
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts

@ -35,10 +35,14 @@ export class DuplicateController {
@Param('projectId') projectId: string,
@Param('baseId') baseId?: string,
@Body()
options?: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
body?: {
options?: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
};
// override duplicated project
project?: any;
},
) {
const project = await Project.get(projectId);
@ -63,7 +67,11 @@ export class DuplicateController {
);
const dupProject = await this.projectsService.projectCreate({
project: { title: uniqueTitle, status: ProjectStatus.JOB },
project: {
title: uniqueTitle,
status: ProjectStatus.JOB,
...(body.project || {}),
},
user: { id: req.user.id },
});
@ -71,7 +79,7 @@ export class DuplicateController {
projectId: project.id,
baseId: base.id,
dupProjectId: dupProject.id,
options,
options: body.options || {},
req: {
user: req.user,
clientIp: req.clientIp,
@ -89,10 +97,12 @@ export class DuplicateController {
@Param('projectId') projectId: string,
@Param('modelId') modelId?: string,
@Body()
options?: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
body?: {
options?: {
excludeData?: boolean;
excludeViews?: boolean;
excludeHooks?: boolean;
};
},
) {
const project = await Project.get(projectId);
@ -121,7 +131,7 @@ export class DuplicateController {
baseId: base.id,
modelId: model.id,
title: uniqueTitle,
options,
options: body.options || {},
req: {
user: req.user,
clientIp: req.clientIp,

77
packages/nocodb/src/schema/swagger.json

@ -2133,16 +2133,25 @@
"schema": {
"type": "object",
"properties": {
"excludeData": {
"type": "boolean",
"required": false
},
"excludeViews": {
"type": "boolean",
"required": false
"options": {
"type": "object",
"properties": {
"excludeData": {
"type": "boolean",
"required": false
},
"excludeViews": {
"type": "boolean",
"required": false
},
"excludeHooks": {
"type": "boolean",
"required": false
}
}
},
"excludeHooks": {
"type": "boolean",
"project": {
"type": "object",
"required": false
}
}
@ -2223,16 +2232,25 @@
"schema": {
"type": "object",
"properties": {
"excludeData": {
"type": "boolean",
"required": false
},
"excludeViews": {
"type": "boolean",
"required": false
"options": {
"type": "object",
"properties": {
"excludeData": {
"type": "boolean",
"required": false
},
"excludeViews": {
"type": "boolean",
"required": false
},
"excludeHooks": {
"type": "boolean",
"required": false
}
}
},
"excludeHooks": {
"type": "boolean",
"project": {
"type": "object",
"required": false
}
}
@ -3978,13 +3996,22 @@
"schema": {
"type": "object",
"properties": {
"excludeData": {
"type": "boolean",
"required": false
},
"excludeViews": {
"type": "boolean",
"required": false
"options": {
"type": "object",
"properties": {
"excludeData": {
"type": "boolean",
"required": false
},
"excludeViews": {
"type": "boolean",
"required": false
},
"excludeHooks": {
"type": "boolean",
"required": false
}
}
}
}
},

Loading…
Cancel
Save