Browse Source

feat: allow virtual column duplication(except LTAR and Links)

pull/8708/head
Pranav C 5 months ago
parent
commit
4a308757de
  1. 2
      packages/nc-gui/components/smartsheet/header/Menu.vue
  2. 11
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts

2
packages/nc-gui/components/smartsheet/header/Menu.vue

@ -393,7 +393,7 @@ const isColumnCRUDAllowed = computed(() => {
</div> </div>
</NcMenuItem> </NcMenuItem>
<NcMenuItem <NcMenuItem
v-if="isUIAllowed('duplicateColumn') && isExpandedForm && !column?.pk" v-if="isUIAllowed('duplicateColumn') && isExpandedForm && !column?.pk && isColumnCRUDAllowed"
:disabled="!isDuplicateAllowed" :disabled="!isDuplicateAllowed"
@click="openDuplicateDlg" @click="openDuplicateDlg"
> >

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

@ -8,7 +8,12 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ProjectStatus, SourceRestriction } from 'nocodb-sdk'; import {
ProjectStatus,
readonlyMetaAllowedTypes,
SourceRestriction,
} from 'nocodb-sdk';
import type { UITypes } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { BasesService } from '~/services/bases.service'; import { BasesService } from '~/services/bases.service';
@ -287,13 +292,15 @@ export class DuplicateController {
const source = await Source.get(context, model.source_id); const source = await Source.get(context, model.source_id);
// if data/schema is readonly, then restrict duplication // check if source is readonly and column type is not allowed
if (!readonlyMetaAllowedTypes.includes(column.uidt as UITypes)) {
if (source.is_schema_readonly) { if (source.is_schema_readonly) {
NcError.sourceMetaReadOnly(source.alias); NcError.sourceMetaReadOnly(source.alias);
} }
if (source.is_data_readonly) { if (source.is_data_readonly) {
NcError.sourceDataReadOnly(source.alias); NcError.sourceDataReadOnly(source.alias);
} }
}
const job = await this.jobsService.add(JobTypes.DuplicateColumn, { const job = await this.jobsService.add(JobTypes.DuplicateColumn, {
context, context,

Loading…
Cancel
Save