update helper and disable input if variable is shared
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Livewire\Project\Database\Redis;
|
|||||||
|
|
||||||
use App\Actions\Database\StartDatabaseProxy;
|
use App\Actions\Database\StartDatabaseProxy;
|
||||||
use App\Actions\Database\StopDatabaseProxy;
|
use App\Actions\Database\StopDatabaseProxy;
|
||||||
|
use App\Models\EnvironmentVariable;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneRedis;
|
use App\Models\StandaloneRedis;
|
||||||
use Exception;
|
use Exception;
|
||||||
@@ -144,6 +145,14 @@ class General extends Component
|
|||||||
return view('livewire.project.database.redis.general');
|
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)
|
private function updateEnvironmentVariable($key, $value)
|
||||||
{
|
{
|
||||||
$envVar = $this->database->runtime_environment_variables()
|
$envVar = $this->database->runtime_environment_variables()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class StandaloneRedis extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $attributes = [
|
protected $attributes = [
|
||||||
'redis_username' => 'redis',
|
'redis_username' => 'default',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
@@ -220,7 +220,8 @@ class StandaloneRedis extends BaseModel
|
|||||||
return new Attribute(
|
return new Attribute(
|
||||||
get: function () {
|
get: function () {
|
||||||
$redis_version = $this->get_redis_version();
|
$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";
|
return "redis://{$username_part}{$this->redis_password}@{$this->uuid}:6379/0";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -232,9 +233,11 @@ class StandaloneRedis extends BaseModel
|
|||||||
get: function () {
|
get: function () {
|
||||||
if ($this->is_public && $this->public_port) {
|
if ($this->is_public && $this->public_port) {
|
||||||
$redis_version = $this->get_redis_version();
|
$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 "redis://{$username_part}{$this->redis_password}@{$this->destination->server->getIp}:{$this->public_port}/0";
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -243,6 +246,7 @@ class StandaloneRedis extends BaseModel
|
|||||||
private function get_redis_version()
|
private function get_redis_version()
|
||||||
{
|
{
|
||||||
$image_parts = explode(':', $this->image);
|
$image_parts = explode(':', $this->image);
|
||||||
|
|
||||||
return $image_parts[1] ?? '0.0';
|
return $image_parts[1] ?? '0.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,9 +313,9 @@ class StandaloneRedis extends BaseModel
|
|||||||
return $parsedCollection->toArray();
|
return $parsedCollection->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBackupSolutionAvailable()
|
public function isBackupSolutionAvailable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,22 @@
|
|||||||
$redis_version = explode(':', $database->image)[1] ?? '0.0';
|
$redis_version = explode(':', $database->image)[1] ?? '0.0';
|
||||||
@endphp
|
@endphp
|
||||||
@if (version_compare($redis_version, '6.0', '>='))
|
@if (version_compare($redis_version, '6.0', '>='))
|
||||||
<x-forms.input label="Username" id="database.redis_username" required helper="If you change this in the database, please sync it here, otherwise automations (like backups) won't work. <br><br>
|
<x-forms.input label="Username" id="database.redis_username" required
|
||||||
<strong>Warning:</strong> If you have set a REDIS_USERNAME environment variable in the Environment Variables tab (team variable or otherwise), and change the Value here in the UI field, the change will be overwritten by the REDIS_USERNAME environment variable value." />
|
helper="You can change the Redis Username in the input field below or by editing the value of the REDIS_USERNAME environment variable.
|
||||||
|
<br><br>
|
||||||
|
If you change the Redis Username in the database, please sync it here, otherwise automations (like backups) won't work.
|
||||||
|
<br><br>
|
||||||
|
Note: If the environment variable REDIS_USERNAME is set as a shared variable (environment, project, or team-based), this input field will become read-only."
|
||||||
|
:disabled="$this->isSharedVariable('REDIS_USERNAME')" />
|
||||||
@endif
|
@endif
|
||||||
<x-forms.input label="Password" id="database.redis_password" type="password" required helper="If you change this in the database, please sync it here, otherwise automations (like backups) won't work. <br><br>
|
<x-forms.input label="Password" id="database.redis_password" type="password" required
|
||||||
<strong>Warning:</strong> If you have set a REDIS_PASSWORD environment variable in the Environment Variables tab (team variable or otherwise), and change the Value here in the UI field, the change will be overwritten by the REDIS_PASSWORD environment variable value." wire:model.defer="database.redis_password" />
|
helper="You can change the Redis Password in the input field below or by editing the value of the REDIS_PASSWORD environment variable.
|
||||||
|
<br><br>
|
||||||
|
If you change the Redis Password in the database, please sync it here, otherwise automations (like backups) won't work.
|
||||||
|
<br><br>
|
||||||
|
Note: If the environment variable REDIS_PASSWORD is set as a shared variable (environment, project, or team-based), this input field will become read-only."
|
||||||
|
wire:model.defer="database.redis_password"
|
||||||
|
:disabled="$this->isSharedVariable('REDIS_PASSWORD')" />
|
||||||
</div>
|
</div>
|
||||||
<x-forms.input
|
<x-forms.input
|
||||||
helper="You can add custom docker run options that will be used when your container is started.<br>Note: Not all options are supported, as they could mess up Coolify's automation and could cause bad experience for users.<br><br>Check the <a class='underline dark:text-white' href='https://coolify.io/docs/knowledge-base/docker/custom-commands'>docs.</a>"
|
helper="You can add custom docker run options that will be used when your container is started.<br>Note: Not all options are supported, as they could mess up Coolify's automation and could cause bad experience for users.<br><br>Check the <a class='underline dark:text-white' href='https://coolify.io/docs/knowledge-base/docker/custom-commands'>docs.</a>"
|
||||||
|
|||||||
Reference in New Issue
Block a user