mirror of
https://github.com/strapi/strapi.git
synced 2025-12-02 01:52:21 +00:00
add offline layout
This commit is contained in:
parent
3bf25de33e
commit
a083dadce9
@ -0,0 +1,5 @@
|
||||
<svg width="88" height="88" viewBox="0 0 88 88" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0.5" y="0.5" width="87" height="87" rx="43.5" fill="#F0F0FF"/>
|
||||
<path d="M34.0469 39.2969H30C27.4479 39.2969 25.2604 40.2448 23.4375 42.1406C21.6146 43.9635 20.7031 46.151 20.7031 48.7031C20.7031 51.2552 21.6146 53.4427 23.4375 55.2656C25.2604 57.0885 27.4479 58 30 58H52.75L34.0469 39.2969ZM23 28.25L25.9531 25.2969L65 64.3438L62.0469 67.2969L57.3438 62.7031H30C26.1354 62.7031 22.8177 61.3542 20.0469 58.6562C17.349 55.8854 16 52.5677 16 48.7031C16 44.9115 17.3125 41.6667 19.9375 38.9688C22.5625 36.2708 25.7344 34.849 29.4531 34.7031L23 28.25ZM61.1719 39.4062C64.1615 39.625 66.7135 40.8646 68.8281 43.125C70.9427 45.3125 72 47.9375 72 51C72 55.0104 70.3594 58.1823 67.0781 60.5156L63.6875 57.125C66.0938 55.8125 67.2969 53.7708 67.2969 51C67.2969 49.1042 66.6042 47.4635 65.2188 46.0781C63.8333 44.6927 62.1927 44 60.2969 44H56.7969V42.7969C56.7969 39.224 55.5573 36.1979 53.0781 33.7188C50.599 31.2396 47.5729 30 44 30C41.9583 30 39.9896 30.474 38.0938 31.4219L34.5938 28.0312C37.4375 26.2083 40.5729 25.2969 44 25.2969C47.9375 25.2969 51.5833 26.6823 54.9375 29.4531C58.3646 32.224 60.4427 35.5417 61.1719 39.4062Z" fill="#4945FF"/>
|
||||
<rect x="0.5" y="0.5" width="87" height="87" rx="43.5" stroke="#D9D8FF"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@ -19,6 +19,8 @@ import { Searchbar } from '@strapi/design-system/Searchbar';
|
||||
import { Box } from '@strapi/design-system/Box';
|
||||
import { LinkButton } from '@strapi/design-system/LinkButton';
|
||||
import { useNotifyAT } from '@strapi/design-system/LiveRegions';
|
||||
import { Typography } from '@strapi/design-system/Typography';
|
||||
import { Flex } from '@strapi/design-system/Flex';
|
||||
import Upload from '@strapi/icons/Upload';
|
||||
|
||||
import PluginCard from './components/PluginCard';
|
||||
@ -27,6 +29,7 @@ import { fetchAppInformation } from './utils/api';
|
||||
import useFetchInstalledPlugins from '../../hooks/useFetchInstalledPlugins';
|
||||
import useFetchMarketplacePlugins from '../../hooks/useFetchMarketplacePlugins';
|
||||
import adminPermissions from '../../permissions';
|
||||
import offlineCloud from '../../assets/images/icon_offline-cloud.svg';
|
||||
|
||||
const matchSearch = (plugins, search) => {
|
||||
return matchSorter(plugins, search, {
|
||||
@ -40,6 +43,30 @@ const matchSearch = (plugins, search) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getOnLineStatus = () =>
|
||||
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean'
|
||||
? navigator.onLine
|
||||
: true;
|
||||
|
||||
const useNavigatorOnLine = () => {
|
||||
const [status, setStatus] = React.useState(getOnLineStatus());
|
||||
|
||||
const setOnline = () => setStatus(true);
|
||||
const setOffline = () => setStatus(false);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('online', setOnline);
|
||||
window.addEventListener('offline', setOffline);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('online', setOnline);
|
||||
window.removeEventListener('offline', setOffline);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
const MarketPlacePage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { trackUsage } = useTracking();
|
||||
@ -48,6 +75,7 @@ const MarketPlacePage = () => {
|
||||
const toggleNotification = useNotification();
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const { autoReload: isInDevelopmentMode } = useAppInfos();
|
||||
const isOnline = useNavigatorOnLine();
|
||||
|
||||
useFocusWhenNavigate();
|
||||
|
||||
@ -116,6 +144,56 @@ const MarketPlacePage = () => {
|
||||
}
|
||||
}, [toggleNotification, isInDevelopmentMode]);
|
||||
|
||||
if (!isOnline) {
|
||||
return (
|
||||
<Layout>
|
||||
<HeaderLayout
|
||||
title={formatMessage({
|
||||
id: 'global.marketplace',
|
||||
defaultMessage: 'Marketplace',
|
||||
})}
|
||||
subtitle={formatMessage({
|
||||
id: 'admin.pages.MarketPlacePage.subtitle',
|
||||
defaultMessage: 'Get more out of Strapi',
|
||||
})}
|
||||
primaryAction={
|
||||
<LinkButton
|
||||
startIcon={<Upload />}
|
||||
variant="tertiary"
|
||||
href="https://market.strapi.io/submit-plugin"
|
||||
onClick={() => trackUsage('didSubmitPlugin')}
|
||||
>
|
||||
{formatMessage({
|
||||
id: 'admin.pages.MarketPlacePage.submit.plugin.link',
|
||||
defaultMessage: 'Submit your plugin',
|
||||
})}
|
||||
</LinkButton>
|
||||
}
|
||||
/>
|
||||
|
||||
<Flex
|
||||
width="100%"
|
||||
direction="column"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
paddingTop={11}
|
||||
>
|
||||
<Box paddingTop={8} paddingBottom={1}>
|
||||
<Typography textColor="neutral700" variant="alpha">
|
||||
You are offline
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box paddingBottom={3}>
|
||||
<Typography textColor="neutral700" variant="epsilon">
|
||||
You need to be connected to the Internet to access Strapi Market.
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box as="img" src={offlineCloud} alt="offline" width={11} height={11} />
|
||||
</Flex>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
if (hasFailed) {
|
||||
return (
|
||||
<Layout>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user