From dd69652942a8397edfce4e30c3e12eb6a1ea3ce1 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Sun, 4 Dec 2022 16:09:42 -0700 Subject: [PATCH 01/10] Fix `No application encryption key has been specified` error while trying to generate said key --- app/Providers/AppServiceProvider.php | 4 ++-- app/Services/Nodes/NodeCreationService.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index d4ffdadbb..6a805bad3 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,12 +2,12 @@ namespace Pterodactyl\Providers; -use View; -use Cache; use Pterodactyl\Models; use Illuminate\Support\Str; use Illuminate\Support\Facades\URL; use Illuminate\Pagination\Paginator; +use Illuminate\Support\Facades\View; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; use Pterodactyl\Extensions\Themes\Theme; diff --git a/app/Services/Nodes/NodeCreationService.php b/app/Services/Nodes/NodeCreationService.php index e4946bc20..b21589c4a 100644 --- a/app/Services/Nodes/NodeCreationService.php +++ b/app/Services/Nodes/NodeCreationService.php @@ -13,7 +13,7 @@ class NodeCreationService /** * NodeCreationService constructor. */ - public function __construct(private Encrypter $encrypter, protected NodeRepositoryInterface $repository) + public function __construct(protected NodeRepositoryInterface $repository) { } @@ -25,7 +25,7 @@ class NodeCreationService public function handle(array $data): Node { $data['uuid'] = Uuid::uuid4()->toString(); - $data['daemon_token'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)); + $data['daemon_token'] = app(Encrypter::class)->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)); $data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH); return $this->repository->create($data, true, true); From 158facd53460e9d697efa29eb6d39259b6a9570e Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Sun, 4 Dec 2022 16:32:15 -0700 Subject: [PATCH 02/10] eslint: fix prettier config --- .eslintrc.js | 25 +++++++------------------ .prettierrc.json | 9 +++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) create mode 100644 .prettierrc.json diff --git a/.eslintrc.js b/.eslintrc.js index 77547d879..a0bb5e9eb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,3 @@ -const prettier = { - singleQuote: true, - jsxSingleQuote: true, - printWidth: 120, -}; - /** @type {import('eslint').Linter.Config} */ module.exports = { parser: '@typescript-eslint/parser', @@ -21,20 +15,15 @@ module.exports = { version: 'detect', }, linkComponents: [ - {name: 'Link', linkAttribute: 'to'}, - {name: 'NavLink', linkAttribute: 'to'}, + { name: 'Link', linkAttribute: 'to' }, + { name: 'NavLink', linkAttribute: 'to' }, ], }, env: { browser: true, es6: true, }, - plugins: [ - 'react', - 'react-hooks', - 'prettier', - '@typescript-eslint', - ], + plugins: ['react', 'react-hooks', 'prettier', '@typescript-eslint'], extends: [ // 'standard', 'eslint:recommended', @@ -44,7 +33,7 @@ module.exports = { ], rules: { eqeqeq: 'error', - 'prettier/prettier': ['error', prettier], + 'prettier/prettier': ['error', {}, { usePrettierrc: true }], // TypeScript can infer this significantly better than eslint ever can. 'react/prop-types': 0, 'react/display-name': 0, @@ -56,7 +45,7 @@ module.exports = { // @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md#how-to-use 'no-use-before-define': 0, '@typescript-eslint/no-use-before-define': 'warn', - '@typescript-eslint/no-unused-vars': ['warn', {argsIgnorePattern: '^_', varsIgnorePattern: '^_'}], - '@typescript-eslint/ban-ts-comment': ['error', {'ts-expect-error': 'allow-with-description'}], - } + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], + '@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }], + }, }; diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..d000a2241 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": true, + "jsxSingleQuote": true, + "endOfLine": "lf" +} From 598c956e4e516441a31dc848c850ff256ef4bb23 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Sun, 4 Dec 2022 16:36:53 -0700 Subject: [PATCH 03/10] ui(server): fix file uploads being canceled instead of completed --- .../server/files/FileManagerStatus.tsx | 4 +-- .../components/server/files/UploadButton.tsx | 30 ++++++++++--------- resources/scripts/state/server/files.ts | 7 +++++ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/resources/scripts/components/server/files/FileManagerStatus.tsx b/resources/scripts/components/server/files/FileManagerStatus.tsx index 620e067c1..3e1c2df24 100644 --- a/resources/scripts/components/server/files/FileManagerStatus.tsx +++ b/resources/scripts/components/server/files/FileManagerStatus.tsx @@ -32,7 +32,7 @@ const Spinner = ({ progress, className }: { progress: number; className?: string const FileUploadList = () => { const { close } = useContext(DialogWrapperContext); - const removeFileUpload = ServerContext.useStoreActions((actions) => actions.files.removeFileUpload); + const cancelFileUpload = ServerContext.useStoreActions((actions) => actions.files.cancelFileUpload); const clearFileUploads = ServerContext.useStoreActions((actions) => actions.files.clearFileUploads); const uploads = ServerContext.useStoreState((state) => Object.entries(state.files.uploads).sort(([a], [b]) => a.localeCompare(b)) @@ -49,7 +49,7 @@ const FileUploadList = () => { {name}