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
Hide 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 {
* 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 {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
*/
async
openPermission
(
from
,
to
)
{
async
openPermission
(
from
,
to
,
method
,
message
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
modalDialog
(
`Permission needed for
${
to
.
displayName
||
to
.
name
}
`
,
this
.
form
(
from
,
to
),
this
.
form
(
from
,
to
,
method
,
message
),
{
label
:
'Accept'
,
fn
:
()
=>
{
...
...
@@ -105,11 +107,11 @@ export class PermissionHandler {
* @param {ModuleProfile} to The profile of the module that receive the call
* @returns {Promise<boolean>}
*/
async
askPermission
(
from
,
to
)
{
async
askPermission
(
from
,
to
,
method
,
message
)
{
try
{
this
.
permissions
=
this
.
_getFromLocal
()
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
]
if
(
!
allow
)
{
...
...
@@ -119,7 +121,7 @@ export class PermissionHandler {
}
return
hash
===
from
.
hash
?
true
// Allow
:
this
.
openPermission
(
from
,
to
)
// New version of a plugin
:
this
.
openPermission
(
from
,
to
,
method
,
message
)
// New version of a plugin
}
catch
(
err
)
{
throw
new
Error
(
err
)
}
...
...
@@ -129,8 +131,10 @@ export class PermissionHandler {
* The permission form
* @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 {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
toName
=
to
.
displayName
||
to
.
name
const
remember
=
this
.
permissions
[
to
.
name
][
from
.
name
]
...
...
@@ -143,10 +147,7 @@ export class PermissionHandler {
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
}
" class="form-check-input" id="remember" data-id="permissionHandlerRememberUnchecked">`
const
message
=
remember
?
`"
${
fromName
}
" has changed and would like to access "
${
toName
}
"`
:
`"
${
fromName
}
" would like to access "
${
toName
}
"`
const
text
=
`"
${
fromName
}
"`
+
(
remember
?
`has changed and`
:
``
)
+
`would like to access to "
${
method
}
" of "
${
toName
}
"`
const
imgFrom
=
yo
`<img id="permissionModalImagesFrom" src="
${
from
.
icon
}
" />`
const
imgTo
=
yo
`<img id="permissionModalImagesTo" src="
${
to
.
icon
}
" />`
const
pluginsImages
=
yo
`
...
...
@@ -165,7 +166,7 @@ export class PermissionHandler {
<section class="
${
css
.
permission
}
">
${
pluginsImages
}
<article>
<h4 data-id="permissionHandlerMessage">
${
message
}
:</h4>
<h4 data-id="permissionHandlerMessage">
${
text
}
:</h4>
<h6>
${
fromName
}
</h6>
<p>
${
from
.
description
||
yo
`<i>No description Provided</i>`
}
</p>
<h6>
${
toName
}
:</p>
...
...
src/remixAppManager.js
View file @
a858c69b
...
...
@@ -2,6 +2,7 @@
import
{
PluginManager
,
IframePlugin
}
from
'@remixproject/engine'
import
{
EventEmitter
}
from
'events'
import
QueryParams
from
'./lib/query-params'
import
{
PermissionHandler
}
from
'./app/ui/persmission-handler'
const
requiredModules
=
[
// services + layout views + system views
'manager'
,
'compilerArtefacts'
,
'compilerMetadata'
,
'contextualListener'
,
'editor'
,
'offsetToLineColumnConverter'
,
'network'
,
'theme'
,
'fileManager'
,
'contentImport'
,
'web3Provider'
,
'scriptRunner'
,
...
...
@@ -20,6 +21,7 @@ export class RemixAppManager extends PluginManager {
this
.
event
=
new
EventEmitter
()
this
.
pluginsDirectory
=
'https://raw.githubusercontent.com/ethereum/remix-plugins-directory/master/build/metadata.json'
this
.
pluginLoader
=
new
PluginLoader
()
this
.
permissionHandler
=
new
PermissionHandler
()
}
async
canActivate
(
from
,
to
)
{
...
...
@@ -30,9 +32,12 @@ export class RemixAppManager extends PluginManager {
return
from
.
name
===
'manager'
}
async
canCall
(
From
,
to
,
method
)
{
// todo This is the dafault behaviour, we could save user choises in session scope
return
true
async
canCall
(
from
,
to
,
method
,
message
)
{
// Make sure the caller of this methods is the target plugin
if
(
to
.
name
!==
this
.
currentRequest
)
{
return
false
}
return
await
this
.
permissionHandler
.
askPermition
(
from
,
to
,
method
,
message
)
}
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