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
880a131d
Unverified
Commit
880a131d
authored
May 13, 2019
by
yann300
Committed by
GitHub
May 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1965 from ethereum/issue#1784-clear_permission_list
Add Permission Management for plugins
parents
c13c9ad8
b815dae7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
8 deletions
+108
-8
plugin-manager-component.js
src/app/components/plugin-manager-component.js
+6
-2
plugin-manager-settings.js
src/app/components/plugin-manager-settings.js
+102
-0
swap-panel.js
src/app/components/swap-panel.js
+0
-6
No files found.
src/app/components/plugin-manager-component.js
View file @
880a131d
...
@@ -3,6 +3,7 @@ const csjs = require('csjs-inject')
...
@@ -3,6 +3,7 @@ const csjs = require('csjs-inject')
const
EventEmitter
=
require
(
'events'
)
const
EventEmitter
=
require
(
'events'
)
const
LocalPlugin
=
require
(
'./local-plugin'
)
const
LocalPlugin
=
require
(
'./local-plugin'
)
import
{
Plugin
,
BaseApi
}
from
'remix-plugin'
import
{
Plugin
,
BaseApi
}
from
'remix-plugin'
import
{
PluginManagerSettings
}
from
'./plugin-manager-settings'
const
css
=
csjs
`
const
css
=
csjs
`
.pluginSearch {
.pluginSearch {
...
@@ -152,14 +153,16 @@ class PluginManagerComponent extends BaseApi {
...
@@ -152,14 +153,16 @@ class PluginManagerComponent extends BaseApi {
</nav>`
</nav>`
:
''
:
''
const
settings
=
new
PluginManagerSettings
().
render
()
const
rootView
=
yo
`
const
rootView
=
yo
`
<div id='pluginManager'>
<div id='pluginManager'>
<
div
class="form-group
${
css
.
pluginSearch
}
">
<
header
class="form-group
${
css
.
pluginSearch
}
">
<input onkeyup="
${
e
=>
this
.
filterPlugins
(
e
)}
" class="form-control" placeholder="Search">
<input onkeyup="
${
e
=>
this
.
filterPlugins
(
e
)}
" class="form-control" placeholder="Search">
<button onclick="
${
_
=>
this
.
openLocalPlugin
()}
" class="btn btn-sm text-info
${
css
.
localPluginBtn
}
">
<button onclick="
${
_
=>
this
.
openLocalPlugin
()}
" class="btn btn-sm text-info
${
css
.
localPluginBtn
}
">
Connect to a Local Plugin
Connect to a Local Plugin
</button>
</button>
</
div
>
</
header
>
<section>
<section>
${
activeTile
}
${
activeTile
}
<div class="list-group list-group-flush">
<div class="list-group list-group-flush">
...
@@ -170,6 +173,7 @@ class PluginManagerComponent extends BaseApi {
...
@@ -170,6 +173,7 @@ class PluginManagerComponent extends BaseApi {
${
inactives
.
map
(
name
=>
this
.
renderItem
(
name
))}
${
inactives
.
map
(
name
=>
this
.
renderItem
(
name
))}
</div>
</div>
</section>
</section>
${
settings
}
</div>
</div>
`
`
if
(
!
this
.
views
.
root
)
this
.
views
.
root
=
rootView
if
(
!
this
.
views
.
root
)
this
.
views
.
root
=
rootView
...
...
src/app/components/plugin-manager-settings.js
0 → 100644
View file @
880a131d
const
yo
=
require
(
'yo-yo'
)
const
csjs
=
require
(
'csjs-inject'
)
const
modalDialog
=
require
(
'../ui/modaldialog'
)
const
css
=
csjs
`
.permissions {
position: sticky;
bottom: 0;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 5px 20px;
}
.permissions button {
padding: 2px 5px;
cursor: pointer;
}
.permissionForm h4 {
font-size: 1.3rem;
text-align: center;
}
.permissionForm h6 {
font-size: 1.1rem;
}
.permissionForm hr {
width: 80%;
}
.checkbox {
display: flex;
align-items: center;
}
.checkbox label {
margin: 0;
font-size: 1rem;
}`
export
class
PluginManagerSettings
{
openDialog
()
{
const
fromLocal
=
window
.
localStorage
.
getItem
(
'plugins/permissions'
)
this
.
permissions
=
JSON
.
parse
(
fromLocal
||
'{}'
)
modalDialog
(
'Plugin Manager Settings'
,
this
.
settings
(),
{
fn
:
()
=>
this
.
onValidation
()
},
)
}
onValidation
()
{
const
permissions
=
JSON
.
stringify
(
this
.
permissions
)
window
.
localStorage
.
setItem
(
'plugins/permissions'
,
permissions
)
}
settings
()
{
const
permissionByModule
=
(
key
,
permission
)
=>
{
const
permissionByPlugin
=
(
name
,
plugin
)
=>
{
function
updatePermission
()
{
plugin
.
allow
=
!
plugin
.
allow
}
const
checkbox
=
plugin
.
allow
?
yo
`<input onchange="
${
updatePermission
}
" type="checkbox" checked id="permission-
${
name
}
" aria-describedby="module
${
key
}
ask permission for
${
name
}
" />`
:
yo
`<input onchange="
${
updatePermission
}
" type="checkbox" id="permission-
${
name
}
" aria-describedby="module
${
key
}
ask permission for
${
name
}
" />`
return
yo
`
<div class="form-group
${
css
.
checkbox
}
">
${
checkbox
}
<label for="permission-
${
name
}
">Allow plugin
${
name
}
to write on
${
key
}
</label>
</div>`
}
const
byModule
=
Object
.
keys
(
permission
)
.
map
(
name
=>
permissionByPlugin
(
name
,
permission
[
name
]))
return
yo
`
<div>
<h6>
${
key
}
:</h6>
${
byModule
}
</div>`
}
const
permissions
=
Object
.
keys
(
this
.
permissions
)
.
map
(
key
=>
permissionByModule
(
key
,
this
.
permissions
[
key
]))
const
title
=
permissions
.
length
===
0
?
yo
`<h4>No Permission requested yet.</h4>`
:
yo
`<h4>Current Permission settings</h4>`
return
yo
`<form class="
${
css
.
permissionForm
}
">
${
title
}
<hr/>
${
permissions
}
</form>`
}
render
()
{
return
yo
`
<footer class="navbar navbar-light bg-light
${
css
.
permissions
}
">
<button onclick="
${()
=>
this
.
openDialog
()}
" class="btn btn-info">Settings</button>
</footer>`
}
}
src/app/components/swap-panel.js
View file @
880a131d
...
@@ -54,19 +54,13 @@ export class SwapPanel extends AbstractPanel {
...
@@ -54,19 +54,13 @@ export class SwapPanel extends AbstractPanel {
/** The header of the swap panel */
/** The header of the swap panel */
renderHeader
()
{
renderHeader
()
{
let
name
=
' - '
let
name
=
' - '
let
hasSettings
=
false
if
(
this
.
active
)
{
if
(
this
.
active
)
{
const
{
profile
}
=
this
.
store
.
getOne
(
this
.
active
)
const
{
profile
}
=
this
.
store
.
getOne
(
this
.
active
)
name
=
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
name
=
profile
.
displayName
?
profile
.
displayName
:
profile
.
name
hasSettings
=
profile
.
settings
||
false
}
}
return
yo
`
return
yo
`
<header class="
${
css
.
swapitHeader
}
">
<header class="
${
css
.
swapitHeader
}
">
<h6 class="
${
css
.
swapitTitle
}
">
${
name
}
</h6>
<h6 class="
${
css
.
swapitTitle
}
">
${
name
}
</h6>
<div class="
${
css
.
icons
}
">
${
hasSettings
?
yo
`<i class="fas fa-cog"></i>`
:
yo
`<i></i>`
}
</div>
</div>
</header>`
</header>`
}
}
...
...
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