mv context menu reg to app manager

fixflattener
bunsenstraat 3 years ago
parent d03fa09b1f
commit e3a727b1a0
  1. 2
      apps/remix-ide/src/app.js
  2. 53
      apps/remix-ide/src/app/components/plugin-manager-component.js
  3. 23
      apps/remix-ide/src/remixAppManager.js

@ -483,7 +483,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
await appManager.activatePlugin(['home'])
await appManager.activatePlugin(['settings'])
await appManager.activatePlugin(['hiddenPanel', 'filePanel', 'pluginManager', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport'])
await appManager.registerContextMenuItems()
// Set workspace after initial activation
if (Array.isArray(workspace)) {
appManager.activatePlugin(workspace).then(async () => {

@ -71,7 +71,7 @@ const css = csjs`
const profile = {
name: 'pluginManager',
displayName: 'Plugin manager',
methods: ['registerFlattener', 'registerOptimismCompiler'],
methods: [],
events: [],
icon: 'assets/img/pluginManager.webp',
description: 'Start/stop services, modules and plugins',
@ -102,57 +102,6 @@ class PluginManagerComponent extends ViewPlugin {
return this.appManager.actives.includes(name)
}
async registerFlattener (event) {
if (!this.appManager.isActive('solidity')) { await this.appManager.activatePlugin('solidity') }
const compiledSuccessfully = await this.call('solidity', 'compileFile', event)
console.log(compiledSuccessfully)
const reportCompileIssue = async () => {
this.call('fileManager', 'open', event.path[0])
addToolTip('Cannot flatten the file. Please make sure it is compiling successfully.')
await this.call('menuicons', 'select', 'solidity')
}
if (compiledSuccessfully) {
const res = await this.call('solidity', 'getCompilationResult')
if (!res) {
reportCompileIssue()
} else {
await this.call('menuicons', 'select', 'f3')
console.log(res)
await this.call('f3', 'flattenAndSave', res)
}
} else {
reportCompileIssue()
}
}
async registerOptimismCompiler (event) {
await this.call('optimism-compiler', 'compile', event.path[0])
await this.call('menuicons', 'select', 'optimism-compiler')
await this.call('fileManager', 'open', event.path[0])
}
async onActivation () {
await this.call('filePanel', 'registerContextMenuItem', {
id: 'pluginManager',
name: 'registerFlattener',
label: 'Flatten',
type: [],
extension: ['.sol'],
path: [],
pattern: []
})
await this.call('filePanel', 'registerContextMenuItem', {
id: 'pluginManager',
name: 'registerOptimismCompiler',
label: 'Compile with Optimism',
type: [],
extension: ['.sol'],
path: [],
pattern: []
})
}
activateP (name) {
this.appManager.activatePlugin(name)
_paq.push(['trackEvent', 'manager', 'activate', name])

@ -133,6 +133,29 @@ export class RemixAppManager extends PluginManager {
return new IframePlugin(plugin)
})
}
async registerContextMenuItems () {
await this.call('filePanel', 'registerContextMenuItem', {
id: 'flattener',
name: 'flattenFileCustomAction',
label: 'Flatten',
type: [],
extension: ['.sol'],
path: [],
pattern: [],
sticky: true
})
await this.call('filePanel', 'registerContextMenuItem', {
id: '2o',
name: 'compileCustomAction',
label: 'Compile with Optimism',
type: [],
extension: ['.sol'],
path: [],
pattern: [],
sticky: true
})
}
}
/** @class Reference loaders.

Loading…
Cancel
Save