fix(ui-schema-storage): duplicate of empty schema
This commit is contained in:
parent
29b47c1d40
commit
5de28cd4c4
@ -225,6 +225,11 @@ describe('ui_schema repository', () => {
|
|||||||
expect(s2['x-uid']).not.toEqual(s['x-uid']);
|
expect(s2['x-uid']).not.toEqual(s['x-uid']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be null', async () => {
|
||||||
|
const s2 = await repository.duplicate('test-null');
|
||||||
|
expect(s2).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
describe('schema', () => {
|
describe('schema', () => {
|
||||||
let schema;
|
let schema;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -445,6 +445,9 @@ export class UiSchemaRepository extends Repository {
|
|||||||
@transaction()
|
@transaction()
|
||||||
async duplicate(uid: string, options?: Transactionable) {
|
async duplicate(uid: string, options?: Transactionable) {
|
||||||
const s = await this.getJsonSchema(uid, { ...options, includeAsyncNode: true });
|
const s = await this.getJsonSchema(uid, { ...options, includeAsyncNode: true });
|
||||||
|
if (!s?.['x-uid']) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
this.regenerateUid(s);
|
this.regenerateUid(s);
|
||||||
return this.insert(s, options);
|
return this.insert(s, options);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user