Problem/Motivation
There are 11 usages of drupalSettings.project_browser.module_path in Svelte, but only 6 of them correctly have drupalSettings.project_browser.origin_url preceding it.
The 5 incorrect usages are in FilterApplied.svelte and Search.svelte.
Steps to reproduce
Install Drupal within a subdirectory, install Project Browser, note that some images are missing (404s in the console)
Proposed resolution
Add usage of origin_url
Optionally, consider refactoring this per nod_'s suggestion:
Also I'm seeing many uses of drupalSettings.project_browser.origin_url it would be better to have a helper that generates the urls instead of hardcoding that all over the place. same for everything that access drupalSettings in fact. having a settings() or something function that gets the value from drupalSettings safely would help with preventing too much "drupal" going into the frontend part.
Remaining tasks
- ✅ File an issue about this project
- ☐ Manual Testing
- ☐ Code Review
- ☐ Accessibility Review
- ☐ Automated tests needed/written?
| Comment | File | Size | Author |
|---|
Issue fork project_browser-3293424
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
libbna commentedI will work on this.
Comment #4
libbna commentedComment #5
narendrarComment #6
libbna commentedokay. I will updated the requested changes.
Comment #7
narendrarHi @Libbna, you can take reference from https://www.drupal.org/project/project_browser/issues/3293937 and use same constants (ORIGIN_URL and MODULE_PATH) and replace all references todrupalSettings.project_browser.origin_urlanddrupalSettings.project_browser.module_pathComment #8
narendrarHi @Libbna, you can take reference from https://www.drupal.org/project/project_browser/issues/3293937 and use same constants (ORIGIN_URL and MODULE_PATH) and replace all references to
drupalSettings.project_browser.origin_urlanddrupalSettings.project_browser.module_pathComment #9
libbna commentedthank you @narendraR I will look into it.
Comment #10
libbna commentedComment #11
omkar-pd commentedThere are still some usage of
drupalSettings.project_browser.origin_url and drupalSettings .project_browser.module_pathin Project.Svelte, Filter.svelte, ProjectBrowser.svelte check other files as well.Comment #12
libbna commentedComment #13
tim.plunkettThis is definitely an improvement. But are there really places we use either of them alone? Why not concatenate them together and have one variable?
Comment #14
libbna commented@tim.plunkett there are places for e.g. in
ActionButton.sveltewhere.origin_urlis used alone.Either we can create 3 variables, one for origin_url, and 2nd for module_path and 3rd variable will be the concatenate of both of them or have 2 separate variables like now.
Comment #15
libbna commentedAlso I have just noticed that there are few areas left to change. I will work on that asap.
Comment #16
omkar-pd commentedstill there are couple of usage of
drupalSettings.project_browser.origin_urlanddrupalSettings .project_browser.module_pathinProject.svelte.Comment #17
omkar-pd commentedAnd as suggested in #13. We can concatenate
ORIGIN_URLandMODULE_PATH.Maybe something like this.
and use like this
src="{FULL_URL}/images/project-usage-icon.svg"instead of
Comment #18
libbna commentedYes we can use one variable for whole url. Ok will work on this.
Comment #19
libbna commentedComment #20
narendrarThere seems unwanted code from other MR. Can you please either remove those or create a new MR with only required changes? Also there are still some references of
drupalSettings.project_browser.modulesin ActionButton.svelte, so please create constant for that also.Constants can be ORIGIN_URL, MODULE_PATH and FULL_MODULE_PATH
Comment #21
libbna commentedComment #22
libbna commentedComment #23
tim.plunkettReviewed the MR with
git diff --color-words=\[^_,\] origin/1.0.xwhich revealed a couple more things to fixComment #24
libbna commentedI will make the necessary changes, thanks @tim.plunkett for reviewing.
Comment #25
libbna commentedComment #26
tim.plunkettEDIT nevermind, this wasn't going to work. Was just desperately trying something, but it seems that there's a larger CI issue happening right now. Back to the MR.
Comment #27
tim.plunkettShould be nothing left to do but merge, once the bots work again.
Comment #29
tim.plunkettAnd we're back! Getting this in now before anything else is committed. Thanks @Libbna for seeing this one through!