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
558951bc
Commit
558951bc
authored
May 13, 2019
by
Grandschtroumpf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a plugin manager settings
parent
53b119fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
+95
-0
plugin-manager-settings.js
src/app/components/plugin-manager-settings.js
+95
-0
No files found.
src/app/components/plugin-manager-settings.js
0 → 100644
View file @
558951bc
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;
}
.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
()
{
this
.
permissions
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'plugins/permissions'
))
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
byPlugin
=
Object
.
keys
(
permission
)
.
map
(
name
=>
permissionByPlugin
(
name
,
permission
[
name
]))
return
yo
`
<div>
<h6>
${
key
}
:</h6>
${
byPlugin
}
</div>`
}
const
permissions
=
Object
.
keys
(
this
.
permissions
)
.
map
(
key
=>
permissionByModule
(
key
,
this
.
permissions
[
key
]))
return
yo
`<form class="
${
css
.
permissionForm
}
">
<h4>Current Permission settings</h4>
<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>`
}
}
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