Fix styling

This commit is contained in:
Thijmen
2024-06-10 20:43:34 +00:00
committed by github-actions[bot]
parent 41fb6a1fc9
commit d86274cc37
429 changed files with 5307 additions and 2831 deletions

View File

@@ -7,15 +7,23 @@ use Livewire\Component;
class Add extends Component
{
public $parameters;
public bool $shared = false;
public bool $is_preview = false;
public string $key;
public ?string $value = null;
public bool $is_build_time = false;
public bool $is_multiline = false;
public bool $is_literal = false;
protected $listeners = ['clearAddEnv' => 'clear'];
protected $rules = [
'key' => 'required|string',
'value' => 'nullable',
@@ -23,6 +31,7 @@ class Add extends Component
'is_multiline' => 'required|boolean',
'is_literal' => 'required|boolean',
];
protected $validationAttributes = [
'key' => 'key',
'value' => 'value',
@@ -40,9 +49,10 @@ class Add extends Component
{
$this->validate();
if (str($this->value)->startsWith('{{') && str($this->value)->endsWith('}}')) {
$type = str($this->value)->after("{{")->before(".")->value;
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
$type = str($this->value)->after('{{')->before('.')->value;
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
return;
}
}

View File

@@ -9,16 +9,24 @@ use Visus\Cuid2\Cuid2;
class All extends Component
{
public $resource;
public string $resourceClass;
public bool $showPreview = false;
public ?string $modalId = null;
public ?string $variables = null;
public ?string $variablesPreview = null;
public string $view = 'normal';
protected $listeners = [
'refreshEnvs',
'saveKey' => 'submit',
];
protected $rules = [
'resource.settings.is_env_sorting_enabled' => 'required|boolean',
];
@@ -27,8 +35,8 @@ class All extends Component
{
$this->resourceClass = get_class($this->resource);
$resourceWithPreviews = ['App\Models\Application'];
$simpleDockerfile = !is_null(data_get($this->resource, 'dockerfile'));
if (str($this->resourceClass)->contains($resourceWithPreviews) && !$simpleDockerfile) {
$simpleDockerfile = ! is_null(data_get($this->resource, 'dockerfile'));
if (str($this->resourceClass)->contains($resourceWithPreviews) && ! $simpleDockerfile) {
$this->showPreview = true;
}
$this->modalId = new Cuid2(7);
@@ -49,6 +57,7 @@ class All extends Component
}
$this->getDevView();
}
public function instantSave()
{
if ($this->resourceClass === 'App\Models\Application' && data_get($this->resource, 'build_pack') !== 'dockercompose') {
@@ -57,6 +66,7 @@ class All extends Component
$this->sortMe();
}
}
public function getDevView()
{
$this->variables = $this->resource->environment_variables->map(function ($item) {
@@ -66,6 +76,7 @@ class All extends Component
if ($item->is_multiline) {
return "$item->key=(multiline, edit in normal view)";
}
return "$item->key=$item->value";
})->join('
');
@@ -77,11 +88,13 @@ class All extends Component
if ($item->is_multiline) {
return "$item->key=(multiline, edit in normal view)";
}
return "$item->key=$item->value";
})->join('
');
}
}
public function switch()
{
if ($this->view === 'normal') {
@@ -91,6 +104,7 @@ class All extends Component
}
$this->sortMe();
}
public function saveVariables($isPreview)
{
if ($isPreview) {
@@ -113,22 +127,25 @@ class All extends Component
}
$found->value = $variable;
if (str($found->value)->startsWith('{{') && str($found->value)->endsWith('}}')) {
$type = str($found->value)->after("{{")->before(".")->value;
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
$type = str($found->value)->after('{{')->before('.')->value;
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
return;
}
}
$found->save();
continue;
} else {
$environment = new EnvironmentVariable();
$environment->key = $key;
$environment->value = $variable;
if (str($environment->value)->startsWith('{{') && str($environment->value)->endsWith('}}')) {
$type = str($environment->value)->after("{{")->before(".")->value;
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
$type = str($environment->value)->after('{{')->before('.')->value;
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
return;
}
}
@@ -177,6 +194,7 @@ class All extends Component
}
$this->refreshEnvs();
}
public function refreshEnvs()
{
$this->resource->refresh();
@@ -189,6 +207,7 @@ class All extends Component
$found = $this->resource->environment_variables()->where('key', $data['key'])->first();
if ($found) {
$this->dispatch('error', 'Environment variable already exists.');
return;
}
$environment = new EnvironmentVariable();

View File

@@ -10,14 +10,21 @@ use Visus\Cuid2\Cuid2;
class Show extends Component
{
public $parameters;
public ModelsEnvironmentVariable|SharedEnvironmentVariable $env;
public ?string $modalId = null;
public bool $isDisabled = false;
public bool $isLocked = false;
public bool $isSharedVariable = false;
public string $type;
protected $listeners = [
"compose_loaded" => '$refresh',
'compose_loaded' => '$refresh',
];
protected $rules = [
@@ -29,6 +36,7 @@ class Show extends Component
'env.is_shown_once' => 'required|boolean',
'env.real_value' => 'nullable',
];
protected $validationAttributes = [
'env.key' => 'Key',
'env.value' => 'Value',
@@ -47,6 +55,7 @@ class Show extends Component
$this->parameters = get_route_parameters();
$this->checkEnvs();
}
public function checkEnvs()
{
$this->isDisabled = false;
@@ -57,6 +66,7 @@ class Show extends Component
$this->isLocked = true;
}
}
public function serialize()
{
data_forget($this->env, 'real_value');
@@ -64,6 +74,7 @@ class Show extends Component
data_forget($this->env, 'is_build_time');
}
}
public function lock()
{
$this->env->is_shown_once = true;
@@ -72,10 +83,12 @@ class Show extends Component
$this->checkEnvs();
$this->dispatch('refreshEnvs');
}
public function instantSave()
{
$this->submit();
}
public function submit()
{
try {
@@ -89,9 +102,10 @@ class Show extends Component
$this->validate();
}
if (str($this->env->value)->startsWith('{{') && str($this->env->value)->endsWith('}}')) {
$type = str($this->env->value)->after("{{")->before(".")->value;
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
$type = str($this->env->value)->after('{{')->before('.')->value;
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
return;
}
}