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
a858c69b
Commit
a858c69b
authored
Mar 04, 2020
by
LianaHus
Committed by
Liana Husikyan
Mar 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added canCall
parent
d1bedca8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
14 deletions
+20
-14
persmission-handler.js
src/app/ui/persmission-handler.js
+12
-11
remixAppManager.js
src/remixAppManager.js
+8
-3
No files found.
src/app/ui/persmission-handler.js
View file @
a858c69b
...
@@ -62,13 +62,15 @@ export class PermissionHandler {
...
@@ -62,13 +62,15 @@ export class PermissionHandler {
* Show a message to ask the user for a permission
* Show a message to ask the user for a permission
* @param {PluginProfile} from The name and hash of the plugin that make the call
* @param {PluginProfile} from The name and hash of the plugin that make the call
* @param {ModuleProfile} to The name of the plugin that receive the call
* @param {ModuleProfile} to The name of the plugin that receive the call
* @param {string} method The name of the function to be called
* @param {string} message from the caller plugin to add more details if needed
* @returns {Promise<{ allow: boolean; remember: boolean }} Answer from the user to the permission
* @returns {Promise<{ allow: boolean; remember: boolean }} Answer from the user to the permission
*/
*/
async
openPermission
(
from
,
to
)
{
async
openPermission
(
from
,
to
,
method
,
message
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
modalDialog
(
modalDialog
(
`Permission needed for
${
to
.
displayName
||
to
.
name
}
`
,
`Permission needed for
${
to
.
displayName
||
to
.
name
}
`
,
this
.
form
(
from
,
to
),
this
.
form
(
from
,
to
,
method
,
message
),
{
{
label
:
'Accept'
,
label
:
'Accept'
,
fn
:
()
=>
{
fn
:
()
=>
{
...
@@ -105,11 +107,11 @@ export class PermissionHandler {
...
@@ -105,11 +107,11 @@ export class PermissionHandler {
* @param {ModuleProfile} to The profile of the module that receive the call
* @param {ModuleProfile} to The profile of the module that receive the call
* @returns {Promise<boolean>}
* @returns {Promise<boolean>}
*/
*/
async
askPermission
(
from
,
to
)
{
async
askPermission
(
from
,
to
,
method
,
message
)
{
try
{
try
{
this
.
permissions
=
this
.
_getFromLocal
()
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
,
from
,
message
)
const
{
allow
,
hash
}
=
this
.
permissions
[
to
.
name
][
from
.
name
]
const
{
allow
,
hash
}
=
this
.
permissions
[
to
.
name
][
from
.
name
]
if
(
!
allow
)
{
if
(
!
allow
)
{
...
@@ -119,7 +121,7 @@ export class PermissionHandler {
...
@@ -119,7 +121,7 @@ export class PermissionHandler {
}
}
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
,
method
,
message
)
// New version of a plugin
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
new
Error
(
err
)
throw
new
Error
(
err
)
}
}
...
@@ -129,8 +131,10 @@ export class PermissionHandler {
...
@@ -129,8 +131,10 @@ export class PermissionHandler {
* The permission form
* The permission form
* @param {PluginProfile} from The name and hash of the plugin that make the call
* @param {PluginProfile} from The name and hash of the plugin that make the call
* @param {ModuleProfile} to The name of the plugin that receive the call
* @param {ModuleProfile} to The name of the plugin that receive the call
* @param {string} method The name of te methode to be called
* @param {string} message from the caller plugin to add more details if needed
*/
*/
form
(
from
,
to
)
{
form
(
from
,
to
,
method
,
message
)
{
const
fromName
=
from
.
displayName
||
from
.
name
const
fromName
=
from
.
displayName
||
from
.
name
const
toName
=
to
.
displayName
||
to
.
name
const
toName
=
to
.
displayName
||
to
.
name
const
remember
=
this
.
permissions
[
to
.
name
][
from
.
name
]
const
remember
=
this
.
permissions
[
to
.
name
][
from
.
name
]
...
@@ -143,10 +147,7 @@ export class PermissionHandler {
...
@@ -143,10 +147,7 @@ export class PermissionHandler {
const
rememberSwitch
=
remember
const
rememberSwitch
=
remember
?
yo
`<input type="checkbox" onchange="
${
switchMode
}
" checkbox class="form-check-input" id="remember" data-id="permissionHandlerRememberChecked">`
?
yo
`<input type="checkbox" onchange="
${
switchMode
}
" checkbox class="form-check-input" id="remember" data-id="permissionHandlerRememberChecked">`
:
yo
`<input type="checkbox" onchange="
${
switchMode
}
" class="form-check-input" id="remember" data-id="permissionHandlerRememberUnchecked">`
:
yo
`<input type="checkbox" onchange="
${
switchMode
}
" class="form-check-input" id="remember" data-id="permissionHandlerRememberUnchecked">`
const
message
=
remember
const
text
=
`"
${
fromName
}
"`
+
(
remember
?
`has changed and`
:
``
)
+
`would like to access to "
${
method
}
" of "
${
toName
}
"`
?
`"
${
fromName
}
" has changed and would like to access "
${
toName
}
"`
:
`"
${
fromName
}
" would like to access "
${
toName
}
"`
const
imgFrom
=
yo
`<img id="permissionModalImagesFrom" src="
${
from
.
icon
}
" />`
const
imgFrom
=
yo
`<img id="permissionModalImagesFrom" src="
${
from
.
icon
}
" />`
const
imgTo
=
yo
`<img id="permissionModalImagesTo" src="
${
to
.
icon
}
" />`
const
imgTo
=
yo
`<img id="permissionModalImagesTo" src="
${
to
.
icon
}
" />`
const
pluginsImages
=
yo
`
const
pluginsImages
=
yo
`
...
@@ -165,7 +166,7 @@ export class PermissionHandler {
...
@@ -165,7 +166,7 @@ export class PermissionHandler {
<section class="
${
css
.
permission
}
">
<section class="
${
css
.
permission
}
">
${
pluginsImages
}
${
pluginsImages
}
<article>
<article>
<h4 data-id="permissionHandlerMessage">
${
message
}
:</h4>
<h4 data-id="permissionHandlerMessage">
${
text
}
:</h4>
<h6>
${
fromName
}
</h6>
<h6>
${
fromName
}
</h6>
<p>
${
from
.
description
||
yo
`<i>No description Provided</i>`
}
</p>
<p>
${
from
.
description
||
yo
`<i>No description Provided</i>`
}
</p>
<h6>
${
toName
}
:</p>
<h6>
${
toName
}
:</p>
...
...
src/remixAppManager.js
View file @
a858c69b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
{
PluginManager
,
IframePlugin
}
from
'@remixproject/engine'
import
{
PluginManager
,
IframePlugin
}
from
'@remixproject/engine'
import
{
EventEmitter
}
from
'events'
import
{
EventEmitter
}
from
'events'
import
QueryParams
from
'./lib/query-params'
import
QueryParams
from
'./lib/query-params'
import
{
PermissionHandler
}
from
'./app/ui/persmission-handler'
const
requiredModules
=
[
// services + layout views + system views
const
requiredModules
=
[
// services + layout views + system views
'manager'
,
'compilerArtefacts'
,
'compilerMetadata'
,
'contextualListener'
,
'editor'
,
'offsetToLineColumnConverter'
,
'network'
,
'theme'
,
'fileManager'
,
'contentImport'
,
'web3Provider'
,
'scriptRunner'
,
'manager'
,
'compilerArtefacts'
,
'compilerMetadata'
,
'contextualListener'
,
'editor'
,
'offsetToLineColumnConverter'
,
'network'
,
'theme'
,
'fileManager'
,
'contentImport'
,
'web3Provider'
,
'scriptRunner'
,
...
@@ -20,6 +21,7 @@ export class RemixAppManager extends PluginManager {
...
@@ -20,6 +21,7 @@ export class RemixAppManager extends PluginManager {
this
.
event
=
new
EventEmitter
()
this
.
event
=
new
EventEmitter
()
this
.
pluginsDirectory
=
'https://raw.githubusercontent.com/ethereum/remix-plugins-directory/master/build/metadata.json'
this
.
pluginsDirectory
=
'https://raw.githubusercontent.com/ethereum/remix-plugins-directory/master/build/metadata.json'
this
.
pluginLoader
=
new
PluginLoader
()
this
.
pluginLoader
=
new
PluginLoader
()
this
.
permissionHandler
=
new
PermissionHandler
()
}
}
async
canActivate
(
from
,
to
)
{
async
canActivate
(
from
,
to
)
{
...
@@ -30,9 +32,12 @@ export class RemixAppManager extends PluginManager {
...
@@ -30,9 +32,12 @@ export class RemixAppManager extends PluginManager {
return
from
.
name
===
'manager'
return
from
.
name
===
'manager'
}
}
async
canCall
(
From
,
to
,
method
)
{
async
canCall
(
from
,
to
,
method
,
message
)
{
// todo This is the dafault behaviour, we could save user choises in session scope
// Make sure the caller of this methods is the target plugin
return
true
if
(
to
.
name
!==
this
.
currentRequest
)
{
return
false
}
return
await
this
.
permissionHandler
.
askPermition
(
from
,
to
,
method
,
message
)
}
}
onPluginActivated
(
plugin
)
{
onPluginActivated
(
plugin
)
{
...
...
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