fix(striker-ui): add message when resource not found in provision server

main
Tsu-ba-me 9 months ago
parent 373f985911
commit 104b158426
  1. 23
      striker-ui/components/ProvisionServerDialog.tsx

@ -18,6 +18,7 @@ import api from '../lib/api';
import Autocomplete from './Autocomplete'; import Autocomplete from './Autocomplete';
import ConfirmDialog from './ConfirmDialog'; import ConfirmDialog from './ConfirmDialog';
import ContainedButton from './ContainedButton'; import ContainedButton from './ContainedButton';
import FlexBox from './FlexBox';
import { dsize, dsizeToByte } from '../lib/format_data_size_wrappers'; import { dsize, dsizeToByte } from '../lib/format_data_size_wrappers';
import IconButton, { IconButtonProps } from './IconButton'; import IconButton, { IconButtonProps } from './IconButton';
import MessageBox, { MessageBoxProps } from './MessageBox'; import MessageBox, { MessageBoxProps } from './MessageBox';
@ -901,6 +902,8 @@ const ProvisionServerDialog = ({
const [allAnvils, setAllAnvils] = useState< const [allAnvils, setAllAnvils] = useState<
OrganizedAnvilDetailMetadataForProvisionServer[] OrganizedAnvilDetailMetadataForProvisionServer[]
>([]); >([]);
// Provision is impossible when one of anvil node list, file list, or storage
// group list is empty.
const [anvilUUIDMapToData, setAnvilUUIDMapToData] = const [anvilUUIDMapToData, setAnvilUUIDMapToData] =
useState<AnvilUUIDMapToData>({}); useState<AnvilUUIDMapToData>({});
const [fileUUIDMapToData, setFileUUIDMapToData] = useState<FileUUIDMapToData>( const [fileUUIDMapToData, setFileUUIDMapToData] = useState<FileUUIDMapToData>(
@ -1480,6 +1483,15 @@ const ProvisionServerDialog = ({
); );
}; };
const hasResource = useMemo<Record<string, boolean>>(
() => ({
'anvil node': Boolean(Object.keys(anvilUUIDMapToData).length),
file: Boolean(Object.keys(fileUUIDMapToData).length),
'storage group': Boolean(Object.keys(storageGroupUUIDMapToData).length),
}),
[anvilUUIDMapToData, fileUUIDMapToData, storageGroupUUIDMapToData],
);
useEffect(() => { useEffect(() => {
api api
.get('/anvil', { .get('/anvil', {
@ -1594,6 +1606,17 @@ const ProvisionServerDialog = ({
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
</PanelHeader> </PanelHeader>
<FlexBox spacing=".6em">
{Object.entries(hasResource).map(
([resource, has]) =>
!has && (
<MessageBox type="warning">
No {resource} available yet. Try refreshing after the resource
gets created.
</MessageBox>
),
)}
</FlexBox>
{isProvisionServerDataReady ? ( {isProvisionServerDataReady ? (
<Box <Box
sx={{ sx={{

Loading…
Cancel
Save