fix: ui schema storage (#187)

* fix: test

* chore: root schema x-index
This commit is contained in:
ChengLei Shao 2022-02-13 09:38:41 +08:00 committed by GitHub
parent 51ca12cc87
commit 2e2b5cd938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -1,13 +1,13 @@
import { mockServer, MockServer } from '@nocobase/test'; import { mockServer, MockServer } from '@nocobase/test';
import { Database } from '@nocobase/database'; 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'; import PluginCollectionManager from '@nocobase/plugin-collection-manager';
describe('server hooks', () => { describe('server hooks', () => {
let app: MockServer; let app: MockServer;
let db: Database; let db: Database;
let uiSchemaRepository: UiSchemaRepository; let uiSchemaRepository: UiSchemaRepository;
let uiSchemaPlugin: PluginUiSchema; let uiSchemaPlugin: UiSchemaStoragePlugin;
const schema = { const schema = {
'x-uid': 'root', 'x-uid': 'root',
@ -61,7 +61,7 @@ describe('server hooks', () => {
db = app.db; db = app.db;
await app.cleanDb(); await app.cleanDb();
app.plugin(PluginUiSchema); app.plugin(UiSchemaStoragePlugin);
app.plugin(PluginCollectionManager); app.plugin(PluginCollectionManager);
await app.loadAndInstall(); await app.loadAndInstall();
@ -69,7 +69,7 @@ describe('server hooks', () => {
uiSchemaRepository = db.getRepository('ui_schemas'); uiSchemaRepository = db.getRepository('ui_schemas');
await uiSchemaRepository.insert(schema); await uiSchemaRepository.insert(schema);
uiSchemaPlugin = app.getPlugin<PluginUiSchema>('PluginUiSchema'); uiSchemaPlugin = app.getPlugin<UiSchemaStoragePlugin>('UiSchemaStoragePlugin');
}); });
it('should call server hooks onFieldDestroy', async () => { it('should call server hooks onFieldDestroy', async () => {

View File

@ -78,7 +78,6 @@ describe('ui schema model', () => {
name: 'root-node', name: 'root-node',
'x-uid': 'root-uid', 'x-uid': 'root-uid',
'x-async': false, 'x-async': false,
'x-index': null,
}); });
}); });
@ -138,7 +137,6 @@ describe('ui schema model', () => {
name: 'new-root-name', name: 'new-root-name',
'x-uid': 'root-uid', 'x-uid': 'root-uid',
'x-async': false, 'x-async': false,
'x-index': null,
}); });
}); });
}); });

View File

@ -196,7 +196,6 @@ describe('ui_schema repository', () => {
name: 'root-name', name: 'root-name',
'x-uid': 'root', 'x-uid': 'root',
'x-async': false, 'x-async': false,
'x-index': null,
}); });
}); });

View File

@ -128,9 +128,12 @@ export class UiSchemaRepository extends Repository {
...lodash.pick(node, [...nodeKeys, 'name']), ...lodash.pick(node, [...nodeKeys, 'name']),
['x-uid']: node.uid, ['x-uid']: node.uid,
['x-async']: !!node.async, ['x-async']: !!node.async,
['x-index']: node.sort,
}; };
if (lodash.isNumber(node.sort)) {
schema['x-index'] = node.sort;
}
return schema; return schema;
}; };