diff --git a/apps/remix-ide/src/app/components/vertical-icons.js b/apps/remix-ide/src/app/components/vertical-icons.js index 7ff9009ac4..35b9f0ac17 100644 --- a/apps/remix-ide/src/app/components/vertical-icons.js +++ b/apps/remix-ide/src/app/components/vertical-icons.js @@ -64,7 +64,7 @@ export class VerticalIcons extends Plugin { * Add an icon to the map * @param {ModuleProfile} profile The profile of the module */ - addIcon ({ kind, name, icon, displayName, tooltip }) { + addIcon ({ kind, name, icon, displayName, tooltip, documentation }) { let title = (tooltip || displayName || name) title = title.replace(/^\w/, c => c.toUpperCase()) this.icons[name] = yo` @@ -73,7 +73,7 @@ export class VerticalIcons extends Plugin { onclick="${() => { this.toggle(name) }}" plugin="${name}" title="${title}" - oncontextmenu="${(e) => this.itemContextMenu(e, name)}" + oncontextmenu="${(e) => this.itemContextMenu(e, name, documentation)}" data-id="verticalIconsKind${name}"> ` @@ -223,13 +223,24 @@ export class VerticalIcons extends Plugin { } } - itemContextMenu (e, name) { - console.log(name) - VERTICALMENU_HANDLE && VERTICALMENU_HANDLE.hide(null, true) + async itemContextMenu (e, name, documentation) { const actions = {} - actions['Deactivate'] = () => { this.call('manager', 'deactivatePlugin', name) } - VERTICALMENU_HANDLE = contextMenu(e, actions) + if (await this.appManager.canDeactivatePlugin(profile, { name })) { + actions.Deactivate = () => { + // this.call('manager', 'deactivatePlugin', name) + this.appManager.deactivatePlugin(name) + } + } + const links = {} + if (documentation) { + links.Documentation = documentation + } + if (Object.keys(actions).length || Object.keys(links).length) { + VERTICALMENU_HANDLE && VERTICALMENU_HANDLE.hide(null, true) + VERTICALMENU_HANDLE = contextMenu(e, actions, links) + } e.preventDefault() + e.stopPropagation() } render () { diff --git a/apps/remix-ide/src/app/ui/contextMenu.js b/apps/remix-ide/src/app/ui/contextMenu.js index f97720c6cd..148261ee5b 100644 --- a/apps/remix-ide/src/app/ui/contextMenu.js +++ b/apps/remix-ide/src/app/ui/contextMenu.js @@ -30,7 +30,7 @@ var css = csjs` } ` -module.exports = (event, items) => { +module.exports = (event, items, linkItems) => { event.preventDefault() function hide (event, force) { @@ -45,7 +45,17 @@ module.exports = (event, items) => { current.onclick = () => { hide(null, true); items[item]() } return current }) - const container = yo`
` + + const menuForLinks = Object.keys(linkItems).map((item, index) => { + const current = yo`