From 85ab936c4c3f1f096ffd1e97d44073e17b04797d Mon Sep 17 00:00:00 2001 From: Chareice Date: Wed, 9 Feb 2022 21:11:29 +0800 Subject: [PATCH] chore: server hooks --- packages/plugin-ui-schema-storage/src/model.ts | 10 +--------- .../plugin-ui-schema-storage/src/server-hooks/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/plugin-ui-schema-storage/src/model.ts b/packages/plugin-ui-schema-storage/src/model.ts index 3aee2ec0e..889502684 100644 --- a/packages/plugin-ui-schema-storage/src/model.ts +++ b/packages/plugin-ui-schema-storage/src/model.ts @@ -1,13 +1,5 @@ import { MagicAttributeModel } from '@nocobase/database'; -import { HookType } from './server-hooks'; -class UiSchemaModel extends MagicAttributeModel { - getListenServerHooks(type: HookType) { - const hooks = this.get('x-server-hooks') || []; - return hooks.filter((hook) => { - hook.type = ''; - }); - } -} +class UiSchemaModel extends MagicAttributeModel {} export { UiSchemaModel }; diff --git a/packages/plugin-ui-schema-storage/src/server-hooks/index.ts b/packages/plugin-ui-schema-storage/src/server-hooks/index.ts index 4a08ee0c0..cc066aca0 100644 --- a/packages/plugin-ui-schema-storage/src/server-hooks/index.ts +++ b/packages/plugin-ui-schema-storage/src/server-hooks/index.ts @@ -2,7 +2,7 @@ import { Database } from '@nocobase/database'; import { ServerHookModel } from './model'; export type HookType = - | 'onSchemaDestroy' + | 'onSelfDestroy' | 'onCollectionDestroy' | 'onCollectionFieldDestroy' | 'onAnyCollectionFieldDestroy' @@ -82,16 +82,16 @@ export class ServerHooks { ); } - protected async onUiSchemaCreate(uiSchemaModel, options) { + protected async onUiSchemaCreate(schemaInstance, options) { const { transaction } = options; await this.findHooksAndCall( { type: 'onSelfCreate', - uid: uiSchemaModel.schema['x-uid'], + uid: schemaInstance.schema['x-uid'], }, { - uiSchemaModel, + schemaInstance, options, }, transaction,