From 4ee2f0fb778081d4e4ceb5f7892f5aab33e509d9 Mon Sep 17 00:00:00 2001 From: Fadil Andrian Date: Tue, 3 Oct 2023 15:19:32 +0700 Subject: [PATCH] chore(workspace.xml): add .idea/workspace.xml file to version control fix(ImportAction.php): add support for custom acceptedMimeTypes in the FileUpload component to allow for more flexible file type validation --- .idea/workspace.xml | 58 ++++++++++++++++++++++++++++++++++++ src/Actions/ImportAction.php | 11 ++++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..2d901a5 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,58 @@ + + + + + + + + + $PROJECT_DIR$/composer.json + + + + + + + + + + + + + + + + 1696317651607 + + + + + + \ No newline at end of file diff --git a/src/Actions/ImportAction.php b/src/Actions/ImportAction.php index ad59b89..4296ea8 100644 --- a/src/Actions/ImportAction.php +++ b/src/Actions/ImportAction.php @@ -37,6 +37,8 @@ class ImportAction extends Action protected null|Closure $handleRecordCreation = null; + protected null|array $acceptedMimeTypes = []; + public static function getDefaultName(): ?string { return 'import'; @@ -84,7 +86,7 @@ public function setInitialForm(): void FileUpload::make('file') ->label('') ->required(! app()->environment('testing')) - ->acceptedFileTypes(config('filament-import.accepted_mimes')) + ->acceptedFileTypes(fn () => $this->acceptedMimeTypes ?: config('filament-import.accepted_mimes')) ->imagePreviewHeight('250') ->reactive() ->disk($this->getTemporaryDisk()) @@ -184,4 +186,11 @@ public function handleRecordCreation(Closure $closure): static return $this; } + + public function acceptedMimeTypes(array $mimeType) + { + $this->acceptedMimeTypes = $mimeType; + + return $this; + } }