Fix db password rotation

updates the password textbox when password is rotated.
This commit is contained in:
notCharles 2024-05-18 18:13:06 -04:00
parent 597f74f105
commit 1bae239971

View File

@ -15,8 +15,6 @@ class DatabasesRelationManager extends RelationManager
{ {
protected static string $relationship = 'databases'; protected static string $relationship = 'databases';
protected $listeners = ['refresh' => 'refreshForm'];
public function form(Form $form): Form public function form(Form $form): Form
{ {
return $form return $form
@ -28,7 +26,7 @@ class DatabasesRelationManager extends RelationManager
Action::make('rotate') Action::make('rotate')
->icon('tabler-refresh') ->icon('tabler-refresh')
->requiresConfirmation() ->requiresConfirmation()
->action(fn (DatabasePasswordService $service, Database $database) => $service->handle($database)) ->action(fn (DatabasePasswordService $service, Database $database, $set) => $this->rotatePassword($service, $database, $set))
) )
->formatStateUsing(fn (Database $database) => decrypt($database->password)), ->formatStateUsing(fn (Database $database) => decrypt($database->password)),
Forms\Components\TextInput::make('remote')->label('Connections From'), Forms\Components\TextInput::make('remote')->label('Connections From'),
@ -60,4 +58,10 @@ class DatabasesRelationManager extends RelationManager
//Tables\Actions\EditAction::make(), //Tables\Actions\EditAction::make(),
]); ]);
} }
protected function rotatePassword(DatabasePasswordService $service, Database $database, $set): void
{
$newPassword = $service->handle($database);
$set('password', $newPassword);
}
} }