Unverified Commit ce60f2d6 authored by bunsenstraat's avatar bunsenstraat Committed by GitHub

Merge pull request #1580 from ethereum/fixlocal

fix whitespaces and canactivate
parents d0a29649 a69a392c
...@@ -20,7 +20,8 @@ const initialState: FormStateProps = { ...@@ -20,7 +20,8 @@ const initialState: FormStateProps = {
type: 'iframe', type: 'iframe',
hash: '', hash: '',
methods: [], methods: [],
location: 'sidePanel' location: 'sidePanel',
canActivate: []
} }
const defaultProfile = { const defaultProfile = {
...@@ -48,9 +49,10 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor ...@@ -48,9 +49,10 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
setName(storagePlugin.name) setName(storagePlugin.name)
setUrl(storagePlugin.url) setUrl(storagePlugin.url)
setLocation(storagePlugin.location as 'sidePanel' | 'mainPanel' | 'none') setLocation(storagePlugin.location as 'sidePanel' | 'mainPanel' | 'none')
setMethods(storagePlugin.methods) setMethods(Array.isArray(storagePlugin.methods) ? storagePlugin.methods.join(',') : storagePlugin.methods)
setType(storagePlugin.type) setType(storagePlugin.type)
setDisplayName(storagePlugin.displayName) setDisplayName(storagePlugin.displayName)
setCanactivate(Array.isArray(storagePlugin.canActivate) ? storagePlugin.canActivate.join(',') : storagePlugin.canActivate)
}, []) }, [])
const handleModalOkClick = async () => { const handleModalOkClick = async () => {
...@@ -61,7 +63,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor ...@@ -61,7 +63,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
} }
if (!location) throw new Error('Plugin should have a location') if (!location) throw new Error('Plugin should have a location')
if (!url) throw new Error('Plugin should have an URL') if (!url) throw new Error('Plugin should have an URL')
const newMethods = typeof methods === 'string' ? methods.split(',').filter(val => val) : [] const newMethods = typeof methods === 'string' ? methods.split(',').filter(val => val).map(val => { return val.trim() }) : []
const targetPlugin = { const targetPlugin = {
name: name, name: name,
displayName: displayName, displayName: displayName,
...@@ -75,7 +77,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor ...@@ -75,7 +77,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
type: type, type: type,
location: location, location: location,
icon: 'assets/img/localPlugin.webp', icon: 'assets/img/localPlugin.webp',
canActivate: typeof canactivate === 'string' ? canactivate.split(',').filter(val => val) : [] canActivate: typeof canactivate === 'string' ? canactivate.split(',').filter(val => val).map(val => { return val.trim() }) : []
} }
const localPlugin = type === 'iframe' ? new IframePlugin(initialState) : new WebsocketPlugin(initialState) const localPlugin = type === 'iframe' ? new IframePlugin(initialState) : new WebsocketPlugin(initialState)
localPlugin.profile.hash = `local-${name}` localPlugin.profile.hash = `local-${name}`
......
...@@ -178,8 +178,9 @@ export interface FormStateProps { ...@@ -178,8 +178,9 @@ export interface FormStateProps {
url: string url: string
type: 'iframe' | 'ws' type: 'iframe' | 'ws'
hash: string hash: string
methods: any methods: string[]
location: string location: string
canActivate: string[]
} }
export type PluginManagerProfile = Profile & { export type PluginManagerProfile = Profile & {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment