Support for rewiring plugin outlets so we can move Akismet up
This commit is contained in:
parent
c6d8bfe3b7
commit
5881f68556
|
@ -47,6 +47,13 @@
|
|||
|
||||
**/
|
||||
|
||||
// TODO: Add all plugin-outlet names dynamically
|
||||
const rewireableOutlets = [
|
||||
'hamburger-admin'
|
||||
];
|
||||
|
||||
const _rewires = {};
|
||||
|
||||
let _connectorCache, _rawCache;
|
||||
|
||||
function findOutlets(collection, callback) {
|
||||
|
@ -63,9 +70,17 @@ function findOutlets(collection, callback) {
|
|||
}
|
||||
|
||||
const segments = res.split("/");
|
||||
const outletName = segments[segments.length-2];
|
||||
let outletName = segments[segments.length-2];
|
||||
const uniqueName = segments[segments.length-1];
|
||||
|
||||
const outletRewires = _rewires[outletName];
|
||||
if (outletRewires) {
|
||||
const newOutlet = outletRewires[uniqueName];
|
||||
if (newOutlet) {
|
||||
outletName = newOutlet;
|
||||
}
|
||||
}
|
||||
|
||||
const dashedName = outletName.replace(/_/g, '-');
|
||||
if (dashedName !== outletName) {
|
||||
Ember.warn("DEPRECATION: You need to use dashes in outlet names, not underscores");
|
||||
|
@ -179,4 +194,11 @@ Ember.HTMLBars._registerHelper('plugin-outlet', function(params, hash, options,
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// Allow plugins to rewire outlets to new outlets if they exist. For example, the akismet
|
||||
// plugin will use `hamburger-admin` if it exists, otherwise `site-menu-links`
|
||||
export function rewire(uniqueName, outlet, wantedOutlet) {
|
||||
if (rewireableOutlets.indexOf(wantedOutlet) !== -1) {
|
||||
_rewires[outlet] = _rewires[outlet] || {};
|
||||
_rewires[outlet][uniqueName] = wantedOutlet;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue