feat(media dir nav): navigation through sub directories and breadcrumbs - #4670
feat(media dir nav): navigation through sub directories and breadcrumbs#4670andrew-paterson wants to merge 64 commits into
Conversation
a750ae1 to
cd217d3
Compare
|
Hi @andrew-paterson, thank you for this - great draft PR. Then we only need to maintain the See my commit to reflect those changes and please let me know what you think. I haven't look into the UI yet, but I hope my changes address your questions. I think the next steps are to see how we handle file uploads and also editorial workflow. For the latter each entry can have its own media folder at the global level, collection level and even at the field level.
|
cd217d3 to
b712a7e
Compare
|
|
Thank you very much for you work, I started using Netlify a short while ago and I am still in the process of publishing my first website managed this way, and the first issue that came was that there is no hierarchy in the media folder (the site is composed of many photo galleries). I just discovered that you are working on this. And indeed, the next thing is going to be the file upload where uploading a single file at a time is not very convenient. |
391aede to
cada8c9
Compare
…ses media library
|
@erezrokah thank you for the refactor! A few updates:
I think the next things should be folder creation and uploading multiple files, but I will wait for your feedback before I start on any of that. |
|
@erezrokah thank you. I have pushed an update where inserting files from a field seems to be working better now, both where a field has a |
|
Running tests for http://localhost:8080/__/#/tests/integration/media_library_spec_github_backend_rest.js, I get a failure when trying to save the entry. API 404 seems to be an error from the mock server. Is this correct? I just want to make sure I understand where this error is coming from. Incidentally, saving an entry with an image using the editorial workflow works fine when I do it manually, pointing to my own Github repo. |
Yes the server is returning 404 for a specific request. We use pre-recorded data, so something might have changed with the requests the CMS sends. I would first make sure the non GitHub/Bitbucket/GitLab/Git Gateway tests work as they don't rely on pre-recorded data. |
|
Ok all of the following tests are passing: I believe those are all the e2e tests that don't rely on a mock backend service. Any ideas on how to approach the backend specific tests? I have no idea what is going wrong with those. |
Let me look into the Cypress failing tests. Does |
|
The result of |
|
You can run |
|
Thanks. I need to do that and push one more update. |
|
Ok there are 4 unit tests failing, that I'm struggling with a little- notes below. The same e2e tests mentioned above are all passing. 1
The This test only passes the public folder to the function: I don't think this is allowed by the actual application, and I'm not sure I can get this test to pass with the new pattern. 2In the latest version of the It's working fine for me in the app, but in the unit tests, After concatenating the media files and entry files, I don't get any objects, and this is causing issues. I'm not sure if this is just an issue with the tests themselves, or if this is a problem for the wider application? |
|
Curious what the status is on this pull request. I am very interested in this feature. |
|
@erezrokah What still needs to be done for this to be merged? Is it only the two merge conflicts and the 3 (I think) failing tests? |
Hi @SignSpice
|
|
@andrew-paterson are you still interested in moving this forward? |
- Resolved merge conflict in entries.ts - Integrated normalizeDoubleSlashes fix from main into selectPublicFolder - Maintained feat/nested_media_dirs functionality with selectPublicFolder helper

This is just a small first step in attempting nested media directories (#3240)
So far it only works with Github, and only navigation up and down directories with breadcrumbs is implemented. As I'm not too familiar with the codebase, it would help to have someone give it a cursory sanity check, before continuing too far on the current path.
My approach has been to add a
listDirsfunction topackages/netlify-cms-backend-github/src/API.tsand then update thegetMedia()function inpackages/netlify-cms-backend-github/src/implementation.tsxto run bothlistFiles()andlistDirs()and concatenate the result.This means both the directories and files are passed to the
MediaLibrarycomponent in thefilesarray. As the Github type is included with each object in the array, thetoTableData()function inpackages/netlify-cms-core/src/components/MediaLibrary/MediaLibrary.jssets theisDirectoryprop for each file object, based on whether it is atreeorblob. TheMediaLibraryCardcomponent can display and behave accordingly.I'm struggling to see if it would be wiser to pass the directories to the component as a separate array altogether. One issue is that a directory should not technically have a
displayURLprop, but if ommitted the following error is thown:Warning: Failed prop type: The prop files[0].displayURL is marked as required in MediaLibrary, but its value is undefinedI'm also not 100% sure if the way in which I've added the
updateMediaFolder()action is correct. Lastly, in order to get the default media directory into the breadcrumbs component, I have ended up adding an action calledgetDefaultMediaFolder()to set a prop calleddefaultMediaFolderand pass that to the component.I'm guessing there is an easier way to get a prop from the site config into a component?