Skip to content

Migrate inline JavaScript event handlers#418

Merged
vagisha merged 7 commits into
release24.3-SNAPSHOTfrom
24.3_fb_migrate-inline-JS-handlers-2
Apr 6, 2024
Merged

Migrate inline JavaScript event handlers#418
vagisha merged 7 commits into
release24.3-SNAPSHOTfrom
24.3_fb_migrate-inline-JS-handlers-2

Conversation

@vagisha
Copy link
Copy Markdown
Collaborator

@vagisha vagisha commented Apr 5, 2024

Related Pull Requests

Changes

  • Migrated inline event handlers from the MacCossLabModules - signup, testresults and SkylineToolsStore
    • signup/SignUpAdmin.jsp
    • SkylineToolsStore/SkylineToolDetails.jsp
    • SkylineToolsStore/SkylineToolsStoreWebPart.jsp
    • testresults/failureDetail.jsp
    • testresults/longTerm.jsp
    • testresults/runDetail.jsp
    • testresults/trainingdata.jsp
  • Include js and css dependencies in the addClientDependencies method
  • Removed unused code from trainingdata.jsp

vagisha added 6 commits April 4, 2024 16:05
…etoolsstore modules

- Add js and css dependencies in the addClientDependencies method
- Fixed bug in SignUpAdmin.jsp - group names were not being displayed in the combobox
…I added to security policy set in the header.
…ent.getElementById("customGctButton")['onclick'] as suggested by Adam. This drops the migrated handlers from text searches looking for typical inline handler patterns ("onclick = ")
{
// add a container listener so we'll know when our container is deleted:
ContainerManager.addContainerListener(new SkylineToolsStoreContainerListener());
SecurityManager.registerAllowedConnectionSource("script-src", "https://code.jquery.com/ui/1.13.2/jquery-ui.min.js");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The key is primarily for use cases where the value may change due to config from users. I'll add some JavaDoc separately to help clarify.

Suggested change
SecurityManager.registerAllowedConnectionSource("script-src", "https://code.jquery.com/ui/1.13.2/jquery-ui.min.js");
SecurityManager.registerAllowedConnectionSource("jquery-ui", "https://code.jquery.com/ui/1.13.2/jquery-ui.min.js");

dependencies.add("skylinetoolsstore/js/functions.js");
}

public final HtmlString editIconImgHtml = HtmlString.unsafe(IMG(DOM.at(src, getWebappURL("skylinetoolsstore/img/pencil.png")).at(alt, "Pencil")).renderToString());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@labkey-matthewb @labkey-adam this works but routing this through unsafe feels unsatisfying. Do you have a recommendation for a different pattern that works with link()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm afraid not. LinkBuilder and link() should take Renderable, which would avoid HtmlString entirely. Feel free to open an issue to me so I don't forget...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, DOM.createHtmlFragment() is your friend here; just don't look at the impl. 😄 I also have a local change to switch html-taking methods to Renderable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. My PR is targeting 24.3 so the changes to builders accepting Renderable will not be available. Should I target "develop" instead? For now, I have replaced HtmlString.unsafe() with DOM.createHtml() to make it look less ugly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whatever's easiest for you... I'd probably stick with 24.3 since that's what you have and my PR isn't merged yet. Though note that develop is fine for all the strict CSP work.

{
// add a container listener so we'll know when our container is deleted:
ContainerManager.addContainerListener(new TestResultsContainerListener());
SecurityManager.registerAllowedConnectionSource("script-src", "https://code.jquery.com/ui/1.13.2/jquery-ui.min.js");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
SecurityManager.registerAllowedConnectionSource("script-src", "https://code.jquery.com/ui/1.13.2/jquery-ui.min.js");
SecurityManager.registerAllowedConnectionSource("jquery-ui", "https://code.jquery.com/ui/1.13.2/jquery-ui.min.js");

@vagisha vagisha merged commit 27295af into release24.3-SNAPSHOT Apr 6, 2024
@vagisha vagisha deleted the 24.3_fb_migrate-inline-JS-handlers-2 branch April 6, 2024 23:11
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.

3 participants