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
ebf52174
Unverified
Commit
ebf52174
authored
May 20, 2019
by
yann300
Committed by
GitHub
May 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1989 from ethereum/issue#1988-clear_permission
Issue#1988 clear permission
parents
c44d5368
b67c4f33
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
plugin-manager-settings.js
src/app/components/plugin-manager-settings.js
+34
-2
persmission-handler.js
src/persmission-handler.js
+6
-1
No files found.
src/app/components/plugin-manager-settings.js
View file @
ebf52174
...
@@ -25,6 +25,14 @@ const css = csjs`
...
@@ -25,6 +25,14 @@ const css = csjs`
.permissionForm hr {
.permissionForm hr {
width: 80%;
width: 80%;
}
}
.permissionKey {
display: flex;
justify-content: space-between;
align-items: center;
}
.permissionKey i {
cursor: pointer;
}
.checkbox {
.checkbox {
display: flex;
display: flex;
align-items: center;
align-items: center;
...
@@ -39,7 +47,8 @@ export class PluginManagerSettings {
...
@@ -39,7 +47,8 @@ export class PluginManagerSettings {
openDialog
()
{
openDialog
()
{
const
fromLocal
=
window
.
localStorage
.
getItem
(
'plugins/permissions'
)
const
fromLocal
=
window
.
localStorage
.
getItem
(
'plugins/permissions'
)
this
.
permissions
=
JSON
.
parse
(
fromLocal
||
'{}'
)
this
.
permissions
=
JSON
.
parse
(
fromLocal
||
'{}'
)
modalDialog
(
'Plugin Manager Settings'
,
this
.
settings
(),
this
.
currentSetting
=
this
.
settings
()
modalDialog
(
'Plugin Manager Settings'
,
this
.
currentSetting
,
{
fn
:
()
=>
this
.
onValidation
()
},
{
fn
:
()
=>
this
.
onValidation
()
},
)
)
}
}
...
@@ -49,6 +58,23 @@ export class PluginManagerSettings {
...
@@ -49,6 +58,23 @@ export class PluginManagerSettings {
window
.
localStorage
.
setItem
(
'plugins/permissions'
,
permissions
)
window
.
localStorage
.
setItem
(
'plugins/permissions'
,
permissions
)
}
}
/** Clear one permission from a plugin */
clearPersmission
(
from
,
to
)
{
if
(
!
this
.
permissions
[
from
])
return
delete
this
.
permissions
[
from
][
to
]
if
(
Object
.
keys
(
this
.
permissions
[
from
]).
length
===
0
)
{
delete
this
.
permissions
[
from
]
}
yo
.
update
(
this
.
currentSetting
,
this
.
settings
())
}
/** Clear all persmissions from a plugin */
clearAllPersmission
(
from
)
{
if
(
!
this
.
permissions
[
from
])
return
delete
this
.
permissions
[
from
]
yo
.
update
(
this
.
currentSetting
,
this
.
settings
())
}
settings
()
{
settings
()
{
const
permissionByModule
=
(
key
,
permission
)
=>
{
const
permissionByModule
=
(
key
,
permission
)
=>
{
const
permissionByPlugin
=
(
name
,
plugin
)
=>
{
const
permissionByPlugin
=
(
name
,
plugin
)
=>
{
...
@@ -60,9 +86,12 @@ export class PluginManagerSettings {
...
@@ -60,9 +86,12 @@ export class PluginManagerSettings {
:
yo
`<input onchange="
${
updatePermission
}
" type="checkbox" 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
`
return
yo
`
<div class="form-group
${
css
.
checkbox
}
">
<div class="form-group
${
css
.
permissionKey
}
">
<div class="
${
css
.
checkbox
}
">
${
checkbox
}
${
checkbox
}
<label for="permission-
${
name
}
">Allow plugin
${
name
}
to write on
${
key
}
</label>
<label for="permission-
${
name
}
">Allow plugin
${
name
}
to write on
${
key
}
</label>
</div>
<i onclick="
${()
=>
this
.
clearPersmission
(
key
,
name
)}
" class="fa fa-trash-alt"></i>
</div>`
</div>`
}
}
...
@@ -72,7 +101,10 @@ export class PluginManagerSettings {
...
@@ -72,7 +101,10 @@ export class PluginManagerSettings {
return
yo
`
return
yo
`
<div>
<div>
<div class="
${
css
.
permissionKey
}
">
<h6>
${
key
}
:</h6>
<h6>
${
key
}
:</h6>
<i onclick="
${()
=>
this
.
clearAllPersmission
(
key
)}
" class="far fa-trash-alt"></i>
</div>
${
byModule
}
${
byModule
}
</div>`
</div>`
}
}
...
...
src/persmission-handler.js
View file @
ebf52174
...
@@ -39,8 +39,12 @@ function notAllowWarning (from, to) {
...
@@ -39,8 +39,12 @@ function notAllowWarning (from, to) {
export
class
PermissionHandler
{
export
class
PermissionHandler
{
constructor
()
{
constructor
()
{
this
.
permissions
=
this
.
_getFromLocal
()
}
_getFromLocal
()
{
const
permission
=
localStorage
.
getItem
(
'plugins/permissions'
)
const
permission
=
localStorage
.
getItem
(
'plugins/permissions'
)
this
.
permissions
=
permission
?
JSON
.
parse
(
permission
)
:
{}
return
permission
?
JSON
.
parse
(
permission
)
:
{}
}
}
persistPermissions
()
{
persistPermissions
()
{
...
@@ -101,6 +105,7 @@ export class PermissionHandler {
...
@@ -101,6 +105,7 @@ export class PermissionHandler {
* @returns {Promise<boolean>}
* @returns {Promise<boolean>}
*/
*/
async
askPermission
(
from
,
to
)
{
async
askPermission
(
from
,
to
)
{
this
.
permissions
=
this
.
_getFromLocal
()
if
(
!
this
.
permissions
[
to
.
name
])
this
.
permissions
[
to
.
name
]
=
{}
if
(
!
this
.
permissions
[
to
.
name
])
this
.
permissions
[
to
.
name
]
=
{}
if
(
!
this
.
permissions
[
to
.
name
][
from
.
name
])
return
this
.
openPermission
(
from
,
to
)
if
(
!
this
.
permissions
[
to
.
name
][
from
.
name
])
return
this
.
openPermission
(
from
,
to
)
...
...
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