mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 04:04:45 +02:00
Fix file writing (#1218)
This commit is contained in:
parent
20f271041a
commit
3639d7ccec
@ -70,10 +70,8 @@ class EditFiles extends Page
|
|||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
||||||
->icon('tabler-device-floppy')
|
->icon('tabler-device-floppy')
|
||||||
->keyBindings('mod+shift+s')
|
->keyBindings('mod+shift+s')
|
||||||
->action(function (array $data) {
|
->action(function () {
|
||||||
|
$this->getDaemonFileRepository()->putContent($this->path, $this->data['editor'] ?? '');
|
||||||
$this->getDaemonFileRepository()
|
|
||||||
->putContent($this->path, $data['editor'] ?? '');
|
|
||||||
|
|
||||||
Activity::event('server:file.write')
|
Activity::event('server:file.write')
|
||||||
->property('file', $this->path)
|
->property('file', $this->path)
|
||||||
@ -92,10 +90,8 @@ class EditFiles extends Page
|
|||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
||||||
->icon('tabler-device-floppy')
|
->icon('tabler-device-floppy')
|
||||||
->keyBindings('mod+s')
|
->keyBindings('mod+s')
|
||||||
->action(function (array $data) {
|
->action(function () {
|
||||||
|
$this->getDaemonFileRepository()->putContent($this->path, $this->data['editor'] ?? '');
|
||||||
$this->getDaemonFileRepository()
|
|
||||||
->putContent($this->path, $data['editor'] ?? '');
|
|
||||||
|
|
||||||
Activity::event('server:file.write')
|
Activity::event('server:file.write')
|
||||||
->property('file', $this->path)
|
->property('file', $this->path)
|
||||||
@ -127,8 +123,7 @@ class EditFiles extends Page
|
|||||||
->showPlaceholder(false)
|
->showPlaceholder(false)
|
||||||
->default(function () {
|
->default(function () {
|
||||||
try {
|
try {
|
||||||
return $this->getDaemonFileRepository()
|
return $this->getDaemonFileRepository()->getContent($this->path, config('panel.files.max_edit_size'));
|
||||||
->getContent($this->path, config('panel.files.max_edit_size'));
|
|
||||||
} catch (FileSizeTooLargeException) {
|
} catch (FileSizeTooLargeException) {
|
||||||
AlertBanner::make()
|
AlertBanner::make()
|
||||||
->title('File too large!')
|
->title('File too large!')
|
||||||
@ -136,6 +131,7 @@ class EditFiles extends Page
|
|||||||
->danger()
|
->danger()
|
||||||
->closable()
|
->closable()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$this->redirect(ListFiles::getUrl());
|
$this->redirect(ListFiles::getUrl());
|
||||||
} catch (FileNotFoundException) {
|
} catch (FileNotFoundException) {
|
||||||
AlertBanner::make()
|
AlertBanner::make()
|
||||||
@ -144,6 +140,7 @@ class EditFiles extends Page
|
|||||||
->danger()
|
->danger()
|
||||||
->closable()
|
->closable()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$this->redirect(ListFiles::getUrl());
|
$this->redirect(ListFiles::getUrl());
|
||||||
} catch (FileNotEditableException) {
|
} catch (FileNotEditableException) {
|
||||||
AlertBanner::make()
|
AlertBanner::make()
|
||||||
@ -152,6 +149,7 @@ class EditFiles extends Page
|
|||||||
->danger()
|
->danger()
|
||||||
->closable()
|
->closable()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$this->redirect(ListFiles::getUrl());
|
$this->redirect(ListFiles::getUrl());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user