allow running script from the file explorer

pull/426/head
yann300 4 years ago
parent fde1f778b2
commit c07f9ec5ac
  1. 10
      apps/remix-ide/src/app/files/file-explorer.js
  2. 2
      apps/remix-ide/src/app/panels/file-panel.js

@ -16,7 +16,7 @@ const globalRegistry = require('../../global/registry')
const queryParams = new QueryParams() const queryParams = new QueryParams()
let MENU_HANDLE let MENU_HANDLE
function fileExplorer (localRegistry, files, menuItems) { function fileExplorer (localRegistry, files, menuItems, plugin) {
var self = this var self = this
this.events = new EventManager() this.events = new EventManager()
// file provider backend // file provider backend
@ -292,6 +292,14 @@ function fileExplorer (localRegistry, files, menuItems) {
() => {} () => {}
) )
} }
if (key.endsWith('.js')) {
actions['Run Script'] = async () => {
provider.get(key, (error, content) => {
if (error) return console.log(error)
plugin.call('scriptRunner', 'execute', content)
})
}
}
} }
MENU_HANDLE = contextMenu(event, actions) MENU_HANDLE = contextMenu(event, actions)
}) })

@ -54,7 +54,7 @@ module.exports = class Filepanel extends ViewPlugin {
} }
function createProvider (key, menuItems) { function createProvider (key, menuItems) {
return new FileExplorer(self._components.registry, self._deps.fileProviders[key], menuItems) return new FileExplorer(self._components.registry, self._deps.fileProviders[key], menuItems, self)
} }
var fileExplorer = createProvider('browser', ['createNewFile', 'publishToGist', canUpload ? 'uploadFile' : '']) var fileExplorer = createProvider('browser', ['createNewFile', 'publishToGist', canUpload ? 'uploadFile' : ''])

Loading…
Cancel
Save