|
|
|
@ -34,7 +34,7 @@ const modalDialogCustom = require('../ui/modal-dialog-custom') |
|
|
|
|
const profile = { |
|
|
|
|
name: 'filePanel', |
|
|
|
|
displayName: 'File explorers', |
|
|
|
|
methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getWorkspaces', 'createWorkspace', 'setWorkspace'], |
|
|
|
|
methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getWorkspaces', 'createWorkspace', 'setWorkspace', 'registerContextMenuItem'], |
|
|
|
|
events: ['setWorkspace', 'renameWorkspace', 'deleteWorkspace', 'createWorkspace'], |
|
|
|
|
icon: 'assets/img/fileManager.webp', |
|
|
|
|
description: ' - ', |
|
|
|
@ -60,9 +60,11 @@ module.exports = class Filepanel extends ViewPlugin { |
|
|
|
|
this.gitHandle = new GitHandle() |
|
|
|
|
this.hardhatHandle = new HardhatHandle() |
|
|
|
|
this.registeredMenuItems = [] |
|
|
|
|
this.removedMenuItems = [] |
|
|
|
|
this.request = {} |
|
|
|
|
this.workspaces = [] |
|
|
|
|
this.initialWorkspace = null |
|
|
|
|
this.appManager = appManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
@ -88,6 +90,7 @@ module.exports = class Filepanel extends ViewPlugin { |
|
|
|
|
request={this.request} |
|
|
|
|
workspaces={this.workspaces} |
|
|
|
|
registeredMenuItems={this.registeredMenuItems} |
|
|
|
|
removedMenuItems={this.removedMenuItems} |
|
|
|
|
initialWorkspace={this.initialWorkspace} |
|
|
|
|
/> |
|
|
|
|
, this.el) |
|
|
|
@ -101,8 +104,22 @@ module.exports = class Filepanel extends ViewPlugin { |
|
|
|
|
if (!item) throw new Error('Invalid register context menu argument') |
|
|
|
|
if (!item.name || !item.id) throw new Error('Item name and id is mandatory') |
|
|
|
|
if (!item.type && !item.path && !item.extension && !item.pattern) throw new Error('Invalid file matching criteria provided') |
|
|
|
|
|
|
|
|
|
if (this.registeredMenuItems.filter((o) => { |
|
|
|
|
return o.id === item.id & o.name === item.name |
|
|
|
|
}).length) throw new Error(`Action ${item.name} already exists on ${item.id}`) |
|
|
|
|
this.registeredMenuItems = [...this.registeredMenuItems, item] |
|
|
|
|
this.removedMenuItems = this.removedMenuItems.filter(menuItem => item.id !== menuItem.id) |
|
|
|
|
this.renderComponent() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removePluginActions (plugin) { |
|
|
|
|
this.registeredMenuItems = this.registeredMenuItems.filter((item) => { |
|
|
|
|
if (item.id !== plugin.name || item.sticky === true) return true |
|
|
|
|
else { |
|
|
|
|
this.removedMenuItems.push(item) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
this.renderComponent() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -163,6 +180,9 @@ module.exports = class Filepanel extends ViewPlugin { |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const self = this |
|
|
|
|
this.appManager.on('manager', 'pluginDeactivated', self.removePluginActions.bind(this)) |
|
|
|
|
// insert example contracts if there are no files to show
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
this._deps.fileProviders.browser.resolveDirectory('/', async (error, filesList) => { |
|
|
|
|