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
966de214
Commit
966de214
authored
Jul 06, 2021
by
joseph izang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish implementing Context for easy state access
parent
68020415
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
84 deletions
+72
-84
plugin-manager-component.js
.../remix-ide/src/app/components/plugin-manager-component.js
+14
-14
activeTile.tsx
...remix-ui/plugin-manager/src/lib/components/activeTile.tsx
+1
-1
rootView.tsx
libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
+8
-19
remix-ui-plugin-manager.tsx
...mix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx
+49
-50
No files found.
apps/remix-ide/src/app/components/plugin-manager-component.js
View file @
966de214
...
@@ -116,9 +116,9 @@ class PluginManagerComponent extends ViewPlugin {
...
@@ -116,9 +116,9 @@ class PluginManagerComponent extends ViewPlugin {
ReactDOM
.
render
(
<
RemixUiPluginManager
/>
,
document
.
getElementById
(
'pluginManager'
))
ReactDOM
.
render
(
<
RemixUiPluginManager
/>
,
document
.
getElementById
(
'pluginManager'
))
}
}
//
isActive (name) {
isActive
(
name
)
{
//
return this.appManager.actives.includes(name)
return
this
.
appManager
.
actives
.
includes
(
name
)
//
}
}
activateP
(
name
)
{
activateP
(
name
)
{
this
.
appManager
.
activatePlugin
(
name
)
this
.
appManager
.
activatePlugin
(
name
)
...
@@ -219,17 +219,17 @@ class PluginManagerComponent extends ViewPlugin {
...
@@ -219,17 +219,17 @@ class PluginManagerComponent extends ViewPlugin {
}
}
// // Filter all active and inactive modules that are not required
// // Filter all active and inactive modules that are not required
//
const { actives, inactives } = this.appManager.getAll()
const
{
actives
,
inactives
}
=
this
.
appManager
.
getAll
()
//
.filter(isFiltered)
.
filter
(
isFiltered
)
//
.filter(isNotRequired)
.
filter
(
isNotRequired
)
//
.filter(isNotDependent)
.
filter
(
isNotDependent
)
//
.filter(isNotHome)
.
filter
(
isNotHome
)
//
.sort(sortByName)
.
sort
(
sortByName
)
//
.reduce(({ actives, inactives }, profile) => {
.
reduce
(({
actives
,
inactives
},
profile
)
=>
{
//
return this.isActive(profile.name)
return
this
.
isActive
(
profile
.
name
)
//
? { actives: [...actives, profile], inactives }
?
{
actives
:
[...
actives
,
profile
],
inactives
}
//
: { inactives: [...inactives, profile], actives }
:
{
inactives
:
[...
inactives
,
profile
],
actives
}
//
}, { actives: [], inactives: [] })
},
{
actives
:
[],
inactives
:
[]
})
// const activeTile = actives.length !== 0
// const activeTile = actives.length !== 0
// ? yo`
// ? yo`
...
...
libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx
View file @
966de214
...
@@ -12,7 +12,7 @@ function ActiveTile ({ inactivesCount, activesCount, tileLabel }: ActiveTileProp
...
@@ -12,7 +12,7 @@ function ActiveTile ({ inactivesCount, activesCount, tileLabel }: ActiveTileProp
<
nav
className=
"plugins-list-header justify-content-between navbar navbar-expand-lg bg-light navbar-light align-items-center"
>
<
nav
className=
"plugins-list-header justify-content-between navbar navbar-expand-lg bg-light navbar-light align-items-center"
>
<
span
className=
"navbar-brand plugins-list-title h6 mb-0 mr-2"
>
{
tileLabel
.
label
}
</
span
>
<
span
className=
"navbar-brand plugins-list-title h6 mb-0 mr-2"
>
{
tileLabel
.
label
}
</
span
>
<
span
className=
"badge badge-primary"
style=
{
{
cursor
:
'default'
}
}
data
-
id=
"pluginManagerComponentInactiveTilesCount"
>
<
span
className=
"badge badge-primary"
style=
{
{
cursor
:
'default'
}
}
data
-
id=
"pluginManagerComponentInactiveTilesCount"
>
{
tileLabel
.
label
===
'Active Module'
?
activesCount
:
inactivesCount
}
{
tileLabel
.
label
===
'Active Module'
?
activesCount
:
tileLabel
.
label
===
'Inactive Modules'
?
inactivesCount
:
'-'
}
</
span
>
</
span
>
</
nav
>
</
nav
>
)
)
...
...
libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
View file @
966de214
import
React
from
'react'
import
React
,
{
useContext
}
from
'react'
import
{
P
rofile
,
TileLabel
}
from
'../../customTypes
'
import
{
P
luginManagerContext
}
from
'../remix-ui-plugin-manager
'
import
ActiveTile
from
'./activeTile'
import
ActiveTile
from
'./activeTile'
import
ListGroupItem
from
'./listGroupItem'
import
ListGroupItem
from
'./listGroupItem'
interface
RootViewProps
{
interface
RootViewProps
{
localPluginButtonText
:
string
localPluginButtonText
:
string
activeProfiles
:
Profile
[]
inactiveProfiles
?:
Profile
[]
filterPlugins
:
()
=>
void
openLocalPlugins
:
()
=>
void
tileLabel
:
TileLabel
}
}
function
RootView
({
function
RootView
({
localPluginButtonText
}:
RootViewProps
)
{
localPluginButtonText
,
const
{
actives
,
inactives
,
tileLabel
}
=
useContext
(
PluginManagerContext
)
activeProfiles
,
inactiveProfiles
,
filterPlugins
,
openLocalPlugins
,
tileLabel
}:
RootViewProps
)
{
return
(
return
(
<
div
id=
"pluginManager"
data
-
id=
"pluginManagerComponentPluginManager"
>
<
div
id=
"pluginManager"
data
-
id=
"pluginManagerComponentPluginManager"
>
<
header
className=
"form-group remixui_pluginSearch plugins-header py-3 px-4 border-bottom"
data
-
id=
"pluginManagerComponentPluginManagerHeader"
>
<
header
className=
"form-group remixui_pluginSearch plugins-header py-3 px-4 border-bottom"
data
-
id=
"pluginManagerComponentPluginManagerHeader"
>
...
@@ -28,13 +17,13 @@ function RootView ({
...
@@ -28,13 +17,13 @@ function RootView ({
</
header
>
</
header
>
<
section
data
-
id=
"pluginManagerComponentPluginManagerSection"
>
<
section
data
-
id=
"pluginManagerComponentPluginManagerSection"
>
<
ActiveTile
<
ActiveTile
activesCount=
{
active
Profile
s
.
length
}
activesCount=
{
actives
.
length
}
inactivesCount=
{
inactive
Profile
s
.
length
}
inactivesCount=
{
inactives
.
length
}
tileLabel=
{
tileLabel
}
tileLabel=
{
tileLabel
}
/>
/>
<
ListGroupItem
<
ListGroupItem
activeProfiles=
{
active
Profile
s
}
activeProfiles=
{
actives
}
inactiveProfiles=
{
inactive
Profile
s
}
inactiveProfiles=
{
inactives
}
/>
/>
</
section
>
</
section
>
</
div
>
</
div
>
...
...
libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx
View file @
966de214
import
React
,
{
createContext
,
useEffect
,
useState
}
from
'react'
import
React
,
{
createContext
,
useEffect
,
useState
}
from
'react'
import
{
Profile
}
from
'../customTypes'
import
{
Profile
,
TileLabel
}
from
'../customTypes'
import
{
RemixAppManager
,
RemixEngine
,
_Paq
}
from
'../types'
import
{
RemixAppManager
,
RemixEngine
,
_Paq
}
from
'../types'
import
RootView
from
'./components/rootView'
import
RootView
from
'./components/rootView'
import
'./remix-ui-plugin-manager.css'
import
'./remix-ui-plugin-manager.css'
/* eslint-disable-next-line */
/* eslint-disable-next-line */
export
interface
RemixUiPluginManag
erProps
{
export
interface
PluginManagerContextProvid
erProps
{
appManager
:
RemixAppManager
appManager
:
RemixAppManager
engine
:
RemixEngine
engine
:
RemixEngine
_paq
:
_Paq
_paq
:
_Paq
filter
:
string
filter
:
string
actives
:
Profile
[]
inactives
:
Profile
[]
activatePlugin
:
(
name
:
string
)
=>
void
activatePlugin
:
(
name
:
string
)
=>
void
deActivatePlugin
:
(
name
:
string
)
=>
void
deActivatePlugin
:
(
name
:
string
)
=>
void
isActive
:
(
name
:
string
)
=>
void
isActive
:
(
name
:
string
)
=>
any
openLocalPlugin
:
()
=>
Promise
<
void
>
openLocalPlugin
:
()
=>
Promise
<
void
>
filterPlugins
:
()
=>
void
filterPlugins
:
()
=>
void
profile
:
Profile
profile
:
Profile
tileLabel
:
TileLabel
}
}
export
const
PluginManagerContext
=
createContext
({})
export
interface
RemixUiPluginManagerProps
{
appManager
:
RemixAppManager
function
PluginManagerContextProvider
({
children
})
{
engine
:
RemixEngine
const
[
globalState
]
=
useState
<
RemixUiPluginManagerProps
>
({}
as
RemixUiPluginManagerProps
)
_paq
:
_Paq
return
(
filter
:
string
<
PluginManagerContext
.
Provider
value=
{
globalState
}
>
actives
:
Profile
[]
{
children
}
inactives
:
Profile
[]
</
PluginManagerContext
.
Provider
>
activatePlugin
:
(
name
:
string
)
=>
void
)
deActivatePlugin
:
(
name
:
string
)
=>
void
isActive
:
(
name
:
string
)
=>
any
openLocalPlugin
:
()
=>
Promise
<
void
>
filterPlugins
:
()
=>
void
profile
:
Profile
tileLabel
:
TileLabel
}
}
// // Filtering helpers
export
const
PluginManagerContext
=
createContext
<
Partial
<
PluginManagerContextProviderProps
>>
({})
// 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
// }
// // Filter all active and inactive modules that are not required
// 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: [] })
export
const
RemixUiPluginManager
=
(
props
:
RemixUiPluginManagerProps
)
=>
{
function
PluginManagerContextProvider
({
children
,
props
})
{
const
[
isFiltered
]
=
useState
((
profile
)
=>
const
[
isFiltered
]
=
useState
((
profile
)
=>
(
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
).
toLowerCase
().
includes
(
props
.
filter
))
(
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
).
toLowerCase
().
includes
(
props
.
filter
))
const
[
isNotRequired
,
setIsNotRequired
]
=
useState
<
boolean
>
(
false
)
const
[
isNotRequired
,
setIsNotRequired
]
=
useState
<
any
>
()
const
[
isNotDependent
,
setIsNotDependent
]
=
useState
((
profile
)
=>
!
props
.
appManager
.
isDependent
(
profile
.
name
))
const
[
isNotDependent
,
setIsNotDependent
]
=
useState
<
any
>
()
const
[
isNotHome
,
setIsNotHome
]
=
useState
((
profile
)
=>
profile
.
name
!==
'home'
)
const
[
isNotHome
,
setIsNotHome
]
=
useState
<
any
>
()
const
[
sortByName
,
setSortByName
]
=
useState
<
1
|
-
1
|
0
>
((
profileA
,
profileB
)
=>
{
const
[
sortByName
,
setSortByName
]
=
useState
<
any
>
()
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
})
const
{
actives
,
inactives
}
=
props
.
appManager
.
getAll
()
const
{
actives
,
inactives
}
=
props
.
appManager
.
getAll
()
.
filter
(
isFiltered
)
.
filter
(
isFiltered
)
.
filter
(
isNotRequired
)
.
filter
(
isNotRequired
)
...
@@ -71,21 +53,38 @@ export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => {
...
@@ -71,21 +53,38 @@ export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => {
.
filter
(
isNotHome
)
.
filter
(
isNotHome
)
.
sort
(
sortByName
)
.
sort
(
sortByName
)
.
reduce
(({
actives
,
inactives
},
profile
)
=>
{
.
reduce
(({
actives
,
inactives
},
profile
)
=>
{
return
thi
s
.
isActive
(
profile
.
name
)
return
prop
s
.
isActive
(
profile
.
name
)
?
{
actives
:
[...
actives
,
profile
],
inactives
}
?
{
actives
:
[...
actives
,
profile
],
inactives
}
:
{
inactives
:
[...
inactives
,
profile
],
actives
}
:
{
inactives
:
[...
inactives
,
profile
],
actives
}
},
{
actives
:
[],
inactives
:
[]
})
},
{
actives
:
[],
inactives
:
[]
})
props
.
actives
=
actives
props
.
inactives
=
inactives
useEffect
(()
=>
{
useEffect
(()
=>
{
const
notRequired
=
(
profile
:
Profile
)
=>
!
props
.
appManager
.
isRequired
(
profile
.
name
)
const
notRequired
=
(
profile
:
Profile
)
=>
!
props
.
appManager
.
isRequired
(
profile
.
name
)
const
notDependent
=
(
profile
)
=>
!
props
.
appManager
.
isDependent
(
profile
.
name
)
const
notHome
=
(
profile
)
=>
profile
.
name
!==
'home'
const
sortedByName
=
(
profileA
:
Profile
,
profileB
:
Profile
)
=>
{
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
}
setIsNotRequired
(
notRequired
(
props
.
profile
))
setIsNotRequired
(
notRequired
(
props
.
profile
))
})
setIsNotDependent
(
notDependent
(
notDependent
))
setIsNotHome
(
notHome
)
setSortByName
(
sortedByName
)
},
[
props
.
appManager
,
props
.
profile
])
return
(
<
PluginManagerContext
.
Provider
value=
{
...
props
}
>
{
children
}
</
PluginManagerContext
.
Provider
>
)
}
export
const
RemixUiPluginManager
=
(
props
:
RemixUiPluginManagerProps
)
=>
{
return
(
return
(
<
PluginManagerContextProvider
>
<
PluginManagerContextProvider
props
>
<
RootView
<
RootView
openLocalPlugins=
{
props
.
openLocalPlugin
}
localPluginButtonText=
"Connect to a Local Plugin"
filterPlugins=
{
props
.
filterPlugins
}
activeProfiles
/>
/>
</
PluginManagerContextProvider
>
</
PluginManagerContextProvider
>
)
)
...
...
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