diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index ebd1c9a7e4..ca95b9b400 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -92,9 +92,10 @@ const profile = { class PluginManagerComponent extends ViewPlugin { constructor (appManager, engine) { super(profile) - // this.event = new EventEmitter() // already exists in engine so not needed here + this.event = new EventEmitter() // already exists in engine so not needed here this.appManager = appManager this.engine = engine + this.pluginManagerSettings = new PluginManagerSettings() this.htmlElement = document.createElement('div') this.htmlElement.setAttribute('id', 'pluginManager') this.views = { @@ -103,9 +104,8 @@ class PluginManagerComponent extends ViewPlugin { } this.localPlugin = new LocalPlugin() this.filter = '' - this.activePlugins = [] - this.inactivePlugins = [] this.pluginNames = this.appManager.actives + // this.pluginManagerSettings. // this.appManager.event.on('activate', () => { this.renderComponent() }) // this.appManager.event.on('deactivate', () => { this.renderComponent() }) // this.engine.event.on('onRegistration', () => { this.renderComponent() }) @@ -116,10 +116,12 @@ class PluginManagerComponent extends ViewPlugin { } activateP (name) { - this.appManager.turnPluginOn(name) - console.log('activateP method reached. And activation of method was successful') + this.appManager.activatePlugin(name) + this.appManager.event.on('activate', () => { + this.renderComponent() + console.log('activateP method reached. And activation of method was successful') + }) _paq.push(['trackEvent', 'manager', 'activate', name]) - this.renderComponent() console.log('activation was logged in _paq and renderComponent has been called.') } @@ -144,10 +146,6 @@ class PluginManagerComponent extends ViewPlugin { engine={this.engine} localPlugin={this.localPlugin} activePluginNames={this.pluginNames} - actives={this.activePlugins} - inactives={this.inactivePlugins} - // activatePlugin={this.activateP} - // deActivatePlugin={this.deactivateP} _paq={_paq} filter={this.filter} />, diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index fb1ef54a80..45bc5a7421 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -75,14 +75,6 @@ export class RemixAppManager extends PluginManager { return await this.permissionHandler.askPermission(this.profiles[from], this.profiles[to], method, message) } - async turnPluginOn (name) { - await this.activatePlugin(name) - } - - async turnPluginOff (name) { - await this.deactivatePlugin(name) - } - onPluginActivated (plugin) { this.pluginLoader.set(plugin, this.actives) this.event.emit('activate', plugin) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx index 203e0b5741..54cb447fa1 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx @@ -1,13 +1,17 @@ -import React, { useContext, useState } from 'react' -import { PluginManagerContext } from '../contexts/pluginmanagercontext' +import React, { useState } from 'react' +import { PluginManagerComponent } from '../../types' interface ButtonProps { buttonText: 'Activate' | 'Deactivate' pluginName: string + pluginComponent: PluginManagerComponent } -function Button ({ buttonText, pluginName }: ButtonProps) { - const { pluginComponent } = useContext(PluginManagerContext) +function Button ({ + buttonText, + pluginName, + pluginComponent +}: ButtonProps) { const dataId = `pluginManagerComponentDeactivateButton${pluginName}` const [needToDeactivate] = useState('btn btn-secondary btn-sm') const [needToActivate] = useState('btn btn-success btn-sm') diff --git a/libs/remix-ui/plugin-manager/src/lib/components/permissions/permissionsSettings.tsx b/libs/remix-ui/plugin-manager/src/lib/components/permissions/permissionsSettings.tsx new file mode 100644 index 0000000000..ce24c1729a --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/permissions/permissionsSettings.tsx @@ -0,0 +1,97 @@ +import React, { Fragment, useState } from 'react' +import { RemixUiCheckbox } from '@remix-ui/checkbox' +import { PluginManagerSettings } from '../../../types' +import { ModalDialog } from '@remix-ui/modal-dialog' + +interface PermissionSettingsProps { + pluginSettings: PluginManagerSettings + toPlugin?: string + funcObj?: {} + methodName?: string + fromPlugins?: {} + +} + +//
+//
+// {fromPluginPermission.allow +// ? +// togglePermission(fromName, toPlugin, methodName)} +// inputType="checkbox" +// id={`permission-checkbox-${toPlugin}-${methodName}-${toPlugin}`} +// aria-describedby={`module ${fromPluginPermission} asks permission for ${methodName}`} +// /> +// +// : +// togglePermission(fromName, toPlugin, methodName)} +// inputType="checkbox" +// id={`permission-checkbox-${toPlugin}-${methodName}-${toPlugin}`} +// aria-describedby={`module ${fromPluginPermission} asks permission for ${methodName}`} +// /> +// +// } +// +//
+// pluginSettings.clearPersmission(fromName, toPlugin, methodName)} className="fa fa-trash-alt" data-id={`pluginManagerSettingsRemovePermission-${toPlugin}-${methodName}-${toPlugin}`}> +//
+ +function PermisssionsSettings ({ pluginSettings }: PermissionSettingsProps) { + /** + * Declare component local state + */ + const [modalVisibility, setModalVisibility] = useState(true) + const toPluginP = '' + const fromName = '' + const methodName = '' + const openModal = () => setModalVisibility(false) + const closeModal = () => setModalVisibility(true) + + const togglePermission = (fromPlugin: string, toPlugin: string, methodName: string) => { + pluginSettings.permissions[toPlugin][methodName][fromPlugin].allow = !pluginSettings.permissions[toPlugin][methodName][fromPlugin].allow + } + + return ( + + +
+
+

toPlugin permissions:

+ pluginSettings.clearAllPersmission(toPluginP)} className="far fa-trash-alt" data-id={`pluginManagerSettingsClearAllPermission-${toPluginP}`}> +
+
+

No Permission requested yet.

+
+
+ {/* ${checkbox} */} + +
+ pluginSettings.clearPersmission(fromName, toPluginP, methodName)} className="fa fa-trash-alt" data-id={`pluginManagerSettingsRemovePermission-${toPluginP}-${methodName}-${toPluginP}`}> +
+
+
+
+
+ +
+
+ ) +} +export default PermisssionsSettings diff --git a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx index 5c0f59e16a..bd77425ad0 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx @@ -1,15 +1,17 @@ -import React, { useContext, useState } from 'react' -import { PluginManagerProfile } from '../../types' -import { PluginManagerContext } from '../contexts/pluginmanagercontext' +import React, { useState } from 'react' +import { PluginManagerComponent, PluginManagerProfile } from '../../types' import '../remix-ui-plugin-manager.css' import Button from './button' interface PluginCardProps { profile: Partial + pluginComponent: PluginManagerComponent } // eslint-disable-next-line no-empty-pattern -function PluginCard ({ profile }: PluginCardProps) { - const { pluginComponent } = useContext(PluginManagerContext) +function PluginCard ({ + profile, + pluginComponent +}: PluginCardProps) { const [displayName] = useState((profile.displayName) ? profile.displayName : profile.name) const [docLink] = useState((profile.documentation) ? ( @@ -35,7 +37,13 @@ function PluginCard ({ profile }: PluginCardProps) {