Merge branch '1.0-develop' into develop

This commit is contained in:
Matthew Penner 2022-10-31 10:59:35 -06:00
commit b7a65436fa
No known key found for this signature in database
10 changed files with 46 additions and 34 deletions

View file

@ -36,6 +36,7 @@ class SettingsController extends ClientApiController
{ {
$this->repository->update($server->id, [ $this->repository->update($server->id, [
'name' => $request->input('name'), 'name' => $request->input('name'),
'description' => $request->input('description') ?? '',
]); ]);
if ($server->name !== $request->input('name')) { if ($server->name !== $request->input('name')) {

View file

@ -11,7 +11,7 @@ class RenameServerRequest extends ClientApiRequest implements ClientPermissionsR
{ {
/** /**
* Returns the permissions string indicating which permission should be used to * Returns the permissions string indicating which permission should be used to
* validate that the authenticated user has permission to perform this action aganist * validate that the authenticated user has permission to perform this action against
* the given resource (server). * the given resource (server).
*/ */
public function permission(): string public function permission(): string
@ -26,6 +26,7 @@ class RenameServerRequest extends ClientApiRequest implements ClientPermissionsR
{ {
return [ return [
'name' => Server::getRules()['name'], 'name' => Server::getRules()['name'],
'description' => 'string|nullable',
]; ];
} }
} }

View file

@ -195,7 +195,7 @@ class Permission extends Model
'settings' => [ 'settings' => [
'description' => 'Permissions that control a user\'s access to the settings for this server.', 'description' => 'Permissions that control a user\'s access to the settings for this server.',
'keys' => [ 'keys' => [
'rename' => 'Allows a user to rename this server.', 'rename' => 'Allows a user to rename this server and change the description of it.',
'reinstall' => 'Allows a user to trigger a reinstall of this server.', 'reinstall' => 'Allows a user to trigger a reinstall of this server.',
], ],
], ],

View file

@ -91,8 +91,8 @@ return [
*/ */
'from' => [ 'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'address' => env('MAIL_FROM_ADDRESS', env('MAIL_FROM')),
'name' => env('MAIL_FROM_NAME', 'Example'), 'name' => env('MAIL_FROM_NAME', 'Pterodactyl Panel'),
], ],
/* /*

View file

@ -33,7 +33,7 @@ return [
'database' => [ 'database' => [
'driver' => 'database', 'driver' => 'database',
'table' => 'jobs', 'table' => 'jobs',
'queue' => 'default', 'queue' => env('QUEUE_STANDARD', 'default'),
'retry_after' => 90, 'retry_after' => 90,
'after_commit' => false, 'after_commit' => false,
], ],
@ -43,7 +43,7 @@ return [
'key' => env('AWS_ACCESS_KEY_ID'), 'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'), 'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'), 'queue' => env('SQS_QUEUE', env('QUEUE_STANDARD', 'default')),
'suffix' => env('SQS_SUFFIX'), 'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false, 'after_commit' => false,
@ -52,7 +52,7 @@ return [
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'), 'queue' => env('REDIS_QUEUE', env('QUEUE_STANDARD', 'default')),
'retry_after' => 90, 'retry_after' => 90,
'block_for' => null, 'block_for' => null,
'after_commit' => false, 'after_commit' => false,

View file

@ -1,28 +1,28 @@
{ {
"_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO",
"meta": { "meta": {
"version": "PTDL_v1", "version": "PTDL_v2",
"update_url": null "update_url": null
}, },
"exported_at": "2021-06-15T16:54:54-04:00", "exported_at": "2022-10-15T12:38:18+02:00",
"name": "Mumble Server", "name": "Mumble Server",
"author": "support@pterodactyl.io", "author": "support@pterodactyl.io",
"description": "Mumble is an open source, low-latency, high quality voice chat software primarily intended for use while gaming.", "description": "Mumble is an open source, low-latency, high quality voice chat software primarily intended for use while gaming.",
"features": null, "features": null,
"images": [ "docker_images": {
"ghcr.io\/pterodactyl\/yolks:alpine" "Mumble": "ghcr.io\/parkervcp\/yolks:voice_mumble"
], },
"file_denylist": [], "file_denylist": [],
"startup": ".\/murmur.x86 -fg", "startup": "mumble-server -fg -ini murmur.ini",
"config": { "config": {
"files": "{\r\n \"murmur.ini\": {\r\n \"parser\": \"ini\",\r\n \"find\": {\r\n \"logfile\": \"murmur.log\",\r\n \"port\": \"{{server.build.default.port}}\",\r\n \"host\": \"0.0.0.0\",\r\n \"users\": \"{{server.build.env.MAX_USERS}}\"\r\n }\r\n }\r\n}", "files": "{\r\n \"murmur.ini\": {\r\n \"parser\": \"ini\",\r\n \"find\": {\r\n \"database\": \"\/home\/container\/murmur.sqlite\",\r\n \"logfile\": \"\/home\/container\/murmur.log\",\r\n \"port\": \"{{server.build.default.port}}\",\r\n \"host\": \"0.0.0.0\",\r\n \"users\": \"{{server.build.env.MAX_USERS}}\"\r\n }\r\n }\r\n}",
"startup": "{\r\n \"done\": \"Server listening on\"\r\n}", "startup": "{\r\n \"done\": \"Server listening on\"\r\n}",
"logs": "{\r\n \"custom\": true,\r\n \"location\": \"logs\/murmur.log\"\r\n}", "logs": "{}",
"stop": "^C" "stop": "^C"
}, },
"scripts": { "scripts": {
"installation": { "installation": {
"script": "#!\/bin\/ash\r\n# Mumble Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\nGITHUB_PACKAGE=mumble-voip\/mumble\r\nMATCH=murmur-static\r\n\r\nif [ ! -d \/mnt\/server\/ ]; then\r\n mkdir \/mnt\/server\/\r\nfi\r\n\r\ncd \/mnt\/server\r\n\r\nif [ -z \"${GITHUB_USER}\" ] && [ -z \"${GITHUB_OAUTH_TOKEN}\" ] ; then\r\n echo -e \"using anon api call\"\r\nelse\r\n echo -e \"user and oauth token set\"\r\n alias curl='curl -u ${GITHUB_USER}:${GITHUB_OAUTH_TOKEN} '\r\nfi\r\n\r\n## get release info and download links\r\nLATEST_JSON=$(curl --silent \"https:\/\/api.github.com\/repos\/${GITHUB_PACKAGE}\/releases\/latest\")\r\nRELEASES=$(curl --silent \"https:\/\/api.github.com\/repos\/${GITHUB_PACKAGE}\/releases\")\r\n\r\nif [ -z \"${VERSION}\" ] || [ \"${VERSION}\" == \"latest\" ]; then\r\n DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url | grep -m 1 -i ${MATCH})\r\nelse\r\n VERSION_CHECK=$(echo ${RELEASES} | jq -r --arg VERSION \"${VERSION}\" '.[] | select(.tag_name==$VERSION) | .tag_name')\r\n if [ \"${VERSION}\" == \"${VERSION_CHECK}\" ]; then\r\n DOWNLOAD_LINK=$(echo ${RELEASES} | jq -r --arg VERSION \"${VERSION}\" '.[] | select(.tag_name==$VERSION) | .assets[].browser_download_url' | grep -m 1 -i ${MATCH})\r\n else\r\n echo -e \"defaulting to latest release\"\r\n DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url)\r\n fi\r\nfi\r\n\r\ncurl -L ${DOWNLOAD_LINK} | tar xjv --strip-components=1", "script": "#!\/bin\/ash\r\n\r\nif [ ! -d \/mnt\/server\/ ]; then\r\n mkdir \/mnt\/server\/\r\nfi\r\n\r\ncd \/mnt\/server\r\n\r\nFILE=\/mnt\/server\/murmur.ini\r\nif [ -f \"$FILE\" ]; then\r\n echo \"Config file already exists.\"\r\nelse \r\n echo \"Downloading the config file.\"\r\n apk add --no-cache murmur\r\n cp \/etc\/murmur.ini \/mnt\/server\/murmur.ini\r\n apk del murmur\r\nfi\r\necho \"done\"",
"container": "ghcr.io\/pterodactyl\/installers:alpine", "container": "ghcr.io\/pterodactyl\/installers:alpine",
"entrypoint": "ash" "entrypoint": "ash"
} }
@ -35,16 +35,8 @@
"default_value": "100", "default_value": "100",
"user_viewable": true, "user_viewable": true,
"user_editable": false, "user_editable": false,
"rules": "required|numeric|digits_between:1,5" "rules": "required|numeric|digits_between:1,5",
}, "field_type": "text"
{
"name": "Server Version",
"description": "Version of Mumble Server to download and use.",
"env_variable": "MUMBLE_VERSION",
"default_value": "latest",
"user_viewable": true,
"user_editable": true,
"rules": "required|string"
} }
] ]
} }

View file

@ -115,6 +115,7 @@ return [
], ],
'settings' => [ 'settings' => [
'rename' => 'Renamed the server from :old to :new', 'rename' => 'Renamed the server from :old to :new',
'description' => 'Changed the server description from :old to :new',
], ],
'startup' => [ 'startup' => [
'edit' => 'Changed the :variable variable from ":old" to ":new"', 'edit' => 'Changed the :variable variable from ":old" to ":new"',

View file

@ -1,8 +1,8 @@
import http from '@/api/http'; import http from '@/api/http';
export default (uuid: string, name: string): Promise<void> => { export default (uuid: string, name: string, description?: string): Promise<void> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
http.post(`/api/client/servers/${uuid}/settings/rename`, { name }) http.post(`/api/client/servers/${uuid}/settings/rename`, { name, description })
.then(() => resolve()) .then(() => resolve())
.catch(reject); .catch(reject);
}); });

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { ServerContext } from '@/state/server'; import { ServerContext } from '@/state/server';
import TitledGreyBox from '@/components/elements/TitledGreyBox'; import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { Form, Formik, FormikHelpers, useFormikContext } from 'formik'; import { Field as FormikField, Form, Formik, FormikHelpers, useFormikContext } from 'formik';
import { Actions, useStoreActions } from 'easy-peasy'; import { Actions, useStoreActions } from 'easy-peasy';
import renameServer from '@/api/server/renameServer'; import renameServer from '@/api/server/renameServer';
import Field from '@/components/elements/Field'; import Field from '@/components/elements/Field';
@ -11,19 +11,29 @@ import { ApplicationStore } from '@/state';
import { httpErrorToHuman } from '@/api/http'; import { httpErrorToHuman } from '@/api/http';
import { Button } from '@/components/elements/button/index'; import { Button } from '@/components/elements/button/index';
import tw from 'twin.macro'; import tw from 'twin.macro';
import Label from '@/components/elements/Label';
import FormikFieldWrapper from '@/components/elements/FormikFieldWrapper';
import { Textarea } from '@/components/elements/Input';
interface Values { interface Values {
name: string; name: string;
description: string;
} }
const RenameServerBox = () => { const RenameServerBox = () => {
const { isSubmitting } = useFormikContext<Values>(); const { isSubmitting } = useFormikContext<Values>();
return ( return (
<TitledGreyBox title={'Change Server Name'} css={tw`relative`}> <TitledGreyBox title={'Change Server Details'} css={tw`relative`}>
<SpinnerOverlay visible={isSubmitting} /> <SpinnerOverlay visible={isSubmitting} />
<Form css={tw`mb-0`}> <Form css={tw`mb-0`}>
<Field id={'name'} name={'name'} label={'Server Name'} type={'text'} /> <Field id={'name'} name={'name'} label={'Server Name'} type={'text'} />
<div css={tw`mt-6`}>
<Label>Server Description</Label>
<FormikFieldWrapper name={'description'}>
<FormikField as={Textarea} name={'description'} rows={3} />
</FormikFieldWrapper>
</div>
<div css={tw`mt-6 text-right`}> <div css={tw`mt-6 text-right`}>
<Button type={'submit'}>Save</Button> <Button type={'submit'}>Save</Button>
</div> </div>
@ -37,10 +47,10 @@ export default () => {
const setServer = ServerContext.useStoreActions((actions) => actions.server.setServer); const setServer = ServerContext.useStoreActions((actions) => actions.server.setServer);
const { addError, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes); const { addError, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
const submit = ({ name }: Values, { setSubmitting }: FormikHelpers<Values>) => { const submit = ({ name, description }: Values, { setSubmitting }: FormikHelpers<Values>) => {
clearFlashes('settings'); clearFlashes('settings');
renameServer(server.uuid, name) renameServer(server.uuid, name, description)
.then(() => setServer({ ...server, name })) .then(() => setServer({ ...server, name, description }))
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
addError({ key: 'settings', message: httpErrorToHuman(error) }); addError({ key: 'settings', message: httpErrorToHuman(error) });
@ -53,9 +63,11 @@ export default () => {
onSubmit={submit} onSubmit={submit}
initialValues={{ initialValues={{
name: server.name, name: server.name,
description: server.description,
}} }}
validationSchema={object().shape({ validationSchema={object().shape({
name: string().required().min(1), name: string().required().min(1),
description: string().nullable(),
})} })}
> >
<RenameServerBox /> <RenameServerBox />

View file

@ -21,9 +21,11 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
/** @var \Pterodactyl\Models\Server $server */ /** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
$originalName = $server->name; $originalName = $server->name;
$originalDescription = $server->description;
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/settings/rename", [ $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/settings/rename", [
'name' => '', 'name' => '',
'description' => '',
]); ]);
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
@ -31,15 +33,18 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
$server = $server->refresh(); $server = $server->refresh();
$this->assertSame($originalName, $server->name); $this->assertSame($originalName, $server->name);
$this->assertSame($originalDescription, $server->description);
$this->actingAs($user) $this->actingAs($user)
->postJson("/api/client/servers/$server->uuid/settings/rename", [ ->postJson("/api/client/servers/$server->uuid/settings/rename", [
'name' => 'Test Server Name', 'name' => 'Test Server Name',
'description' => 'This is a test server.',
]) ])
->assertStatus(Response::HTTP_NO_CONTENT); ->assertStatus(Response::HTTP_NO_CONTENT);
$server = $server->refresh(); $server = $server->refresh();
$this->assertSame('Test Server Name', $server->name); $this->assertSame('Test Server Name', $server->name);
$this->assertSame('This is a test server.', $server->description);
} }
/** /**