Skip to content

Commit

Permalink
feat: add customHelper to stack-form
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Oct 10, 2024
1 parent 789fc13 commit 9330a3f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/Livewire/Project/Service/StackForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public function mount()
$value = data_get($field, 'value');
$rules = data_get($field, 'rules', 'nullable');
$isPassword = data_get($field, 'isPassword', false);
$customHelper = data_get($field, 'customHelper', false);
$this->fields->put($key, [
'serviceName' => $serviceName,
'key' => $key,
'name' => $fieldKey,
'value' => $value,
'isPassword' => $isPassword,
'rules' => $rules,
'customHelper' => $customHelper,
]);

$this->rules["fields.$key.value"] = $rules;
Expand Down
16 changes: 16 additions & 0 deletions app/Models/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,21 @@ public function extraFields()
continue;
}
switch ($image) {
case $image->contains('castopod'):
$data = collect([]);
$disable_https = $this->environment_variables()->where('key', 'CP_DISABLE_HTTPS')->first();
if ($disable_https) {
$data = $data->merge([
'Disable HTTPS' => [
'key' => 'CP_DISABLE_HTTPS',
'value' => data_get($disable_https, 'value'),
'rules' => 'required',
'customHelper' => "If you want to use https, set this to 0. Variable name: CP_DISABLE_HTTPS",
],
]);
}
$fields->put('Castopod', $data->toArray());
break;
case $image->contains('label-studio'):
$data = collect([]);
$username = $this->environment_variables()->where('key', 'LABEL_STUDIO_USERNAME')->first();
Expand Down Expand Up @@ -1093,6 +1108,7 @@ public function saveExtraFields($fields)
foreach ($fields as $field) {
$key = data_get($field, 'key');
$value = data_get($field, 'value');
ray($key, $value);
$found = $this->environment_variables()->where('key', $key)->first();
if ($found) {
$found->value = $value;
Expand Down
9 changes: 7 additions & 2 deletions resources/views/livewire/project/service/stack-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@
<div class="grid grid-cols-2 gap-2">
@foreach ($fields as $serviceName => $field)
<div class="flex items-center gap-2"><span
class="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}<x-helper
helper="Variable name: {{ $serviceName }}" /></div>
class="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}
@if (data_get($field, 'customHelper'))
<x-helper helper="{{ data_get($field, 'customHelper') }}" />
@else
<x-helper helper="Variable name: {{ $serviceName }}" />
@endif
</div>
<x-forms.input type="{{ data_get($field, 'isPassword') ? 'password' : 'text' }}"
required="{{ str(data_get($field, 'rules'))?->contains('required') }}"
id="fields.{{ $serviceName }}.value"></x-forms.input>
Expand Down

0 comments on commit 9330a3f

Please sign in to comment.