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
b7e37f1c
Commit
b7e37f1c
authored
Jul 13, 2021
by
joseph izang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and clean up rootView component
parent
006c370b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
55 deletions
+5
-55
plugin-manager-component.js
.../remix-ide/src/app/components/plugin-manager-component.js
+0
-31
rootView.tsx
libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
+5
-24
No files found.
apps/remix-ide/src/app/components/plugin-manager-component.js
View file @
b7e37f1c
...
@@ -167,37 +167,6 @@ class PluginManagerComponent extends ViewPlugin {
...
@@ -167,37 +167,6 @@ class PluginManagerComponent extends ViewPlugin {
}
}
}
}
filterHelper
()
{
const
isFiltered
=
(
profile
)
=>
(
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
).
toLowerCase
().
includes
(
this
.
filter
)
const
isNotRequired
=
(
profile
)
=>
!
this
.
appManager
.
isRequired
(
profile
.
name
)
const
isNotDependent
=
(
profile
)
=>
!
this
.
appManager
.
isDependent
(
profile
.
name
)
const
isNotHome
=
(
profile
)
=>
profile
.
name
!==
'home'
const
sortByName
=
(
profileA
,
profileB
)
=>
{
const
nameA
=
((
profileA
.
displayName
)
?
profileA
.
displayName
:
profileA
.
name
).
toUpperCase
()
const
nameB
=
((
profileB
.
displayName
)
?
profileB
.
displayName
:
profileB
.
name
).
toUpperCase
()
return
(
nameA
<
nameB
)
?
-
1
:
(
nameA
>
nameB
)
?
1
:
0
}
return
(
isFiltered
,
isNotRequired
,
isNotDependent
,
isNotHome
,
sortByName
)
}
getAllPlugins
()
{
// // Filter all active and inactive modules that are not required
const
[
isFiltered
,
isNotRequired
,
isNotDependent
,
isNotHome
,
sortByName
]
=
this
.
filterHelper
()
const
{
actives
,
inactives
}
=
this
.
appManager
.
getAll
()
.
filter
(
isFiltered
)
.
filter
(
isNotRequired
)
.
filter
(
isNotDependent
)
.
filter
(
isNotHome
)
.
sort
(
sortByName
)
.
reduce
(({
actives
,
inactives
},
profile
)
=>
{
return
this
.
isActive
(
profile
.
name
)
?
{
actives
:
[...
actives
,
profile
],
inactives
}
:
{
inactives
:
[...
inactives
,
profile
],
actives
}
},
{
actives
:
[],
inactives
:
[]
})
this
.
activePlugins
=
actives
this
.
inactivePlugins
=
inactives
}
render
()
{
render
()
{
// Filtering helpers
// Filtering helpers
const
isFiltered
=
(
profile
)
=>
(
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
).
toLowerCase
().
includes
(
this
.
filter
)
const
isFiltered
=
(
profile
)
=>
(
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
).
toLowerCase
().
includes
(
this
.
filter
)
...
...
libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
View file @
b7e37f1c
...
@@ -21,18 +21,9 @@ const initialState: FormStateProps = {
...
@@ -21,18 +21,9 @@ const initialState: FormStateProps = {
interface
ShowInactivesProps
{
interface
ShowInactivesProps
{
inactives
:
Partial
<
PluginManagerProfile
>
[]
inactives
:
Partial
<
PluginManagerProfile
>
[]
appManager
?:
RemixAppManager
headinglabel
:
string
headinglabel
:
string
}
}
function
ShowInactives
({
inactives
,
appManager
,
headinglabel
}:
ShowInactivesProps
)
{
function
ShowInactives
({
inactives
,
headinglabel
}:
ShowInactivesProps
)
{
const
[
plugins
]
=
useState
<
Profile
<
any
>
[]
>
(
appManager
.
getAll
())
const
[
litUpProfiles
]
=
useState
<
Profile
<
any
>
[]
>
(
appManager
.
getActiveProfiles
())
const
pluginNames
=
litUpProfiles
.
map
(
p
=>
p
.
name
)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let
temp
:
Profile
<
any
>
[]
pluginNames
.
forEach
(
x
=>
{
temp
=
plugins
.
filter
(
plugin
=>
plugin
.
name
===
x
)
})
return
(
return
(
<
Fragment
>
<
Fragment
>
<
ModuleHeading
headingLabel=
{
headinglabel
}
/>
<
ModuleHeading
headingLabel=
{
headinglabel
}
/>
...
@@ -43,7 +34,7 @@ function ShowInactives ({ inactives, appManager, headinglabel }: ShowInactivesPr
...
@@ -43,7 +34,7 @@ function ShowInactives ({ inactives, appManager, headinglabel }: ShowInactivesPr
)
)
}
}
function
ShowActives
({
inactives
,
appManager
,
headinglabel
}:
ShowInactivesProps
)
{
function
ShowActives
({
inactives
,
headinglabel
}:
ShowInactivesProps
)
{
const
[
plugins
]
=
useState
<
any
[]
>
([])
const
[
plugins
]
=
useState
<
any
[]
>
([])
if
(
inactives
.
length
===
0
)
{
if
(
inactives
.
length
===
0
)
{
plugins
.
map
(
plugin
=>
inactives
.
push
(
plugin
))
plugins
.
map
(
plugin
=>
inactives
.
push
(
plugin
))
...
@@ -62,11 +53,6 @@ function RootView () {
...
@@ -62,11 +53,6 @@ function RootView () {
const
{
appManager
,
actives
,
engine
,
inactives
,
localPlugin
,
filter
}
=
useContext
(
PluginManagerContext
)
const
{
appManager
,
actives
,
engine
,
inactives
,
localPlugin
,
filter
}
=
useContext
(
PluginManagerContext
)
const
[
visible
,
setVisible
]
=
useState
<
boolean
>
(
true
)
const
[
visible
,
setVisible
]
=
useState
<
boolean
>
(
true
)
const
[
plugin
,
setPlugin
]
=
useState
(
initialState
)
const
[
plugin
,
setPlugin
]
=
useState
(
initialState
)
const
[
allPlugins
]
=
useState
(
appManager
.
getAll
())
const
[
activePlugins
,
setActivePlugins
]
=
useState
([])
const
[
inactivePlugins
,
setInactivePlugins
]
=
useState
([])
console
.
log
(
`allPlugins state has
${
allPlugins
.
length
}
plugins ready to be filtered`
)
function
pluginChangeHandler
<
P
extends
keyof
FormStateProps
>
(
formProps
:
P
,
value
:
FormStateProps
[
P
])
{
function
pluginChangeHandler
<
P
extends
keyof
FormStateProps
>
(
formProps
:
P
,
value
:
FormStateProps
[
P
])
{
setPlugin
({
...
plugin
,
[
formProps
]:
value
})
setPlugin
({
...
plugin
,
[
formProps
]:
value
})
...
@@ -77,11 +63,6 @@ function RootView () {
...
@@ -77,11 +63,6 @@ function RootView () {
const
closeModal
=
()
=>
setVisible
(
true
)
const
closeModal
=
()
=>
setVisible
(
true
)
const
activatePlugin
=
async
(
name
:
string
)
=>
{
await
appManager
.
activatePlugin
(
name
)
}
console
.
log
(
'active plugins'
,
activePlugins
)
return
(
return
(
<
Fragment
>
<
Fragment
>
<
form
id=
"local-plugin-form"
>
<
form
id=
"local-plugin-form"
>
...
@@ -203,10 +184,10 @@ function RootView () {
...
@@ -203,10 +184,10 @@ function RootView () {
</
header
>
</
header
>
<
section
data
-
id=
"pluginManagerComponentPluginManagerSection"
>
<
section
data
-
id=
"pluginManagerComponentPluginManagerSection"
>
{
actives
!==
undefined
{
actives
!==
undefined
?
(<
ShowActives
appManager=
{
appManager
}
headinglabel=
"Active Modules"
inactives=
{
inactivePlugin
s
}
/>)
?
(<
ShowActives
headinglabel=
"Active Modules"
inactives=
{
active
s
}
/>)
:
(<
ShowActives
headinglabel=
"Active Modules"
inactives=
{
active
Plugin
s
}
/>)
:
(<
ShowActives
headinglabel=
"Active Modules"
inactives=
{
actives
}
/>)
}
}
{
inactives
!==
undefined
?
(<
ShowInactives
appManager=
{
appManager
}
inactives=
{
inactives
}
headinglabel=
"Inactive Modules"
/>)
:
<
ShowInactives
inactives=
{
inactives
}
headinglabel=
"Inactive Modules"
/>
}
{
inactives
!==
undefined
?
(<
ShowInactives
inactives=
{
inactives
}
headinglabel=
"Inactive Modules"
/>)
:
<
ShowInactives
inactives=
{
inactives
}
headinglabel=
"Inactive Modules"
/>
}
</
section
>
</
section
>
</
div
>
</
div
>
</
Fragment
>
</
Fragment
>
...
...
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