Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
2e427534
Commit
2e427534
authored
Aug 06, 2021
by
joseph izang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes for localplugin creation and activation
parent
59e4db6a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
20 deletions
+45
-20
plugin-manager-component.js
.../remix-ide/src/app/components/plugin-manager-component.js
+17
-1
InactivePluginCardContainer.tsx
...anager/src/lib/components/InactivePluginCardContainer.tsx
+3
-2
LocalPluginForm.tsx
...-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
+22
-15
types.d.ts
libs/remix-ui/plugin-manager/src/types.d.ts
+3
-2
No files found.
apps/remix-ide/src/app/components/plugin-manager-component.js
View file @
2e427534
...
@@ -37,13 +37,13 @@ class PluginManagerComponent extends ViewPlugin {
...
@@ -37,13 +37,13 @@ class PluginManagerComponent extends ViewPlugin {
this
.
appManager
=
appManager
this
.
appManager
=
appManager
this
.
engine
=
engine
this
.
engine
=
engine
this
.
pluginManagerSettings
=
new
PluginManagerSettings
()
this
.
pluginManagerSettings
=
new
PluginManagerSettings
()
this
.
localPlugin
=
new
LocalPlugin
()
this
.
htmlElement
=
document
.
createElement
(
'div'
)
this
.
htmlElement
=
document
.
createElement
(
'div'
)
this
.
htmlElement
.
setAttribute
(
'id'
,
'pluginManager'
)
this
.
htmlElement
.
setAttribute
(
'id'
,
'pluginManager'
)
this
.
views
=
{
this
.
views
=
{
root
:
null
,
root
:
null
,
items
:
{}
items
:
{}
}
}
this
.
localPlugin
=
new
LocalPlugin
()
this
.
filter
=
''
this
.
filter
=
''
this
.
pluginNames
=
this
.
appManager
.
actives
this
.
pluginNames
=
this
.
appManager
.
actives
this
.
activePlugins
=
[]
this
.
activePlugins
=
[]
...
@@ -81,6 +81,22 @@ class PluginManagerComponent extends ViewPlugin {
...
@@ -81,6 +81,22 @@ class PluginManagerComponent extends ViewPlugin {
}
}
/**
/**
* Takes the name of a local plugin and does both
* activation and registration
* @param {Profile} pluginName
* @returns {void}
*/
async
activateAndRegisterLocalPlugin
(
plugin
,
localPlugin
)
{
if
(
plugin
)
{
debugger
this
.
engine
.
register
(
localPlugin
)
await
this
.
appManager
.
activatePlugin
(
plugin
)
// localStorage.setItem('targetLocalPlugin', plugin.name)
// localStorage.setItem('plugins/local', JSON.stringify(properPlugin))
}
}
/**
* Calls and triggers the event deactivatePlugin
* Calls and triggers the event deactivatePlugin
* with with manager permission passing in the name
* with with manager permission passing in the name
* of the plugin
* of the plugin
...
...
libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx
View file @
2e427534
...
@@ -35,7 +35,7 @@ function InactivePluginCardContainer ({ pluginComponent }: InactivePluginCardCon
...
@@ -35,7 +35,7 @@ function InactivePluginCardContainer ({ pluginComponent }: InactivePluginCardCon
if
(
savedLocalPlugins
===
null
)
{
if
(
savedLocalPlugins
===
null
)
{
localStorage
.
setItem
(
'plugins/local'
,
'{}'
)
localStorage
.
setItem
(
'plugins/local'
,
'{}'
)
}
}
if
(
savedInactiveProfiles
&&
pluginComponent
.
inactivePlugins
.
length
>
savedInactiveProfiles
.
length
)
{
if
(
savedInactiveProfiles
&&
savedInactiveProfiles
.
length
>
0
&&
pluginComponent
.
inactivePlugins
.
length
>
savedInactiveProfiles
.
length
)
{
if
(
Object
.
keys
(
savedLocalPlugins
).
length
>
0
&&
!
pluginComponent
.
inactivePlugins
.
includes
(
savedLocalPlugins
.
profile
as
Profile
))
{
if
(
Object
.
keys
(
savedLocalPlugins
).
length
>
0
&&
!
pluginComponent
.
inactivePlugins
.
includes
(
savedLocalPlugins
.
profile
as
Profile
))
{
const
inactiveLocalPlugin
=
savedLocalPlugins
.
profile
const
inactiveLocalPlugin
=
savedLocalPlugins
.
profile
localStorage
.
setItem
(
'currentLocalPlugin'
,
inactiveLocalPlugin
.
name
)
localStorage
.
setItem
(
'currentLocalPlugin'
,
inactiveLocalPlugin
.
name
)
...
@@ -48,9 +48,10 @@ function InactivePluginCardContainer ({ pluginComponent }: InactivePluginCardCon
...
@@ -48,9 +48,10 @@ function InactivePluginCardContainer ({ pluginComponent }: InactivePluginCardCon
const
inactiveLocalPlugin
=
savedLocalPlugins
.
profile
const
inactiveLocalPlugin
=
savedLocalPlugins
.
profile
localStorage
.
setItem
(
'currentLocalPlugin'
,
inactiveLocalPlugin
.
name
)
localStorage
.
setItem
(
'currentLocalPlugin'
,
inactiveLocalPlugin
.
name
)
temp
.
push
([...
pluginComponent
.
inactivePlugins
,
inactiveLocalPlugin
])
temp
.
push
([...
pluginComponent
.
inactivePlugins
,
inactiveLocalPlugin
])
}
setinactiveProfiles
(
temp
)
setinactiveProfiles
(
temp
)
}
}
setinactiveProfiles
(
pluginComponent
.
inactivePlugins
)
}
},
[
pluginComponent
,
pluginComponent
.
inactivePlugins
])
},
[
pluginComponent
,
pluginComponent
.
inactivePlugins
])
return
(
return
(
<
Fragment
>
<
Fragment
>
...
...
libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
View file @
2e427534
/* eslint-disable no-debugger */
import
React
,
{
useState
}
from
'react'
import
React
,
{
useState
}
from
'react'
import
{
ModalDialog
}
from
'@remix-ui/modal-dialog'
import
{
ModalDialog
}
from
'@remix-ui/modal-dialog'
import
{
Toaster
}
from
'@remix-ui/toaster'
import
{
Toaster
}
from
'@remix-ui/toaster'
...
@@ -13,31 +14,37 @@ interface LocalPluginFormProps {
...
@@ -13,31 +14,37 @@ interface LocalPluginFormProps {
}
}
const
handleModalOkClick
=
async
(
pluginManager
:
PluginManagerComponent
,
plugin
:
FormStateProps
,
setErrorMsg
:
React
.
Dispatch
<
React
.
SetStateAction
<
string
>>
)
=>
{
const
handleModalOkClick
=
async
(
pluginManager
:
PluginManagerComponent
,
plugin
:
FormStateProps
,
setErrorMsg
:
React
.
Dispatch
<
React
.
SetStateAction
<
string
>>
)
=>
{
debugger
try
{
try
{
const
profile
=
JSON
.
parse
(
localStorage
.
getItem
(
'plugins/local'
))
||
plugin
const
profile
=
JSON
.
parse
(
localStorage
.
getItem
(
'plugins/local'
))
if
(
!
profile
)
return
if
(
profile
.
profile
&&
Object
.
keys
(
profile
).
length
>
0
)
{
if
(
profile
.
profile
)
{
if
(
pluginManager
.
appManager
.
getIds
().
includes
(
profile
.
profile
.
name
))
{
if
(
pluginManager
.
appManager
.
getIds
().
includes
(
profile
.
profile
.
name
))
{
throw
new
Error
(
'This name has already been used'
)
throw
new
Error
(
'This name has already been used'
)
}
}
}
else
{
if
(
pluginManager
.
appManager
.
getIds
().
includes
(
profile
.
name
))
{
throw
new
Error
(
'This name has already been used'
)
}
}
if
(
!
profile
.
location
)
throw
new
Error
(
'Plugin should have a location'
)
if
(
!
plugin
.
location
)
throw
new
Error
(
'Plugin should have a location'
)
if
(
!
profile
.
name
)
throw
new
Error
(
'Plugin should have a name'
)
if
(
!
plugin
.
name
)
throw
new
Error
(
'Plugin should have a name'
)
if
(
!
profile
.
url
)
throw
new
Error
(
'Plugin should have an URL'
)
if
(
!
plugin
.
url
)
throw
new
Error
(
'Plugin should have an URL'
)
const
localPlugin
=
profile
.
type
===
'iframe'
?
new
IframePlugin
(
profile
)
:
new
WebsocketPlugin
(
profile
)
const
localPlugin
=
plugin
.
type
===
'iframe'
?
new
IframePlugin
(
plugin
)
:
new
WebsocketPlugin
(
plugin
)
localPlugin
.
profile
.
hash
=
`local-
${
profile
.
name
}
`
localPlugin
.
profile
.
hash
=
`local-
${
plugin
.
name
}
`
// <-------------------------------- Plumbing starts here --------------------------------------->
// <-------------------------------- Plumbing starts here --------------------------------------->
pluginManager
.
engine
.
register
(
localPlugin
)
const
targetPlugin
=
{
localStorage
.
setItem
(
'plugins/local'
,
JSON
.
stringify
(
localPlugin
))
name
:
localPlugin
.
profile
.
name
,
pluginManager
.
activateP
(
localPlugin
.
profile
.
name
)
displayName
:
localPlugin
.
profile
.
displayName
,
description
:
(
localPlugin
.
profile
.
description
!==
undefined
?
localPlugin
.
profile
.
description
:
''
),
documentation
:
localPlugin
.
profile
.
url
,
events
:
(
localPlugin
.
profile
.
events
!==
undefined
?
localPlugin
.
profile
.
events
:
[]),
hash
:
localPlugin
.
profile
.
hash
,
kind
:
(
localPlugin
.
profile
.
kind
!==
undefined
?
localPlugin
.
profile
.
kind
:
''
),
methods
:
localPlugin
.
profile
.
methods
,
type
:
plugin
.
type
,
location
:
plugin
.
location
}
}
pluginManager
.
activateAndRegisterLocalPlugin
(
targetPlugin
,
localPlugin
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
)
console
.
error
(
error
)
// setErrorMsg(error.message)
// setErrorMsg(error.message)
setErrorMsg
(
'This name has already been used'
)
setErrorMsg
(
error
.
message
)
}
}
}
}
function
LocalPluginForm
({
changeHandler
,
plugin
,
closeModal
,
visible
,
pluginManager
}:
LocalPluginFormProps
)
{
function
LocalPluginForm
({
changeHandler
,
plugin
,
closeModal
,
visible
,
pluginManager
}:
LocalPluginFormProps
)
{
...
...
libs/remix-ui/plugin-manager/src/types.d.ts
View file @
2e427534
...
@@ -3,7 +3,7 @@ import { PluginManager } from '@remixproject/engine/lib/manager'
...
@@ -3,7 +3,7 @@ import { PluginManager } from '@remixproject/engine/lib/manager'
import
{
EventEmitter
}
from
'events'
import
{
EventEmitter
}
from
'events'
import
{
Engine
}
from
'@remixproject/engine/lib/engine'
import
{
Engine
}
from
'@remixproject/engine/lib/engine'
import
{
PluginBase
,
Profile
}
from
'@remixproject/plugin-utils'
import
{
PluginBase
,
Profile
}
from
'@remixproject/plugin-utils'
import
{
View
Plugin
}
from
'@remixproject/engine-web'
import
{
IframePlugin
,
ViewPlugin
,
Websocket
Plugin
}
from
'@remixproject/engine-web'
/* eslint-disable camelcase */
/* eslint-disable camelcase */
declare
module
'yo-yo'
{
declare
module
'yo-yo'
{
interface
yo_yo
{
interface
yo_yo
{
...
@@ -105,6 +105,7 @@ export class PluginManagerComponent extends ViewPlugin extends Plugin implements
...
@@ -105,6 +105,7 @@ export class PluginManagerComponent extends ViewPlugin extends Plugin implements
render
():
HTMLDivElement
render
():
HTMLDivElement
getAndFilterPlugins
:
(
filter
?:
string
)
=>
void
getAndFilterPlugins
:
(
filter
?:
string
)
=>
void
triggerEngineEventListener
:
()
=>
void
triggerEngineEventListener
:
()
=>
void
activateAndRegisterLocalPlugin
:
(
plugin
:
Profile
,
localPlugin
:
IframePlugin
|
WebsocketPlugin
)
=>
Promise
<
void
>
activeProfiles
:
string
[]
activeProfiles
:
string
[]
_paq
:
any
_paq
:
any
}
}
...
@@ -193,7 +194,7 @@ export interface FormStateProps {
...
@@ -193,7 +194,7 @@ export interface FormStateProps {
name
:
string
name
:
string
displayName
:
string
displayName
:
string
url
:
string
url
:
string
type
:
string
type
:
'iframe'
|
'ws'
hash
:
string
hash
:
string
methods
:
any
methods
:
any
location
:
string
location
:
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment