Commit 34ffbab2 authored by LianaHus's avatar LianaHus Committed by Liana Husikyan

added documentation and deactivate to context menu of vertical icons bar

parent 67783eab
...@@ -64,7 +64,7 @@ export class VerticalIcons extends Plugin { ...@@ -64,7 +64,7 @@ export class VerticalIcons extends Plugin {
* Add an icon to the map * Add an icon to the map
* @param {ModuleProfile} profile The profile of the module * @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) let title = (tooltip || displayName || name)
title = title.replace(/^\w/, c => c.toUpperCase()) title = title.replace(/^\w/, c => c.toUpperCase())
this.icons[name] = yo` this.icons[name] = yo`
...@@ -73,7 +73,7 @@ export class VerticalIcons extends Plugin { ...@@ -73,7 +73,7 @@ export class VerticalIcons extends Plugin {
onclick="${() => { this.toggle(name) }}" onclick="${() => { this.toggle(name) }}"
plugin="${name}" plugin="${name}"
title="${title}" title="${title}"
oncontextmenu="${(e) => this.itemContextMenu(e, name)}" oncontextmenu="${(e) => this.itemContextMenu(e, name, documentation)}"
data-id="verticalIconsKind${name}"> data-id="verticalIconsKind${name}">
<img class="image" src="${icon}" alt="${name}" /> <img class="image" src="${icon}" alt="${name}" />
</div>` </div>`
...@@ -223,13 +223,24 @@ export class VerticalIcons extends Plugin { ...@@ -223,13 +223,24 @@ export class VerticalIcons extends Plugin {
} }
} }
itemContextMenu (e, name) { async itemContextMenu (e, name, documentation) {
console.log(name)
VERTICALMENU_HANDLE && VERTICALMENU_HANDLE.hide(null, true)
const actions = {} const actions = {}
actions['Deactivate'] = () => { this.call('manager', 'deactivatePlugin', name) } if (await this.appManager.canDeactivatePlugin(profile, { name })) {
VERTICALMENU_HANDLE = contextMenu(e, actions) 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.preventDefault()
e.stopPropagation()
} }
render () { render () {
......
...@@ -30,7 +30,7 @@ var css = csjs` ...@@ -30,7 +30,7 @@ var css = csjs`
} }
` `
module.exports = (event, items) => { module.exports = (event, items, linkItems) => {
event.preventDefault() event.preventDefault()
function hide (event, force) { function hide (event, force) {
...@@ -45,7 +45,17 @@ module.exports = (event, items) => { ...@@ -45,7 +45,17 @@ module.exports = (event, items) => {
current.onclick = () => { hide(null, true); items[item]() } current.onclick = () => { hide(null, true); items[item]() }
return current return current
}) })
const container = yo`<div id="menuItemsContainer" class="p-1 ${css.container} bg-light shadow border"><ul id='menuitems'>${menu}</ul></div>`
const menuForLinks = Object.keys(linkItems).map((item, index) => {
const current = yo`<li id="menuitem${item.toLowerCase()}" class=${css.liitem}><a href=${linkItems[item]} target="_blank">${item}</a></li>`
current.onclick = () => { hide(null, true) }
return current
})
const container = yo`
<div id="menuItemsContainer" class="p-1 ${css.container} bg-light shadow border">
<ul id='menuitems'>${menu} ${menuForLinks}</ul>
</div>
`
container.style.left = event.pageX + 'px' container.style.left = event.pageX + 'px'
container.style.top = event.pageY + 'px' container.style.top = event.pageY + 'px'
......
...@@ -6,12 +6,12 @@ import QueryParams from './lib/query-params' ...@@ -6,12 +6,12 @@ import QueryParams from './lib/query-params'
import { PermissionHandler } from './app/ui/persmission-handler' import { PermissionHandler } from './app/ui/persmission-handler'
const requiredModules = [ // services + layout views + system views const requiredModules = [ // services + layout views + system views
'manager', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'fileManager', 'contentImport', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'manager', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme',
'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'fileExplorers', 'fileManager', 'contentImport', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons',
'terminal', 'settings', 'pluginManager', 'tabs'] 'fileExplorers', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp']
export function isNative (name) { export function isNative (name) {
const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd'] const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons']
return nativePlugins.includes(name) || requiredModules.includes(name) return nativePlugins.includes(name) || requiredModules.includes(name)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment