fix: content loading
This commit is contained in:
parent
8acba12025
commit
d32261bb88
@ -1,5 +1,5 @@
|
|||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useAPIClient, useRequest } from '../api-client';
|
import { useAPIClient, useRequest } from '../api-client';
|
||||||
import { CollectionManagerSchemaComponentProvider } from './CollectionManagerSchemaComponentProvider';
|
import { CollectionManagerSchemaComponentProvider } from './CollectionManagerSchemaComponentProvider';
|
||||||
import { CollectionManagerContext } from './context';
|
import { CollectionManagerContext } from './context';
|
||||||
@ -28,6 +28,7 @@ export const CollectionManagerProvider: React.FC<CollectionManagerOptions> = (pr
|
|||||||
|
|
||||||
export const RemoteCollectionManagerProvider = (props: any) => {
|
export const RemoteCollectionManagerProvider = (props: any) => {
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
|
const [contentLoading, setContentLoading] = useState(false);
|
||||||
const options = {
|
const options = {
|
||||||
resource: 'collections',
|
resource: 'collections',
|
||||||
action: 'list',
|
action: 'list',
|
||||||
@ -46,11 +47,13 @@ export const RemoteCollectionManagerProvider = (props: any) => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<CollectionManagerProvider
|
<CollectionManagerProvider
|
||||||
service={service}
|
service={{...service, contentLoading, setContentLoading}}
|
||||||
collections={service?.data?.data}
|
collections={service?.data?.data}
|
||||||
refreshCM={async () => {
|
refreshCM={async () => {
|
||||||
|
setContentLoading(true);
|
||||||
const { data } = await api.request(options);
|
const { data } = await api.request(options);
|
||||||
service.mutate(data);
|
service.mutate(data);
|
||||||
|
setContentLoading(false);
|
||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { Layout } from 'antd';
|
import { Layout, Spin } from 'antd';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import { useHistory, useRouteMatch } from 'react-router-dom';
|
import { useHistory, useRouteMatch } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
ACLAllowConfigure, ACLRolesCheckProvider,
|
ACLAllowConfigure,
|
||||||
|
ACLRolesCheckProvider,
|
||||||
CurrentUser,
|
CurrentUser,
|
||||||
CurrentUserProvider,
|
CurrentUserProvider,
|
||||||
findByUid,
|
findByUid,
|
||||||
@ -17,6 +18,7 @@ import {
|
|||||||
useRoute,
|
useRoute,
|
||||||
useSystemSettings
|
useSystemSettings
|
||||||
} from '../../../';
|
} from '../../../';
|
||||||
|
import { useCollectionManager } from '../../../collection-manager';
|
||||||
import { PoweredBy } from '../../../powered-by';
|
import { PoweredBy } from '../../../powered-by';
|
||||||
|
|
||||||
const filterByACL = (schema, options) => {
|
const filterByACL = (schema, options) => {
|
||||||
@ -56,6 +58,7 @@ const InternalAdminLayout = (props: any) => {
|
|||||||
};
|
};
|
||||||
const [hidden, setHidden] = useState(false);
|
const [hidden, setHidden] = useState(false);
|
||||||
const result = useSystemSettings();
|
const result = useSystemSettings();
|
||||||
|
const { service } = useCollectionManager();
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Layout.Header
|
<Layout.Header
|
||||||
@ -156,7 +159,7 @@ const InternalAdminLayout = (props: any) => {
|
|||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{props.children}
|
{service.contentLoading ? <Spin /> : props.children}
|
||||||
<Layout.Footer>
|
<Layout.Footer>
|
||||||
<PoweredBy />
|
<PoweredBy />
|
||||||
</Layout.Footer>
|
</Layout.Footer>
|
||||||
|
Loading…
Reference in New Issue
Block a user