Skip to content

Commit

Permalink
chore(workspace.xml): add .idea/workspace.xml file to version control
Browse files Browse the repository at this point in the history
fix(ImportAction.php): add support for custom acceptedMimeTypes in the FileUpload component to allow for more flexible file type validation
  • Loading branch information
fadilAndrian committed Oct 3, 2023
1 parent d090ed4 commit 4ee2f0f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
58 changes: 58 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/Actions/ImportAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class ImportAction extends Action

protected null|Closure $handleRecordCreation = null;

protected null|array $acceptedMimeTypes = [];

public static function getDefaultName(): ?string
{
return 'import';
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -184,4 +186,11 @@ public function handleRecordCreation(Closure $closure): static

return $this;
}

public function acceptedMimeTypes(array $mimeType)
{
$this->acceptedMimeTypes = $mimeType;

return $this;
}
}

0 comments on commit 4ee2f0f

Please sign in to comment.