diff --git a/resources/lang/en/activity.php b/resources/lang/en/activity.php index f821f362b..64e0bb760 100644 --- a/resources/lang/en/activity.php +++ b/resources/lang/en/activity.php @@ -36,6 +36,7 @@ return [ ], ], 'server' => [ + 'reinstall' => 'Reinstalled server', 'backup' => [ 'download' => 'Downloaded the :name backup', 'delete' => 'Deleted the :name backup', @@ -88,7 +89,6 @@ return [ ], 'settings' => [ 'rename' => 'Renamed the server from :old to :new', - 'reinstall' => 'Triggered a server reinstall', ], 'startup' => [ 'edit' => 'Changed the :variable variable from ":old" to ":new"', diff --git a/resources/scripts/components/dashboard/AccountApiContainer.tsx b/resources/scripts/components/dashboard/AccountApiContainer.tsx index f3497d994..938b35b85 100644 --- a/resources/scripts/components/dashboard/AccountApiContainer.tsx +++ b/resources/scripts/components/dashboard/AccountApiContainer.tsx @@ -5,46 +5,42 @@ import getApiKeys, { ApiKey } from '@/api/account/getApiKeys'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faKey, faTrashAlt } from '@fortawesome/free-solid-svg-icons'; -import ConfirmationModal from '@/components/elements/ConfirmationModal'; import deleteApiKey from '@/api/account/deleteApiKey'; -import { Actions, useStoreActions } from 'easy-peasy'; -import { ApplicationStore } from '@/state'; import FlashMessageRender from '@/components/FlashMessageRender'; -import { httpErrorToHuman } from '@/api/http'; import { format } from 'date-fns'; import PageContentBlock from '@/components/elements/PageContentBlock'; import tw from 'twin.macro'; import GreyRowBox from '@/components/elements/GreyRowBox'; +import { Dialog } from '@/components/elements/dialog'; +import { useFlashKey } from '@/plugins/useFlash'; +import Code from '@/components/elements/Code'; export default () => { const [ deleteIdentifier, setDeleteIdentifier ] = useState(''); const [ keys, setKeys ] = useState([]); const [ loading, setLoading ] = useState(true); - const { addError, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes); + const { clearAndAddHttpError } = useFlashKey('account'); useEffect(() => { - clearFlashes('account'); getApiKeys() .then(keys => setKeys(keys)) .then(() => setLoading(false)) - .catch(error => { - console.error(error); - addError({ key: 'account', message: httpErrorToHuman(error) }); - }); + .catch(error => clearAndAddHttpError(error)); }, []); const doDeletion = (identifier: string) => { setLoading(true); - clearFlashes('account'); + + clearAndAddHttpError(); deleteApiKey(identifier) .then(() => setKeys(s => ([ ...(s || []).filter(key => key.identifier !== identifier), ]))) - .catch(error => { - console.error(error); - addError({ key: 'account', message: httpErrorToHuman(error) }); - }) - .then(() => setLoading(false)); + .catch(error => clearAndAddHttpError(error)) + .then(() => { + setLoading(false); + setDeleteIdentifier(''); + }); }; return ( @@ -56,19 +52,15 @@ export default () => { - { - doDeletion(deleteIdentifier); - setDeleteIdentifier(''); - }} - onModalDismissed={() => setDeleteIdentifier('')} + setDeleteIdentifier('')} + onConfirmed={() => doDeletion(deleteIdentifier)} > - Are you sure you wish to delete this API key? All requests using it will immediately be - invalidated and will fail. - + All requests using the {deleteIdentifier} key will be invalidated. + { keys.length === 0 ?

diff --git a/resources/scripts/components/dashboard/ssh/AccountSSHContainer.tsx b/resources/scripts/components/dashboard/ssh/AccountSSHContainer.tsx index 59539b3ce..95584775d 100644 --- a/resources/scripts/components/dashboard/ssh/AccountSSHContainer.tsx +++ b/resources/scripts/components/dashboard/ssh/AccountSSHContainer.tsx @@ -55,7 +55,7 @@ export default () => { {format(key.createdAt, 'MMM do, yyyy HH:mm')}

- + )) } diff --git a/resources/scripts/components/dashboard/ssh/DeleteSSHKeyButton.tsx b/resources/scripts/components/dashboard/ssh/DeleteSSHKeyButton.tsx index f5c31e322..78661a4b6 100644 --- a/resources/scripts/components/dashboard/ssh/DeleteSSHKeyButton.tsx +++ b/resources/scripts/components/dashboard/ssh/DeleteSSHKeyButton.tsx @@ -3,10 +3,11 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'; import React, { useState } from 'react'; import { useFlashKey } from '@/plugins/useFlash'; -import ConfirmationModal from '@/components/elements/ConfirmationModal'; import { deleteSSHKey, useSSHKeys } from '@/api/account/ssh-keys'; +import { Dialog } from '@/components/elements/dialog'; +import Code from '@/components/elements/Code'; -export default ({ fingerprint }: { fingerprint: string }) => { +export default ({ name, fingerprint }: { name: string; fingerprint: string }) => { const { clearAndAddHttpError } = useFlashKey('account'); const [ visible, setVisible ] = useState(false); const { mutate } = useSSHKeys(); @@ -19,22 +20,22 @@ export default ({ fingerprint }: { fingerprint: string }) => { deleteSSHKey(fingerprint), ]) .catch((error) => { - mutate(undefined, true); + mutate(undefined, true).catch(console.error); clearAndAddHttpError(error); }); }; return ( <> - setVisible(false)} + onClose={() => setVisible(false)} > - Are you sure you wish to delete this SSH key? - + Removing the {name} SSH key will invalidate its usage across the Panel. + @@ -203,7 +196,7 @@ export default ({ backup }: Props) => { : diff --git a/resources/scripts/components/server/settings/ReinstallServerBox.tsx b/resources/scripts/components/server/settings/ReinstallServerBox.tsx index 0c1ce8ec7..d1c8e1327 100644 --- a/resources/scripts/components/server/settings/ReinstallServerBox.tsx +++ b/resources/scripts/components/server/settings/ReinstallServerBox.tsx @@ -1,23 +1,21 @@ import React, { useEffect, useState } from 'react'; import { ServerContext } from '@/state/server'; import TitledGreyBox from '@/components/elements/TitledGreyBox'; -import ConfirmationModal from '@/components/elements/ConfirmationModal'; 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'; +import { Dialog } from '@/components/elements/dialog'; export default () => { const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); - const [ isSubmitting, setIsSubmitting ] = useState(false); const [ modalVisible, setModalVisible ] = useState(false); const { addFlash, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes); const reinstall = () => { clearFlashes('settings'); - setIsSubmitting(true); reinstallServer(uuid) .then(() => { addFlash({ @@ -31,10 +29,7 @@ export default () => { addFlash({ key: 'settings', type: 'error', message: httpErrorToHuman(error) }); }) - .then(() => { - setIsSubmitting(false); - setModalVisible(false); - }); + .then(() => setModalVisible(false)); }; useEffect(() => { @@ -43,17 +38,16 @@ export default () => { return ( - setModalVisible(false)} onConfirmed={reinstall} - showSpinnerOverlay={isSubmitting} - visible={modalVisible} - onModalDismissed={() => setModalVisible(false)} > Your server will be stopped and some files may be deleted or modified during this process, are you sure you wish to continue? - +

Reinstalling your server will stop it, and then re-run the installation script that initially set it up.