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
74a9a43a
Commit
74a9a43a
authored
Aug 09, 2021
by
joseph izang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes for localplugin toast
parent
90cb475a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
9 deletions
+25
-9
pluginManager.spec.ts
apps/remix-ide-e2e/src/tests/pluginManager.spec.ts
+1
-1
LocalPluginForm.tsx
...-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
+12
-8
pluginManagerReducer.ts
libs/remix-ui/plugin-manager/src/pluginManagerReducer.ts
+12
-0
No files found.
apps/remix-ide-e2e/src/tests/pluginManager.spec.ts
View file @
74a9a43a
...
@@ -131,7 +131,7 @@ module.exports = {
...
@@ -131,7 +131,7 @@ module.exports = {
.
clearValue
(
'*[data-id="localPluginUrl"]'
).
setValue
(
'*[data-id="localPluginUrl"]'
,
testData
.
pluginUrl
)
.
clearValue
(
'*[data-id="localPluginUrl"]'
).
setValue
(
'*[data-id="localPluginUrl"]'
,
testData
.
pluginUrl
)
.
click
(
'*[data-id="localPluginRadioButtoniframe"]'
)
.
click
(
'*[data-id="localPluginRadioButtoniframe"]'
)
.
click
(
'*[data-id="localPluginRadioButtonsidePanel"]'
)
.
click
(
'*[data-id="localPluginRadioButtonsidePanel"]'
)
.
click
(
'*[data-id="pluginManagerLocalPluginModalDialog
ModalDialogModalFooter
-react"]'
)
.
click
(
'*[data-id="pluginManagerLocalPluginModalDialog
-modal-footer-ok
-react"]'
)
// .modalFooterOKClick()
// .modalFooterOKClick()
.
pause
(
5000
)
.
pause
(
5000
)
.
waitForElementVisible
(
'*[data-shared="tooltipPopup"]'
)
.
waitForElementVisible
(
'*[data-shared="tooltipPopup"]'
)
...
...
libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
View file @
74a9a43a
/* eslint-disable no-debugger */
/* eslint-disable no-debugger */
import
React
,
{
useState
}
from
'react'
import
React
,
{
Dispatch
,
useReducer
}
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'
import
{
IframePlugin
,
WebsocketPlugin
}
from
'@remixproject/engine-web'
import
{
IframePlugin
,
WebsocketPlugin
}
from
'@remixproject/engine-web'
import
{
FormStateProps
,
PluginManagerComponent
}
from
'../../types'
import
{
FormStateProps
,
PluginManagerComponent
}
from
'../../types'
import
{
localPluginReducerActionType
,
localPluginToastReducer
}
from
'../../pluginManagerReducer'
interface
LocalPluginFormProps
{
interface
LocalPluginFormProps
{
changeHandler
:
(
propertyName
:
string
,
value
:
any
)
=>
void
changeHandler
:
(
propertyName
:
string
,
value
:
any
)
=>
void
...
@@ -13,7 +14,8 @@ interface LocalPluginFormProps {
...
@@ -13,7 +14,8 @@ interface LocalPluginFormProps {
pluginManager
:
PluginManagerComponent
pluginManager
:
PluginManagerComponent
}
}
const
handleModalOkClick
=
async
(
pluginManager
:
PluginManagerComponent
,
plugin
:
FormStateProps
,
setErrorMsg
:
React
.
Dispatch
<
React
.
SetStateAction
<
string
>>
)
=>
{
const
handleModalOkClick
=
async
(
pluginManager
:
PluginManagerComponent
,
plugin
:
FormStateProps
,
toastDispatcher
:
Dispatch
<
localPluginReducerActionType
>
)
=>
{
try
{
try
{
const
profile
=
JSON
.
parse
(
localStorage
.
getItem
(
'plugins/local'
))
const
profile
=
JSON
.
parse
(
localStorage
.
getItem
(
'plugins/local'
))
if
(
profile
&&
profile
.
profile
&&
Object
.
keys
(
profile
).
length
>
0
)
{
if
(
profile
&&
profile
.
profile
&&
Object
.
keys
(
profile
).
length
>
0
)
{
...
@@ -28,7 +30,6 @@ const handleModalOkClick = async (pluginManager: PluginManagerComponent, plugin:
...
@@ -28,7 +30,6 @@ const handleModalOkClick = async (pluginManager: PluginManagerComponent, plugin:
const
localPlugin
=
plugin
.
type
===
'iframe'
?
new
IframePlugin
(
plugin
)
:
new
WebsocketPlugin
(
plugin
)
const
localPlugin
=
plugin
.
type
===
'iframe'
?
new
IframePlugin
(
plugin
)
:
new
WebsocketPlugin
(
plugin
)
localPlugin
.
profile
.
hash
=
`local-
${
plugin
.
name
}
`
localPlugin
.
profile
.
hash
=
`local-
${
plugin
.
name
}
`
// <-------------------------------- Plumbing starts here --------------------------------------->
const
targetPlugin
=
{
const
targetPlugin
=
{
name
:
localPlugin
.
profile
.
name
,
name
:
localPlugin
.
profile
.
name
,
displayName
:
localPlugin
.
profile
.
displayName
,
displayName
:
localPlugin
.
profile
.
displayName
,
...
@@ -45,13 +46,14 @@ const handleModalOkClick = async (pluginManager: PluginManagerComponent, plugin:
...
@@ -45,13 +46,14 @@ const handleModalOkClick = async (pluginManager: PluginManagerComponent, plugin:
localPlugin
.
profile
=
{
...
localPlugin
.
profile
,
...
targetPlugin
}
localPlugin
.
profile
=
{
...
localPlugin
.
profile
,
...
targetPlugin
}
pluginManager
.
activateAndRegisterLocalPlugin
(
localPlugin
)
pluginManager
.
activateAndRegisterLocalPlugin
(
localPlugin
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
)
console
.
log
(
error
)
// setErrorMsg(error.message)
// setErrorMsg(error.message)
setErrorMsg
(
error
.
message
)
const
action
:
localPluginReducerActionType
=
{
type
:
'show'
,
payload
:
`
${
error
.
message
}
`
}
toastDispatcher
(
action
)
}
}
}
}
function
LocalPluginForm
({
changeHandler
,
plugin
,
closeModal
,
visible
,
pluginManager
}:
LocalPluginFormProps
)
{
function
LocalPluginForm
({
changeHandler
,
plugin
,
closeModal
,
visible
,
pluginManager
}:
LocalPluginFormProps
)
{
const
[
errorMsg
,
setErrorMsg
]
=
useState
(
''
)
const
[
errorMsg
,
dispatchToastMsg
]
=
useReducer
(
localPluginToastReducer
,
''
)
return
(
return
(
<><
ModalDialog
<><
ModalDialog
...
@@ -60,7 +62,7 @@ function LocalPluginForm ({ changeHandler, plugin, closeModal, visible, pluginMa
...
@@ -60,7 +62,7 @@ function LocalPluginForm ({ changeHandler, plugin, closeModal, visible, pluginMa
hide=
{
visible
}
hide=
{
visible
}
title=
"Local Plugin"
title=
"Local Plugin"
okLabel=
"OK"
okLabel=
"OK"
okFn=
{
()
=>
handleModalOkClick
(
pluginManager
,
plugin
,
setError
Msg
)
}
okFn=
{
()
=>
handleModalOkClick
(
pluginManager
,
plugin
,
dispatchToast
Msg
)
}
cancelLabel=
"Cancel"
cancelLabel=
"Cancel"
cancelFn=
{
closeModal
}
cancelFn=
{
closeModal
}
>
>
...
@@ -173,7 +175,9 @@ function LocalPluginForm ({ changeHandler, plugin, closeModal, visible, pluginMa
...
@@ -173,7 +175,9 @@ function LocalPluginForm ({ changeHandler, plugin, closeModal, visible, pluginMa
</
div
>
</
div
>
</
div
>
</
div
>
</
form
>
</
form
>
</
ModalDialog
><
Toaster
message=
{
`Cannot create Plugin : ${errorMsg}`
}
timeOut=
{
10000
}
/></>
</
ModalDialog
>
{
errorMsg
?
<
Toaster
message=
{
errorMsg
}
timeOut=
{
3000
}
/>
:
null
}
</>
)
)
}
}
...
...
libs/remix-ui/plugin-manager/src/pluginManagerReducer.ts
0 → 100644
View file @
74a9a43a
export
type
localPluginReducerActionType
=
{
type
:
'show'
|
'close'
,
payload
?:
any
}
export
function
localPluginToastReducer
(
currentState
:
string
,
toastAction
:
localPluginReducerActionType
)
{
switch
(
toastAction
.
type
)
{
case
'show'
:
return
`Cannot create Plugin :
${
toastAction
.
payload
!
}
`
}
}
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