update helper and disable input if variable is shared

This commit is contained in:
peaklabs-dev
2024-10-16 13:44:17 +02:00
parent 6f97d589ae
commit 85c3270dcc
3 changed files with 32 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Livewire\Project\Database\Redis;
use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy;
use App\Models\EnvironmentVariable;
use App\Models\Server;
use App\Models\StandaloneRedis;
use Exception;
@@ -144,6 +145,14 @@ class General extends Component
return view('livewire.project.database.redis.general');
}
public function isSharedVariable($name)
{
return EnvironmentVariable::where('key', $name)
->where('standalone_redis_id', $this->database->id)
->where('is_shared', true)
->exists();
}
private function updateEnvironmentVariable($key, $value)
{
$envVar = $this->database->runtime_environment_variables()

View File

@@ -21,7 +21,7 @@ class StandaloneRedis extends BaseModel
];
protected $attributes = [
'redis_username' => 'redis',
'redis_username' => 'default',
];
protected static function booted()
@@ -220,7 +220,8 @@ class StandaloneRedis extends BaseModel
return new Attribute(
get: function () {
$redis_version = $this->get_redis_version();
$username_part = version_compare($redis_version, '6.0', '>=') ? "{$this->redis_username}:" : "";
$username_part = version_compare($redis_version, '6.0', '>=') ? "{$this->redis_username}:" : '';
return "redis://{$username_part}{$this->redis_password}@{$this->uuid}:6379/0";
}
);
@@ -232,9 +233,11 @@ class StandaloneRedis extends BaseModel
get: function () {
if ($this->is_public && $this->public_port) {
$redis_version = $this->get_redis_version();
$username_part = version_compare($redis_version, '6.0', '>=') ? "{$this->redis_username}:" : "";
$username_part = version_compare($redis_version, '6.0', '>=') ? "{$this->redis_username}:" : '';
return "redis://{$username_part}{$this->redis_password}@{$this->destination->server->getIp}:{$this->public_port}/0";
}
return null;
}
);
@@ -243,6 +246,7 @@ class StandaloneRedis extends BaseModel
private function get_redis_version()
{
$image_parts = explode(':', $this->image);
return $image_parts[1] ?? '0.0';
}
@@ -309,9 +313,9 @@ class StandaloneRedis extends BaseModel
return $parsedCollection->toArray();
}
}
public function isBackupSolutionAvailable()
{
return false;
}
}