mirror of
https://github.com/nocobase/nocobase.git
synced 2026-09-19 02:23:00 +08:00
fix(plugin-multi-portal): handle empty type (#10212)
This commit is contained in:
+17
-3
@@ -89,12 +89,26 @@ describe('Multi Portal runtime registration failures', () => {
|
||||
expect(layoutManager.registerLayout).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('registers only no-code portals and skips every other portal type', () => {
|
||||
it('treats empty portal types as no-code portals', () => {
|
||||
const layoutManager = createLayoutManager();
|
||||
const emptyTypePortals = [
|
||||
{ ...portal, uid: 'missing-type-portal', portalName: 'missingType', portalType: undefined },
|
||||
{ ...portal, uid: 'null-type-portal', portalName: 'nullType', portalType: null },
|
||||
{ ...portal, uid: 'empty-type-portal', portalName: 'emptyType', portalType: '' },
|
||||
];
|
||||
|
||||
expect(registerMultiPortalRecords(layoutManager, emptyTypePortals)).toEqual([
|
||||
'missing-type-portal',
|
||||
'null-type-portal',
|
||||
'empty-type-portal',
|
||||
]);
|
||||
expect(layoutManager.registerLayout).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it('skips ai and unknown non-empty portal types', () => {
|
||||
const layoutManager = createLayoutManager();
|
||||
const skippedPortals = [
|
||||
{ ...portal, uid: 'ai-portal', portalName: 'ai', portalType: 'ai' },
|
||||
{ ...portal, uid: 'missing-type-portal', portalName: 'missingType', portalType: undefined },
|
||||
{ ...portal, uid: 'empty-type-portal', portalName: 'emptyType', portalType: '' },
|
||||
{ ...portal, uid: 'unknown-type-portal', portalName: 'unknownType', portalType: 'custom' },
|
||||
];
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export { getMultiPortalRouteScopeCacheKey };
|
||||
export type MultiPortalRuntimeRecord = {
|
||||
uid: string;
|
||||
title?: string;
|
||||
portalType?: string;
|
||||
portalType?: string | null;
|
||||
portalName: string;
|
||||
routePath: string;
|
||||
authCheck: boolean;
|
||||
@@ -74,7 +74,7 @@ const layoutModeMobileRegisterOptions = {
|
||||
} satisfies Pick<LayoutRegisterOptions, 'layoutModelClass' | 'rootPageModelClass' | 'childPageModelClass'>;
|
||||
|
||||
function isRuntimePortal(record: MultiPortalRuntimeRecord) {
|
||||
return record.portalType === 'no-code';
|
||||
return (record.portalType || 'no-code') === 'no-code';
|
||||
}
|
||||
|
||||
export function toMultiPortalLayoutRegisterOptions(record: MultiPortalRuntimeRecord): LayoutRegisterOptions | null {
|
||||
|
||||
Reference in New Issue
Block a user