Update logic for tracking a server's transfer state
This commit is contained in:
parent
5d03c0d2e5
commit
e6c4a68e4a
20 changed files with 206 additions and 74 deletions
|
@ -35,10 +35,12 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
|
|||
const rootAdmin = useStoreState(state => state.user.data!.rootAdmin);
|
||||
const [ error, setError ] = useState('');
|
||||
const [ installing, setInstalling ] = useState(false);
|
||||
const [ transferring, setTransferring ] = useState(false);
|
||||
|
||||
const id = ServerContext.useStoreState(state => state.server.data?.id);
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data?.uuid);
|
||||
const isInstalling = ServerContext.useStoreState(state => state.server.data?.isInstalling);
|
||||
const isTransferring = ServerContext.useStoreState(state => state.server.data?.isTransferring);
|
||||
const serverId = ServerContext.useStoreState(state => state.server.data?.internalId);
|
||||
const getServer = ServerContext.useStoreActions(actions => actions.server.getServer);
|
||||
const clearServerState = ServerContext.useStoreActions(actions => actions.clearServerState);
|
||||
|
@ -51,13 +53,23 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
|
|||
setInstalling(!!isInstalling);
|
||||
}, [ isInstalling ]);
|
||||
|
||||
useEffect(() => {
|
||||
setTransferring(!!isTransferring);
|
||||
}, [ isTransferring ]);
|
||||
|
||||
useEffect(() => {
|
||||
setError('');
|
||||
setInstalling(false);
|
||||
setTransferring(false);
|
||||
|
||||
getServer(match.params.id)
|
||||
.catch(error => {
|
||||
if (error.response?.status === 409) {
|
||||
setInstalling(true);
|
||||
if (error.response.data?.errors[0]?.detail?.includes('transfer')) {
|
||||
setTransferring(true);
|
||||
} else {
|
||||
setInstalling(true);
|
||||
}
|
||||
} else {
|
||||
console.error(error);
|
||||
setError(httpErrorToHuman(error));
|
||||
|
@ -117,9 +129,9 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
|
|||
</CSSTransition>
|
||||
<InstallListener/>
|
||||
<WebsocketHandler/>
|
||||
{(installing && (!rootAdmin || (rootAdmin && !location.pathname.endsWith(`/server/${id}`)))) ?
|
||||
{((installing || transferring) && (!rootAdmin || (rootAdmin && !location.pathname.endsWith(`/server/${id}`)))) ?
|
||||
<ScreenBlock
|
||||
title={'Your server is installing.'}
|
||||
title={installing ? 'Your server is installing.' : 'Your server is currently being transferred.'}
|
||||
image={'/assets/svgs/server_installing.svg'}
|
||||
message={'Please check back in a few minutes.'}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue