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 { 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>('PluginUiSchema');
uiSchemaPlugin = app.getPlugin<UiSchemaStoragePlugin>('UiSchemaStoragePlugin');
});
it('should call server hooks onFieldDestroy', async () => {

View File

@ -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,
});
});
});

View File

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

View File

@ -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;
};