feat(SonataAdmin): Search in the choose media modal#129
Open
loic425 wants to merge 1 commit into
Open
Conversation
ebdd2a1 to
c9579d9
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a search capability to the SonataAdmin “choose media” modal by introducing a search UI in the modal list template and wiring it to server-side filtering of directories and medias.
Changes:
- Add translated labels for search UI (EN/FR).
- Render a search input/button in the “choose” modal list view and pass the current search value from the controller.
- Implement search behavior: JS augments modal navigation/submit flows and the controller switches to recursive listings with filter callbacks when searching.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Bridge/SonataAdmin/translations/JoliMediaSonataAdminBundle.fr.yaml | Adds FR labels for the search UI and tweaks a media success string. |
| src/Bridge/SonataAdmin/translations/JoliMediaSonataAdminBundle.en.yaml | Adds EN labels for the search UI. |
| src/Bridge/SonataAdmin/templates/list.html.twig | Adds the search form to the choose/choose-directory modal view. |
| src/Bridge/SonataAdmin/src/Controller/MediaAdminController.php | Reads search query param; enables recursive listing + filtering when searching; passes search to Twig. |
| src/Bridge/SonataAdmin/public/manifest.json | Updates asset hashes. |
| src/Bridge/SonataAdmin/public/joli-media-sonata-admin.b1b110a9.css | Rebuilt compiled CSS including .joli-media-search styling. |
| src/Bridge/SonataAdmin/public/joli-media-sonata-admin.27ab3a73.js | Rebuilt compiled JS including modal search behavior. |
| src/Bridge/SonataAdmin/public/entrypoints.json | Updates entrypoint asset hashes. |
| src/Bridge/SonataAdmin/assets/styles/media-choice.css | Adds .joli-media-search styling. |
| src/Bridge/SonataAdmin/assets/js/components/mediaSelector.js | Adds modal search state + URL handling + event wiring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
17
to
20
| fetchFolder = (url) => { | ||
| this.currentFolder = url; | ||
| return fetch(url).then((response) => response.text()); | ||
| }; |
Comment on lines
+47
to
+52
| newInput.addEventListener('search', () => { | ||
| if (!newInput.value) { | ||
| this.currentSearchValue = ''; | ||
| this.fetchFolder(this.currentFolder).then(this.configureModal); | ||
| } | ||
| }); |
Comment on lines
255
to
+267
| $trashPath = $this->getOriginalStorage()->getTrashPath(); | ||
|
|
||
| if ($trashPath === $currentKey || str_starts_with($currentKey, $trashPath . '/')) { | ||
| throw new ForbiddenPathException($trashPath); | ||
| } | ||
|
|
||
| $directories = $this->getOriginalStorage()->listDirectories($currentKey, recursive: false); | ||
| natcasesort($directories); | ||
| $dirFilter = null; | ||
| if ($hasSearch) { | ||
| $dirFilter = static fn (string $a): bool => str_contains(strtolower($a), strtolower($searchValue)); | ||
| } | ||
|
|
||
| $directories = $this->getOriginalStorage()->listDirectories($currentKey, recursive: $hasSearch, filter: $dirFilter); | ||
|
|
81fc37a to
2a48250
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.