forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReinstallServerBox.tsx
More file actions
66 lines (61 loc) · 2.6 KB
/
ReinstallServerBox.tsx
File metadata and controls
66 lines (61 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React, { useEffect, useState } from 'react';
import { ServerContext } from '@/state/server';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
import reinstallServer from '@/api/server/reinstallServer';
import { Actions, useStoreActions } from 'easy-peasy';
import { ApplicationStore } from '@/state';
import { httpErrorToHuman } from '@/api/http';
import tw from 'twin.macro';
import { Button } from '@/components/elements/button/index';
import { Dialog } from '@/components/elements/dialog';
export default () => {
const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid);
const [modalVisible, setModalVisible] = useState(false);
const { addFlash, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
const reinstall = () => {
clearFlashes('settings');
reinstallServer(uuid)
.then(() => {
addFlash({
key: 'settings',
type: 'success',
message: 'Your server has begun the reinstallation process.',
});
})
.catch((error) => {
console.error(error);
addFlash({ key: 'settings', type: 'error', message: httpErrorToHuman(error) });
})
.then(() => setModalVisible(false));
};
useEffect(() => {
clearFlashes();
}, []);
return (
<TitledGreyBox title={'Reinstall Server'} css={tw`relative`}>
<Dialog.Confirm
open={modalVisible}
title={'Confirm server reinstallation'}
confirm={'Yes, reinstall server'}
onClose={() => setModalVisible(false)}
onConfirmed={reinstall}
>
Your server will be stopped and some files may be deleted or modified during this process, are you sure
you wish to continue?
</Dialog.Confirm>
<p css={tw`text-sm`}>
Reinstalling your server will stop it, and then re-run the installation script that initially set it
up.
<strong css={tw`font-medium`}>
Some files may be deleted or modified during this process, please back up your data before
continuing.
</strong>
</p>
<div css={tw`mt-6 text-right`}>
<Button.Danger variant={Button.Variants.Secondary} onClick={() => setModalVisible(true)}>
Reinstall Server
</Button.Danger>
</div>
</TitledGreyBox>
);
};