From e549111d617b063be29b3836063899d7b70ce89e Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 23 Aug 2021 12:21:00 +0200 Subject: [PATCH] rm old local plugin js --- .../src/app/components/local-plugin.js | 129 ------------------ 1 file changed, 129 deletions(-) delete mode 100644 apps/remix-ide/src/app/components/local-plugin.js diff --git a/apps/remix-ide/src/app/components/local-plugin.js b/apps/remix-ide/src/app/components/local-plugin.js deleted file mode 100644 index c93bb6775b..0000000000 --- a/apps/remix-ide/src/app/components/local-plugin.js +++ /dev/null @@ -1,129 +0,0 @@ -/* global localStorage */ -const yo = require('yo-yo') -const modalDialog = require('../ui/modaldialog') - -const defaultProfile = { - methods: [], - location: 'sidePanel', - type: 'iframe' -} - -module.exports = class LocalPlugin { - /** - * Open a modal to create a local plugin - * @param {Profile[]} plugins The list of the plugins in the store - * @returns {Promise<{api: any, profile: any}>} A promise with the new plugin profile - */ - open (plugins) { - this.profile = JSON.parse(localStorage.getItem('plugins/local')) || defaultProfile - return new Promise((resolve, reject) => { - const onValidation = () => { - try { - const profile = this.create() - resolve(profile) - } catch (err) { - reject(err) - } - } - modalDialog('Local Plugin', this.form(), - { fn: () => onValidation() }, - { fn: () => resolve() } - ) - }) - } - - /** - * Create the object to add to the plugin-list - */ - create () { - const profile = { - icon: 'assets/img/localPlugin.webp', - methods: [], - location: 'sidePanel', - type: 'iframe', - ...this.profile, - hash: `local-${this.profile.name}` - } - if (!profile.location) throw new Error('Plugin should have a location') - if (!profile.name) throw new Error('Plugin should have a name') - if (!profile.url) throw new Error('Plugin should have an URL') - localStorage.setItem('plugins/local', JSON.stringify(profile)) - return profile - } - - updateName ({ target }) { - this.profile.name = target.value - } - - updateUrl ({ target }) { - this.profile.url = target.value - } - - updateDisplayName ({ target }) { - this.profile.displayName = target.value - } - - updateProfile (key, e) { - this.profile[key] = e.target.value - } - - updateMethods ({ target }) { - if (target.value) { - try { - this.profile.methods = target.value.split(',') - } catch (e) {} - } - } - - /** The form to create a local plugin */ - form () { - const name = this.profile.name || '' - const url = this.profile.url || '' - const displayName = this.profile.displayName || '' - const methods = (this.profile.methods && this.profile.methods.join(',')) || '' - const radioSelection = (key, label, message) => { - return this.profile[key] === label - ? yo`
- - -
` - : yo`
- - -
` - } - - return yo` -
-
- - -
-
- - -
- -
- - -
- -
- - -
-
Type of connection (required)
-
- ${radioSelection('type', 'iframe', 'Iframe')} - ${radioSelection('type', 'ws', 'Websocket')} -
-
Location in remix (required)
-
- ${radioSelection('location', 'sidePanel', 'Side Panel')} - ${radioSelection('location', 'mainPanel', 'Main Panel')} - ${radioSelection('location', 'none', 'None')} -
-
` - } -}