Skip to content

Commit 9330a3f

Browse files
committed
feat: add customHelper to stack-form
1 parent 789fc13 commit 9330a3f

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

app/Livewire/Project/Service/StackForm.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ public function mount()
3434
$value = data_get($field, 'value');
3535
$rules = data_get($field, 'rules', 'nullable');
3636
$isPassword = data_get($field, 'isPassword', false);
37+
$customHelper = data_get($field, 'customHelper', false);
3738
$this->fields->put($key, [
3839
'serviceName' => $serviceName,
3940
'key' => $key,
4041
'name' => $fieldKey,
4142
'value' => $value,
4243
'isPassword' => $isPassword,
4344
'rules' => $rules,
45+
'customHelper' => $customHelper,
4446
]);
4547

4648
$this->rules["fields.$key.value"] = $rules;

app/Models/Service.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,21 @@ public function extraFields()
288288
continue;
289289
}
290290
switch ($image) {
291+
case $image->contains('castopod'):
292+
$data = collect([]);
293+
$disable_https = $this->environment_variables()->where('key', 'CP_DISABLE_HTTPS')->first();
294+
if ($disable_https) {
295+
$data = $data->merge([
296+
'Disable HTTPS' => [
297+
'key' => 'CP_DISABLE_HTTPS',
298+
'value' => data_get($disable_https, 'value'),
299+
'rules' => 'required',
300+
'customHelper' => "If you want to use https, set this to 0. Variable name: CP_DISABLE_HTTPS",
301+
],
302+
]);
303+
}
304+
$fields->put('Castopod', $data->toArray());
305+
break;
291306
case $image->contains('label-studio'):
292307
$data = collect([]);
293308
$username = $this->environment_variables()->where('key', 'LABEL_STUDIO_USERNAME')->first();
@@ -1093,6 +1108,7 @@ public function saveExtraFields($fields)
10931108
foreach ($fields as $field) {
10941109
$key = data_get($field, 'key');
10951110
$value = data_get($field, 'value');
1111+
ray($key, $value);
10961112
$found = $this->environment_variables()->where('key', $key)->first();
10971113
if ($found) {
10981114
$found->value = $value;

resources/views/livewire/project/service/stack-form.blade.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
<div class="grid grid-cols-2 gap-2">
2525
@foreach ($fields as $serviceName => $field)
2626
<div class="flex items-center gap-2"><span
27-
class="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}<x-helper
28-
helper="Variable name: {{ $serviceName }}" /></div>
27+
class="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}
28+
@if (data_get($field, 'customHelper'))
29+
<x-helper helper="{{ data_get($field, 'customHelper') }}" />
30+
@else
31+
<x-helper helper="Variable name: {{ $serviceName }}" />
32+
@endif
33+
</div>
2934
<x-forms.input type="{{ data_get($field, 'isPassword') ? 'password' : 'text' }}"
3035
required="{{ str(data_get($field, 'rules'))?->contains('required') }}"
3136
id="fields.{{ $serviceName }}.value"></x-forms.input>

0 commit comments

Comments
 (0)