diff --git a/packages/plugin-ui-schema-storage/src/__tests__/server-hook.test.ts b/packages/plugin-ui-schema-storage/src/__tests__/server-hook.test.ts index 5e3d06077..6bbab2aa4 100644 --- a/packages/plugin-ui-schema-storage/src/__tests__/server-hook.test.ts +++ b/packages/plugin-ui-schema-storage/src/__tests__/server-hook.test.ts @@ -1,13 +1,13 @@ import { mockServer, MockServer } from '@nocobase/test'; import { Database } from '@nocobase/database'; -import PluginUiSchema, { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage'; +import UiSchemaStoragePlugin, { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage'; import PluginCollectionManager from '@nocobase/plugin-collection-manager'; describe('server hooks', () => { let app: MockServer; let db: Database; let uiSchemaRepository: UiSchemaRepository; - let uiSchemaPlugin: PluginUiSchema; + let uiSchemaPlugin: UiSchemaStoragePlugin; const schema = { 'x-uid': 'root', @@ -61,7 +61,7 @@ describe('server hooks', () => { db = app.db; await app.cleanDb(); - app.plugin(PluginUiSchema); + app.plugin(UiSchemaStoragePlugin); app.plugin(PluginCollectionManager); await app.loadAndInstall(); @@ -69,7 +69,7 @@ describe('server hooks', () => { uiSchemaRepository = db.getRepository('ui_schemas'); await uiSchemaRepository.insert(schema); - uiSchemaPlugin = app.getPlugin('PluginUiSchema'); + uiSchemaPlugin = app.getPlugin('UiSchemaStoragePlugin'); }); it('should call server hooks onFieldDestroy', async () => { diff --git a/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-model.test.ts b/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-model.test.ts index dcade8141..0a46fd4f2 100644 --- a/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-model.test.ts +++ b/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-model.test.ts @@ -78,7 +78,6 @@ describe('ui schema model', () => { name: 'root-node', 'x-uid': 'root-uid', 'x-async': false, - 'x-index': null, }); }); @@ -138,7 +137,6 @@ describe('ui schema model', () => { name: 'new-root-name', 'x-uid': 'root-uid', 'x-async': false, - 'x-index': null, }); }); }); diff --git a/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-repository.test.ts b/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-repository.test.ts index e3f2f48f1..03c6b1c23 100644 --- a/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-repository.test.ts +++ b/packages/plugin-ui-schema-storage/src/__tests__/ui-schema-repository.test.ts @@ -196,7 +196,6 @@ describe('ui_schema repository', () => { name: 'root-name', 'x-uid': 'root', 'x-async': false, - 'x-index': null, }); }); diff --git a/packages/plugin-ui-schema-storage/src/repository.ts b/packages/plugin-ui-schema-storage/src/repository.ts index d28e1deb5..e313bc813 100644 --- a/packages/plugin-ui-schema-storage/src/repository.ts +++ b/packages/plugin-ui-schema-storage/src/repository.ts @@ -128,9 +128,12 @@ export class UiSchemaRepository extends Repository { ...lodash.pick(node, [...nodeKeys, 'name']), ['x-uid']: node.uid, ['x-async']: !!node.async, - ['x-index']: node.sort, }; + if (lodash.isNumber(node.sort)) { + schema['x-index'] = node.sort; + } + return schema; };