2023-06-20 00:03:07 +00:00
|
|
|
import { Box, styled } from '@mui/material';
|
2021-04-28 15:50:42 +00:00
|
|
|
import { useContext } from 'react';
|
2021-04-19 15:11:56 +00:00
|
|
|
|
2023-06-20 00:03:07 +00:00
|
|
|
import API_BASE_URL from '../../lib/consts/API_BASE_URL';
|
|
|
|
import { LARGE_MOBILE_BREAKPOINT } from '../../lib/consts/DEFAULT_THEME';
|
|
|
|
|
|
|
|
import { AnvilContext } from '../AnvilContext';
|
2022-02-17 21:01:56 +00:00
|
|
|
import { Panel, InnerPanel, InnerPanelHeader } from '../Panels';
|
2022-02-24 21:29:47 +00:00
|
|
|
import periodicFetch from '../../lib/fetchers/periodicFetch';
|
2023-06-20 00:03:07 +00:00
|
|
|
import SharedStorageHost from './SharedStorageHost';
|
2021-05-28 00:31:34 +00:00
|
|
|
import Spinner from '../Spinner';
|
2023-06-20 00:03:07 +00:00
|
|
|
import { BodyText, HeaderText } from '../Text';
|
2021-03-22 15:39:34 +00:00
|
|
|
|
2022-01-07 20:14:12 +00:00
|
|
|
const PREFIX = 'SharedStorage';
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
root: `${PREFIX}-root`,
|
|
|
|
};
|
|
|
|
|
|
|
|
const StyledDiv = styled('div')(({ theme }) => ({
|
|
|
|
[`& .${classes.root}`]: {
|
2021-04-30 15:11:47 +00:00
|
|
|
overflow: 'auto',
|
2021-04-30 17:39:28 +00:00
|
|
|
height: '78vh',
|
2021-04-30 21:48:10 +00:00
|
|
|
paddingLeft: '.3em',
|
2021-06-30 16:41:28 +00:00
|
|
|
paddingRight: '.3em',
|
|
|
|
[theme.breakpoints.down(LARGE_MOBILE_BREAKPOINT)]: {
|
2021-04-30 15:11:47 +00:00
|
|
|
height: '100%',
|
|
|
|
},
|
|
|
|
},
|
2021-04-28 21:50:45 +00:00
|
|
|
}));
|
|
|
|
|
2021-05-28 21:44:11 +00:00
|
|
|
const SharedStorage = (): JSX.Element => {
|
2021-04-28 15:50:42 +00:00
|
|
|
const { uuid } = useContext(AnvilContext);
|
2023-06-20 00:03:07 +00:00
|
|
|
|
2022-02-24 21:29:47 +00:00
|
|
|
const { data, isLoading } = periodicFetch<AnvilSharedStorage>(
|
2023-06-20 00:03:07 +00:00
|
|
|
`${API_BASE_URL}/anvil/${uuid}/store`,
|
2021-03-22 15:39:34 +00:00
|
|
|
);
|
2023-06-20 00:03:07 +00:00
|
|
|
|
2021-03-09 16:34:44 +00:00
|
|
|
return (
|
|
|
|
<Panel>
|
2022-01-07 20:14:12 +00:00
|
|
|
<StyledDiv>
|
|
|
|
<HeaderText text="Shared Storage" />
|
|
|
|
{!isLoading ? (
|
|
|
|
<Box className={classes.root}>
|
|
|
|
{data?.storage_groups &&
|
|
|
|
data.storage_groups.map(
|
|
|
|
(storageGroup: AnvilSharedStorageGroup): JSX.Element => (
|
|
|
|
<InnerPanel key={storageGroup.storage_group_uuid}>
|
2022-02-17 21:01:56 +00:00
|
|
|
<InnerPanelHeader>
|
2022-05-31 20:24:28 +00:00
|
|
|
<BodyText text={storageGroup.storage_group_name} />
|
2022-02-17 21:01:56 +00:00
|
|
|
</InnerPanelHeader>
|
2022-01-07 20:14:12 +00:00
|
|
|
<SharedStorageHost
|
|
|
|
group={storageGroup}
|
|
|
|
key={storageGroup.storage_group_uuid}
|
|
|
|
/>
|
|
|
|
</InnerPanel>
|
|
|
|
),
|
|
|
|
)}
|
|
|
|
</Box>
|
|
|
|
) : (
|
|
|
|
<Spinner />
|
|
|
|
)}
|
|
|
|
</StyledDiv>
|
2021-03-09 16:34:44 +00:00
|
|
|
</Panel>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SharedStorage;
|