|
|
@ -4,17 +4,10 @@ import PluginManagerProxy from './app/components/plugin-manager-proxy' |
|
|
|
|
|
|
|
|
|
|
|
export class RemixAppManager extends AppManagerApi { |
|
|
|
export class RemixAppManager extends AppManagerApi { |
|
|
|
|
|
|
|
|
|
|
|
constructor (store, swapPanelApi, mainPanelApi, verticalIconsApi) { |
|
|
|
constructor (store) { |
|
|
|
super(null) |
|
|
|
super(null) |
|
|
|
this.location = { |
|
|
|
|
|
|
|
'default': swapPanelApi, |
|
|
|
|
|
|
|
'swapPanel': swapPanelApi, |
|
|
|
|
|
|
|
'mainPanel': mainPanelApi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.store = store |
|
|
|
this.store = store |
|
|
|
this.verticalIconsApi = verticalIconsApi |
|
|
|
this.hiddenServices = {} |
|
|
|
this.swapPanelApi = swapPanelApi |
|
|
|
|
|
|
|
this.hiddenNodes = {} |
|
|
|
|
|
|
|
this.event = new EventEmitter() |
|
|
|
this.event = new EventEmitter() |
|
|
|
this.data = { |
|
|
|
this.data = { |
|
|
|
proxy: new PluginManagerProxy() |
|
|
|
proxy: new PluginManagerProxy() |
|
|
@ -28,20 +21,14 @@ export class RemixAppManager extends AppManagerApi { |
|
|
|
|
|
|
|
|
|
|
|
setActive (name, isActive) { |
|
|
|
setActive (name, isActive) { |
|
|
|
const entity = this.getEntity(name) |
|
|
|
const entity = this.getEntity(name) |
|
|
|
if (entity && entity.profile.icon && entity.api.render && typeof entity.api.render === 'function') { |
|
|
|
|
|
|
|
// here we have an internal module (it does not need to be rendered necessarily - "rendered" means pushed to the DOM)
|
|
|
|
|
|
|
|
// if it contains `render` function, we push the view to `resolveLocation`
|
|
|
|
|
|
|
|
isActive ? this.resolveLocation(entity.profile, entity.api.render()) |
|
|
|
|
|
|
|
: this.removeComponent(entity.profile) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// at this point, if it's an iframe plugin, it should have already been rendered (to the DOM)
|
|
|
|
|
|
|
|
// either using `location` in json profile or using the optionnal api in the `Plugin` class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// temp
|
|
|
|
// temp
|
|
|
|
if (entity && name === 'solidity') { |
|
|
|
if (entity && name === 'solidity') { |
|
|
|
isActive ? this.data.proxy.register(entity.api) : this.data.proxy.unregister(entity.api) |
|
|
|
isActive ? this.data.proxy.register(entity.api) : this.data.proxy.unregister(entity.api) |
|
|
|
} |
|
|
|
} |
|
|
|
isActive ? this.store.activate(name) : this.store.deactivate(name) |
|
|
|
isActive ? this.store.activate(name) : this.store.deactivate(name) |
|
|
|
|
|
|
|
if (!isActive) { |
|
|
|
|
|
|
|
this.removeHiddenServices(entity) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getEntity (entityName) { |
|
|
|
getEntity (entityName) { |
|
|
@ -52,24 +39,19 @@ export class RemixAppManager extends AppManagerApi { |
|
|
|
this.store.add(entity.profile.name, entity) |
|
|
|
this.store.add(entity.profile.name, entity) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this function is only used for iframe plugins
|
|
|
|
resolveLocation (profile, domEl) { |
|
|
|
resolveLocation (profile, domEl) { |
|
|
|
// if there's an icon, we add to the swap panel
|
|
|
|
|
|
|
|
// if not we suppose it just need to be put to DOM (that would be)
|
|
|
|
|
|
|
|
if (profile.icon) { |
|
|
|
if (profile.icon) { |
|
|
|
var panel = this.location[profile.prefferedLocation] ? this.location[profile.prefferedLocation] : this.location['default'] |
|
|
|
this.event.emit('pluginNeedsLocation', profile, domEl) |
|
|
|
domEl.style.height = '100%' |
|
|
|
} else { |
|
|
|
domEl.style.width = '100%' |
|
|
|
this.hiddenServices[profile.name] = domEl |
|
|
|
domEl.style.border = '0' |
|
|
|
document.body.appendChild(domEl) |
|
|
|
panel.add(profile, domEl) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.hiddenNodes[profile.name] = domEl |
|
|
|
|
|
|
|
document.body.appendChild(domEl) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
removeComponent (profile) { |
|
|
|
removeHiddenServices (profile) { |
|
|
|
let hiddenNode = this.hiddenNodes[profile.name] |
|
|
|
let hiddenServices = this.hiddenServices[profile.name] |
|
|
|
if (hiddenNode) document.body.removeChild(hiddenNode) |
|
|
|
if (hiddenServices) document.body.removeChild(hiddenServices) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
plugins () { |
|
|
|
plugins () { |
|
|
|