plugin calls for methods

appPlugin
aniket-engg 3 years ago
parent 341a821738
commit 9310ecc31e
  1. 20
      apps/remix-ide/src/app.js
  2. 9
      apps/remix-ide/src/app/tabs/compile-tab.js
  3. 8
      libs/remix-ui/renderer/src/lib/renderer.tsx

@ -55,7 +55,7 @@ const profile = {
name: 'app',
displayName: 'App',
description: 'Application',
methods: []
methods: ['getAppParameter', 'setAppParameter']
}
class AppComponent extends Plugin {
@ -63,6 +63,7 @@ class AppComponent extends Plugin {
super(profile)
const self = this
self.appManager = new RemixAppManager({})
self.queryParams = new QueryParams()
self._components = {}
self.registry = registry
// setup storage
@ -86,6 +87,22 @@ class AppComponent extends Plugin {
migrateFileSystem(self._components.filesProviders.browser)
}
getAppParameter (name) {
// first look in the URL params then in the local storage
const self = this
const params = self.queryParams.get()
const config = registry.get('config').api
const param = params[name] ? params[name] : config.get(name)
if (param === 'true') return true
if (param === 'false') return false
return param
}
setAppParameter (name, value) {
const config = registry.get('config').api
config.set(name, value)
}
async run () {
const self = this
// APP_MANAGER
@ -168,6 +185,7 @@ class AppComponent extends Plugin {
const contextualListener = new ContextualListener({ editor })
self.engine.register([
this,
blockchain,
contentImport,
self.themeModule,

@ -145,16 +145,11 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
}
getAppParameter (name) {
// first look in the URL params then in the local storage
const params = this.queryParams.get()
const param = params[name] ? params[name] : this.config.get(name)
if (param === 'true') return true
if (param === 'false') return false
return param
this.call('app', 'getAppParameter', name)
}
setAppParameter (name, value) {
this.config.set(name, value)
this.call('app', 'setAppParameter', name, value)
}
}

@ -69,7 +69,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => {
}
const addAnnotation = (file, error) => {
if (file === plugin.getAppParameter('currentFile')) {
if (file === plugin.call('app', 'getAppParameter', 'currentFile')) {
plugin.call('editor', 'addAnnotation', error, file)
}
}
@ -87,10 +87,10 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => {
}
const _errorClick = async (errFile, errLine, errCol) => {
if (errFile !== plugin.getAppParameter('currentFile')) {
if (errFile !== plugin.call('app', 'getAppParameter', 'currentFile')) {
// TODO: refactor with this._components.contextView.jumpTo
if (await plugin.fileExists(errFile)) {
plugin.open(errFile)
if (await plugin.call('fileManager', 'exists', errFile)) {
plugin.call('fileManager', 'open', errFile)
plugin.call('editor', 'gotoLine', errLine, errCol)
}
} else {

Loading…
Cancel
Save