mw.util.addPortletLink works inside Minerva but it produces menu items that have no design consistency with the rest of the skin.
While gadget developers can update their associated styles to make their items look like the others, such a solution is not going to be resilient to changes.
In T231925 https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/545636/7/resources/src/mediawiki.util/util.js was proposed as the way to resolve this - for compatiblity with Minerva, text would be in a span and and assigned an icon. Ideally such code would live in Minerva.
Let's allow skins to define the render function for mw.util.addPortletLink.
How would this work in practice? Could ResourceLoaderSkinModule be used?
Developer notes
A portlet link is added by:
mw.util.addPortletLink('p-interaction', 'http://en.wikipedia.org/wiki/Wikipedia:Dashboard', 'Dashboard', 'n-dashboard', 'Visit the dashboard', 'd');
A monkey patch like so gives the right result and a programmatically created icon:
var _portletLink = mw.util.addPortletLink; mw.util.addPortletLink = function( _1, _2, _3, id ) { var $item = $(_portletLink.apply(this,arguments)); var $a = $item.find('a'); $a.addClass('menu-list-item__button menu__item--' + id + ' mw-ui-icon mw-ui-icon-before mw-ui-icon-portletlink-' + id) var $label = $('<span class="menu-list-item__label">').text( $item.text()); $a.empty().append($label); return $item[0]; }
Instead of monkey patching addPortletLink could fire a hook allowing modification of menu items. mw.hook('addPortletLink').fire and Minerva should subscribe to that hook using mw.hook('addPortletLink').add