Added admin configuration
This is not working just yet but the fields have been added to the admin control area.
This commit is contained in:
parent
da30977364
commit
d80660f047
5 changed files with 85 additions and 25 deletions
|
@ -16,6 +16,7 @@ import GreyRowBox from '@/components/elements/GreyRowBox';
|
|||
|
||||
const NetworkContainer = () => {
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const allocationLimit = ServerContext.useStoreState(state => state.server.data!.featureLimits.allocations);
|
||||
const allocations = useDeepMemoize(ServerContext.useStoreState(state => state.server.data!.allocations));
|
||||
const [ addingAllocation, setAddingAllocation ] = useState(false);
|
||||
|
||||
|
@ -48,14 +49,16 @@ const NetworkContainer = () => {
|
|||
clearFlashes('server:network');
|
||||
setAddingAllocation(true);
|
||||
|
||||
const initial = data;
|
||||
|
||||
newServerAllocation(uuid)
|
||||
.then(allocation => {
|
||||
mutate(data => ({ ...data, items: data.concat(allocation) }), false);
|
||||
mutate(data?.concat(allocation), false);
|
||||
setAddingAllocation(false);
|
||||
})
|
||||
.catch(error => {
|
||||
clearAndAddHttpError({ key: 'server:network', error });
|
||||
mutate(data, false);
|
||||
mutate(initial, false);
|
||||
setAddingAllocation(false);
|
||||
});
|
||||
};
|
||||
|
@ -78,23 +81,29 @@ const NetworkContainer = () => {
|
|||
/>
|
||||
))
|
||||
}
|
||||
<GreyRowBox
|
||||
$hoverable={false}
|
||||
css={tw`mt-2 overflow-x-auto flex items-center justify-center`}
|
||||
>
|
||||
{addingAllocation ?
|
||||
<Spinner size={'base'} centered/>
|
||||
:
|
||||
<Button
|
||||
color={'primary'}
|
||||
isSecondary
|
||||
onClick={() => getNewAllocation() }
|
||||
css={tw`my-2`}
|
||||
>
|
||||
Add New Allocation
|
||||
</Button>
|
||||
}
|
||||
</GreyRowBox>
|
||||
{allocationLimit > data!.length ?
|
||||
<GreyRowBox
|
||||
$hoverable={false}
|
||||
css={tw`mt-2 overflow-x-auto flex items-center justify-center`}
|
||||
>
|
||||
{addingAllocation ?
|
||||
<Spinner size={'base'} centered/>
|
||||
:
|
||||
<Button
|
||||
color={'primary'}
|
||||
isSecondary
|
||||
onClick={() => getNewAllocation()}
|
||||
css={tw`my-2`}
|
||||
>
|
||||
Add New Allocation
|
||||
</Button>
|
||||
}
|
||||
</GreyRowBox>
|
||||
:
|
||||
<p css={tw`mt-2 text-center text-sm text-neutral-400`}>
|
||||
You have reached the max number of allocations allowed for your server.
|
||||
</p>
|
||||
}
|
||||
</ServerContentBlock>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue