Skip to content

feat(SonataAdmin): Search in the choose media modal#129

Open
loic425 wants to merge 1 commit into
jolicode:mainfrom
loic425:feat-sonata/search-in-choose-media-modal
Open

feat(SonataAdmin): Search in the choose media modal#129
loic425 wants to merge 1 commit into
jolicode:mainfrom
loic425:feat-sonata/search-in-choose-media-modal

Conversation

@loic425
Copy link
Copy Markdown
Contributor

@loic425 loic425 commented May 21, 2026

No description provided.

@loic425 loic425 changed the title feat(EasyAdmin): Search in the choose media modal feat(SonataAdmin): Search in the choose media modal May 21, 2026
@loic425 loic425 force-pushed the feat-sonata/search-in-choose-media-modal branch from ebdd2a1 to c9579d9 Compare May 21, 2026 15:33
@damienalexandre damienalexandre requested a review from Copilot May 26, 2026 13:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/Bridge/SonataAdmin/assets/js/components/mediaSelector.js Outdated
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);

@loic425 loic425 force-pushed the feat-sonata/search-in-choose-media-modal branch from 81fc37a to 2a48250 Compare May 29, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants