Add redis username
This commit is contained in:
@@ -25,6 +25,7 @@ class General extends Component
|
||||
'database.name' => 'required',
|
||||
'database.description' => 'nullable',
|
||||
'database.redis_conf' => 'nullable',
|
||||
'database.redis_username' => 'required',
|
||||
'database.redis_password' => 'required',
|
||||
'database.image' => 'required',
|
||||
'database.ports_mappings' => 'nullable',
|
||||
@@ -37,6 +38,7 @@ class General extends Component
|
||||
'database.name' => 'Name',
|
||||
'database.description' => 'Description',
|
||||
'database.redis_conf' => 'Redis Configuration',
|
||||
'database.redis_username' => 'Redis Username',
|
||||
'database.redis_password' => 'Redis Password',
|
||||
'database.image' => 'Image',
|
||||
'database.ports_mappings' => 'Port Mapping',
|
||||
@@ -73,16 +75,33 @@ class General extends Component
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
if ($this->database->redis_conf === '') {
|
||||
$this->database->redis_conf = null;
|
||||
|
||||
$redis_version = $this->get_redis_version();
|
||||
|
||||
if (version_compare($redis_version, '6.0', '>=')) {
|
||||
if ($this->database->isDirty('redis_username')) {
|
||||
$this->database->redis_username = $this->database->redis_username;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->database->isDirty('redis_password')) {
|
||||
$this->database->redis_password = $this->database->redis_password;
|
||||
}
|
||||
|
||||
$this->database->save();
|
||||
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_redis_version()
|
||||
{
|
||||
$image_parts = explode(':', $this->database->image);
|
||||
return $image_parts[1] ?? '0.0';
|
||||
}
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
try {
|
||||
@@ -123,4 +142,4 @@ class General extends Component
|
||||
{
|
||||
return view('livewire.project.database.redis.general');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user