diff --git a/CHANGELOG.md b/CHANGELOG.md index e6e4e33d0..e8a60ce46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * Fix data integrity exception thrown when attempting to store updated server egg variables. * Added missing permissions check on 'SFTP Configuration' page to ensure user has permission to access a server's SFTP server before showing a user credentials. +### Added +* Added ability for end users to change the name of their server through the UI. This option is only open to the server owner or an admin. + ### Changed * Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline. * Sessions handled through redis now use a seperate database (default `1`) to store session database to avoid logging users out when flushing the cache. diff --git a/app/Http/Controllers/Server/Settings/NameController.php b/app/Http/Controllers/Server/Settings/NameController.php new file mode 100644 index 000000000..29cdb9ed9 --- /dev/null +++ b/app/Http/Controllers/Server/Settings/NameController.php @@ -0,0 +1,59 @@ +repository = $repository; + } + + /** + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function index(Request $request) + { + $this->authorize('view-name', $request->attributes->get('server')); + $this->setRequest($request)->injectJavascript(); + + return view('server.settings.name'); + } + + /** + * Update the stored name for a specific server. + * + * @param \Pterodactyl\Http\Requests\Server\Settings\ChangeServerNameRequest $request + * @return \Illuminate\Http\RedirectResponse + * + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + */ + public function update(ChangeServerNameRequest $request): RedirectResponse + { + $this->repository->update($request->getServer()->id, $request->validated()); + + return redirect()->route('server.settings.name', $request->getServer()->uuidShort); + } +} diff --git a/app/Http/Requests/Server/Settings/ChangeServerNameRequest.php b/app/Http/Requests/Server/Settings/ChangeServerNameRequest.php new file mode 100644 index 000000000..c969cb0e2 --- /dev/null +++ b/app/Http/Requests/Server/Settings/ChangeServerNameRequest.php @@ -0,0 +1,31 @@ + Server::getCreateRules()['name'], + ]; + } +} diff --git a/resources/lang/en/navigation.php b/resources/lang/en/navigation.php index f8a9deebb..c97c18a78 100644 --- a/resources/lang/en/navigation.php +++ b/resources/lang/en/navigation.php @@ -27,5 +27,6 @@ return [ 'edit_file' => 'Edit File', 'admin_header' => 'ADMINISTRATIVE', 'admin' => 'Server Configuration', + 'server_name' => 'Server Name', ], ]; diff --git a/resources/lang/en/server.php b/resources/lang/en/server.php index 76002aedf..b84f76387 100644 --- a/resources/lang/en/server.php +++ b/resources/lang/en/server.php @@ -289,6 +289,11 @@ return [ ], ], 'config' => [ + 'name' => [ + 'header' => 'Server Name', + 'header_sub' => 'Change this server\'s name.', + 'details' => 'The server name is only a reference to this server on the panel, and will not affect any server specific configurations that may display to users in games.', + ], 'startup' => [ 'header' => 'Start Configuration', 'header_sub' => 'Control server startup arguments.', diff --git a/resources/themes/pterodactyl/layouts/master.blade.php b/resources/themes/pterodactyl/layouts/master.blade.php index 32b75823a..020f8b637 100644 --- a/resources/themes/pterodactyl/layouts/master.blade.php +++ b/resources/themes/pterodactyl/layouts/master.blade.php @@ -184,6 +184,9 @@