From 81e1ebe7c13dacb06080ecb3e2f87033ce9a6fb7 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Tue, 29 Jun 2021 12:26:42 +0100 Subject: [PATCH 001/209] create skeleton of plugin manager in react --- libs/remix-ui/plugin-manager/.babelrc | 4 + libs/remix-ui/plugin-manager/.eslintrc | 248 ++++++++++++++++++ libs/remix-ui/plugin-manager/README.md | 7 + libs/remix-ui/plugin-manager/src/index.ts | 1 + .../src/lib/remix-ui-plugin-manager.css | 57 ++++ .../src/lib/remix-ui-plugin-manager.tsx | 16 ++ libs/remix-ui/plugin-manager/tsconfig.json | 16 ++ .../remix-ui/plugin-manager/tsconfig.lib.json | 13 + nx.json | 3 + tsconfig.base.json | 50 ++++ workspace.json | 19 ++ 11 files changed, 434 insertions(+) create mode 100644 libs/remix-ui/plugin-manager/.babelrc create mode 100644 libs/remix-ui/plugin-manager/.eslintrc create mode 100644 libs/remix-ui/plugin-manager/README.md create mode 100644 libs/remix-ui/plugin-manager/src/index.ts create mode 100644 libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css create mode 100644 libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx create mode 100644 libs/remix-ui/plugin-manager/tsconfig.json create mode 100644 libs/remix-ui/plugin-manager/tsconfig.lib.json create mode 100644 tsconfig.base.json diff --git a/libs/remix-ui/plugin-manager/.babelrc b/libs/remix-ui/plugin-manager/.babelrc new file mode 100644 index 0000000000..09d67939cc --- /dev/null +++ b/libs/remix-ui/plugin-manager/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@nrwl/react/babel"], + "plugins": [] +} diff --git a/libs/remix-ui/plugin-manager/.eslintrc b/libs/remix-ui/plugin-manager/.eslintrc new file mode 100644 index 0000000000..977f139a09 --- /dev/null +++ b/libs/remix-ui/plugin-manager/.eslintrc @@ -0,0 +1,248 @@ +{ + "rules": { + "array-callback-return": "warn", + "dot-location": ["warn", "property"], + "eqeqeq": ["warn", "smart"], + "new-parens": "warn", + "no-caller": "warn", + "no-cond-assign": ["warn", "except-parens"], + "no-const-assign": "warn", + "no-control-regex": "warn", + "no-delete-var": "warn", + "no-dupe-args": "warn", + "no-dupe-keys": "warn", + "no-duplicate-case": "warn", + "no-empty-character-class": "warn", + "no-empty-pattern": "warn", + "no-eval": "warn", + "no-ex-assign": "warn", + "no-extend-native": "warn", + "no-extra-bind": "warn", + "no-extra-label": "warn", + "no-fallthrough": "warn", + "no-func-assign": "warn", + "no-implied-eval": "warn", + "no-invalid-regexp": "warn", + "no-iterator": "warn", + "no-label-var": "warn", + "no-labels": ["warn", { "allowLoop": true, "allowSwitch": false }], + "no-lone-blocks": "warn", + "no-loop-func": "warn", + "no-mixed-operators": [ + "warn", + { + "groups": [ + ["&", "|", "^", "~", "<<", ">>", ">>>"], + ["==", "!=", "===", "!==", ">", ">=", "<", "<="], + ["&&", "||"], + ["in", "instanceof"] + ], + "allowSamePrecedence": false + } + ], + "no-multi-str": "warn", + "no-native-reassign": "warn", + "no-negated-in-lhs": "warn", + "no-new-func": "warn", + "no-new-object": "warn", + "no-new-symbol": "warn", + "no-new-wrappers": "warn", + "no-obj-calls": "warn", + "no-octal": "warn", + "no-octal-escape": "warn", + "no-redeclare": "warn", + "no-regex-spaces": "warn", + "no-restricted-syntax": ["warn", "WithStatement"], + "no-script-url": "warn", + "no-self-assign": "warn", + "no-self-compare": "warn", + "no-sequences": "warn", + "no-shadow-restricted-names": "warn", + "no-sparse-arrays": "warn", + "no-template-curly-in-string": "warn", + "no-this-before-super": "warn", + "no-throw-literal": "warn", + "no-restricted-globals": [ + "error", + "addEventListener", + "blur", + "close", + "closed", + "confirm", + "defaultStatus", + "defaultstatus", + "event", + "external", + "find", + "focus", + "frameElement", + "frames", + "history", + "innerHeight", + "innerWidth", + "length", + "location", + "locationbar", + "menubar", + "moveBy", + "moveTo", + "name", + "onblur", + "onerror", + "onfocus", + "onload", + "onresize", + "onunload", + "open", + "opener", + "opera", + "outerHeight", + "outerWidth", + "pageXOffset", + "pageYOffset", + "parent", + "print", + "removeEventListener", + "resizeBy", + "resizeTo", + "screen", + "screenLeft", + "screenTop", + "screenX", + "screenY", + "scroll", + "scrollbars", + "scrollBy", + "scrollTo", + "scrollX", + "scrollY", + "self", + "status", + "statusbar", + "stop", + "toolbar", + "top" + ], + "no-unexpected-multiline": "warn", + "no-unreachable": "warn", + "no-unused-expressions": [ + "error", + { + "allowShortCircuit": true, + "allowTernary": true, + "allowTaggedTemplates": true + } + ], + "no-unused-labels": "warn", + "no-useless-computed-key": "warn", + "no-useless-concat": "warn", + "no-useless-escape": "warn", + "no-useless-rename": [ + "warn", + { + "ignoreDestructuring": false, + "ignoreImport": false, + "ignoreExport": false + } + ], + "no-with": "warn", + "no-whitespace-before-property": "warn", + "react-hooks/exhaustive-deps": "warn", + "require-yield": "warn", + "rest-spread-spacing": ["warn", "never"], + "strict": ["warn", "never"], + "unicode-bom": ["warn", "never"], + "use-isnan": "warn", + "valid-typeof": "warn", + "no-restricted-properties": [ + "error", + { + "object": "require", + "property": "ensure", + "message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting" + }, + { + "object": "System", + "property": "import", + "message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting" + } + ], + "getter-return": "warn", + "import/first": "error", + "import/no-amd": "error", + "import/no-webpack-loader-syntax": "error", + "react/forbid-foreign-prop-types": ["warn", { "allowInPropTypes": true }], + "react/jsx-no-comment-textnodes": "warn", + "react/jsx-no-duplicate-props": "warn", + "react/jsx-no-target-blank": "warn", + "react/jsx-no-undef": "error", + "react/jsx-pascal-case": ["warn", { "allowAllCaps": true, "ignore": [] }], + "react/jsx-uses-react": "warn", + "react/jsx-uses-vars": "warn", + "react/no-danger-with-children": "warn", + "react/no-direct-mutation-state": "warn", + "react/no-is-mounted": "warn", + "react/no-typos": "error", + "react/react-in-jsx-scope": "error", + "react/require-render-return": "error", + "react/style-prop-object": "warn", + "react/jsx-no-useless-fragment": "warn", + "jsx-a11y/accessible-emoji": "warn", + "jsx-a11y/alt-text": "warn", + "jsx-a11y/anchor-has-content": "warn", + "jsx-a11y/anchor-is-valid": [ + "warn", + { "aspects": ["noHref", "invalidHref"] } + ], + "jsx-a11y/aria-activedescendant-has-tabindex": "warn", + "jsx-a11y/aria-props": "warn", + "jsx-a11y/aria-proptypes": "warn", + "jsx-a11y/aria-role": "warn", + "jsx-a11y/aria-unsupported-elements": "warn", + "jsx-a11y/heading-has-content": "warn", + "jsx-a11y/iframe-has-title": "warn", + "jsx-a11y/img-redundant-alt": "warn", + "jsx-a11y/no-access-key": "warn", + "jsx-a11y/no-distracting-elements": "warn", + "jsx-a11y/no-redundant-roles": "warn", + "jsx-a11y/role-has-required-aria-props": "warn", + "jsx-a11y/role-supports-aria-props": "warn", + "jsx-a11y/scope": "warn", + "react-hooks/rules-of-hooks": "error", + "default-case": "off", + "no-dupe-class-members": "off", + "no-undef": "off", + "@typescript-eslint/consistent-type-assertions": "warn", + "no-array-constructor": "off", + "@typescript-eslint/no-array-constructor": "warn", + "@typescript-eslint/no-namespace": "error", + "no-use-before-define": "off", + "@typescript-eslint/no-use-before-define": [ + "warn", + { + "functions": false, + "classes": false, + "variables": false, + "typedefs": false + } + ], + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { "args": "none", "ignoreRestSiblings": true } + ], + "no-useless-constructor": "off", + "@typescript-eslint/no-useless-constructor": "warn" + }, + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "jest": true, + "node": true + }, + "settings": { "react": { "version": "detect" } }, + "plugins": ["import", "jsx-a11y", "react", "react-hooks"], + "extends": ["../../../.eslintrc"], + "ignorePatterns": ["!**/*"] +} diff --git a/libs/remix-ui/plugin-manager/README.md b/libs/remix-ui/plugin-manager/README.md new file mode 100644 index 0000000000..5cfa932a12 --- /dev/null +++ b/libs/remix-ui/plugin-manager/README.md @@ -0,0 +1,7 @@ +# remix-ui-plugin-manager + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test remix-ui-plugin-manager` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/remix-ui/plugin-manager/src/index.ts b/libs/remix-ui/plugin-manager/src/index.ts new file mode 100644 index 0000000000..fe4343e6ef --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/index.ts @@ -0,0 +1 @@ +export * from './lib/remix-ui-plugin-manager'; diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css new file mode 100644 index 0000000000..51b5e0a64d --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css @@ -0,0 +1,57 @@ +.pluginSearch { + display: flex; + flex-direction: column; + align-items: center; + background-color: var(--light); + padding: 10px; + position: sticky; + top: 0; + z-index: 2; + margin-bottom: 0px; +} +.pluginSearchInput { + height: 38px; +} +.pluginSearchButton { + font-size: 13px; +} +.displayName { + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; +} +.pluginIcon { + height: 0.7rem; + width: 0.7rem; + filter: invert(0.5); +} +.description { + font-size: 13px; + line-height: 18px; +} +.descriptiontext { + display: block; +} +.descriptiontext:first-letter { + text-transform: uppercase; +} +.row { + display: flex; + flex-direction: row; +} +.isStuck { + background-color: var(--primary); + /* color: */ +} +.versionWarning { + padding: 4px; + margin: 0 8px; + font-weight: 700; + font-size: 9px; + line-height: 12px; + text-transform: uppercase; + cursor: default; + border: 1px solid; + border-radius: 2px; +} diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx new file mode 100644 index 0000000000..842bba98ff --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -0,0 +1,16 @@ +import React from 'react'; + +import './remix-ui-plugin-manager.css'; + +/* eslint-disable-next-line */ +export interface RemixUiPluginManagerProps {} + +export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { + return ( +
+

Welcome to remix-ui-plugin-manager!

+
+ ); +}; + +export default RemixUiPluginManager; diff --git a/libs/remix-ui/plugin-manager/tsconfig.json b/libs/remix-ui/plugin-manager/tsconfig.json new file mode 100644 index 0000000000..d52e31ad74 --- /dev/null +++ b/libs/remix-ui/plugin-manager/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-ui/plugin-manager/tsconfig.lib.json b/libs/remix-ui/plugin-manager/tsconfig.lib.json new file mode 100644 index 0000000000..b560bc4dec --- /dev/null +++ b/libs/remix-ui/plugin-manager/tsconfig.lib.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "exclude": ["**/*.spec.ts", "**/*.spec.tsx"], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/nx.json b/nx.json index a63c015d64..1f6ef9f80f 100644 --- a/nx.json +++ b/nx.json @@ -101,6 +101,9 @@ }, "remix-ui-checkbox": { "tags": [] + }, + "remix-ui-plugin-manager": { + "tags": [] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000000..fd6266ba13 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,50 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "rootDir": ".", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": true, + "target": "es2015", + "module": "commonjs", + "typeRoots": ["node_modules/@types"], + "lib": ["es2017", "es2019", "dom"], + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "baseUrl": ".", + "paths": { + "@remix-project/remix-analyzer": ["dist/libs/remix-analyzer/index.js"], + "@remix-project/remix-astwalker": ["dist/libs/remix-astwalker/index.js"], + "@remix-project/remix-debug": ["dist/libs/remix-debug/src/index.js"], + "@remix-project/remix-lib": ["dist/libs/remix-lib/src/index.js"], + "@remix-project/remix-simulator": [ + "dist/libs/remix-simulator/src/index.js" + ], + "@remix-project/remix-solidity": ["dist/libs/remix-solidity/index.js"], + "@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"], + "@remix-project/remix-url-resolver": [ + "dist/libs/remix-url-resolver/index.js" + ], + "@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"], + "@remix-project/remixd": ["dist/libs/remixd/index.js"], + "@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"], + "@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"], + "@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"], + "@remix-ui/clipboard": ["libs/remix-ui/clipboard/src/index.ts"], + "@remix-project/remix-solidity-ts": ["libs/remix-solidity/src/index.ts"], + "@remix-ui/modal-dialog": ["libs/remix-ui/modal-dialog/src/index.ts"], + "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], + "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], + "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], + "@remix-ui/static-analyser": [ + "libs/remix-ui/static-analyser/src/index.ts" + ], + "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], + "@remix-ui/project-manager": ["libs/remix-ui/plugin-manager/src/index.ts"] + } + }, + "exclude": ["node_modules", "tmp"] +} diff --git a/workspace.json b/workspace.json index 5d2bf912c0..422d71f73e 100644 --- a/workspace.json +++ b/workspace.json @@ -760,6 +760,25 @@ } } } + }, + "remix-ui-plugin-manager": { + "root": "libs/remix-ui/plugin-manager", + "sourceRoot": "libs/remix-ui/plugin-manager/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": ["libs/remix-ui/plugin-manager/tsconfig.lib.json"], + "exclude": [ + "**/node_modules/**", + "!libs/remix-ui/plugin-manager/**/*" + ] + } + } + } } }, "cli": { From 856838ba55ae936e3188bf453556b4a2b678c7e0 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Wed, 30 Jun 2021 11:43:29 +0100 Subject: [PATCH 002/209] add button component. tsconfig for json imports --- .../src/lib/components/button.tsx | 23 +++++++++++++++++++ .../src/lib/remix-ui-plugin-manager.tsx | 16 +++++++++++-- libs/remix-ui/plugin-manager/tsconfig.json | 3 ++- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/button.tsx diff --git a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx new file mode 100644 index 0000000000..29a81e8baf --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx @@ -0,0 +1,23 @@ +import React, { useState } from 'react' + +interface ButtonProps { + profileName: string + deactivatePlugin?: (name: string) => {} + activatePlugin?: (name: string) => {} + buttonText?: string +} + +function Button ({ profileName, deactivatePlugin, buttonText }: ButtonProps) { + const [isActive, toggleIsActive] = useState(false) + const dataId = `pluginManagerComponentDeactivateButton${profileName}` + + return ( + + ) +} diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index 842bba98ff..5840946adb 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,9 +1,21 @@ -import React from 'react'; +import React from 'react' +import * as packageJson from '../../../../../package.json' import './remix-ui-plugin-manager.css'; /* eslint-disable-next-line */ -export interface RemixUiPluginManagerProps {} +export interface RemixUiPluginManagerProps { + name: 'pluginManager', + displayName: 'Plugin manager', + methods: [], + events: [], + icon: 'assets/img/pluginManager.webp', + description: 'Start/stop services, modules and plugins', + kind: 'settings', + location: 'sidePanel', + documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', + version: packageJson.version +} export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { return ( diff --git a/libs/remix-ui/plugin-manager/tsconfig.json b/libs/remix-ui/plugin-manager/tsconfig.json index d52e31ad74..efb99f9af9 100644 --- a/libs/remix-ui/plugin-manager/tsconfig.json +++ b/libs/remix-ui/plugin-manager/tsconfig.json @@ -4,7 +4,8 @@ "jsx": "react", "allowJs": true, "esModuleInterop": true, - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true }, "files": [], "include": [], From 039b07293df27b0404d42cb75ece9ce7dd43e6b7 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Wed, 30 Jun 2021 21:59:58 +0100 Subject: [PATCH 003/209] create more components --- .../components/plugin-manager-component.js | 32 ++++++------- .../plugin-manager/src/customTypes.ts | 7 +++ .../src/lib/components/activeTile.tsx | 24 ++++++++++ .../src/lib/components/button.tsx | 5 ++- .../src/lib/components/pluginCard.tsx | 45 +++++++++++++++++++ .../src/lib/components/rootView.tsx | 11 +++++ .../src/lib/remix-ui-plugin-manager.tsx | 3 +- libs/remix-ui/plugin-manager/src/types.d.ts | 19 ++++++++ 8 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 libs/remix-ui/plugin-manager/src/customTypes.ts create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx create mode 100644 libs/remix-ui/plugin-manager/src/types.d.ts 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 34ddc8ee5e..9893496535 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -53,7 +53,7 @@ const css = csjs` } .isStuck { background-color: var(--primary); - color: + color: } .versionWarning { padding: 4px; @@ -146,22 +146,22 @@ class PluginManagerComponent extends ViewPlugin { ` return yo` -
-
-
-
- ${displayName} - ${doclink} - ${versionWarning} -
- ${activationButton} -
+
+
+
+
+ ${displayName} + ${doclink} + ${versionWarning}
-
- - ${profile.description} -
-
+ ${activationButton} + +
+
+ + ${profile.description} +
+
` } diff --git a/libs/remix-ui/plugin-manager/src/customTypes.ts b/libs/remix-ui/plugin-manager/src/customTypes.ts new file mode 100644 index 0000000000..e696caeb52 --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/customTypes.ts @@ -0,0 +1,7 @@ +export type PluginManagerSettings = { + openDialog: () => void + onValidation: () => void + clearPermission: (from: any, to: any, method: any) => void + settings: () => HTMLElement + render: () => HTMLElement +} diff --git a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx new file mode 100644 index 0000000000..f2a8a0050a --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx @@ -0,0 +1,24 @@ +import React from 'react' + +type tileLabel = { + label: 'Active Module' | 'Inactive Modules' +} + +interface ActiveTileProps { + inactivesCount?: number + activesCount?: number + tileLabel?: tileLabel +} + +function ActiveTile ({ inactivesCount, activesCount, tileLabel }: ActiveTileProps) { + return ( + + ) +} + +export default ActiveTile 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 29a81e8baf..10cb650379 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx @@ -1,14 +1,14 @@ -import React, { useState } from 'react' +import React from 'react' interface ButtonProps { profileName: string deactivatePlugin?: (name: string) => {} activatePlugin?: (name: string) => {} + isActive: boolean buttonText?: string } function Button ({ profileName, deactivatePlugin, buttonText }: ButtonProps) { - const [isActive, toggleIsActive] = useState(false) const dataId = `pluginManagerComponentDeactivateButton${profileName}` return ( @@ -21,3 +21,4 @@ function Button ({ profileName, deactivatePlugin, buttonText }: ButtonProps) { ) } +export default Button diff --git a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx new file mode 100644 index 0000000000..ede66729e2 --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx @@ -0,0 +1,45 @@ +import React from 'react' +import '../remix-ui-plugin-manager.css' +import '' +import Button from './button' +interface PluginCardProps { + profileName: string + displayName: string + docLink: string + versionWarning: string + profileIcon: string + profileDescription: string +} + +function PluginCard ({ + profileName, + displayName, + docLink, + versionWarning, + profileIcon, + profileDescription +}: PluginCardProps) { + return ( +
+
+
+
+ {displayName} + {docLink} + {versionWarning} +
+
+
+
+ profile icon + {profileDescription} +
+
+ ) +} + +export default PluginCard diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx new file mode 100644 index 0000000000..1ffcb603d4 --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +function RootView () { + return ( +
+
+
+ ) +} + +export default RootView diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index 5840946adb..ca52b183e0 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,5 +1,4 @@ import React from 'react' -import * as packageJson from '../../../../../package.json' import './remix-ui-plugin-manager.css'; @@ -14,7 +13,7 @@ export interface RemixUiPluginManagerProps { kind: 'settings', location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', - version: packageJson.version + version: string } export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { diff --git a/libs/remix-ui/plugin-manager/src/types.d.ts b/libs/remix-ui/plugin-manager/src/types.d.ts new file mode 100644 index 0000000000..2014ac099b --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/types.d.ts @@ -0,0 +1,19 @@ +/* eslint-disable camelcase */ + +declare module 'yo-yo'{ + interface yo_yo { + (strings:string[], ...values:any[]):HTMLElement; + update(element:HTMLElement, element2:HTMLElement); + } + var yo:yo_yo + export = yo; +} + +declare module 'dom-css'{ + interface dom_css{ + (element:HTMLElement, css:any):void; + } + + var css:dom_css + export = css; +} From 5d86e1923436a554c4cc12c169faba0054b23b65 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Wed, 30 Jun 2021 22:55:37 +0100 Subject: [PATCH 004/209] create rootView component --- .../src/lib/components/rootView.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx index 1ffcb603d4..3c951b7ebf 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -1,9 +1,24 @@ import React from 'react' +import ActiveTile from './activeTile' + +interface RowViewProps { + localPluginButtonText: string + +} function RootView () { return ( -
-
+
+
+ + +
+
+ +
+ +
+
) } From 3f939f61a3cf30b98ac2392556838bbec074ea0c Mon Sep 17 00:00:00 2001 From: joseph izang Date: Thu, 1 Jul 2021 13:03:16 +0100 Subject: [PATCH 005/209] add types and a few more components --- libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx | 1 - 1 file changed, 1 deletion(-) 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 ede66729e2..85e95dc707 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx @@ -1,6 +1,5 @@ import React from 'react' import '../remix-ui-plugin-manager.css' -import '' import Button from './button' interface PluginCardProps { profileName: string From 38320e2bc45430f5a18e7680939418968f613ff3 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Thu, 1 Jul 2021 13:03:47 +0100 Subject: [PATCH 006/209] add listgroupitem component --- .../plugin-manager/src/customTypes.ts | 13 +++++++++ .../src/lib/components/listGroupItem.tsx | 21 ++++++++++++++ .../src/lib/components/rootView.tsx | 29 ++++++++++++++----- .../src/lib/remix-ui-plugin-manager.tsx | 20 ++++--------- nx.json | 3 -- 5 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx diff --git a/libs/remix-ui/plugin-manager/src/customTypes.ts b/libs/remix-ui/plugin-manager/src/customTypes.ts index e696caeb52..5c0efa46e1 100644 --- a/libs/remix-ui/plugin-manager/src/customTypes.ts +++ b/libs/remix-ui/plugin-manager/src/customTypes.ts @@ -5,3 +5,16 @@ export type PluginManagerSettings = { settings: () => HTMLElement render: () => HTMLElement } + +export type Profile = { + name: 'pluginManager', + displayName: 'Plugin manager', + methods: [], + events: [], + icon: 'assets/img/pluginManager.webp', + description: 'Start/stop services, modules and plugins', + kind: 'settings', + location: 'sidePanel', + documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', + version: string +} diff --git a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx new file mode 100644 index 0000000000..fab9496217 --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx @@ -0,0 +1,21 @@ +import React from 'react' +import { Profile } from '../../customTypes' + +interface ListGroupItemProps { + activeProfiles: Profile[] + inactiveProfiles: Profile[] + renderItem: (profile: Profile) => void +} + +function ListGroupItem ({ activeProfiles, inactiveProfiles, renderItem }: ListGroupItemProps) { + return ( +
+ { activeProfiles.length > 0 + ? activeProfiles.map(profile => renderItem(profile)) + : inactiveProfiles.map(profile => renderItem(profile)) + } +
+ ) +} + +export default ListGroupItem diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx index 3c951b7ebf..266014cd7d 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -1,23 +1,38 @@ import React from 'react' +import { Profile } from '../../customTypes' import ActiveTile from './activeTile' +import ListGroupItem from './listGroupItem' -interface RowViewProps { +interface RootViewProps { localPluginButtonText: string - + activeProfiles: Profile[] + inactiveProfiles?: Profile[] + filterPlugins: () => void + openLocalPlugins: () => void + renderItem: (profile: Profile) => void } -function RootView () { +function RootView ({ + localPluginButtonText, + activeProfiles, + inactiveProfiles, + filterPlugins, + openLocalPlugins, + renderItem +}: RootViewProps) { return (
- +
-
- -
+
) diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index ca52b183e0..93f091f2a8 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,19 +1,9 @@ import React from 'react' - -import './remix-ui-plugin-manager.css'; +import './remix-ui-plugin-manager.css' /* eslint-disable-next-line */ export interface RemixUiPluginManagerProps { - name: 'pluginManager', - displayName: 'Plugin manager', - methods: [], - events: [], - icon: 'assets/img/pluginManager.webp', - description: 'Start/stop services, modules and plugins', - kind: 'settings', - location: 'sidePanel', - documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', - version: string + } export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { @@ -21,7 +11,7 @@ export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => {

Welcome to remix-ui-plugin-manager!

- ); -}; + ) +} -export default RemixUiPluginManager; +export default RemixUiPluginManager diff --git a/nx.json b/nx.json index 58b46318d6..7243217040 100644 --- a/nx.json +++ b/nx.json @@ -108,8 +108,5 @@ "remix-ui-plugin-manager": { "tags": [] } - "remix-ui-settings": { - "tags": [] - } } } From a0dc968d33ce56a99c3095b268ebe9aeb76ff6a3 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Fri, 2 Jul 2021 11:55:05 +0100 Subject: [PATCH 007/209] trying to import react component --- .../components/plugin-manager-component.js | 79 ++++++++++++------- .../plugin-manager/src/customTypes.ts | 9 +++ .../src/lib/remix-ui-plugin-manager.tsx | 9 ++- libs/remix-ui/plugin-manager/tsconfig.json | 2 +- tsconfig.base.json | 50 ------------ tsconfig.json | 4 +- 6 files changed, 70 insertions(+), 83 deletions(-) delete mode 100644 tsconfig.base.json 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 9893496535..1ec2fb5994 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -1,5 +1,8 @@ import { IframePlugin, ViewPlugin, WebsocketPlugin } from '@remixproject/engine-web' import { PluginManagerSettings } from './plugin-manager-settings' +import React from 'react' +import { ReactDOM } from 'react-dom' +import { RemixUIPluginManager } from '@remix-ui/plugin-manager' import * as packageJson from '../../../../../package.json' const yo = require('yo-yo') const csjs = require('csjs-inject') @@ -96,6 +99,12 @@ class PluginManagerComponent extends ViewPlugin { this.appManager.event.on('deactivate', () => { this.reRender() }) this.engine = engine this.engine.event.on('onRegistration', () => { this.reRender() }) + this.htmlElement = document.createElement('div') + this.htmlElement.setAttribute('id', 'pluginManager') + } + + onActivation () { + this.renderComponent() } isActive (name) { @@ -188,8 +197,14 @@ class PluginManagerComponent extends ViewPlugin { } } + // return this.htmlElement() + + // render () { + // return this.htmlElement() + // } + render () { - // Filtering helpers + // Filtering helpers const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) @@ -215,46 +230,52 @@ class PluginManagerComponent extends ViewPlugin { const activeTile = actives.length !== 0 ? yo` - ` + + ` : '' const inactiveTile = inactives.length !== 0 ? yo` - ` + + ` : '' const settings = new PluginManagerSettings().render() const rootView = yo` -
-
- - -
-
- ${activeTile} -
- ${actives.map(profile => this.renderItem(profile))} -
- ${inactiveTile} -
- ${inactives.map(profile => this.renderItem(profile))} -
-
- ${settings} -
- ` +
+
+ + +
+
+ ${activeTile} +
+ ${actives.map(profile => this.renderItem(profile))} +
+ ${inactiveTile} +
+ ${inactives.map(profile => this.renderItem(profile))} +
+
+ ${settings} +
+ ` if (!this.views.root) this.views.root = rootView return rootView } + renderComponent () { + ReactDOM.render(, this.htmElement) + } + reRender () { if (this.views.root) { yo.update(this.views.root, this.render()) diff --git a/libs/remix-ui/plugin-manager/src/customTypes.ts b/libs/remix-ui/plugin-manager/src/customTypes.ts index 5c0efa46e1..5004c94b60 100644 --- a/libs/remix-ui/plugin-manager/src/customTypes.ts +++ b/libs/remix-ui/plugin-manager/src/customTypes.ts @@ -18,3 +18,12 @@ export type Profile = { documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', version: string } + +export type LocalPlugin = { + create: () => Profile + updateName: (target: string) => void + updateDisplayName: (displayName: string) => void + updateProfile: (key: string, e: Event) => void + updateMethods: (target: any) => void + form: () => HTMLElement +} diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index 93f091f2a8..242a293d8c 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,9 +1,16 @@ import React from 'react' +import { Profile } from '../customTypes' import './remix-ui-plugin-manager.css' /* eslint-disable-next-line */ export interface RemixUiPluginManagerProps { - + activatePlugin: (name: string) => void + deActivatePlugin: (name: string) => void + isActive: () => void + openLocalPlugin: () => Promise + filterPlugins: () => void + reRender: () => void + profile: Profile } export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { diff --git a/libs/remix-ui/plugin-manager/tsconfig.json b/libs/remix-ui/plugin-manager/tsconfig.json index efb99f9af9..fda01bcde2 100644 --- a/libs/remix-ui/plugin-manager/tsconfig.json +++ b/libs/remix-ui/plugin-manager/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.base.json", + "extends": "../../../tsconfig.json", "compilerOptions": { "jsx": "react", "allowJs": true, diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index fd6266ba13..0000000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "rootDir": ".", - "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "target": "es2015", - "module": "commonjs", - "typeRoots": ["node_modules/@types"], - "lib": ["es2017", "es2019", "dom"], - "skipLibCheck": true, - "skipDefaultLibCheck": true, - "baseUrl": ".", - "paths": { - "@remix-project/remix-analyzer": ["dist/libs/remix-analyzer/index.js"], - "@remix-project/remix-astwalker": ["dist/libs/remix-astwalker/index.js"], - "@remix-project/remix-debug": ["dist/libs/remix-debug/src/index.js"], - "@remix-project/remix-lib": ["dist/libs/remix-lib/src/index.js"], - "@remix-project/remix-simulator": [ - "dist/libs/remix-simulator/src/index.js" - ], - "@remix-project/remix-solidity": ["dist/libs/remix-solidity/index.js"], - "@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"], - "@remix-project/remix-url-resolver": [ - "dist/libs/remix-url-resolver/index.js" - ], - "@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"], - "@remix-project/remixd": ["dist/libs/remixd/index.js"], - "@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"], - "@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"], - "@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"], - "@remix-ui/clipboard": ["libs/remix-ui/clipboard/src/index.ts"], - "@remix-project/remix-solidity-ts": ["libs/remix-solidity/src/index.ts"], - "@remix-ui/modal-dialog": ["libs/remix-ui/modal-dialog/src/index.ts"], - "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], - "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], - "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], - "@remix-ui/static-analyser": [ - "libs/remix-ui/static-analyser/src/index.ts" - ], - "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], - "@remix-ui/project-manager": ["libs/remix-ui/plugin-manager/src/index.ts"] - } - }, - "exclude": ["node_modules", "tmp"] -} diff --git a/tsconfig.json b/tsconfig.json index 573a63975e..85c784b3a1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -39,10 +39,10 @@ "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], - "@remix-ui/settings": ["libs/remix-ui/settings/src/index.ts"], "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"], "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], - "@remix-ui/settings": ["libs/remix-ui/settings/src/index.ts"] + "@remix-ui/settings": ["libs/remix-ui/settings/src/index.ts"], + "@remix-ui/plugin-manager": ["libs/remix-ui/plugin-manager/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] From 3047f8203ccdfe486241345da1967d0a7c7801fc Mon Sep 17 00:00:00 2001 From: joseph izang Date: Mon, 5 Jul 2021 11:58:19 +0100 Subject: [PATCH 008/209] basic react component to show in plugin manager --- .../components/plugin-manager-component.js | 315 +++++++++--------- .../app/components/plugin-manager-settings.js | 4 +- libs/remix-ui/plugin-manager/src/index.ts | 2 +- .../lib/components/pluginManagerProvider.tsx | 36 ++ .../src/lib/remix-ui-plugin-manager.css | 61 +++- .../src/lib/remix-ui-plugin-manager.tsx | 2 - 6 files changed, 249 insertions(+), 171 deletions(-) create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx 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 1ec2fb5994..f9d2b3ea24 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -1,13 +1,18 @@ -import { IframePlugin, ViewPlugin, WebsocketPlugin } from '@remixproject/engine-web' +/* eslint-disable no-unused-vars */ +import { + IframePlugin, + ViewPlugin, + WebsocketPlugin +} from '@remixproject/engine-web' import { PluginManagerSettings } from './plugin-manager-settings' -import React from 'react' -import { ReactDOM } from 'react-dom' -import { RemixUIPluginManager } from '@remix-ui/plugin-manager' +import React from 'react' // eslint-disable-line +import ReactDOM from 'react-dom' +import {RemixUiPluginManager} from '@remix-ui/plugin-manager' // eslint-disable-line import * as packageJson from '../../../../../package.json' const yo = require('yo-yo') const csjs = require('csjs-inject') const EventEmitter = require('events') -const LocalPlugin = require('./local-plugin') +const LocalPlugin = require('./local-plugin') // eslint-disable-line const addToolTip = require('../ui/tooltip') const _paq = window._paq = window._paq || [] @@ -87,92 +92,96 @@ const profile = { class PluginManagerComponent extends ViewPlugin { constructor (appManager, engine) { super(profile) - this.event = new EventEmitter() - this.appManager = appManager - this.views = { - root: null, - items: {} - } - this.localPlugin = new LocalPlugin() - this.filter = '' - this.appManager.event.on('activate', () => { this.reRender() }) - this.appManager.event.on('deactivate', () => { this.reRender() }) - this.engine = engine - this.engine.event.on('onRegistration', () => { this.reRender() }) + // this.event = new EventEmitter() + // this.appManager = appManager + // this.engine = engine this.htmlElement = document.createElement('div') this.htmlElement.setAttribute('id', 'pluginManager') + // this.views = { + // root: null, + // items: {} + // } + // this.localPlugin = new LocalPlugin() + // this.filter = '' + // this.appManager.event.on('activate', () => { this.reRender() }) + // this.appManager.event.on('deactivate', () => { this.reRender() }) + // this.engine.event.on('onRegistration', () => { this.reRender() }) } onActivation () { this.renderComponent() } - isActive (name) { - return this.appManager.actives.includes(name) + renderComponent () { + ReactDOM.render(, document.getElementById('pluginManager')) } - activateP (name) { - this.appManager.activatePlugin(name) - _paq.push(['trackEvent', 'manager', 'activate', name]) - } + // isActive (name) { + // return this.appManager.actives.includes(name) + // } - deactivateP (name) { - this.call('manager', 'deactivatePlugin', name) - _paq.push(['trackEvent', 'manager', 'deactivate', name]) - } + // activateP (name) { + // this.appManager.activatePlugin(name) + // _paq.push(['trackEvent', 'manager', 'activate', name]) + // } - renderItem (profile) { - const displayName = (profile.displayName) ? profile.displayName : profile.name - const doclink = profile.documentation ? yo`` - : yo`` + // deactivateP (name) { + // this.call('manager', 'deactivatePlugin', name) + // _paq.push(['trackEvent', 'manager', 'deactivate', name]) + // } - // Check version of the plugin - let versionWarning - // Alpha - if (profile.version && profile.version.match(/\b(\w*alpha\w*)\b/g)) { - versionWarning = yo`alpha` - } - // Beta - if (profile.version && profile.version.match(/\b(\w*beta\w*)\b/g)) { - versionWarning = yo`beta` - } + // renderItem (profile) { + // const displayName = (profile.displayName) ? profile.displayName : profile.name + // const doclink = profile.documentation ? yo`` + // : yo`` - const activationButton = this.isActive(profile.name) - ? yo` - - ` - : yo` - ` + // // Check version of the plugin + // let versionWarning + // // Alpha + // if (profile.version && profile.version.match(/\b(\w*alpha\w*)\b/g)) { + // versionWarning = yo`alpha` + // } + // // Beta + // if (profile.version && profile.version.match(/\b(\w*beta\w*)\b/g)) { + // versionWarning = yo`beta` + // } - return yo` -
-
-
-
- ${displayName} - ${doclink} - ${versionWarning} -
- ${activationButton} -
-
-
- - ${profile.description} -
-
- ` - } + // const activationButton = this.isActive(profile.name) + // ? yo` + // + // ` + // : yo` + // ` + + // return yo` + //
+ //
+ //
+ //
+ // ${displayName} + // ${doclink} + // ${versionWarning} + //
+ // ${activationButton} + //
+ //
+ //
+ // + // ${profile.description} + //
+ //
+ // ` + // } /*************** * SUB-COMPONENT @@ -197,95 +206,91 @@ class PluginManagerComponent extends ViewPlugin { } } - // return this.htmlElement() + // // return this.htmlElement() - // render () { - // return this.htmlElement() - // } + // // render () { + // // return this.htmlElement() + // // } render () { - // Filtering helpers - const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) - const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) - const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) - const isNotHome = (profile) => profile.name !== 'home' - const sortByName = (profileA, profileB) => { - const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() - const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() - return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 - } + // // Filtering helpers + // const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) + // const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) + // const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) + // const isNotHome = (profile) => profile.name !== 'home' + // const sortByName = (profileA, profileB) => { + // const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() + // const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() + // return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 + // } - // Filter all active and inactive modules that are not required - const { actives, inactives } = this.appManager.getAll() - .filter(isFiltered) - .filter(isNotRequired) - .filter(isNotDependent) - .filter(isNotHome) - .sort(sortByName) - .reduce(({ actives, inactives }, profile) => { - return this.isActive(profile.name) - ? { actives: [...actives, profile], inactives } - : { inactives: [...inactives, profile], actives } - }, { actives: [], inactives: [] }) + // // Filter all active and inactive modules that are not required + // const { actives, inactives } = this.appManager.getAll() + // .filter(isFiltered) + // .filter(isNotRequired) + // .filter(isNotDependent) + // .filter(isNotHome) + // .sort(sortByName) + // .reduce(({ actives, inactives }, profile) => { + // return this.isActive(profile.name) + // ? { actives: [...actives, profile], inactives } + // : { inactives: [...inactives, profile], actives } + // }, { actives: [], inactives: [] }) - const activeTile = actives.length !== 0 - ? yo` - - ` - : '' - const inactiveTile = inactives.length !== 0 - ? yo` - - ` - : '' + // const activeTile = actives.length !== 0 + // ? yo` + // + // ` + // : '' + // const inactiveTile = inactives.length !== 0 + // ? yo` + // + // ` + // : '' - const settings = new PluginManagerSettings().render() + // const settings = new PluginManagerSettings().render() - const rootView = yo` -
-
- - -
-
- ${activeTile} -
- ${actives.map(profile => this.renderItem(profile))} -
- ${inactiveTile} -
- ${inactives.map(profile => this.renderItem(profile))} -
-
- ${settings} -
- ` - if (!this.views.root) this.views.root = rootView - return rootView - } - - renderComponent () { - ReactDOM.render(, this.htmElement) + // const rootView = yo` + //
+ //
+ // + // + //
+ //
+ // ${activeTile} + //
+ // ${actives.map(profile => this.renderItem(profile))} + //
+ // ${inactiveTile} + //
+ // ${inactives.map(profile => this.renderItem(profile))} + //
+ //
+ // ${settings} + //
+ // ` + // if (!this.views.root) this.views.root = rootView + return this.htmlElement } - reRender () { - if (this.views.root) { - yo.update(this.views.root, this.render()) - } - } + // reRender () { --> no needed possibly + // if (this.views.root) { + // yo.update(this.views.root, this.render()) + // } + // } - filterPlugins ({ target }) { - this.filter = target.value.toLowerCase() - this.reRender() - } + // filterPlugins ({ target }) { + // this.filter = target.value.toLowerCase() + // this.reRender() + // } } module.exports = PluginManagerComponent diff --git a/apps/remix-ide/src/app/components/plugin-manager-settings.js b/apps/remix-ide/src/app/components/plugin-manager-settings.js index 3b6cc291cf..ed9ef3bbad 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-settings.js +++ b/apps/remix-ide/src/app/components/plugin-manager-settings.js @@ -2,8 +2,8 @@ const yo = require('yo-yo') const csjs = require('csjs-inject') const modalDialog = require('../ui/modaldialog') -const css = csjs` -.permissions { +const css = csjs` +.remixui_permissions { position: sticky; bottom: 0; display: flex; diff --git a/libs/remix-ui/plugin-manager/src/index.ts b/libs/remix-ui/plugin-manager/src/index.ts index fe4343e6ef..030e10c5dd 100644 --- a/libs/remix-ui/plugin-manager/src/index.ts +++ b/libs/remix-ui/plugin-manager/src/index.ts @@ -1 +1 @@ -export * from './lib/remix-ui-plugin-manager'; +export * from './lib/remix-ui-plugin-manager' diff --git a/libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx b/libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx new file mode 100644 index 0000000000..3ce7c87a2a --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx @@ -0,0 +1,36 @@ +import React, { createContext, useState } from 'react' +import { Profile } from '../../customTypes' +import * as packageJson from '../../../../../../package.json' +// export interface RemixUiPluginManagerProps { +// activatePlugin: (name: string) => void +// deActivatePlugin: (name: string) => void +// isActive: () => void +// openLocalPlugin: () => Promise +// filterPlugins: () => void +// reRender: () => void +// profile: Profile +// } + +export const PluginManagerContext = createContext({}) + +function PluginManagerContextProvider ({ children }) { + const [profile] = useState({ + name: 'pluginManager', + displayName: 'Plugin manager', + methods: [], + events: [], + icon: 'assets/img/pluginManager.webp', + description: 'Start/stop services, modules and plugins', + kind: 'settings', + location: 'sidePanel', + documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', + version: packageJson.version + }) + return ( + + {children} + + ) +} + +export default PluginManagerContextProvider diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css index 51b5e0a64d..413e6c5846 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.css @@ -1,4 +1,4 @@ -.pluginSearch { +.remixui_pluginSearch { display: flex; flex-direction: column; align-items: center; @@ -9,42 +9,42 @@ z-index: 2; margin-bottom: 0px; } -.pluginSearchInput { +.remixui_pluginSearchInput { height: 38px; } -.pluginSearchButton { +.remixui_pluginSearchButton { font-size: 13px; } -.displayName { +.remixui_displayName { width: 100%; display: flex; align-items: center; justify-content: space-between; } -.pluginIcon { +.remixui_pluginIcon { height: 0.7rem; width: 0.7rem; filter: invert(0.5); } -.description { +.remixui_description { font-size: 13px; line-height: 18px; } -.descriptiontext { +.remixui_descriptiontext { display: block; } -.descriptiontext:first-letter { +.remixui_descriptiontext:first-letter { text-transform: uppercase; } -.row { +.remixui_row { display: flex; flex-direction: row; } -.isStuck { +.remixui_isStuck { background-color: var(--primary); /* color: */ } -.versionWarning { +.remixui_versionWarning { padding: 4px; margin: 0 8px; font-weight: 700; @@ -55,3 +55,42 @@ border: 1px solid; border-radius: 2px; } + +.remixui_permissions { + position: sticky; + bottom: 0; + display: flex; + justify-content: flex-end; + align-items: center; + padding: 5px 20px; +} +.remixui_permissions button { + padding: 2px 5px; + cursor: pointer; +} +.remixui_permissionForm h4 { + font-size: 1.3rem; + text-align: center; +} +.remixui_permissionForm h6 { + font-size: 1.1rem; +} +.remixui_permissionForm hr { + width: 80%; +} +.remixui_permissionKey { + display: flex; + justify-content: space-between; + align-items: center; +} +.remixui_permissionKey i { + cursor: pointer; +} +.remixui_checkbox { + display: flex; + align-items: center; +} +.remixui_checkbox label { + margin: 0; + font-size: 1rem; +} diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index 242a293d8c..f07ea78765 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -20,5 +20,3 @@ export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => {
) } - -export default RemixUiPluginManager From 2f62e81069d7d627a7f2a1aa177c20fe777241bd Mon Sep 17 00:00:00 2001 From: joseph izang Date: Mon, 5 Jul 2021 18:32:00 +0100 Subject: [PATCH 009/209] generate types to align remixuipluginmanager props --- app/ui/modal-dialog-custom.d.ts | 30 +++++++ app/ui/modaldialog.d.ts | 7 ++ app/ui/persmission-handler.d.ts | 36 ++++++++ app/ui/styles/modal-dialog-custom-styles.d.ts | 2 + app/ui/styles/modaldialog-styles.d.ts | 2 + app/ui/styles/tooltip-styles.d.ts | 2 + app/ui/tooltip.d.ts | 2 + .../components/plugin-manager-component.js | 44 +++++----- global/registry.d.ts | 9 ++ lib/query-params.d.ts | 7 ++ .../plugin-manager/src/customTypes.ts | 6 +- .../src/lib/components/activeTile.tsx | 7 +- .../src/lib/components/listGroupItem.tsx | 12 ++- .../src/lib/components/pluginCard.tsx | 2 +- .../lib/components/pluginManagerProvider.tsx | 36 -------- .../src/lib/components/renderItem.tsx | 54 ++++++++++++ .../src/lib/components/rootView.tsx | 15 ++-- .../src/lib/remix-ui-plugin-manager.tsx | 82 +++++++++++++++++-- libs/remix-ui/plugin-manager/src/types.d.ts | 56 +++++++++++++ registry.d.ts | 10 +++ 20 files changed, 337 insertions(+), 84 deletions(-) create mode 100644 app/ui/modal-dialog-custom.d.ts create mode 100644 app/ui/modaldialog.d.ts create mode 100644 app/ui/persmission-handler.d.ts create mode 100644 app/ui/styles/modal-dialog-custom-styles.d.ts create mode 100644 app/ui/styles/modaldialog-styles.d.ts create mode 100644 app/ui/styles/tooltip-styles.d.ts create mode 100644 app/ui/tooltip.d.ts create mode 100644 global/registry.d.ts create mode 100644 lib/query-params.d.ts delete mode 100644 libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx create mode 100644 libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx create mode 100644 registry.d.ts diff --git a/app/ui/modal-dialog-custom.d.ts b/app/ui/modal-dialog-custom.d.ts new file mode 100644 index 0000000000..4d90a2b68b --- /dev/null +++ b/app/ui/modal-dialog-custom.d.ts @@ -0,0 +1,30 @@ +export function alert(title: any, text: any): { + container: HTMLElement; + okListener: () => void; + cancelListener: () => void; + hide: () => void; +}; +export function prompt(title: any, text: any, inputValue: any, ok: any, cancel: any, focus: any): void; +export function promptPassphrase(title: any, text: any, inputValue: any, ok: any, cancel: any): void; +export function promptPassphraseCreation(ok: any, cancel: any): { + container: HTMLElement; + okListener: () => void; + cancelListener: () => void; + hide: () => void; +}; +export function promptMulti({ title, text, inputValue }: { + title: any; + text: any; + inputValue: any; +}, ok: any, cancel: any): { + container: HTMLElement; + okListener: () => void; + cancelListener: () => void; + hide: () => void; +}; +export function confirm(title: any, text: any, ok: any, cancel: any): { + container: HTMLElement; + okListener: () => void; + cancelListener: () => void; + hide: () => void; +}; diff --git a/app/ui/modaldialog.d.ts b/app/ui/modaldialog.d.ts new file mode 100644 index 0000000000..8ca5058d19 --- /dev/null +++ b/app/ui/modaldialog.d.ts @@ -0,0 +1,7 @@ +declare function _exports(title: any, content: any, ok: any, cancel: any, focusSelector: any, opts: any): { + container: HTMLElement; + okListener: () => void; + cancelListener: () => void; + hide: () => void; +}; +export = _exports; diff --git a/app/ui/persmission-handler.d.ts b/app/ui/persmission-handler.d.ts new file mode 100644 index 0000000000..1458be6c9b --- /dev/null +++ b/app/ui/persmission-handler.d.ts @@ -0,0 +1,36 @@ +export class PermissionHandler { + permissions: any; + currentVersion: number; + _getFromLocal(): any; + persistPermissions(): void; + clear(): void; + /** + * 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 + */ + openPermission(from: any, to: any, method: string, message: string): Promise<{ + allow: boolean; + remember: boolean; + }>; + /** + * Check if a plugin has the permission to call another plugin and askPermission if needed + * @param {PluginProfile} from the profile of the plugin that make the call + * @param {ModuleProfile} to The profile of the module 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} + */ + askPermission(from: any, to: any, method: string, message: string): Promise; + /** + * 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: any, to: any, method: string, message: string): any; +} diff --git a/app/ui/styles/modal-dialog-custom-styles.d.ts b/app/ui/styles/modal-dialog-custom-styles.d.ts new file mode 100644 index 0000000000..17eaa199b0 --- /dev/null +++ b/app/ui/styles/modal-dialog-custom-styles.d.ts @@ -0,0 +1,2 @@ +export = css; +declare var css: any; diff --git a/app/ui/styles/modaldialog-styles.d.ts b/app/ui/styles/modaldialog-styles.d.ts new file mode 100644 index 0000000000..17eaa199b0 --- /dev/null +++ b/app/ui/styles/modaldialog-styles.d.ts @@ -0,0 +1,2 @@ +export = css; +declare var css: any; diff --git a/app/ui/styles/tooltip-styles.d.ts b/app/ui/styles/tooltip-styles.d.ts new file mode 100644 index 0000000000..17eaa199b0 --- /dev/null +++ b/app/ui/styles/tooltip-styles.d.ts @@ -0,0 +1,2 @@ +export = css; +declare var css: any; diff --git a/app/ui/tooltip.d.ts b/app/ui/tooltip.d.ts new file mode 100644 index 0000000000..3dabc371e3 --- /dev/null +++ b/app/ui/tooltip.d.ts @@ -0,0 +1,2 @@ +declare function _exports(tooltipText: string, action?: Function, opts: any): any; +export = _exports; 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 f9d2b3ea24..cea87ed9ed 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -92,7 +92,7 @@ const profile = { class PluginManagerComponent extends ViewPlugin { constructor (appManager, engine) { super(profile) - // this.event = new EventEmitter() + // this.event = new EventEmitter() //already exists in engine so not needed here // this.appManager = appManager // this.engine = engine this.htmlElement = document.createElement('div') @@ -120,15 +120,15 @@ class PluginManagerComponent extends ViewPlugin { // return this.appManager.actives.includes(name) // } - // activateP (name) { - // this.appManager.activatePlugin(name) - // _paq.push(['trackEvent', 'manager', 'activate', name]) - // } + activateP (name) { + this.appManager.activatePlugin(name) + _paq.push(['trackEvent', 'manager', 'activate', name]) + } - // deactivateP (name) { - // this.call('manager', 'deactivatePlugin', name) - // _paq.push(['trackEvent', 'manager', 'deactivate', name]) - // } + deactivateP (name) { + this.call('manager', 'deactivatePlugin', name) + _paq.push(['trackEvent', 'manager', 'deactivate', name]) + } // renderItem (profile) { // const displayName = (profile.displayName) ? profile.displayName : profile.name @@ -206,23 +206,17 @@ class PluginManagerComponent extends ViewPlugin { } } - // // return this.htmlElement() - - // // render () { - // // return this.htmlElement() - // // } - render () { - // // Filtering helpers - // const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) - // const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) - // const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) - // const isNotHome = (profile) => profile.name !== 'home' - // const sortByName = (profileA, profileB) => { - // const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() - // const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() - // return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 - // } + // Filtering helpers + const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) + const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) + const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) + const isNotHome = (profile) => profile.name !== 'home' + const sortByName = (profileA, profileB) => { + const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() + const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() + return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 + } // // Filter all active and inactive modules that are not required // const { actives, inactives } = this.appManager.getAll() diff --git a/global/registry.d.ts b/global/registry.d.ts new file mode 100644 index 0000000000..f706ab2a37 --- /dev/null +++ b/global/registry.d.ts @@ -0,0 +1,9 @@ +declare const _exports: { + state: {}; + put({ api, name }: { + api: any; + name: any; + }): any; + get(name: any): any; +}; +export = _exports; diff --git a/lib/query-params.d.ts b/lib/query-params.d.ts new file mode 100644 index 0000000000..537b864249 --- /dev/null +++ b/lib/query-params.d.ts @@ -0,0 +1,7 @@ +export = QueryParams; +declare function QueryParams(_window: any): void; +declare class QueryParams { + constructor(_window: any); + get: () => {}; + update: (params: any) => void; +} diff --git a/libs/remix-ui/plugin-manager/src/customTypes.ts b/libs/remix-ui/plugin-manager/src/customTypes.ts index 5004c94b60..8f6a286e25 100644 --- a/libs/remix-ui/plugin-manager/src/customTypes.ts +++ b/libs/remix-ui/plugin-manager/src/customTypes.ts @@ -16,7 +16,11 @@ export type Profile = { kind: 'settings', location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', - version: string + version: any +} + +export type TileLabel = { + label: 'Active Module' | 'Inactive Modules' } export type LocalPlugin = { diff --git a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx index f2a8a0050a..fa1ea10316 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx @@ -1,13 +1,10 @@ import React from 'react' - -type tileLabel = { - label: 'Active Module' | 'Inactive Modules' -} +import { TileLabel } from '../../customTypes' interface ActiveTileProps { inactivesCount?: number activesCount?: number - tileLabel?: tileLabel + tileLabel?: TileLabel } function ActiveTile ({ inactivesCount, activesCount, tileLabel }: ActiveTileProps) { diff --git a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx index fab9496217..cc92302409 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx @@ -1,18 +1,22 @@ import React from 'react' import { Profile } from '../../customTypes' +import RenderItem from './renderItem' interface ListGroupItemProps { activeProfiles: Profile[] inactiveProfiles: Profile[] - renderItem: (profile: Profile) => void } -function ListGroupItem ({ activeProfiles, inactiveProfiles, renderItem }: ListGroupItemProps) { +function ListGroupItem ({ activeProfiles, inactiveProfiles }: ListGroupItemProps) { return (
{ activeProfiles.length > 0 - ? activeProfiles.map(profile => renderItem(profile)) - : inactiveProfiles.map(profile => renderItem(profile)) + ? activeProfiles.map(profile => ( + + )) + : inactiveProfiles.map(profile => ( + + )) }
) 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 85e95dc707..da9bca617e 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx @@ -5,7 +5,7 @@ interface PluginCardProps { profileName: string displayName: string docLink: string - versionWarning: string + versionWarning: any profileIcon: string profileDescription: string } diff --git a/libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx b/libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx deleted file mode 100644 index 3ce7c87a2a..0000000000 --- a/libs/remix-ui/plugin-manager/src/lib/components/pluginManagerProvider.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React, { createContext, useState } from 'react' -import { Profile } from '../../customTypes' -import * as packageJson from '../../../../../../package.json' -// export interface RemixUiPluginManagerProps { -// activatePlugin: (name: string) => void -// deActivatePlugin: (name: string) => void -// isActive: () => void -// openLocalPlugin: () => Promise -// filterPlugins: () => void -// reRender: () => void -// profile: Profile -// } - -export const PluginManagerContext = createContext({}) - -function PluginManagerContextProvider ({ children }) { - const [profile] = useState({ - name: 'pluginManager', - displayName: 'Plugin manager', - methods: [], - events: [], - icon: 'assets/img/pluginManager.webp', - description: 'Start/stop services, modules and plugins', - kind: 'settings', - location: 'sidePanel', - documentation: 'https://remix-ide.readthedocs.io/en/latest/plugin_manager.html', - version: packageJson.version - }) - return ( - - {children} - - ) -} - -export default PluginManagerContextProvider diff --git a/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx new file mode 100644 index 0000000000..f976357f24 --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx @@ -0,0 +1,54 @@ +import React, { useEffect, useState } from 'react' +import { Profile } from '../../customTypes' +import PluginCard from './pluginCard' + +interface RenderItemProps { + profile: Profile +} + +function RenderItem ({ profile }: RenderItemProps) { + const [displayName, setDisplayName] = useState('') + const [docLink, setDocLink] = useState() + const [versionWarning, setVersionWarning] = useState, HTMLElement>>() + + useEffect(() => { + const checkPluginVersion = (version: string) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + let versionWarning: React.DetailedHTMLProps, HTMLElement> + if (version && version.match(/\b(\w*alpha\w*)\b/g)) { + versionWarning = alpha + } + // Beta + if (version && version.match(/\b(\w*beta\w*)\b/g)) { + versionWarning = beta + } + return versionWarning + } + + setDisplayName((profile.displayName) ? profile.displayName : profile.name) + setDocLink( + profile.documentation ? ( + + + + ) : '') + setVersionWarning(checkPluginVersion(profile.version)) + }, [profile.displayName, profile.documentation, profile.name, profile.version, versionWarning]) + + return ( + + ) +} + +export default RenderItem diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx index 266014cd7d..e4d2aeffbb 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { Profile } from '../../customTypes' +import { Profile, TileLabel } from '../../customTypes' import ActiveTile from './activeTile' import ListGroupItem from './listGroupItem' @@ -9,7 +9,7 @@ interface RootViewProps { inactiveProfiles?: Profile[] filterPlugins: () => void openLocalPlugins: () => void - renderItem: (profile: Profile) => void + tileLabel: TileLabel } function RootView ({ @@ -18,20 +18,23 @@ function RootView ({ inactiveProfiles, filterPlugins, openLocalPlugins, - renderItem + tileLabel }: RootViewProps) { return (
-
+
- +
diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index f07ea78765..ab845dc6dc 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,22 +1,92 @@ -import React from 'react' +import React, { createContext, useEffect, useState } from 'react' import { Profile } from '../customTypes' +import { RemixAppManager, RemixEngine, _Paq } from '../types' +import RootView from './components/rootView' import './remix-ui-plugin-manager.css' /* eslint-disable-next-line */ export interface RemixUiPluginManagerProps { + appManager: RemixAppManager + engine: RemixEngine + _paq: _Paq + filter: string activatePlugin: (name: string) => void deActivatePlugin: (name: string) => void - isActive: () => void + isActive: (name: string) => void openLocalPlugin: () => Promise filterPlugins: () => void - reRender: () => void profile: Profile } +export const PluginManagerContext = createContext({}) + +function PluginManagerContextProvider ({ children }) { + const [globalState] = useState({} as RemixUiPluginManagerProps) + return ( + + {children} + + ) +} + +// // Filtering helpers +// const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) +// const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) +// const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) +// const isNotHome = (profile) => profile.name !== 'home' +// const sortByName = (profileA, profileB) => { +// const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() +// const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() +// return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 +// } + +// // Filter all active and inactive modules that are not required +// const { actives, inactives } = this.appManager.getAll() +// .filter(isFiltered) +// .filter(isNotRequired) +// .filter(isNotDependent) +// .filter(isNotHome) +// .sort(sortByName) +// .reduce(({ actives, inactives }, profile) => { +// return this.isActive(profile.name) +// ? { actives: [...actives, profile], inactives } +// : { inactives: [...inactives, profile], actives } +// }, { actives: [], inactives: [] }) + export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { + const [isFiltered] = useState((profile) => + (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(props.filter)) + const [isNotRequired, setIsNotRequired] = useState(false) + const [isNotDependent, setIsNotDependent] = useState((profile) => !props.appManager.isDependent(profile.name)) + const [isNotHome, setIsNotHome] = useState((profile) => profile.name !== 'home') + const [sortByName, setSortByName] = useState<1 | -1 | 0>((profileA, profileB) => { + const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() + const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() + return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 + }) + const { actives, inactives } = props.appManager.getAll() + .filter(isFiltered) + .filter(isNotRequired) + .filter(isNotDependent) + .filter(isNotHome) + .sort(sortByName) + .reduce(({ actives, inactives }, profile) => { + return this.isActive(profile.name) + ? { actives: [...actives, profile], inactives } + : { inactives: [...inactives, profile], actives } + }, { actives: [], inactives: [] }) + useEffect(() => { + const notRequired = (profile: Profile) => !props.appManager.isRequired(profile.name) + setIsNotRequired(notRequired(props.profile)) + }) + return ( -
-

Welcome to remix-ui-plugin-manager!

-
+ + + ) } diff --git a/libs/remix-ui/plugin-manager/src/types.d.ts b/libs/remix-ui/plugin-manager/src/types.d.ts index 2014ac099b..4167ddc17b 100644 --- a/libs/remix-ui/plugin-manager/src/types.d.ts +++ b/libs/remix-ui/plugin-manager/src/types.d.ts @@ -1,3 +1,7 @@ +import { PermissionHandler } from './app/ui/persmission-handler' +import { PluginManager } from '@remixproject/engine/lib/manager' +import { EventEmitter } from 'events' +import { Engine } from '@remixproject/engine/lib/engine' /* eslint-disable camelcase */ declare module 'yo-yo'{ @@ -17,3 +21,55 @@ declare module 'dom-css'{ var css:dom_css export = css; } + +interface SetPluginOptionType { + queueTimeout: number +} + +export interface _Paq { + _paq: Window & typeof globalThis | [] +} + +export class RemixEngine extends Engine { + event: EventEmitter; + setPluginOption ({ name, kind }) : SetPluginOptionType + onRegistration (plugin) : void +} + +export function isNative(name: any): any; +/** + * Checks if plugin caller 'from' is allowed to activate plugin 'to' + * The caller can have 'canActivate' as a optional property in the plugin profile. + * This is an array containing the 'name' property of the plugin it wants to call. + * canActivate = ['plugin1-to-call','plugin2-to-call',....] + * or the plugin is allowed by default because it is native + * + * @param {any, any} + * @returns {boolean} + */ +export function canActivate(from: any, to: any): boolean; +export class RemixAppManager extends PluginManager { + constructor(); + event: EventEmitter; + pluginsDirectory: string; + pluginLoader: PluginLoader; + permissionHandler: PermissionHandler; + getAll(): import('@remixproject/plugin-utils').Profile[]; + getIds(): string[]; + isDependent(name: any): any; + isRequired(name: any): any; + registeredPlugins(): Promise; +} +/** @class Reference loaders. + * A loader is a get,set based object which load a workspace from a defined sources. + * (localStorage, queryParams) + **/ +declare class PluginLoader { + get currentLoader(): any; + donotAutoReload: string[]; + loaders: {}; + current: string; + set(plugin: any, actives: any): void; + get(): any; +} +export { } diff --git a/registry.d.ts b/registry.d.ts new file mode 100644 index 0000000000..7257a4b711 --- /dev/null +++ b/registry.d.ts @@ -0,0 +1,10 @@ +declare class registry { + state: {}; + put({ api, name }: { + api: any; + name: any; + }): any + + get(name: any): any; +} +export = registry; From 9f516a846734bdcaf45936e91895f74a257ba16d Mon Sep 17 00:00:00 2001 From: joseph izang Date: Tue, 6 Jul 2021 10:39:16 +0100 Subject: [PATCH 010/209] Finish implementing Context for easy state access --- .../components/plugin-manager-component.js | 28 +++--- .../src/lib/components/activeTile.tsx | 2 +- .../src/lib/components/rootView.tsx | 27 ++--- .../src/lib/remix-ui-plugin-manager.tsx | 99 +++++++++---------- 4 files changed, 72 insertions(+), 84 deletions(-) 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 cea87ed9ed..799e841088 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -116,9 +116,9 @@ class PluginManagerComponent extends ViewPlugin { ReactDOM.render(, document.getElementById('pluginManager')) } - // isActive (name) { - // return this.appManager.actives.includes(name) - // } + isActive (name) { + return this.appManager.actives.includes(name) + } activateP (name) { this.appManager.activatePlugin(name) @@ -219,17 +219,17 @@ class PluginManagerComponent extends ViewPlugin { } // // Filter all active and inactive modules that are not required - // const { actives, inactives } = this.appManager.getAll() - // .filter(isFiltered) - // .filter(isNotRequired) - // .filter(isNotDependent) - // .filter(isNotHome) - // .sort(sortByName) - // .reduce(({ actives, inactives }, profile) => { - // return this.isActive(profile.name) - // ? { actives: [...actives, profile], inactives } - // : { inactives: [...inactives, profile], actives } - // }, { actives: [], inactives: [] }) + const { actives, inactives } = this.appManager.getAll() + .filter(isFiltered) + .filter(isNotRequired) + .filter(isNotDependent) + .filter(isNotHome) + .sort(sortByName) + .reduce(({ actives, inactives }, profile) => { + return this.isActive(profile.name) + ? { actives: [...actives, profile], inactives } + : { inactives: [...inactives, profile], actives } + }, { actives: [], inactives: [] }) // const activeTile = actives.length !== 0 // ? yo` diff --git a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx index fa1ea10316..7bb42ca5ad 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx @@ -12,7 +12,7 @@ function ActiveTile ({ inactivesCount, activesCount, tileLabel }: ActiveTileProp ) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx index e4d2aeffbb..28c822d1df 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -1,25 +1,14 @@ -import React from 'react' -import { Profile, TileLabel } from '../../customTypes' +import React, { useContext } from 'react' +import { PluginManagerContext } from '../remix-ui-plugin-manager' import ActiveTile from './activeTile' import ListGroupItem from './listGroupItem' interface RootViewProps { localPluginButtonText: string - activeProfiles: Profile[] - inactiveProfiles?: Profile[] - filterPlugins: () => void - openLocalPlugins: () => void - tileLabel: TileLabel } -function RootView ({ - localPluginButtonText, - activeProfiles, - inactiveProfiles, - filterPlugins, - openLocalPlugins, - tileLabel -}: RootViewProps) { +function RootView ({ localPluginButtonText }: RootViewProps) { + const { actives, inactives, tileLabel } = useContext(PluginManagerContext) return (
@@ -28,13 +17,13 @@ function RootView ({
diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index ab845dc6dc..9c7fd7be6a 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,69 +1,51 @@ import React, { createContext, useEffect, useState } from 'react' -import { Profile } from '../customTypes' +import { Profile, TileLabel } from '../customTypes' import { RemixAppManager, RemixEngine, _Paq } from '../types' import RootView from './components/rootView' import './remix-ui-plugin-manager.css' /* eslint-disable-next-line */ -export interface RemixUiPluginManagerProps { +export interface PluginManagerContextProviderProps { appManager: RemixAppManager engine: RemixEngine _paq: _Paq filter: string + actives: Profile[] + inactives: Profile[] activatePlugin: (name: string) => void deActivatePlugin: (name: string) => void - isActive: (name: string) => void + isActive: (name: string) => any openLocalPlugin: () => Promise filterPlugins: () => void profile: Profile + tileLabel: TileLabel } -export const PluginManagerContext = createContext({}) - -function PluginManagerContextProvider ({ children }) { - const [globalState] = useState({} as RemixUiPluginManagerProps) - return ( - - {children} - - ) +export interface RemixUiPluginManagerProps { + appManager: RemixAppManager + engine: RemixEngine + _paq: _Paq + filter: string + actives: Profile[] + inactives: Profile[] + activatePlugin: (name: string) => void + deActivatePlugin: (name: string) => void + isActive: (name: string) => any + openLocalPlugin: () => Promise + filterPlugins: () => void + profile: Profile + tileLabel: TileLabel } -// // Filtering helpers -// const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) -// const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) -// const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) -// const isNotHome = (profile) => profile.name !== 'home' -// const sortByName = (profileA, profileB) => { -// const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() -// const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() -// return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 -// } - -// // Filter all active and inactive modules that are not required -// const { actives, inactives } = this.appManager.getAll() -// .filter(isFiltered) -// .filter(isNotRequired) -// .filter(isNotDependent) -// .filter(isNotHome) -// .sort(sortByName) -// .reduce(({ actives, inactives }, profile) => { -// return this.isActive(profile.name) -// ? { actives: [...actives, profile], inactives } -// : { inactives: [...inactives, profile], actives } -// }, { actives: [], inactives: [] }) +export const PluginManagerContext = createContext>({}) -export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { +function PluginManagerContextProvider ({ children, props }) { const [isFiltered] = useState((profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(props.filter)) - const [isNotRequired, setIsNotRequired] = useState(false) - const [isNotDependent, setIsNotDependent] = useState((profile) => !props.appManager.isDependent(profile.name)) - const [isNotHome, setIsNotHome] = useState((profile) => profile.name !== 'home') - const [sortByName, setSortByName] = useState<1 | -1 | 0>((profileA, profileB) => { - const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() - const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() - return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 - }) + const [isNotRequired, setIsNotRequired] = useState() + const [isNotDependent, setIsNotDependent] = useState() + const [isNotHome, setIsNotHome] = useState() + const [sortByName, setSortByName] = useState() const { actives, inactives } = props.appManager.getAll() .filter(isFiltered) .filter(isNotRequired) @@ -71,21 +53,38 @@ export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { .filter(isNotHome) .sort(sortByName) .reduce(({ actives, inactives }, profile) => { - return this.isActive(profile.name) + return props.isActive(profile.name) ? { actives: [...actives, profile], inactives } : { inactives: [...inactives, profile], actives } }, { actives: [], inactives: [] }) + props.actives = actives + props.inactives = inactives useEffect(() => { const notRequired = (profile: Profile) => !props.appManager.isRequired(profile.name) + const notDependent = (profile) => !props.appManager.isDependent(profile.name) + const notHome = (profile) => profile.name !== 'home' + const sortedByName = (profileA: Profile, profileB: Profile) => { + const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() + const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() + return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 + } setIsNotRequired(notRequired(props.profile)) - }) + setIsNotDependent(notDependent(notDependent)) + setIsNotHome(notHome) + setSortByName(sortedByName) + }, [props.appManager, props.profile]) + return ( + + {children} + + ) +} +export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { return ( - + ) From 4c05461e588a1ce6c712ed72ed567e7a13a8efb9 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Wed, 7 Jul 2021 00:25:00 +0100 Subject: [PATCH 011/209] Fix components and plug props at provider level --- .../components/plugin-manager-component.js | 157 ++++++++++++------ .../src/lib/components/activeTile.tsx | 19 +-- .../src/lib/components/listGroupItem.tsx | 12 +- .../src/lib/components/pluginCard.tsx | 28 ++-- .../src/lib/components/renderItem.tsx | 77 ++++----- .../src/lib/components/rootView.tsx | 37 +++-- .../src/lib/contexts/pluginmanagercontext.tsx | 14 ++ .../src/lib/remix-ui-plugin-manager.tsx | 95 ++--------- libs/remix-ui/plugin-manager/src/types.d.ts | 36 ++++ 9 files changed, 257 insertions(+), 218 deletions(-) create mode 100644 libs/remix-ui/plugin-manager/src/lib/contexts/pluginmanagercontext.tsx 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 799e841088..a37232e5f8 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -92,11 +92,12 @@ const profile = { class PluginManagerComponent extends ViewPlugin { constructor (appManager, engine) { super(profile) - // this.event = new EventEmitter() //already exists in engine so not needed here - // this.appManager = appManager - // this.engine = engine + // this.event = new EventEmitter() // already exists in engine so not needed here + this.appManager = appManager + this.engine = engine this.htmlElement = document.createElement('div') this.htmlElement.setAttribute('id', 'pluginManager') + this.props = {} // this.views = { // root: null, // items: {} @@ -106,6 +107,22 @@ class PluginManagerComponent extends ViewPlugin { // this.appManager.event.on('activate', () => { this.reRender() }) // this.appManager.event.on('deactivate', () => { this.reRender() }) // this.engine.event.on('onRegistration', () => { this.reRender() }) + // const { actives, inactives } = this.getAllPlugins() + } + + reactProps () { + return { + views: this.views, + filter: this.filter, + localPlugin: this.localPlugin, + isActive: this.isActive, + activatePlugin: this.activateP, + deactivePlugin: this.deactivateP, + openLocalPlugin: this.openLocalPlugin, + profile: this.profile + // actives: actives, + // inactives: inactives + } } onActivation () { @@ -113,22 +130,46 @@ class PluginManagerComponent extends ViewPlugin { } renderComponent () { - ReactDOM.render(, document.getElementById('pluginManager')) + // const props = this.reactProps() + ReactDOM.render( + // , + , + document.getElementById('pluginManager')) } - isActive (name) { - return this.appManager.actives.includes(name) - } + // isActive (name) { + // return this.appManager.actives.includes(name) + // } - activateP (name) { - this.appManager.activatePlugin(name) - _paq.push(['trackEvent', 'manager', 'activate', name]) - } + // activateP (name) { + // this.appManager.activatePlugin(name) + // _paq.push(['trackEvent', 'manager', 'activate', name]) + // } - deactivateP (name) { - this.call('manager', 'deactivatePlugin', name) - _paq.push(['trackEvent', 'manager', 'deactivate', name]) - } + // deactivateP (name) { + // this.call('manager', 'deactivatePlugin', name) + // _paq.push(['trackEvent', 'manager', 'deactivate', name]) + // } // renderItem (profile) { // const displayName = (profile.displayName) ? profile.displayName : profile.name @@ -189,47 +230,55 @@ class PluginManagerComponent extends ViewPlugin { /** * Add a local plugin to the list of plugins */ - async openLocalPlugin () { - try { - const profile = await this.localPlugin.open(this.appManager.getAll()) - if (!profile) return - if (this.appManager.getIds().includes(profile.name)) { - throw new Error('This name has already been used') - } - const plugin = profile.type === 'iframe' ? new IframePlugin(profile) : new WebsocketPlugin(profile) - this.engine.register(plugin) - await this.appManager.activatePlugin(plugin.name) - } catch (err) { - // TODO : Use an alert to handle this error instead of a console.log - console.log(`Cannot create Plugin : ${err.message}`) - addToolTip(`Cannot create Plugin : ${err.message}`) - } - } + // async openLocalPlugin () { + // try { + // const profile = await this.localPlugin.open(this.appManager.getAll()) + // if (!profile) return + // if (this.appManager.getIds().includes(profile.name)) { + // throw new Error('This name has already been used') + // } + // const plugin = profile.type === 'iframe' ? new IframePlugin(profile) : new WebsocketPlugin(profile) + // this.engine.register(plugin) + // await this.appManager.activatePlugin(plugin.name) + // } catch (err) { + // // TODO : Use an alert to handle this error instead of a console.log + // console.log(`Cannot create Plugin : ${err.message}`) + // addToolTip(`Cannot create Plugin : ${err.message}`) + // } + // } + + // filterHelper () { + // const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) + // const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) + // const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) + // const isNotHome = (profile) => profile.name !== 'home' + // const sortByName = (profileA, profileB) => { + // const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() + // const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() + // return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 + // } + // return (isFiltered, isNotRequired, isNotDependent, isNotHome, sortByName) + // } + + // getAllPlugins () { + // // // Filter all active and inactive modules that are not required + // const [isFiltered, isNotRequired, isNotDependent, isNotHome, sortByName] = this.filterHelper() + // const { actives, inactives } = this.appManager.getAll() + // .filter(isFiltered) + // .filter(isNotRequired) + // .filter(isNotDependent) + // .filter(isNotHome) + // .sort(sortByName) + // .reduce(({ actives, inactives }, profile) => { + // return this.isActive(profile.name) + // ? { actives: [...actives, profile], inactives } + // : { inactives: [...inactives, profile], actives } + // }, { actives: [], inactives: [] }) + // return (actives, inactives) + // } render () { // Filtering helpers - const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) - const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) - const isNotDependent = (profile) => !this.appManager.isDependent(profile.name) - const isNotHome = (profile) => profile.name !== 'home' - const sortByName = (profileA, profileB) => { - const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() - const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() - return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 - } - - // // Filter all active and inactive modules that are not required - const { actives, inactives } = this.appManager.getAll() - .filter(isFiltered) - .filter(isNotRequired) - .filter(isNotDependent) - .filter(isNotHome) - .sort(sortByName) - .reduce(({ actives, inactives }, profile) => { - return this.isActive(profile.name) - ? { actives: [...actives, profile], inactives } - : { inactives: [...inactives, profile], actives } - }, { actives: [], inactives: [] }) // const activeTile = actives.length !== 0 // ? yo` @@ -275,7 +324,7 @@ class PluginManagerComponent extends ViewPlugin { return this.htmlElement } - // reRender () { --> no needed possibly + // reRender () { // if (this.views.root) { // yo.update(this.views.root, this.render()) // } diff --git a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx index 7bb42ca5ad..8067a42a4e 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/activeTile.tsx @@ -1,21 +1,20 @@ -import React from 'react' -import { TileLabel } from '../../customTypes' +import React, { useContext } from 'react' +import { PluginManagerContext } from '../contexts/pluginmanagercontext' -interface ActiveTileProps { - inactivesCount?: number - activesCount?: number - tileLabel?: TileLabel +interface ModuleHeadingProps { + headingLabel: string } -function ActiveTile ({ inactivesCount, activesCount, tileLabel }: ActiveTileProps) { +function ModuleHeading ({ headingLabel }: ModuleHeadingProps) { + const { inactivesCount, activesCount } = useContext(PluginManagerContext) return ( ) } -export default ActiveTile +export default ModuleHeading diff --git a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx index cc92302409..e767c2cb02 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx @@ -3,21 +3,23 @@ import { Profile } from '../../customTypes' import RenderItem from './renderItem' interface ListGroupItemProps { - activeProfiles: Profile[] - inactiveProfiles: Profile[] + activeProfiles?: Profile[] + inactiveProfiles?: Profile[] } -function ListGroupItem ({ activeProfiles, inactiveProfiles }: ListGroupItemProps) { +function ListGroupItem () { return (
- { activeProfiles.length > 0 + {/* { activeProfiles.length > 0 ? activeProfiles.map(profile => ( )) : inactiveProfiles.map(profile => ( )) - } + } */} + +
List Group Item Component
) } 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 da9bca617e..f5f5b62d47 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx @@ -1,4 +1,5 @@ -import React from 'react' +import React, { useContext } from 'react' +import { PluginManagerContext } from '../contexts/pluginmanagercontext' import '../remix-ui-plugin-manager.css' import Button from './button' interface PluginCardProps { @@ -10,32 +11,27 @@ interface PluginCardProps { profileDescription: string } -function PluginCard ({ - profileName, - displayName, - docLink, - versionWarning, - profileIcon, - profileDescription -}: PluginCardProps) { +// eslint-disable-next-line no-empty-pattern +function PluginCard () { + const { profile } = useContext(PluginManagerContext) return ( -
+
- {displayName} - {docLink} - {versionWarning} + {profile.displayName} + {profile.docLink} + {profile.versionWarning}
- profile icon - {profileDescription} + profile icon + {profile.description}
) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx index f976357f24..efe554a140 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx @@ -1,52 +1,55 @@ -import React, { useEffect, useState } from 'react' +import React, { useContext } from 'react' import { Profile } from '../../customTypes' +import { PluginManagerContext } from '../contexts/pluginmanagercontext' import PluginCard from './pluginCard' interface RenderItemProps { profile: Profile } -function RenderItem ({ profile }: RenderItemProps) { - const [displayName, setDisplayName] = useState('') - const [docLink, setDocLink] = useState() - const [versionWarning, setVersionWarning] = useState, HTMLElement>>() +function RenderItem () { + const { profile } = useContext(PluginManagerContext) + // const [displayName, setDisplayName] = useState('') + // const [docLink, setDocLink] = useState() + // const [versionWarning, setVersionWarning] = useState, HTMLElement>>() - useEffect(() => { - const checkPluginVersion = (version: string) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - let versionWarning: React.DetailedHTMLProps, HTMLElement> - if (version && version.match(/\b(\w*alpha\w*)\b/g)) { - versionWarning = alpha - } - // Beta - if (version && version.match(/\b(\w*beta\w*)\b/g)) { - versionWarning = beta - } - return versionWarning - } + // useEffect(() => { + // const checkPluginVersion = (version: string) => { + // // eslint-disable-next-line @typescript-eslint/no-unused-vars + // let versionWarning: React.DetailedHTMLProps, HTMLElement> + // if (version && version.match(/\b(\w*alpha\w*)\b/g)) { + // versionWarning = alpha + // } + // // Beta + // if (version && version.match(/\b(\w*beta\w*)\b/g)) { + // versionWarning = beta + // } + // return versionWarning + // } - setDisplayName((profile.displayName) ? profile.displayName : profile.name) - setDocLink( - profile.documentation ? ( - - - - ) : '') - setVersionWarning(checkPluginVersion(profile.version)) - }, [profile.displayName, profile.documentation, profile.name, profile.version, versionWarning]) + // setDisplayName((profile.displayName) ? profile.displayName : profile.name) + // setDocLink( + // profile.documentation ? ( + // + // + // + // ) : '') + // setVersionWarning(checkPluginVersion(profile.version)) + // }, [profile.displayName, profile.documentation, profile.name, profile.version, versionWarning]) + console.log('Profile object from render item component', profile) return ( ) } diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx index 28c822d1df..9cda87e04e 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -1,5 +1,4 @@ -import React, { useContext } from 'react' -import { PluginManagerContext } from '../remix-ui-plugin-manager' +import React from 'react' import ActiveTile from './activeTile' import ListGroupItem from './listGroupItem' @@ -8,23 +7,35 @@ interface RootViewProps { } function RootView ({ localPluginButtonText }: RootViewProps) { - const { actives, inactives, tileLabel } = useContext(PluginManagerContext) + // const { actives, inactives, tileLabel } = useContext(PluginManagerContext) return ( + //
+ //
+ // + // + //
+ //
+ // + // + //
+ //
+
- +
- - + + +
) diff --git a/libs/remix-ui/plugin-manager/src/lib/contexts/pluginmanagercontext.tsx b/libs/remix-ui/plugin-manager/src/lib/contexts/pluginmanagercontext.tsx new file mode 100644 index 0000000000..4e853458c8 --- /dev/null +++ b/libs/remix-ui/plugin-manager/src/lib/contexts/pluginmanagercontext.tsx @@ -0,0 +1,14 @@ +import React, { createContext } from 'react' +import { PluginManagerContextProviderProps } from '../../types' + +export const PluginManagerContext = createContext>({}) + +function PluginManagerContextProvider ({ children, props }) { + return ( + + {children} + + ) +} + +export default PluginManagerContextProvider diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index 9c7fd7be6a..cd0ad8e4ee 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,91 +1,20 @@ -import React, { createContext, useEffect, useState } from 'react' -import { Profile, TileLabel } from '../customTypes' -import { RemixAppManager, RemixEngine, _Paq } from '../types' +import React from 'react' +import { RemixUiPluginManagerProps } from '../types' import RootView from './components/rootView' +import PluginManagerContextProvider from './contexts/pluginmanagercontext' import './remix-ui-plugin-manager.css' -/* eslint-disable-next-line */ -export interface PluginManagerContextProviderProps { - appManager: RemixAppManager - engine: RemixEngine - _paq: _Paq - filter: string - actives: Profile[] - inactives: Profile[] - activatePlugin: (name: string) => void - deActivatePlugin: (name: string) => void - isActive: (name: string) => any - openLocalPlugin: () => Promise - filterPlugins: () => void - profile: Profile - tileLabel: TileLabel -} - -export interface RemixUiPluginManagerProps { - appManager: RemixAppManager - engine: RemixEngine - _paq: _Paq - filter: string - actives: Profile[] - inactives: Profile[] - activatePlugin: (name: string) => void - deActivatePlugin: (name: string) => void - isActive: (name: string) => any - openLocalPlugin: () => Promise - filterPlugins: () => void - profile: Profile - tileLabel: TileLabel -} - -export const PluginManagerContext = createContext>({}) - -function PluginManagerContextProvider ({ children, props }) { - const [isFiltered] = useState((profile) => - (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(props.filter)) - const [isNotRequired, setIsNotRequired] = useState() - const [isNotDependent, setIsNotDependent] = useState() - const [isNotHome, setIsNotHome] = useState() - const [sortByName, setSortByName] = useState() - const { actives, inactives } = props.appManager.getAll() - .filter(isFiltered) - .filter(isNotRequired) - .filter(isNotDependent) - .filter(isNotHome) - .sort(sortByName) - .reduce(({ actives, inactives }, profile) => { - return props.isActive(profile.name) - ? { actives: [...actives, profile], inactives } - : { inactives: [...inactives, profile], actives } - }, { actives: [], inactives: [] }) - props.actives = actives - props.inactives = inactives - useEffect(() => { - const notRequired = (profile: Profile) => !props.appManager.isRequired(profile.name) - const notDependent = (profile) => !props.appManager.isDependent(profile.name) - const notHome = (profile) => profile.name !== 'home' - const sortedByName = (profileA: Profile, profileB: Profile) => { - const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase() - const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase() - return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0 - } - setIsNotRequired(notRequired(props.profile)) - setIsNotDependent(notDependent(notDependent)) - setIsNotHome(notHome) - setSortByName(sortedByName) - }, [props.appManager, props.profile]) - return ( - - {children} - - ) -} - export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { + console.log('current state of appmanager', props.appManager) return ( - - + // + // + // + +

Remix UI Plugin Manager React

+
) } diff --git a/libs/remix-ui/plugin-manager/src/types.d.ts b/libs/remix-ui/plugin-manager/src/types.d.ts index 4167ddc17b..0ee4d6ca44 100644 --- a/libs/remix-ui/plugin-manager/src/types.d.ts +++ b/libs/remix-ui/plugin-manager/src/types.d.ts @@ -60,6 +60,42 @@ export class RemixAppManager extends PluginManager { isRequired(name: any): any; registeredPlugins(): Promise; } + +export interface PluginManagerContextProviderProps { + appManager: RemixAppManager + engine: RemixEngine + _paq: _Paq + filter: string + actives: Profile[] + inactives: Profile[] + activatePlugin: (name: string) => void + deActivatePlugin: (name: string) => void + isActive: (name: string) => any + openLocalPlugin: () => Promise + filterPlugins: () => void + profile: Profile + inactivesCount: number + activesCount: number + headingLabel: string +} + +export interface RemixUiPluginManagerProps { + appManager: RemixAppManager + engine: RemixEngine + _paq: _Paq + filter: string + actives: Profile[] + inactives: Profile[] + activatePlugin: (name: string) => void + deActivatePlugin: (name: string) => void + isActive: (name: string) => any + openLocalPlugin: () => Promise + filterPlugins: () => void + profile: Profile + inactivesCount: number + activesCount: number + headingLabel: string +} /** @class Reference loaders. * A loader is a get,set based object which load a workspace from a defined sources. * (localStorage, queryParams) From e9444c1b978bc0ffec810408c7d253ddec7ceb46 Mon Sep 17 00:00:00 2001 From: joseph izang Date: Wed, 7 Jul 2021 11:32:37 +0100 Subject: [PATCH 012/209] rename activeTile to moduleHeading. add changes to pluginCard --- .../components/plugin-manager-component.js | 1 + .../src/lib/components/button.tsx | 16 ++++---- .../{activeTile.tsx => moduleHeading.tsx} | 0 .../src/lib/components/pluginCard.tsx | 40 ++++++++++++------- .../src/lib/components/rootView.tsx | 10 +++-- .../src/lib/remix-ui-plugin-manager.tsx | 1 + libs/remix-ui/plugin-manager/src/types.d.ts | 2 +- 7 files changed, 42 insertions(+), 28 deletions(-) rename libs/remix-ui/plugin-manager/src/lib/components/{activeTile.tsx => moduleHeading.tsx} (100%) 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 a37232e5f8..c0ee59c73f 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -151,6 +151,7 @@ class PluginManagerComponent extends ViewPlugin { engine={this.engine} activesCount={3} inactivesCount={4} + isActive={() => false} actives={[]} inactives={[]} />, 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 10cb650379..2d7bf93c31 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx @@ -1,19 +1,17 @@ -import React from 'react' +import React, { useContext } from 'react' +import { PluginManagerContext } from '../contexts/pluginmanagercontext' interface ButtonProps { - profileName: string - deactivatePlugin?: (name: string) => {} - activatePlugin?: (name: string) => {} - isActive: boolean - buttonText?: string + buttonText: 'Activate' | 'Deactivate' } -function Button ({ profileName, deactivatePlugin, buttonText }: ButtonProps) { - const dataId = `pluginManagerComponentDeactivateButton${profileName}` +function Button ({ buttonText }: ButtonProps) { + const { profile, deActivatePlugin, activatePlugin } = useContext(PluginManagerContext) + const dataId = `pluginManagerComponentDeactivateButton${profile.name}` return (