-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
451 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace GeoSot\FilamentEnvEditor\Pages\Actions\Backups; | ||
|
||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Support\Colors\Color; | ||
use Filament\Support\Enums\ActionSize; | ||
use GeoSot\EnvEditor\Dto\BackupObj; | ||
use GeoSot\EnvEditor\Facades\EnvEditor; | ||
use GeoSot\FilamentEnvEditor\Pages\ViewEnv; | ||
|
||
class DeleteBackupAction extends Action | ||
{ | ||
private BackupObj $entry; | ||
|
||
public static function getDefaultName(): ?string | ||
{ | ||
return 'delete'; | ||
} | ||
|
||
public function setEntry(BackupObj $obj): static | ||
{ | ||
$this->entry = $obj; | ||
|
||
return $this; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->icon('heroicon-o-trash'); | ||
$this->hiddenLabel(); | ||
$this->outlined(); | ||
$this->color(Color::Rose); | ||
|
||
$this->size(ActionSize::Small); | ||
$this->tooltip(fn (): string => __('filament-env-editor::filament-env-editor.actions.delete-backup.tooltip', ['name' => $this->entry->name])); | ||
$this->modalIcon('heroicon-o-trash'); | ||
$this->modalHeading(fn (): string => __('filament-env-editor::filament-env-editor.actions.delete-backup.confirm.title', ['name' => $this->entry->name])); | ||
|
||
$this->action(function (ViewEnv $page) { | ||
EnvEditor::deleteBackup($this->entry->name); | ||
$page->refresh(); | ||
}); | ||
|
||
$this->requiresConfirmation(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace GeoSot\FilamentEnvEditor\Pages\Actions\Backups; | ||
|
||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Support\Colors\Color; | ||
use GeoSot\EnvEditor\EnvEditor; | ||
use GeoSot\EnvEditor\Exceptions\EnvException; | ||
|
||
class DownloadEnvFileAction extends Action | ||
{ | ||
private string $file = ''; | ||
|
||
public static function getDefaultName(): ?string | ||
{ | ||
return 'download'; | ||
} | ||
|
||
public function setEntry(string $file): static | ||
{ | ||
$this->file = $file; | ||
|
||
return $this; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->label(fn (): string => __('filament-env-editor::filament-env-editor.actions.download.title')); | ||
$this->tooltip(fn (): string => __('filament-env-editor::filament-env-editor.actions.download.tooltip', ['name' => $this->file])); | ||
|
||
$this->outlined(); | ||
$this->icon('heroicon-c-inbox-arrow-down'); | ||
|
||
$this->action(function () { | ||
$result = false; | ||
try { | ||
$result = app(EnvEditor::class)->getFilePath($this->file); | ||
} catch (EnvException $exception) { | ||
$this->failureNotificationTitle($exception->getMessage()); | ||
$this->failure(); | ||
$this->halt(); | ||
} | ||
|
||
return response()->download($result); | ||
}); | ||
|
||
$this->color(Color::Sky); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace GeoSot\FilamentEnvEditor\Pages\Actions\Backups; | ||
|
||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Support\Colors\Color; | ||
use GeoSot\EnvEditor\Exceptions\EnvException; | ||
use GeoSot\EnvEditor\Facades\EnvEditor; | ||
use GeoSot\FilamentEnvEditor\Pages\ViewEnv; | ||
|
||
class MakeBackupAction extends Action | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->label(fn (): string => __('filament-env-editor::filament-env-editor.actions.backup.title')); | ||
|
||
$this->action(function (array $data, ViewEnv $page) { | ||
$result = false; | ||
try { | ||
$result = EnvEditor::backUpCurrent(); | ||
$page->refresh(); | ||
$this->successNotificationTitle(fn ( | ||
): string => __('filament-env-editor::filament-env-editor.actions.backup.success.title')); | ||
} catch (EnvException $exception) { | ||
$this->failureNotificationTitle($exception->getMessage()); | ||
$this->failure(); | ||
$this->halt(); | ||
} | ||
|
||
$result ? $this->success() : $this->failure(); | ||
}); | ||
|
||
$this->color(Color::Teal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace GeoSot\FilamentEnvEditor\Pages\Actions\Backups; | ||
|
||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Support\Colors\Color; | ||
use Filament\Support\Enums\ActionSize; | ||
use GeoSot\EnvEditor\Facades\EnvEditor; | ||
use GeoSot\FilamentEnvEditor\Pages\ViewEnv; | ||
|
||
class RestoreBackupAction extends Action | ||
{ | ||
private string $file; | ||
|
||
public static function getDefaultName(): ?string | ||
{ | ||
return 'restore'; | ||
} | ||
|
||
public function setEntry(string $file): static | ||
{ | ||
$this->file = $file; | ||
|
||
return $this; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->icon('heroicon-s-bars-arrow-up'); | ||
$this->hiddenLabel(); | ||
$this->outlined(); | ||
$this->color(Color::Teal); | ||
|
||
$this->size(ActionSize::Small); | ||
$this->tooltip(fn (): string => __('filament-env-editor::filament-env-editor.actions.restore-backup.tooltip', | ||
['name' => $this->file])); | ||
$this->modalIcon('heroicon-s-bars-arrow-up'); | ||
$this->modalHeading(fn ( | ||
): string => __('filament-env-editor::filament-env-editor.actions.restore-backup.confirm.title', | ||
['name' => $this->file])); | ||
|
||
$this->action(function (ViewEnv $page) { | ||
EnvEditor::restoreBackUp($this->file); | ||
$page->refresh(); | ||
}); | ||
|
||
$this->requiresConfirmation(); | ||
$this->modalSubmitActionLabel(fn ( | ||
) => __('filament-env-editor::filament-env-editor.actions.restore-backup.modalSubmit')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace GeoSot\FilamentEnvEditor\Pages\Actions\Backups; | ||
|
||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Forms\Components\Placeholder; | ||
use Filament\Support\Colors\Color; | ||
use Filament\Support\Enums\ActionSize; | ||
use GeoSot\EnvEditor\Dto\BackupObj; | ||
use Illuminate\Support\HtmlString; | ||
|
||
class ShowBackupContentAction extends Action | ||
{ | ||
private BackupObj $entry; | ||
|
||
public static function getDefaultName(): ?string | ||
{ | ||
return 'show_raw_content_'; | ||
} | ||
|
||
public function setEntry(BackupObj $obj): static | ||
{ | ||
$this->entry = $obj; | ||
|
||
return $this; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->modalHeading(fn (): string => __('filament-env-editor::filament-env-editor.actions.show-content.modalHeading', ['name' => $this->entry->name])); | ||
$this->tooltip(fn (): string => __('filament-env-editor::filament-env-editor.actions.show-content.tooltip')); | ||
$this->hiddenLabel(); | ||
$this->outlined(); | ||
$this->modalSubmitAction(false); | ||
$this->icon('heroicon-o-newspaper'); | ||
$this->size(ActionSize::Small); | ||
|
||
$this->form(fn () => [ | ||
Placeholder::make('')->content(new HtmlString("<pre>{$this->entry->rawContent}</pre>")), | ||
]); | ||
|
||
$this->color(Color::Zinc); | ||
} | ||
} |
Oops, something went wrong.