Browse Source

feat: restrict deleting first base

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3573/head
mertmit 2 years ago
parent
commit
3c99a3e79f
  1. 10
      packages/nc-gui/components/dashboard/settings/DataSources.vue
  2. 4
      packages/nocodb/src/lib/models/Base.ts

10
packages/nc-gui/components/dashboard/settings/DataSources.vue

@ -246,16 +246,6 @@ watch(
Edit
</div>
</a-button>
<a-button
v-if="!sources[0].is_meta"
class="nc-action-btn cursor-pointer outline-0"
@click="deleteBase(sources[0])"
>
<div class="flex items-center gap-2 text-red-500 font-light">
<MdiDeleteOutline class="text-lg group-hover:text-accent" />
Delete
</div>
</a-button>
</div>
</div>
</div>

4
packages/nocodb/src/lib/models/Base.ts

@ -289,6 +289,10 @@ export default class Base implements BaseType {
}
async delete(ncMeta = Noco.ncMeta) {
const bases = await Base.list({ projectId: this.project_id }, ncMeta);
if (bases[0].id === this.id) NcError.badRequest('Cannot delete first base');
const models = await Model.list(
{
base_id: this.id,

Loading…
Cancel
Save