Skip to content

Commit 2212f28

Browse files
committed
Don't break the page if no variable rules are provided.
1 parent bd5952b commit 2212f28

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
66
### v0.7.0-beta.5 (Derelict Dermodactylus)
77
### Fixed
88
* `[beta.4]` — Fixes some bad search and replace action that happened previously and was throwing errors when validating user permissions.
9+
* `[beta.4]` — Fixes behavior of variable validation to not break the page when no rules are provided.
910

1011
## v0.7.0-beta.4 (Derelict Dermodactylus)
1112
### Fixed

app/Http/Requests/Admin/Egg/EggVariableFormRequest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Http\Requests\Admin\Egg;
114

@@ -15,6 +8,8 @@
158
class EggVariableFormRequest extends AdminFormRequest
169
{
1710
/**
11+
* Define rules for validation of this request.
12+
*
1813
* @return array
1914
*/
2015
public function rules()
@@ -23,7 +18,7 @@ public function rules()
2318
'name' => 'required|string|min:1|max:255',
2419
'description' => 'sometimes|nullable|string',
2520
'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES,
26-
'default_value' => 'string',
21+
'default_value' => 'nullable|string',
2722
'options' => 'sometimes|required|array',
2823
'rules' => 'bail|required|string',
2924
];
@@ -41,6 +36,13 @@ public function withValidator($validator)
4136
$rules = $this->input('rules', $this->route()->parameter('egg')->rules);
4237
}
4338

39+
// If rules is not a string it is already violating the rule defined above
40+
// so just skip the addition of default value rules since this request
41+
// will fail anyways.
42+
if (! is_string($rules)) {
43+
return;
44+
}
45+
4446
$validator->addRules(['default_value' => $rules]);
4547
}
4648
}

resources/themes/pterodactyl/admin/eggs/variables.blade.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,40 +99,40 @@
9999
<div class="modal-content">
100100
<div class="modal-header">
101101
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
102-
<h4 class="modal-title">Create New Option Variable</h4>
102+
<h4 class="modal-title">Create New Egg Variable</h4>
103103
</div>
104104
<form action="{{ route('admin.nests.egg.variables', $egg->id) }}" method="POST">
105105
<div class="modal-body">
106106
<div class="form-group">
107-
<label class="form-label">Name</label>
107+
<label class="control-label">Name <span class="field-required"></span></label>
108108
<input type="text" name="name" class="form-control" />
109109
</div>
110110
<div class="form-group">
111-
<label class="form-label">Description</label>
111+
<label class="control-label">Description</label>
112112
<textarea name="description" class="form-control" rows="3"></textarea>
113113
</div>
114114
<div class="row">
115115
<div class="form-group col-md-6">
116-
<label class="form-label">Environment Variable</label>
116+
<label class="control-label">Environment Variable <span class="field-required"></span></label>
117117
<input type="text" name="env_variable" class="form-control" />
118118
</div>
119119
<div class="form-group col-md-6">
120-
<label class="form-label">Default Value</label>
120+
<label class="control-label">Default Value</label>
121121
<input type="text" name="default_value" class="form-control" />
122122
</div>
123123
<div class="col-xs-12">
124124
<p class="text-muted small">This variable can be accessed in the statup command by entering <code>@{{environment variable value}}</code>.</p>
125125
</div>
126126
</div>
127127
<div class="form-group">
128-
<label class="form-label">Permissions</label>
128+
<label class="control-label">Permissions</label>
129129
<select name="options[]" class="pOptions form-control" multiple>
130130
<option value="user_viewable">Users Can View</option>
131131
<option value="user_editable">Users Can Edit</option>
132132
</select>
133133
</div>
134134
<div class="form-group">
135-
<label class="form-label">Input Rules</label>
135+
<label class="control-label">Input Rules <span class="field-required"></span></label>
136136
<input type="text" name="rules" class="form-control" value="required|string|max:20" placeholder="required|string|max:20" />
137137
<p class="text-muted small">These rules are defined using standard Laravel Framework validation rules.</p>
138138
</div>

0 commit comments

Comments
 (0)