mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 16:44:44 +02:00
Add bulk move (#1117)
This commit is contained in:
parent
3d29243cf0
commit
4a7951995e
@ -332,21 +332,19 @@ class ListFiles extends ListRecords
|
|||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
BulkAction::make('move')
|
BulkAction::make('move')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
||||||
->hidden() // TODO
|
|
||||||
->form([
|
->form([
|
||||||
TextInput::make('location')
|
TextInput::make('location')
|
||||||
->label('File name')
|
->label('Directory')
|
||||||
->hint('Enter the new name and directory of this file or folder, relative to the current directory.')
|
->hint('Enter the new directory, relative to the current directory.')
|
||||||
->default(fn (File $file) => $file->name)
|
|
||||||
->required()
|
->required()
|
||||||
->live(),
|
->live(),
|
||||||
Placeholder::make('new_location')
|
Placeholder::make('new_location')
|
||||||
->content(fn (Get $get) => resolve_path('./' . join_paths($this->path, $get('location') ?? ''))),
|
->content(fn (Get $get) => resolve_path('./' . join_paths($this->path, $get('location') ?? ''))),
|
||||||
])
|
])
|
||||||
->action(function (Collection $files, $data) {
|
->action(function (Collection $files, $data) {
|
||||||
$location = resolve_path(join_paths($this->path, $data['location']));
|
$location = rtrim($data['location'], '/');
|
||||||
|
|
||||||
$files = $files->map(fn ($file) => ['to' => $location, 'from' => $file['name']])->toArray();
|
$files = $files->map(fn ($file) => ['to' => join_paths($location, $file['name']), 'from' => $file['name']])->toArray();
|
||||||
$this->getDaemonFileRepository()
|
$this->getDaemonFileRepository()
|
||||||
->renameFiles($this->path, $files);
|
->renameFiles($this->path, $files);
|
||||||
|
|
||||||
@ -356,7 +354,7 @@ class ListFiles extends ListRecords
|
|||||||
->log();
|
->log();
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title(count($files) . ' Files were moved from ' . $location)
|
->title(count($files) . ' Files were moved to ' . resolve_path(join_paths($this->path, $location)))
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user