@@ -2,10 +2,8 @@
|
||||
|
||||
namespace App\Livewire\Project\Shared\EnvironmentVariable;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\EnvironmentVariable;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class All extends Component
|
||||
{
|
||||
@@ -33,7 +31,7 @@ class All extends Component
|
||||
{
|
||||
$this->is_env_sorting_enabled = data_get($this->resource, 'settings.is_env_sorting_enabled', false);
|
||||
$this->resourceClass = get_class($this->resource);
|
||||
$resourceWithPreviews = [Application::class];
|
||||
$resourceWithPreviews = [\App\Models\Application::class];
|
||||
$simpleDockerfile = filled(data_get($this->resource, 'dockerfile'));
|
||||
if (str($this->resourceClass)->contains($resourceWithPreviews) && ! $simpleDockerfile) {
|
||||
$this->showPreview = true;
|
||||
@@ -103,13 +101,11 @@ class All extends Component
|
||||
|
||||
$this->updateOrder();
|
||||
$this->sortEnvironmentVariables();
|
||||
} catch (Throwable $e) {
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
$this->refreshEnvs();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function updateOrder()
|
||||
@@ -171,17 +167,17 @@ class All extends Component
|
||||
|
||||
private function createEnvironmentVariable($data)
|
||||
{
|
||||
$environmentVariable = new EnvironmentVariable;
|
||||
$environmentVariable->key = $data['key'];
|
||||
$environmentVariable->value = $data['value'];
|
||||
$environmentVariable->is_build_time = $data['is_build_time'] ?? false;
|
||||
$environmentVariable->is_multiline = $data['is_multiline'] ?? false;
|
||||
$environmentVariable->is_literal = $data['is_literal'] ?? false;
|
||||
$environmentVariable->is_preview = $data['is_preview'] ?? false;
|
||||
$environmentVariable->resourceable_id = $this->resource->id;
|
||||
$environmentVariable->resourceable_type = $this->resource->getMorphClass();
|
||||
$environment = new EnvironmentVariable;
|
||||
$environment->key = $data['key'];
|
||||
$environment->value = $data['value'];
|
||||
$environment->is_build_time = $data['is_build_time'] ?? false;
|
||||
$environment->is_multiline = $data['is_multiline'] ?? false;
|
||||
$environment->is_literal = $data['is_literal'] ?? false;
|
||||
$environment->is_preview = $data['is_preview'] ?? false;
|
||||
$environment->resourceable_id = $this->resource->id;
|
||||
$environment->resourceable_type = $this->resource->getMorphClass();
|
||||
|
||||
return $environmentVariable;
|
||||
return $environment;
|
||||
}
|
||||
|
||||
private function deleteRemovedVariables($isPreview, $variables)
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Livewire\Project\Shared\EnvironmentVariable;
|
||||
|
||||
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
|
||||
use App\Models\SharedEnvironmentVariable;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
|
||||
class Show extends Component
|
||||
@@ -61,7 +60,7 @@ class Show extends Component
|
||||
public function mount()
|
||||
{
|
||||
$this->syncData();
|
||||
if ($this->env->getMorphClass() === SharedEnvironmentVariable::class) {
|
||||
if ($this->env->getMorphClass() === \App\Models\SharedEnvironmentVariable::class) {
|
||||
$this->isSharedVariable = true;
|
||||
}
|
||||
$this->parameters = get_route_parameters();
|
||||
@@ -117,7 +116,7 @@ class Show extends Component
|
||||
public function serialize()
|
||||
{
|
||||
data_forget($this->env, 'real_value');
|
||||
if ($this->env->getMorphClass() === SharedEnvironmentVariable::class) {
|
||||
if ($this->env->getMorphClass() === \App\Models\SharedEnvironmentVariable::class) {
|
||||
data_forget($this->env, 'is_build_time');
|
||||
}
|
||||
}
|
||||
@@ -157,7 +156,7 @@ class Show extends Component
|
||||
$this->value = $oldValue;
|
||||
$this->dispatch('error', 'Required environment variable cannot be empty.');
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->serialize();
|
||||
@@ -169,11 +168,9 @@ class Show extends Component
|
||||
$this->syncData(true);
|
||||
$this->dispatch('success', 'Environment variable updated.');
|
||||
$this->dispatch('envsUpdated');
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return handleError($e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
@@ -182,10 +179,8 @@ class Show extends Component
|
||||
$this->env->delete();
|
||||
$this->dispatch('environmentVariableDeleted');
|
||||
$this->dispatch('success', 'Environment variable deleted successfully.');
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return handleError($e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user