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
b68387ea
Commit
b68387ea
authored
Mar 21, 2019
by
Grandschtroumpf
Committed by
François
Mar 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tooltip to permission and throw error
parent
48578523
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
16 deletions
+41
-16
fileManager.js
src/app/files/fileManager.js
+2
-1
tooltip-styles.js
src/app/ui/styles/tooltip-styles.js
+3
-1
tooltip.js
src/app/ui/tooltip.js
+11
-2
persmission-handler.js
src/persmission-handler.js
+25
-12
No files found.
src/app/files/fileManager.js
View file @
b68387ea
...
@@ -49,7 +49,8 @@ class FileManager extends ApiFactory {
...
@@ -49,7 +49,8 @@ class FileManager extends ApiFactory {
name
:
'fileManager'
,
name
:
'fileManager'
,
methods
:
[
'getFilesFromPath'
,
'getCurrentFile'
,
'getFile'
,
'setFile'
],
methods
:
[
'getFilesFromPath'
,
'getCurrentFile'
,
'getFile'
,
'setFile'
],
events
:
[
'currentFileChanged'
],
events
:
[
'currentFileChanged'
],
description
:
'service - read/write to any files or folders, require giving permissions'
description
:
'service - read/write to any files or folders, require giving permissions'
,
permission
:
true
}
}
}
}
...
...
src/app/ui/styles/tooltip-styles.js
View file @
b68387ea
...
@@ -3,7 +3,9 @@ var csjs = require('csjs-inject')
...
@@ -3,7 +3,9 @@ var csjs = require('csjs-inject')
var
css
=
csjs
`
var
css
=
csjs
`
.tooltip {
.tooltip {
z-index: 1001;
z-index: 1001;
display: inline-block;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
position: fixed;
color: var(--primary)
color: var(--primary)
min-height: 50px;
min-height: 50px;
...
...
src/app/ui/tooltip.js
View file @
b68387ea
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
css
=
require
(
'./styles/tooltip-styles'
)
var
css
=
require
(
'./styles/tooltip-styles'
)
module
.
exports
=
function
addTooltip
(
tooltipText
)
{
/**
var
tooltip
=
yo
`<div class="
${
css
.
tooltip
}
bg-secondary">
${
tooltipText
}
</div>`
* Open a tooltip
* @param {string} tooltipText The text shown by the tooltip
* @param {HTMLElement} [action] An HTMLElement to display for action
*/
module
.
exports
=
function
addTooltip
(
tooltipText
,
action
)
{
var
tooltip
=
yo
`
<div class="
${
css
.
tooltip
}
bg-secondary">
<span>
${
tooltipText
}
</span>
${
action
}
</div>`
document
.
body
.
appendChild
(
tooltip
)
document
.
body
.
appendChild
(
tooltip
)
setTimeout
(
function
()
{
setTimeout
(
function
()
{
document
.
body
.
removeChild
(
tooltip
)
document
.
body
.
removeChild
(
tooltip
)
...
...
src/persmission-handler.js
View file @
b68387ea
/* global localStorage */
/* global localStorage */
const
yo
=
require
(
'yo-yo'
)
const
yo
=
require
(
'yo-yo'
)
const
csjs
=
require
(
'csjs-inject'
)
const
csjs
=
require
(
'csjs-inject'
)
const
addTooltip
=
require
(
'./app/ui/tooltip'
)
const
modalDialog
=
require
(
'./app/ui/modaldialog'
)
const
modalDialog
=
require
(
'./app/ui/modaldialog'
)
const
css
=
csjs
`
const
css
=
csjs
`
.permission
p
{
.permission
h4
{
text-align: center;
text-align: center;
}
}
.images {
.images {
display: flex;
display: flex;
justify-content: center;
justify-content: center;
align-item: center;
align-items: center;
padding: 10px;
}
}
.images img {
.images img {
width: 40px;
width: 40px;
height: 40px;
height: 40px;
}
}
.images span {
marign: 0 20px;
}
`
`
function
notAllowWarning
(
from
,
to
)
{
return
`
${
from
.
displayName
||
from
.
name
}
is not allowed to call
${
to
.
displayName
||
to
.
name
}
.`
}
export
class
PermissionHandler
{
export
class
PermissionHandler
{
constructor
()
{
constructor
()
{
const
permission
=
localStorage
.
getItem
(
'plugin
-
permissions'
)
const
permission
=
localStorage
.
getItem
(
'plugin
s/
permissions'
)
this
.
permissions
=
permission
?
JSON
.
parse
(
permission
)
:
{}
this
.
permissions
=
permission
?
JSON
.
parse
(
permission
)
:
{}
}
}
persistPermissions
()
{
persistPermissions
()
{
const
permissions
=
JSON
.
stringify
(
this
.
permissions
)
const
permissions
=
JSON
.
stringify
(
this
.
permissions
)
localStorage
.
setItem
(
'plugin
-
permissions'
,
permissions
)
localStorage
.
setItem
(
'plugin
s/
permissions'
,
permissions
)
}
}
clear
()
{
clear
()
{
localStorage
.
removeItem
(
'plugin
-
permissions'
)
localStorage
.
removeItem
(
'plugin
s/
permissions'
)
}
}
/**
/**
...
@@ -52,7 +61,7 @@ export class PermissionHandler {
...
@@ -52,7 +61,7 @@ export class PermissionHandler {
this
.
permissions
[
to
.
name
][
from
.
name
].
allow
=
true
this
.
permissions
[
to
.
name
][
from
.
name
].
allow
=
true
this
.
persistPermissions
()
this
.
persistPermissions
()
}
}
resolve
(
true
)
resolve
()
}
}
},
},
{
{
...
@@ -62,7 +71,7 @@ export class PermissionHandler {
...
@@ -62,7 +71,7 @@ export class PermissionHandler {
this
.
permissions
[
to
.
name
][
from
.
name
].
allow
=
false
this
.
permissions
[
to
.
name
][
from
.
name
].
allow
=
false
this
.
persistPermissions
()
this
.
persistPermissions
()
}
}
re
solve
(
false
)
re
ject
(
notAllowWarning
(
from
,
to
)
)
}
}
}
}
)
)
...
@@ -80,7 +89,11 @@ export class PermissionHandler {
...
@@ -80,7 +89,11 @@ export class PermissionHandler {
if
(
!
this
.
permissions
[
to
.
name
][
from
.
name
])
return
this
.
openPermission
(
from
,
to
)
if
(
!
this
.
permissions
[
to
.
name
][
from
.
name
])
return
this
.
openPermission
(
from
,
to
)
const
{
allow
,
hash
}
=
this
.
permissions
[
to
.
name
][
from
.
name
]
const
{
allow
,
hash
}
=
this
.
permissions
[
to
.
name
][
from
.
name
]
if
(
!
allow
)
return
false
if
(
!
allow
)
{
const
warning
=
notAllowWarning
(
from
,
to
)
addTooltip
(
warning
)
throw
new
Error
(
warning
)
}
return
hash
===
from
.
hash
return
hash
===
from
.
hash
?
true
// Allow
?
true
// Allow
:
this
.
openPermission
(
from
,
to
)
// New version of a plugin
:
this
.
openPermission
(
from
,
to
)
// New version of a plugin
...
@@ -93,7 +106,7 @@ export class PermissionHandler {
...
@@ -93,7 +106,7 @@ export class PermissionHandler {
*/
*/
form
(
from
,
to
)
{
form
(
from
,
to
)
{
const
fromName
=
from
.
displayName
||
from
.
name
const
fromName
=
from
.
displayName
||
from
.
name
const
toName
=
from
.
displayName
||
from
.
name
const
toName
=
to
.
displayName
||
to
.
name
const
remember
=
this
.
permissions
[
to
.
name
][
from
.
name
]
const
remember
=
this
.
permissions
[
to
.
name
][
from
.
name
]
const
switchMode
=
(
e
)
=>
{
const
switchMode
=
(
e
)
=>
{
...
@@ -103,7 +116,7 @@ export class PermissionHandler {
...
@@ -103,7 +116,7 @@ export class PermissionHandler {
}
}
const
rememberSwitch
=
remember
const
rememberSwitch
=
remember
?
yo
`<input type="checkbox" onchange="
${
switchMode
}
" checkbox class="custom-control-input" id="remember">`
?
yo
`<input type="checkbox" onchange="
${
switchMode
}
" checkbox class="custom-control-input" id="remember">`
:
yo
`<input type="checkbox" class="custom-control-input" id="remember">`
:
yo
`<input type="checkbox"
onchange="
${
switchMode
}
"
class="custom-control-input" id="remember">`
const
message
=
remember
const
message
=
remember
?
`
${
fromName
}
has changed and would like to access the plugin
${
toName
}
.`
?
`
${
fromName
}
has changed and would like to access the plugin
${
toName
}
.`
:
`
${
fromName
}
would like to access plugin
${
toName
}
.`
:
`
${
fromName
}
would like to access plugin
${
toName
}
.`
...
@@ -112,10 +125,10 @@ export class PermissionHandler {
...
@@ -112,10 +125,10 @@ export class PermissionHandler {
<section class="
${
css
.
permission
}
">
<section class="
${
css
.
permission
}
">
<article class="
${
css
.
images
}
">
<article class="
${
css
.
images
}
">
<img src="
${
from
.
icon
}
" />
<img src="
${
from
.
icon
}
" />
<span> -> </span>
<span> -
--
> </span>
<img src="
${
to
.
icon
}
" />
<img src="
${
to
.
icon
}
" />
</article>
</article>
<
p>
${
message
}
</p
>
<
h4>
${
message
}
</h4
>
<div class="custom-control custom-checkbox">
<div class="custom-control custom-checkbox">
${
rememberSwitch
}
${
rememberSwitch
}
<label class="custom-control-label" for="remember">Remember this choice</label>
<label class="custom-control-label" for="remember">Remember this choice</label>
...
...
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