mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 15:32:35 +00:00
Add database and database users sync (#537)
* Add database and database users sync * get mysl users * add mariadb and postgres * fix phpstan
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
namespace App\Web\Pages\Servers\Databases;
|
||||
|
||||
use App\Actions\Database\CreateDatabase;
|
||||
use App\Actions\Database\SyncDatabases;
|
||||
use App\Models\Database;
|
||||
use App\Models\Server;
|
||||
use App\Web\Contracts\HasSecondSubNav;
|
||||
@ -85,6 +86,26 @@ public static function getCollationInput(Server $server): Select
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('sync')
|
||||
->color('gray')
|
||||
->label('Sync Databases')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->authorize(fn () => auth()->user()?->can('create', [Database::class, $this->server]))
|
||||
->requiresConfirmation()
|
||||
->modalDescription('This will create databases that exist on the server but not in Vito.')
|
||||
->modalSubmitActionLabel('Sync')
|
||||
->action(function () {
|
||||
run_action($this, function () {
|
||||
app(SyncDatabases::class)->sync($this->server);
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Databases synced!')
|
||||
->send();
|
||||
});
|
||||
}),
|
||||
Action::make('create')
|
||||
->label('Create Database')
|
||||
->icon('heroicon-o-plus')
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Actions\Database\CreateDatabase;
|
||||
use App\Actions\Database\CreateDatabaseUser;
|
||||
use App\Actions\Database\SyncDatabaseUsers;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Web\Contracts\HasSecondSubNav;
|
||||
use App\Web\Pages\Servers\Page;
|
||||
@ -29,6 +30,26 @@ public function mount(): void
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('sync')
|
||||
->color('gray')
|
||||
->label('Sync Users')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->authorize(fn () => auth()->user()?->can('create', [DatabaseUser::class, $this->server]))
|
||||
->requiresConfirmation()
|
||||
->modalDescription('This will create db users that exist on the server but not in Vito.')
|
||||
->modalSubmitActionLabel('Sync')
|
||||
->action(function () {
|
||||
run_action($this, function () {
|
||||
app(SyncDatabaseUsers::class)->sync($this->server);
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Users synced!')
|
||||
->send();
|
||||
});
|
||||
}),
|
||||
Action::make('create')
|
||||
->icon('heroicon-o-plus')
|
||||
->modalWidth(MaxWidth::Large)
|
||||
@ -43,6 +64,7 @@ protected function getHeaderActions(): array
|
||||
Checkbox::make('remote')
|
||||
->label('Remote')
|
||||
->default(false)
|
||||
->visible(in_array($this->server->database()->name, ['mysql', 'mariadb']))
|
||||
->reactive(),
|
||||
TextInput::make('host')
|
||||
->label('Host')
|
||||
|
Reference in New Issue
Block a user