Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twinkle: refactor addPortlet code #1843

Closed
3 tasks
NovemLinguae opened this issue Aug 4, 2023 · 3 comments
Closed
3 tasks

twinkle: refactor addPortlet code #1843

NovemLinguae opened this issue Aug 4, 2023 · 3 comments
Labels
Module: twinkle The twinkle.js global gadget file

Comments

@NovemLinguae
Copy link
Member

NovemLinguae commented Aug 4, 2023

Tracking task for my refactoring of Twinkle.addPortlet() and related code

  • Patch 1 - twinkle.js: group all portlet code in a class #1836
    • group addPortlet and addPortletLink and config variables into a class
    • convert Twinkle's 5 skin preference variables (which are hidden and do not show up on the preferences page, are basically hard coded) to class variables
  • Patch 2
    • replace addPortlet code to just process a JSON that looks like this. this will make this code much easier to read and work on. if the skin devs make a change that breaks twinkle, you just look at this JSON, inspect element in your browser, compare the two, see what changed, make the change. all the complicated logic and the 5 config variables will be deleted.
this.addPortletHTML = {
    'vector-2022': {
        insertionTarget: '#blah',
        insertionMethod: 'append',
        htmlToInsert: `
<nav aria-labelledby="p-twinkle-label" class="mw-portlet vector-menu vector-menu-dropdown vector-dropdown vector-menu-dropdown-noicon" id="p-twinkle">
    <input id="p-twinkle-dropdown-checkbox" class="vector-menu-checkbox vector-dropdown-checkbox" type="checkbox" aria-labelledby="p-twinkle-label">
    <h3 id="p-twinkle-label" for="p-twinkle-dropdown-checkbox" class="vector-menu-heading vector-dropdown-label">
        <span>TW</span>
        <a href="#"></a>
    </h3>
    <div class="vector-menu-content vector-dropdown-content">
        <ul class="vector-menu-content-list">
        </ul>
    </div>
</nav>
        `
}
  • Patch 3
    • switch to mw.util.addPortlet()?
@NovemLinguae NovemLinguae added the Module: twinkle The twinkle.js global gadget file label Aug 4, 2023
@NovemLinguae
Copy link
Member Author

Related #1835 twinkle: switch to mw.util.addPortlet() function

@NovemLinguae
Copy link
Member Author

WMF web team says mw.util.addPortlet() is ready for use now. https://phabricator.wikimedia.org/T342815#9303586

@NovemLinguae
Copy link
Member Author

Closing in favor of #1835

@NovemLinguae NovemLinguae closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: twinkle The twinkle.js global gadget file
Projects
None yet
Development

No branches or pull requests

1 participant