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?
CommentFileSizeAuthor
#26 3293424-be-consistent-in-26.patch69.73 KBtim.plunkett
Command icon 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

tim.plunkett created an issue. See original summary.

libbna’s picture

Assigned: Unassigned » libbna

I will work on this.

libbna’s picture

Assigned: libbna » Unassigned
Status: Active » Needs review
narendrar’s picture

Status: Needs review » Needs work
libbna’s picture

Assigned: Unassigned » libbna

okay. I will updated the requested changes.

narendrar’s picture

Hi @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_url and drupalSettings.project_browser.module_path

narendrar’s picture

Hi @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_url and drupalSettings.project_browser.module_path

libbna’s picture

thank you @narendraR I will look into it.

libbna’s picture

Status: Needs work » Needs review
omkar-pd’s picture

Status: Needs review » Needs work

There are still some usage of drupalSettings.project_browser.origin_url and drupalSettings .project_browser.module_path in Project.Svelte, Filter.svelte, ProjectBrowser.svelte check other files as well.

libbna’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

This is definitely an improvement. But are there really places we use either of them alone? Why not concatenate them together and have one variable?

libbna’s picture

@tim.plunkett there are places for e.g. in ActionButton.svelte where .origin_url is 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.

libbna’s picture

Also I have just noticed that there are few areas left to change. I will work on that asap.

omkar-pd’s picture

Status: Needs review » Needs work

still there are couple of usage of drupalSettings.project_browser.origin_url and drupalSettings .project_browser.module_path in Project.svelte.

src="{drupalSettings.project_browser.origin_url}/{drupalSettings
            .project_browser.module_path}/images/blue-security-shield-icon.svg"
src="{drupalSettings.project_browser.origin_url}/{drupalSettings
              .project_browser.module_path}/images/triangle-alert.svg"
omkar-pd’s picture

And as suggested in #13. We can concatenate ORIGIN_URL and MODULE_PATH.

Maybe something like this.

export const FULL_URL = 
  `${ORIGIN_URL}/${drupalSettings.project_browser.module_path}`;

and use like this

src="{FULL_URL}/images/project-usage-icon.svg"

instead of

src="{ORIGIN_URL}/{MODULE_PATH}/images/project-usage-icon.svg"
libbna’s picture

Yes we can use one variable for whole url. Ok will work on this.

libbna’s picture

Status: Needs work » Needs review
narendrar’s picture

Status: Needs review » Needs work

There 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.modules in ActionButton.svelte, so please create constant for that also.
Constants can be ORIGIN_URL, MODULE_PATH and FULL_MODULE_PATH

libbna’s picture

Status: Needs work » Needs review
libbna’s picture

Assigned: libbna » Unassigned
tim.plunkett’s picture

Status: Needs review » Needs work

Reviewed the MR with git diff --color-words=\[^_,\] origin/1.0.x which revealed a couple more things to fix

libbna’s picture

Assigned: Unassigned » libbna

I will make the necessary changes, thanks @tim.plunkett for reviewing.

libbna’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

StatusFileSize
new69.73 KB

EDIT 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.

tim.plunkett’s picture

Assigned: libbna » Unassigned

Should be nothing left to do but merge, once the bots work again.

  • tim.plunkett committed d4d0547 on 1.0.x authored by Libbna
    Issue #3293424 by Libbna, tim.plunkett, narendraR, omkar-pd: Be...
tim.plunkett’s picture

Status: Needs review » Fixed

And we're back! Getting this in now before anything else is committed. Thanks @Libbna for seeing this one through!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.