From 5f40a47d87d9a9db1075c1be2332a3ab6062423f Mon Sep 17 00:00:00 2001 From: kokofixcomputers koko Date: Wed, 30 Oct 2024 01:56:11 +0000 Subject: [PATCH] Lint and make allow server deletion toggle function. Thanks Gamer3514! --- .../Commands/Schedule/RenewalCommand.php | 10 +++---- .../Api/Client/DiscordController.php | 1 + app/Http/ViewComposers/StoreComposer.php | 4 +++ .../components/auth/LoginContainer.tsx | 22 ++++++++++------ .../components/dashboard/ApiKeyModal.tsx | 4 +-- .../dashboard/DashboardContainer.tsx | 6 +++-- .../components/dashboard/ServerRow.tsx | 26 ++++++++----------- .../server/console/PowerButtons.tsx | 8 +++--- .../server/files/ChmodFileModal.tsx | 10 +++++-- .../server/files/FileEditContainer.tsx | 11 +++----- .../server/settings/SettingsContainer.tsx | 4 ++- .../server/users/UsersContainer.tsx | 4 ++- .../components/store/CreateContainer.tsx | 4 ++- .../components/store/PurchaseContainer.tsx | 3 ++- .../components/store/ResourcesContainer.tsx | 24 +++++++++++------ .../components/tickets/OverviewContainer.tsx | 6 ++++- resources/scripts/routers/StoreRouter.tsx | 1 - resources/scripts/state/settings.ts | 2 +- resources/scripts/state/storefront.ts | 3 +++ 19 files changed, 93 insertions(+), 60 deletions(-) diff --git a/app/Console/Commands/Schedule/RenewalCommand.php b/app/Console/Commands/Schedule/RenewalCommand.php index a2539cf26..a4c283f82 100644 --- a/app/Console/Commands/Schedule/RenewalCommand.php +++ b/app/Console/Commands/Schedule/RenewalCommand.php @@ -6,7 +6,7 @@ use Illuminate\Console\Command; use Jexactyl\Services\Servers\SuspensionService; use Jexactyl\Services\Servers\ServerDeletionService; -use Exception; + class RenewalCommand extends Command { /** @@ -51,19 +51,19 @@ protected function process(Server $server) foreach ($servers as $svr) { try { $this->line('Renewing server ' . $svr->name, false); - + $svr->update(['renewal' => $svr->renewal - 1]); - + if ($svr->renewal <= 0) { $this->line('Suspending server ' . $svr->name, false); $this->suspensionService->toggle($svr, 'suspend'); } - + if ($svr->renewal <= -7) { $this->line('Deleting server ' . $svr->name, false); $this->deletionService->handle($svr); } - } catch (Exception $e) { + } catch (\Exception $e) { $this->line('Error processing server ' . $svr->name . ': ' . $e->getMessage()); } } diff --git a/app/Http/Controllers/Api/Client/DiscordController.php b/app/Http/Controllers/Api/Client/DiscordController.php index 6ec6ac2d8..ea6501cd9 100644 --- a/app/Http/Controllers/Api/Client/DiscordController.php +++ b/app/Http/Controllers/Api/Client/DiscordController.php @@ -36,6 +36,7 @@ public function unlink(): JsonResponse return new JsonResponse(['error' => 'No authenticated user'], 401); } $user->update(['discord_id' => null]); + return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } diff --git a/app/Http/ViewComposers/StoreComposer.php b/app/Http/ViewComposers/StoreComposer.php index e2c6e33ba..ca068251e 100644 --- a/app/Http/ViewComposers/StoreComposer.php +++ b/app/Http/ViewComposers/StoreComposer.php @@ -38,6 +38,10 @@ public function compose(View $view) 'enabled' => $this->setting('renewal:editing', Composer::TYPE_BOOL), ], + 'deletion' => [ + 'enabled' => $this->setting('renewal:deletion', Composer::TYPE_BOOL), + ], + 'referrals' => [ 'enabled' => $this->setting('referrals:enabled', Composer::TYPE_BOOL), 'reward' => $this->setting('referrals:reward', Composer::TYPE_INT), diff --git a/resources/scripts/components/auth/LoginContainer.tsx b/resources/scripts/components/auth/LoginContainer.tsx index 2aa6a9f5f..afa8e6830 100644 --- a/resources/scripts/components/auth/LoginContainer.tsx +++ b/resources/scripts/components/auth/LoginContainer.tsx @@ -6,7 +6,7 @@ import useFlash from '@/plugins/useFlash'; import { useStoreState } from 'easy-peasy'; import { Formik, FormikHelpers } from 'formik'; import { FaDiscord } from 'react-icons/fa'; -import { MdOutlineEmail } from "react-icons/md"; +import { MdOutlineEmail } from 'react-icons/md'; import Field from '@/components/elements/Field'; import React, { useEffect, useRef, useState } from 'react'; import { Button } from '@/components/elements/button/index'; @@ -108,19 +108,25 @@ const LoginContainer = ({ history }: RouteComponentProps) => {
{email && ( - )} {discord && ( - - + + )}
)} diff --git a/resources/scripts/components/dashboard/ApiKeyModal.tsx b/resources/scripts/components/dashboard/ApiKeyModal.tsx index 3b26f604c..55ef8363d 100644 --- a/resources/scripts/components/dashboard/ApiKeyModal.tsx +++ b/resources/scripts/components/dashboard/ApiKeyModal.tsx @@ -16,8 +16,8 @@ const ApiKeyModal = ({ apiKey }: Props) => { <>

Your API Key

- The API key you have requested is shown below. For safety reasons, please store this in a safe location, it will not be - shown again. + The API key you have requested is shown below. For safety reasons, please store this in a safe location, + it will not be shown again.

                 
diff --git a/resources/scripts/components/dashboard/DashboardContainer.tsx b/resources/scripts/components/dashboard/DashboardContainer.tsx
index 43edab2b9..d38a40e30 100644
--- a/resources/scripts/components/dashboard/DashboardContainer.tsx
+++ b/resources/scripts/components/dashboard/DashboardContainer.tsx
@@ -59,7 +59,8 @@ export default () => {
                                 {showOnlyAdmin ? 'Showing other servers' : 'Showing your servers'}
                             
                             

- Select a server to view, update or modify. Go to storefront in the sidebar to create a new server. + Select a server to view, update or modify. Go to storefront in the sidebar to create a + new server.

{ ) : (

- Doesn't look like you have any servers here. Create one in storefront from the sidebar if it's open. + Doesn't look like you have any servers here. Create one in storefront from the + sidebar if it's open.

) } diff --git a/resources/scripts/components/dashboard/ServerRow.tsx b/resources/scripts/components/dashboard/ServerRow.tsx index 96ee7b187..7fa16ef83 100644 --- a/resources/scripts/components/dashboard/ServerRow.tsx +++ b/resources/scripts/components/dashboard/ServerRow.tsx @@ -37,7 +37,7 @@ const StatusIndicatorBox = styled(GreyRowBox)<{ $status: ServerPowerState | unde ? tw`bg-green-500` : tw`bg-yellow-500`}; } - + &:hover .status-bar { ${tw`opacity-75`}; } @@ -89,19 +89,17 @@ export default ({ server, className }: { server: Server; className?: string }) = >
-

- {server.name || "No Server Name"} -

+

{server.name || 'No Server Name'}

- {server.allocations.length > 0 + {server.allocations.length > 0 ? server.allocations - .filter((alloc) => alloc.isDefault) - .map((allocation) => ( - - {allocation.alias || ip(allocation.ip)}:{allocation.port} - - )) - : "No Allocations"} + .filter((alloc) => alloc.isDefault) + .map((allocation) => ( + + {allocation.alias || ip(allocation.ip)}:{allocation.port} + + )) + : 'No Allocations'}

@@ -136,9 +134,7 @@ export default ({ server, className }: { server: Server; className?: string }) =
- - {stats.cpuUsagePercent.toFixed(2)}% - + {stats.cpuUsagePercent.toFixed(2)}%
diff --git a/resources/scripts/components/server/console/PowerButtons.tsx b/resources/scripts/components/server/console/PowerButtons.tsx index 1cad68670..7dd4e1ea0 100644 --- a/resources/scripts/components/server/console/PowerButtons.tsx +++ b/resources/scripts/components/server/console/PowerButtons.tsx @@ -55,12 +55,12 @@ export default ({ className }: PowerButtonProps) => { disabled={status !== 'offline'} onClick={onButtonClick.bind(this, 'start')} > - Start + Start - Restart + Restart @@ -69,7 +69,7 @@ export default ({ className }: PowerButtonProps) => { disabled={status === 'offline'} onClick={onButtonClick.bind(this, killable ? 'stop' : 'stop')} > - {killable ? 'Stop' : 'Stop'} + {killable ? 'Stop' : 'Stop'} @@ -78,7 +78,7 @@ export default ({ className }: PowerButtonProps) => { disabled={status === 'offline'} onClick={onButtonClick.bind(this, killable ? 'kill' : 'kill')} > - {killable ? 'Kill' : 'Kill'} + {killable ? 'Kill' : 'Kill'}
diff --git a/resources/scripts/components/server/files/ChmodFileModal.tsx b/resources/scripts/components/server/files/ChmodFileModal.tsx index 6f823efe9..8008720a2 100644 --- a/resources/scripts/components/server/files/ChmodFileModal.tsx +++ b/resources/scripts/components/server/files/ChmodFileModal.tsx @@ -53,7 +53,7 @@ const ChmodFileModal = ({ files, ...props }: OwnProps) => { }; // Generate a title based on the files being chmoded - const title = `Changing Permissions for: ${files.map(f => f.file).join(', ')}`; + const title = `Changing Permissions for: ${files.map((f) => f.file).join(', ')}`; return ( 1 ? '' : files[0].mode || '' }}> @@ -64,7 +64,13 @@ const ChmodFileModal = ({ files, ...props }: OwnProps) => {
- +
diff --git a/resources/scripts/components/server/files/FileEditContainer.tsx b/resources/scripts/components/server/files/FileEditContainer.tsx index e485f8f64..5c756777d 100644 --- a/resources/scripts/components/server/files/FileEditContainer.tsx +++ b/resources/scripts/components/server/files/FileEditContainer.tsx @@ -87,7 +87,6 @@ const getLanguageFromFilename = (filename: string) => { case 'swift': return 'swift'; case 'm': - case 'h': return 'objectivec'; case 'scala': return 'scala'; @@ -161,10 +160,8 @@ export default () => { setLoading(true); clearFlashes('files:view'); - - const savePromise = isMobile() - ? fetchFileContent!() - : Promise.resolve(editorRef.current.getValue()); + + const savePromise = isMobile() ? fetchFileContent!() : Promise.resolve(editorRef.current.getValue()); savePromise .then((content) => saveFileContents(uuid, name || hashToPath(hash), content)) @@ -234,8 +231,8 @@ export default () => { /> ) : ( { diff --git a/resources/scripts/components/server/settings/SettingsContainer.tsx b/resources/scripts/components/server/settings/SettingsContainer.tsx index f33462c4d..2f10c1354 100644 --- a/resources/scripts/components/server/settings/SettingsContainer.tsx +++ b/resources/scripts/components/server/settings/SettingsContainer.tsx @@ -2,6 +2,7 @@ import React from 'react'; import tw from 'twin.macro'; import Can from '@/components/elements/Can'; import { ServerContext } from '@/state/server'; +import { useStoreState } from 'easy-peasy'; import CopyOnClick from '@/components/elements/CopyOnClick'; import TitledGreyBox from '@/components/elements/TitledGreyBox'; import ServerContentBlock from '@/components/elements/ServerContentBlock'; @@ -11,6 +12,7 @@ import ReinstallServerBox from '@/components/server/settings/ReinstallServerBox' import ChangeBackgroundBox from '@/components/server/settings/ChangeBackgroundBox'; export default () => { + const deletion = useStoreState((state) => state.storefront.data!.deletion.enabled); const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid); const node = ServerContext.useStoreState((state) => state.server.data!.node); @@ -34,7 +36,7 @@ export default () => {
- + {deletion && }
diff --git a/resources/scripts/components/server/users/UsersContainer.tsx b/resources/scripts/components/server/users/UsersContainer.tsx index b9e656725..15e2d8ba7 100644 --- a/resources/scripts/components/server/users/UsersContainer.tsx +++ b/resources/scripts/components/server/users/UsersContainer.tsx @@ -53,7 +53,9 @@ export default () => { showFlashKey={'users'} > {!subusers.length ? ( -

It looks like this server doesn't have any subusers.

+

+ It looks like this server doesn't have any subusers. +

) : ( subusers.map((subuser) => ) )} diff --git a/resources/scripts/components/store/CreateContainer.tsx b/resources/scripts/components/store/CreateContainer.tsx index 1c288576c..87be725c4 100644 --- a/resources/scripts/components/store/CreateContainer.tsx +++ b/resources/scripts/components/store/CreateContainer.tsx @@ -246,7 +246,9 @@ export default () => { ))} -

Select a nest or catagory to use for your server.

+

+ Select a nest or catagory to use for your server. +