mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 04:05:13 +00:00
fix: bug
This commit is contained in:
parent
08ccdb2964
commit
6ac6f050c2
@ -20,17 +20,18 @@ export const CollectionProvider: FC<{
|
||||
const collectionName = getCollectionName(name || collection);
|
||||
const cm = useCollectionManagerV2();
|
||||
const hasCollection = cm.getCollection(collectionName);
|
||||
if (hasCollection || allowNull)
|
||||
if (hasCollection || (allowNull && !collection))
|
||||
return (
|
||||
<CollectionProviderV2 allowNull={allowNull} name={collectionName}>
|
||||
{children}
|
||||
</CollectionProviderV2>
|
||||
);
|
||||
if (typeof collection === 'object')
|
||||
if (typeof collection === 'object') {
|
||||
return (
|
||||
<CollectionManagerProvider collections={[collection]}>
|
||||
<CollectionProviderV2 name={collection.name}>{children}</CollectionProviderV2>
|
||||
</CollectionManagerProvider>
|
||||
);
|
||||
}
|
||||
return <DeletedPlaceholder type="Collection" name={name} />;
|
||||
};
|
||||
|
@ -4,15 +4,15 @@ import { message } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAPIClient } from '../../../api-client';
|
||||
import { i18n } from '../../../i18n';
|
||||
import { CollectionOptions } from '../../types';
|
||||
import { CollectionCategory } from '../components/CollectionCategory';
|
||||
import { CollectionTemplate } from '../components/CollectionTemplate';
|
||||
import { CollectionOptionsV2 } from '../../../application';
|
||||
|
||||
const compile = (source) => {
|
||||
return Schema.compile(source, { t: i18n.t });
|
||||
};
|
||||
|
||||
export const collection: CollectionOptions = {
|
||||
export const collection: CollectionOptionsV2 = {
|
||||
name: 'collections',
|
||||
filterTargetKey: 'name',
|
||||
targetKey: 'name',
|
||||
|
@ -41,6 +41,7 @@ import { InheritanceCollectionMixin } from './mixins/InheritanceCollectionMixin'
|
||||
// import { general, expression, sql, tree, view } from './templates';
|
||||
import { interfaces } from './Configuration/interfaces';
|
||||
import { collectionTemplates } from './Configuration/templates';
|
||||
import { collection } from './Configuration/schemas/collections';
|
||||
|
||||
export class CollectionPlugin extends Plugin {
|
||||
async load() {
|
||||
@ -114,6 +115,6 @@ export class CollectionPlugin extends Plugin {
|
||||
},
|
||||
});
|
||||
|
||||
return service?.data?.data || [];
|
||||
return [...(service?.data?.data || []), collection];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user