feat: removeSchema Hook with params

This commit is contained in:
Chareice 2022-02-10 20:39:05 +08:00 committed by chenos
parent 34f33844d5
commit 0667efefb4

View File

@ -0,0 +1,18 @@
import { hookFactory } from './factory';
import { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage';
export async function removeSchema({ schemaInstance, options, db, params }) {
const { transaction } = options;
const uiSchemaRepository: UiSchemaRepository = db.getRepository('ui_schemas');
const uid = schemaInstance.get('uid') as string;
if (params?.removeEmptyParents) {
await uiSchemaRepository.removeEmptyParents({
uid,
breakComponent: params['breakComponent'],
transaction,
});
} else {
await uiSchemaRepository.remove(uid);
}
}