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', name: 'app',
displayName: 'App', displayName: 'App',
description: 'Application', description: 'Application',
methods: [] methods: ['getAppParameter', 'setAppParameter']
} }
class AppComponent extends Plugin { class AppComponent extends Plugin {
@ -63,6 +63,7 @@ class AppComponent extends Plugin {
super(profile) super(profile)
const self = this const self = this
self.appManager = new RemixAppManager({}) self.appManager = new RemixAppManager({})
self.queryParams = new QueryParams()
self._components = {} self._components = {}
self.registry = registry self.registry = registry
// setup storage // setup storage
@ -86,6 +87,22 @@ class AppComponent extends Plugin {
migrateFileSystem(self._components.filesProviders.browser) 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 () { async run () {
const self = this const self = this
// APP_MANAGER // APP_MANAGER
@ -168,6 +185,7 @@ class AppComponent extends Plugin {
const contextualListener = new ContextualListener({ editor }) const contextualListener = new ContextualListener({ editor })
self.engine.register([ self.engine.register([
this,
blockchain, blockchain,
contentImport, contentImport,
self.themeModule, self.themeModule,

@ -145,16 +145,11 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
} }
getAppParameter (name) { getAppParameter (name) {
// first look in the URL params then in the local storage this.call('app', 'getAppParameter', name)
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
} }
setAppParameter (name, value) { 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) => { const addAnnotation = (file, error) => {
if (file === plugin.getAppParameter('currentFile')) { if (file === plugin.call('app', 'getAppParameter', 'currentFile')) {
plugin.call('editor', 'addAnnotation', error, file) plugin.call('editor', 'addAnnotation', error, file)
} }
} }
@ -87,10 +87,10 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => {
} }
const _errorClick = async (errFile, errLine, errCol) => { 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 // TODO: refactor with this._components.contextView.jumpTo
if (await plugin.fileExists(errFile)) { if (await plugin.call('fileManager', 'exists', errFile)) {
plugin.open(errFile) plugin.call('fileManager', 'open', errFile)
plugin.call('editor', 'gotoLine', errLine, errCol) plugin.call('editor', 'gotoLine', errLine, errCol)
} }
} else { } else {

Loading…
Cancel
Save