From f56322337589b3e2cf310f6adaa0ef3af465cf89 Mon Sep 17 00:00:00 2001 From: OttoMation-Movai Date: Thu, 31 Aug 2023 15:40:22 +0000 Subject: [PATCH 1/2] [skip actions] Automatic Bump of build version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 53817d6a..bb338712 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mov-ai/mov-fe-lib-ide", - "version": "1.2.0-1", + "version": "1.2.0-2", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index fc630761..e53f1fba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mov-ai/mov-fe-lib-ide", - "version": "1.2.0-1", + "version": "1.2.0-2", "main": "./dist/index.js", "exports": { ".": { From d81fb9421be8a25bb637f159eae499c1d40d4b6c Mon Sep 17 00:00:00 2001 From: Paulo Andre Azevedo Quirino Date: Fri, 1 Sep 2023 12:34:09 +0100 Subject: [PATCH 2/2] Resolve deploy errors and regression with Flow --- .eslintrc.cjs | 32 + .eslintrc.js | 24 - .swcrc | 31 +- .../@mov-ai/mov-fe-lib-code-editor.js | 0 .../@mov-ai/mov-fe-lib-react.js | 0 {src/__mocks__ => __mocks__}/fileMock.js | 0 jest.config.cjs => jest.config.mjs | 8 +- package-lock.json | 357 +++++++++- package.json | 14 +- package/package.json | 107 --- src/__mocks__/@mov-ai/mov-fe-lib-core.js | 4 - .../Callback/view/dialogs/AddImport.jsx | 3 +- .../Callback/view/dialogs/EditMessage.jsx | 3 +- ...nkManager.test.js => LinkManager.test.jsx} | 0 src/editors/Flow/view/Flow.jsx | 630 +++++++++--------- .../KeyValueTable/KeyValueEditorDialog.jsx | 3 +- .../KeyValueTable/ParametersEditorDialog.jsx | 3 +- .../{Manager.test.js => Manager.test.jsx} | 0 src/plugins/Dialog/Dialog.jsx | 3 +- .../Dialog/components/AppDialog/AppDialog.jsx | 3 +- .../components/FormDialog/FormDialog.jsx | 3 +- src/utils/{Constants.js => Constants.mjs} | 0 tsconfig.json | 2 +- 23 files changed, 729 insertions(+), 501 deletions(-) create mode 100644 .eslintrc.cjs delete mode 100644 .eslintrc.js rename {src/__mocks__ => __mocks__}/@mov-ai/mov-fe-lib-code-editor.js (100%) rename {src/__mocks__ => __mocks__}/@mov-ai/mov-fe-lib-react.js (100%) rename {src/__mocks__ => __mocks__}/fileMock.js (100%) rename jest.config.cjs => jest.config.mjs (67%) delete mode 100644 package/package.json delete mode 100644 src/__mocks__/@mov-ai/mov-fe-lib-core.js rename src/editors/Flow/model/subModels/Link/{LinkManager.test.js => LinkManager.test.jsx} (100%) rename src/models/Manager/{Manager.test.js => Manager.test.jsx} (100%) rename src/utils/{Constants.js => Constants.mjs} (100%) diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..ad95fad0 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,32 @@ +module.exports = { + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint", "react"], + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended" + ], + rules: { + // Add your rules here. For instance: + }, + env: { + "browser": true, + "es2021": true + }, + overrides: [], + parserOptions: { + "ecmaVersion": "latest", + "sourceType": "module" + }, + rules: { + "react/prop-types": 0, + "react/display-name": 0, + '@typescript-eslint/no-use-before-define': ['error'] + }, + settings: { + react: { + version: "detect", + } + } +} diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 9e9df8ad..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:react-hooks/recommended" - ], - "overrides": [ - ], - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "react", - ], - "rules": { - "react/prop-types": 0, - "react/display-name": 0 - } -} diff --git a/.swcrc b/.swcrc index cbcb73dd..7fcfe8a6 100644 --- a/.swcrc +++ b/.swcrc @@ -1,33 +1,14 @@ -[{ +{ "$schema": "https://json.schemastore.org/swcrc", + "module": { + "type": "commonjs" + }, "jsc": { "parser": { "syntax": "typescript", "tsx": true, - "dynamicImport": false, - "privateMethod": false, - "functionBind": false, - "exportDefaultFrom": false, - "exportNamespaceFrom": false, - "decorators": false, - "decoratorsBeforeExport": false, - "topLevelAwait": false, - "importMeta": false, - "emotion": true - }, - "target": "es2020", - "loose": false, - "externalHelpers": false, - "keepClassNames": false - }, - "minify": false -}, { - "$schema": "https://json.schemastore.org/swcrc", - "jsc": { - "parser": { - "syntax": "ecmascript", "jsx": true, - "dynamicImport": false, + "dynamicImport": true, "privateMethod": false, "functionBind": false, "exportDefaultFrom": false, @@ -44,4 +25,4 @@ "keepClassNames": false }, "minify": false -}] +} diff --git a/src/__mocks__/@mov-ai/mov-fe-lib-code-editor.js b/__mocks__/@mov-ai/mov-fe-lib-code-editor.js similarity index 100% rename from src/__mocks__/@mov-ai/mov-fe-lib-code-editor.js rename to __mocks__/@mov-ai/mov-fe-lib-code-editor.js diff --git a/src/__mocks__/@mov-ai/mov-fe-lib-react.js b/__mocks__/@mov-ai/mov-fe-lib-react.js similarity index 100% rename from src/__mocks__/@mov-ai/mov-fe-lib-react.js rename to __mocks__/@mov-ai/mov-fe-lib-react.js diff --git a/src/__mocks__/fileMock.js b/__mocks__/fileMock.js similarity index 100% rename from src/__mocks__/fileMock.js rename to __mocks__/fileMock.js diff --git a/jest.config.cjs b/jest.config.mjs similarity index 67% rename from jest.config.cjs rename to jest.config.mjs index 253bd647..b28b7675 100644 --- a/jest.config.cjs +++ b/jest.config.mjs @@ -1,12 +1,13 @@ -module.exports = { +export default { verbose: true, transformIgnorePatterns: [ "/dist/", - "/node_modules/(?!(?:@mov-ai/.*|@babylonjs/core)/)", + "/../../libs/(?!(core)/)", + "/node_modules/(?!(@babylonjs/core|@mov-ai/mov-fe-lib-core)/)" ], testPathIgnorePatterns: ["/node_modules/", "/dist/"], testEnvironment: "jsdom", - moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + moduleFileExtensions: ["ts", "tsx", "js", "mjs", "jsx", "json", "node"], moduleNameMapper: { "^@babylonjs/core$": "/__mocks__/@babylonjs/core.js", "\\.(svg)$": "/__mocks__/mockSvg.js", @@ -16,3 +17,4 @@ module.exports = { "^.+\\.(js|jsx|ts|tsx)?$": "@swc/jest", } }; + diff --git a/package-lock.json b/package-lock.json index bb338712..29418129 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@mov-ai/mov-fe-lib-ide", - "version": "1.2.0-1", + "version": "1.2.0-2", "license": "ISC", "dependencies": { "@emotion/react": "^11.4.1", @@ -55,18 +55,20 @@ "@types/react": "^16.14.45", "@types/react-dom": "^16.9.19", "@types/testing-library__jest-dom": "^5.9.5", - "eslint": "^8.43.0", - "eslint-plugin-react": "^7.32.2", + "@typescript-eslint/eslint-plugin": "^6.5.0", + "@typescript-eslint/parser": "^6.5.0", + "eslint": "^8.48.0", + "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "http-proxy-middleware": "^2.0.4", - "jest": "^29.3.1", + "jest": "^29.6.4", "jest-environment-jsdom": "^29.0.3", "react": ">=16.14.0", "react-dom": ">=16.14.0", "react-i18next": "^11.13.0", "react-virtualized": "9.22.3", "storybook-addon-mock": "^2.4.1", - "typescript": "^4.9.5" + "typescript": "^5.2.2" }, "peerDependencies": { "@material-ui/core": ">=4.12.3", @@ -8995,6 +8997,18 @@ "version": "2.6.2", "license": "0BSD" }, + "node_modules/@mov-ai/mov-fe-lib-code-editor/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@mov-ai/mov-fe-lib-code-editor/node_modules/write-file-atomic": { "version": "4.0.2", "license": "ISC", @@ -9045,6 +9059,19 @@ "dev": true, "license": "0BSD" }, + "node_modules/@mov-ai/mov-fe-lib-core/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@mov-ai/mov-fe-lib-react": { "resolved": "../react", "link": true @@ -15932,6 +15959,12 @@ "version": "0.16.3", "license": "MIT" }, + "node_modules/@types/semver": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-cJRQXpObxfNKkFAZbJl2yjWtJCqELQIdShsogr1d2MilP8dKD9TE/nEKHkJgUNHdGKCQaf9HbIynuV2csLGVLg==", + "dev": true + }, "node_modules/@types/source-list-map": { "version": "0.1.2", "dev": true, @@ -16047,6 +16080,294 @@ "version": "21.0.0", "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.5.0.tgz", + "integrity": "sha512-2pktILyjvMaScU6iK3925uvGU87E+N9rh372uGZgiMYwafaw9SXq86U04XPq3UH6tzRvNgBsub6x2DacHc33lw==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.5.0", + "@typescript-eslint/type-utils": "6.5.0", + "@typescript-eslint/utils": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/@typescript-eslint/parser": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.5.0.tgz", + "integrity": "sha512-LMAVtR5GN8nY0G0BadkG0XIe4AcNMeyEy3DyhKGAh9k4pLSMBO7rF29JvDBpZGCmp5Pgz5RLHP6eCpSYZJQDuQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.5.0", + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/typescript-estree": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.5.0.tgz", + "integrity": "sha512-A8hZ7OlxURricpycp5kdPTH3XnjG85UpJS6Fn4VzeoH4T388gQJ/PGP4ole5NfKt4WDVhmLaQ/dBLNDC4Xl/Kw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.5.0.tgz", + "integrity": "sha512-f7OcZOkRivtujIBQ4yrJNIuwyCQO1OjocVqntl9dgSIZAdKqicj3xFDqDOzHDlGCZX990LqhLQXWRnQvsapq8A==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.5.0", + "@typescript-eslint/utils": "6.5.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.5.0.tgz", + "integrity": "sha512-eqLLOEF5/lU8jW3Bw+8auf4lZSbbljHR2saKnYqON12G/WsJrGeeDHWuQePoEf9ro22+JkbPfWQwKEC5WwLQ3w==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.5.0.tgz", + "integrity": "sha512-q0rGwSe9e5Kk/XzliB9h2LBc9tmXX25G0833r7kffbl5437FPWb2tbpIV9wAATebC/018pGa9fwPDuvGN+LxWQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.5.0.tgz", + "integrity": "sha512-9nqtjkNykFzeVtt9Pj6lyR9WEdd8npPhhIPM992FWVkZuS6tmxHfGVnlUcjpUP2hv8r4w35nT33mlxd+Be1ACQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.5.0", + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/typescript-estree": "6.5.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.5.0.tgz", + "integrity": "sha512-yCB/2wkbv3hPsh02ZS8dFQnij9VVQXJMN/gbQsaaY+zxALkZnxa/wagvLEFsAWMPv7d7lxQmNsIzGU1w/T/WyA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.5.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "dev": true, @@ -20873,8 +21194,9 @@ }, "node_modules/eslint": { "version": "8.48.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz", + "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==", "dev": true, - "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -20926,8 +21248,9 @@ }, "node_modules/eslint-plugin-react": { "version": "7.33.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.33.2.tgz", + "integrity": "sha512-73QQMKALArI8/7xGLNI/3LylrEYrlKZSb5C9+q3OtOewTnMQi5cT+aE9E41sLCmli3I9PGGmD1yiZydyo4FEPw==", "dev": true, - "license": "MIT", "dependencies": { "array-includes": "^3.1.6", "array.prototype.flatmap": "^1.3.1", @@ -33597,6 +33920,18 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/ts-api-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.2.tgz", + "integrity": "sha512-Cbu4nIqnEdd+THNEsBdkolnOXhg0I8XteoHaEKgvsxpsbWda4IsUut2c187HxywQCvveojow0Dgw/amxtSKVkQ==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-dedent": { "version": "2.2.0", "dev": true, @@ -33743,14 +34078,16 @@ } }, "node_modules/typescript": { - "version": "4.9.5", - "license": "Apache-2.0", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uglify-js": { diff --git a/package.json b/package.json index e53f1fba..418af43b 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@mov-ai/mov-fe-lib-ide", "version": "1.2.0-2", "main": "./dist/index.js", + "type": "module", "exports": { ".": { "default": "./dist/index.js" @@ -23,9 +24,10 @@ "license": "ISC", "homepage": "https://github.com/MOV-AI/frontend-npm-lib-ide/blob/main/README.md", "scripts": { - "test": "node --experimental-vm-modules ./node_modules/.bin/jest", + "test": "NODE_OPTIONS=--experimental-vm-modules jest", "testDev": "jest --watchAll", "build": "tsc && cd src && find . -type f -exec cp --parents {} ../dist/ \\;", + "lint": "./node_modules/.bin/eslint --format compact --ext .js,.jsx,.ts,.tsx src/", "clean": "rm -rf node_modules/ package-lock.json", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook" @@ -89,18 +91,20 @@ "@types/react": "^16.14.45", "@types/react-dom": "^16.9.19", "@types/testing-library__jest-dom": "^5.9.5", - "eslint": "^8.43.0", - "eslint-plugin-react": "^7.32.2", + "@typescript-eslint/eslint-plugin": "^6.5.0", + "@typescript-eslint/parser": "^6.5.0", + "eslint": "^8.48.0", + "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "http-proxy-middleware": "^2.0.4", - "jest": "^29.3.1", + "jest": "^29.6.4", "jest-environment-jsdom": "^29.0.3", "react": ">=16.14.0", "react-dom": ">=16.14.0", "react-i18next": "^11.13.0", "react-virtualized": "9.22.3", "storybook-addon-mock": "^2.4.1", - "typescript": "^4.9.5" + "typescript": "^5.2.2" }, "files": [ "dist" diff --git a/package/package.json b/package/package.json deleted file mode 100644 index 38976e42..00000000 --- a/package/package.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "name": "@mov-ai/mov-fe-lib-ide", - "version": "1.2.0-1", - "main": "./dist/index.js", - "exports": { - ".": { - "default": "./dist/index.js" - }, - "./package.json": "./package.json", - "./dist/*": "./dist/*" - }, - "repository": { - "type": "git", - "url": "https://github.com/MOV-AI/frontend-npm-lib-ide.git" - }, - "keywords": [ - "frontend", - "ide", - "react", - "lib" - ], - "author": "MOV.AI", - "license": "ISC", - "homepage": "https://github.com/MOV-AI/frontend-npm-lib-ide/blob/main/README.md", - "scripts": { - "test": "node --experimental-vm-modules ./node_modules/.bin/jest", - "testDev": "jest --watchAll", - "build": "tsc && cd src && find . -type f -exec cp --parents {} ../dist/ \\;", - "clean": "rm -rf node_modules/ package-lock.json", - "storybook": "start-storybook -p 6006", - "build-storybook": "build-storybook" - }, - "dependencies": { - "@emotion/react": "^11.4.1", - "@emotion/styled": "^11.3.0", - "@material-table/core": "^4.3.11", - "@mov-ai/mov-fe-lib-code-editor": "^1.0.8-2", - "@remixproject/engine": "^0.3.19", - "@remixproject/engine-web": "^0.3.19", - "d3": "^5.16.0", - "hotkeys-js": "^3.8.7", - "joi": "^17.4.2", - "lodash": "^4.17.21", - "monet": "^0.9.2", - "rc-dock": "^3.2.2", - "react-virtualized": "^9.22.3", - "react-virtualized-auto-sizer": "^1.0.6", - "react-virtualized-tree": "^3.4.1", - "react-window": "^1.8.7", - "rxjs": "^6.6.7", - "web-vitals": "^1.1.2" - }, - "peerDependencies": { - "@material-ui/core": ">=4.12.3", - "@material-ui/icons": ">=4.11.2", - "@material-ui/lab": ">=4.0.0-alpha.60", - "@material-ui/styles": ">=4.11.4", - "@mov-ai/mov-fe-lib-react": "file:../react", - "@tty-pt/styles": "^0.1.7", - "react": "^16.14.0", - "react-dom": "^16.14.0", - "react-i18next": "^11.13.0" - }, - "devDependencies": { - "@codingame/monaco-languageclient": "^0.17.4", - "@material-ui/core": ">=4.12.3", - "@material-ui/icons": ">=4.11.2", - "@material-ui/lab": ">=4.0.0-alpha.60", - "@material-ui/styles": ">=4.11.4", - "@mov-ai/mov-fe-lib-core": "^1.1.2-25", - "@mov-ai/mov-fe-lib-react": "file:../react", - "@storybook/addon-actions": "^6.5.12", - "@storybook/addon-essentials": "^6.5.12", - "@storybook/addon-interactions": "^6.5.12", - "@storybook/addon-links": "^6.5.12", - "@storybook/builder-webpack5": "^6.5.12", - "@storybook/manager-webpack5": "^6.5.12", - "@storybook/react": "^6.5.12", - "@storybook/testing-library": "^0.0.13", - "@swc/cli": "^0.1.62", - "@swc/core": "^1.3.56", - "@swc/jest": "^0.2.26", - "@testing-library/jest-dom": "^5.14.1", - "@testing-library/react": "^11.2.7", - "@testing-library/user-event": "^12.8.3", - "@tty-pt/styles": "^0.1.7", - "@types/jest": "^26.0.23", - "@types/node": "^20.5.6", - "@types/react": "^16.14.45", - "@types/react-dom": "^16.9.19", - "@types/testing-library__jest-dom": "^5.9.5", - "eslint": "^8.43.0", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-hooks": "^4.6.0", - "http-proxy-middleware": "^2.0.4", - "jest": "^29.3.1", - "jest-environment-jsdom": "^29.0.3", - "react": ">=16.14.0", - "react-dom": ">=16.14.0", - "react-i18next": "^11.13.0", - "storybook-addon-mock": "^2.4.1", - "typescript": "^4.9.5" - }, - "files": [ - "dist" - ] -} diff --git a/src/__mocks__/@mov-ai/mov-fe-lib-core.js b/src/__mocks__/@mov-ai/mov-fe-lib-core.js deleted file mode 100644 index 670b109c..00000000 --- a/src/__mocks__/@mov-ai/mov-fe-lib-core.js +++ /dev/null @@ -1,4 +0,0 @@ -import { Utils as UtilsOriginal } from "@mov-ai/mov-fe-lib-core" -export const Utils = { randomId: UtilsOriginal.randomId }; -export const CONSTANTS = { GLOBAL_WORKSPACE: "global" } -export const MasterDB = { subscribe: () => { } } diff --git a/src/editors/Callback/view/dialogs/AddImport.jsx b/src/editors/Callback/view/dialogs/AddImport.jsx index 083d99fc..6028512f 100644 --- a/src/editors/Callback/view/dialogs/AddImport.jsx +++ b/src/editors/Callback/view/dialogs/AddImport.jsx @@ -9,7 +9,6 @@ import { DialogActions } from "@material-ui/core"; import { PLUGINS } from "../../../../utils/Constants"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import { DialogTitle } from "../../../../plugins/Dialog/components/AppDialog/AppDialog"; import Loader from "../../../_shared/Loader/Loader"; import MaterialTree from "../../../_shared/MaterialTree/MaterialTree"; @@ -156,4 +155,4 @@ const AddImportDialog = props => { ); }; -export default withTheme(AddImportDialog); +export default AddImportDialog; diff --git a/src/editors/Callback/view/dialogs/EditMessage.jsx b/src/editors/Callback/view/dialogs/EditMessage.jsx index 26509b03..58915932 100644 --- a/src/editors/Callback/view/dialogs/EditMessage.jsx +++ b/src/editors/Callback/view/dialogs/EditMessage.jsx @@ -9,7 +9,6 @@ import { DialogActions } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import { PLUGINS } from "../../../../utils/Constants"; import { ERROR_MESSAGES } from "../../../../utils/Messages"; import { DialogTitle } from "../../../../plugins/Dialog/components/AppDialog/AppDialog"; @@ -196,4 +195,4 @@ const EditMessageDialog = props => { ); }; -export default withTheme(EditMessageDialog); +export default EditMessageDialog; diff --git a/src/editors/Flow/model/subModels/Link/LinkManager.test.js b/src/editors/Flow/model/subModels/Link/LinkManager.test.jsx similarity index 100% rename from src/editors/Flow/model/subModels/Link/LinkManager.test.js rename to src/editors/Flow/model/subModels/Link/LinkManager.test.jsx diff --git a/src/editors/Flow/view/Flow.jsx b/src/editors/Flow/view/Flow.jsx index ff5faa30..e8fdc9ed 100644 --- a/src/editors/Flow/view/Flow.jsx +++ b/src/editors/Flow/view/Flow.jsx @@ -134,6 +134,13 @@ export const Flow = (props, ref) => { return flowClasses[viewMode] ?? GraphBase; }; + /** + * @private Get main interface instance + */ + const getMainInterface = () => { + return mainInterfaceRef.current; + }; + /** * Updates the status of flow debugging variable on graph * And then re strokes the links (to add or remove the debug colors) @@ -152,32 +159,6 @@ export const Flow = (props, ref) => { updateLinkStroke(); }, [flowDebugging, updateLinkStroke]); - /** - * Start node - * @param {Object} target : Node to be started - */ - const startNode = useCallback( - node => { - commandNode("RUN", node).then(() => { - node.statusLoading = true; - }); - }, - [commandNode] - ); - - /** - * Stop node - * @param {Object} target : Node to be stopped - */ - const stopNode = useCallback( - node => { - commandNode("KILL", node).then(() => { - node.statusLoading = true; - }); - }, - [commandNode] - ); - /** * Execute command action to node to start or stop * @@ -224,19 +205,38 @@ export const Flow = (props, ref) => { [call, robotSelected, t] ); + /** + * Start node + * @param {Object} target : Node to be started + */ + const startNode = useCallback( + node => { + commandNode("RUN", node).then(() => { + node.statusLoading = true; + }); + }, + [commandNode] + ); + + /** + * Stop node + * @param {Object} target : Node to be stopped + */ + const stopNode = useCallback( + node => { + commandNode("KILL", node).then(() => { + node.statusLoading = true; + }); + }, + [commandNode] + ); + //======================================================================================== /* * * Helper * * */ //======================================================================================== - /** - * @private Get main interface instance - */ - const getMainInterface = () => { - return mainInterfaceRef.current; - }; - /** * Set mode * @param {string} mode : Interface mode @@ -413,42 +413,50 @@ export const Flow = (props, ref) => { ); /** - * Open Dialog to Enter Paste Node name - * @param {*} position : x and y position in canvas - * @param {*} nodeToCopy : Node data - * @returns {Promise} Resolved only after submit or cancel dialog + * Remove Node Bookmark and set selectedNode to null */ - const pasteNodeDialog = useCallback( - (position, nodeToCopy) => { - const node = nodeToCopy.node; - return new Promise(resolve => { - const args = { - title: t("PasteNodeModel", { nodeModel: node.model }), - value: `${node.id}_copy`, - onClose: () => { - setFlowsToDefault(); - resolve(); - }, - onValidation: newName => - getMainInterface().graph.validator.validateNodeName( - newName, - t(node.model) - ), - onSubmit: newName => - getMainInterface().pasteNode(newName, node, position) - }; - // Open Dialog - call(PLUGINS.DIALOG.NAME, PLUGINS.DIALOG.CALL.FORM_DIALOG, args); - }); - }, - [call, setFlowsToDefault, t] - ); + const unselectNode = useCallback(() => { + call( + PLUGINS.RIGHT_DRAWER.NAME, + PLUGINS.RIGHT_DRAWER.CALL.REMOVE_BOOKMARK, + MENUS.current.NODE.NAME, + MENUS.current.DETAIL.NAME + ); + selectedNodeRef.current = null; + }, [call, selectedNodeRef]); - //======================================================================================== - /* * - * Right menu initialization * - * */ - //======================================================================================== + /** + * Call broadcast method to emit event to all open flows + */ + const setFlowsToDefault = useCallback(() => { + activateEditor(); + + // Remove selected node and link bookmark + clearTimeout(debounceSelection.current); + contextArgs.current = null; + debounceSelection.current = setTimeout(unselectNode, 300); + unselectNode(); + + // unselect link + activateEditor(); + selectedLinkRef.current = null; + getMainInterface().selectedLink = null; + call( + PLUGINS.RIGHT_DRAWER.NAME, + PLUGINS.RIGHT_DRAWER.CALL.REMOVE_BOOKMARK, + MENUS.current.LINK.NAME, + activeBookmark + ); + + // Update render of right menu + // broadcast event to other flows + call( + PLUGINS.DOC_MANAGER.NAME, + PLUGINS.DOC_MANAGER.CALL.BROADCAST, + PLUGINS.DOC_MANAGER.ON.FLOW_EDITOR, + { action: "setMode", value: EVT_NAMES.DEFAULT } + ); + }, [unselectNode, call, activateEditor]); /** * @private Get Menu component based on node model (Flow or Node) @@ -552,6 +560,111 @@ export const Flow = (props, ref) => { [call, getLinkMenuToAdd] ); + /** + * On Link selected + * @param {BaseLink} link : Link instance + */ + const onLinkSelected = useCallback( + link => { + activateEditor(); + selectedLinkRef.current = link; + getMainInterface().selectedLink = link; + const currentMode = getMainInterface().mode.mode; + // We only want 1 selection at the time. + // So let's unselect nodes if any is selected + if ( + currentMode.id === EVT_NAMES.SELECT_NODE && + currentMode.props.shiftKey + ) { + // If we're making multiple node selection we need to reset the mode + getMainInterface().setMode(EVT_NAMES.DEFAULT); + // Since we resetted the mode, we need to add back the selected link + getMainInterface().selectedLink = link; + } else if (selectedNodeRef.current) { + // If we just selected 1 node, it's ok, let's just unselect it + selectedNodeRef.current.selected = false; + } + + // Remove node menu + unselectNode(); + + activeBookmark = MENUS.current.LINK.NAME; + addLinkMenu(link, true); + }, + [activateEditor, unselectNode, addLinkMenu] + ); + + /** + * On Node Selected + * @param {*} node + */ + const onNodeSelected = useCallback( + node => { + clearTimeout(debounceSelection.current); + contextArgs.current = node; + debounceSelection.current = setTimeout(() => { + // We only want 1 selection at the time. + // So let's unselect links if any is selected + if (selectedLinkRef.current) { + // unselect link + activateEditor(); + selectedLinkRef.current = null; + getMainInterface().selectedLink = null; + call( + PLUGINS.RIGHT_DRAWER.NAME, + PLUGINS.RIGHT_DRAWER.CALL.REMOVE_BOOKMARK, + MENUS.current.LINK.NAME, + activeBookmark + ); + } + + + selectedNodeRef.current = node; + activeBookmark = MENUS.current.NODE.NAME; + addNodeMenu(node, true); + }, 300); + }, + [activateEditor, call, addNodeMenu] + ); + + /** + * Open Dialog to Enter Paste Node name + * @param {*} position : x and y position in canvas + * @param {*} nodeToCopy : Node data + * @returns {Promise} Resolved only after submit or cancel dialog + */ + const pasteNodeDialog = useCallback( + (position, nodeToCopy) => { + const node = nodeToCopy.node; + return new Promise(resolve => { + const args = { + title: t("PasteNodeModel", { nodeModel: node.model }), + value: `${node.id}_copy`, + onClose: () => { + setFlowsToDefault(); + resolve(); + }, + onValidation: newName => + getMainInterface().graph.validator.validateNodeName( + newName, + t(node.model) + ), + onSubmit: newName => + getMainInterface().pasteNode(newName, node, position) + }; + // Open Dialog + call(PLUGINS.DIALOG.NAME, PLUGINS.DIALOG.CALL.FORM_DIALOG, args); + }); + }, + [setFlowsToDefault, call, t] + ); + + //======================================================================================== + /* * + * Right menu initialization * + * */ + //======================================================================================== + const renderRightMenu = useCallback(() => { const details = props.data?.details || {}; const bookmarks = { @@ -682,87 +795,6 @@ export const Flow = (props, ref) => { * */ //======================================================================================== - /** - * Remove Node Bookmark and set selectedNode to null - */ - const unselectNode = useCallback(() => { - call( - PLUGINS.RIGHT_DRAWER.NAME, - PLUGINS.RIGHT_DRAWER.CALL.REMOVE_BOOKMARK, - MENUS.current.NODE.NAME, - MENUS.current.DETAIL.NAME - ); - selectedNodeRef.current = null; - }, [call, selectedNodeRef]); - - /** - * On Node Selected - * @param {*} node - */ - const onNodeSelected = useCallback( - node => { - clearTimeout(debounceSelection.current); - contextArgs.current = node; - debounceSelection.current = setTimeout(() => { - if (!node) { - unselectNode(); - } else { - // We only want 1 selection at the time. - // So let's unselect links if any is selected - if (selectedLinkRef.current) onLinkSelected(null); - - selectedNodeRef.current = node; - activeBookmark = MENUS.current.NODE.NAME; - addNodeMenu(node, true); - } - }, 300); - }, - [addNodeMenu, unselectNode, onLinkSelected] - ); - - /** - * On Link selected - * @param {BaseLink} link : Link instance - */ - const onLinkSelected = useCallback( - link => { - activateEditor(); - selectedLinkRef.current = link; - getMainInterface().selectedLink = link; - if (!link) { - call( - PLUGINS.RIGHT_DRAWER.NAME, - PLUGINS.RIGHT_DRAWER.CALL.REMOVE_BOOKMARK, - MENUS.current.LINK.NAME, - activeBookmark - ); - } else { - const currentMode = getMainInterface().mode.mode; - // We only want 1 selection at the time. - // So let's unselect nodes if any is selected - if ( - currentMode.id === EVT_NAMES.SELECT_NODE && - currentMode.props.shiftKey - ) { - // If we're making multiple node selection we need to reset the mode - getMainInterface().setMode(EVT_NAMES.DEFAULT); - // Since we resetted the mode, we need to add back the selected link - getMainInterface().selectedLink = link; - } else if (selectedNodeRef.current) { - // If we just selected 1 node, it's ok, let's just unselect it - selectedNodeRef.current.selected = false; - } - - // Remove node menu - unselectNode(); - - activeBookmark = MENUS.current.LINK.NAME; - addLinkMenu(link, true); - } - }, - [activateEditor, call, unselectNode, addLinkMenu] - ); - /** * Close context menu */ @@ -772,23 +804,148 @@ export const Flow = (props, ref) => { getMainInterface().setMode(EVT_NAMES.DEFAULT); }, []); - /** - * Call broadcast method to emit event to all open flows - */ - const setFlowsToDefault = useCallback(() => { - activateEditor(); - // Remove selected node and link bookmark - onNodeSelected(null); - onLinkSelected(null); - // Update render of right menu - // broadcast event to other flows - call( - PLUGINS.DOC_MANAGER.NAME, - PLUGINS.DOC_MANAGER.CALL.BROADCAST, - PLUGINS.DOC_MANAGER.ON.FLOW_EDITOR, - { action: "setMode", value: EVT_NAMES.DEFAULT } - ); - }, [call, activateEditor, onLinkSelected, onNodeSelected]); + const getContextOptions = useCallback( + (mode, data, args) => { + const baseContextOptions = getBaseContextOptions(mode, data, args); + const contextOpts = contextOptions?.(baseContextOptions)?.[mode]?.(data); + + return contextOpts ?? baseContextOptions; + }, + [contextOptions] + ); + + /** + * Handle copy node + */ + const handleCopyNode = useCallback( + evt => { + evt?.preventDefault?.(); + const selectedNodes = getSelectedNodes(); + const nodesPos = selectedNodes.map(n => + Vec2.of(n.center.xCenter, n.center.yCenter) + ); + let center = nodesPos.reduce((e, x) => e.add(x), Vec2.ZERO); + center = center.scale(1 / selectedNodes.length); + // Nodes to copy + const nodesToCopy = { + nodes: selectedNodes.map(n => n.data), + flow: data.id, + nodesPosFromCenter: nodesPos.map(pos => pos.sub(center)) + }; + // Write nodes to copy to clipboard + clipboard.write(KEYS.NODES_TO_COPY, nodesToCopy); + }, + [clipboard, getSelectedNodes, data.id] + ); + + /** + * Handle Delete : Show confirmation dialog before performing delete action + * @param {{nodeId: string, callback: function}} data + */ + const handleDelete = useCallback( + ({ message, callback }) => { + confirmationAlert({ + submitText: t("Delete"), + title: t("ConfirmDelete"), + onSubmit: callback, + onClose: setFlowsToDefault, + message + }); + }, + [confirmationAlert, t, setFlowsToDefault] + ); + + /** + * Handle delete node + */ + const handleDeleteNode = useCallback(() => { + const selectedNodes = getSelectedNodes(); + if (!selectedNodes.length) return; + // Callback to delete all nodes + const callback = () => { + selectedNodes.forEach(node => { + getMainInterface().deleteNode(node.data); + }); + unselectNode(); + }; + // Compose confirmation message + const message = t("NodeDeleteConfirmation", { + nodes: + selectedNodes.length === 1 + ? selectedNodes[0].data.id + : t("TheSelectedNodes") + }); + // Show confirmation before delete + handleDelete({ message, callback }); + }, [handleDelete, unselectNode, getSelectedNodes, t]); + + /** + * Handle paste nodes in canvas + */ + const handlePasteNodes = useCallback( + async evt => { + evt?.preventDefault?.(); + const position = (contextArgs.current = + getMainInterface().canvas.mousePosition); + const nodesToCopy = clipboard.read(KEYS.NODES_TO_COPY); + if (!nodesToCopy) return; + + for (const [i, node] of nodesToCopy.nodes.entries()) { + const nodesPosFromCenter = nodesToCopy.nodesPosFromCenter || [ + Vec2.ZERO + ]; + const newPos = Vec2.of(position.x, position.y).add( + nodesPosFromCenter[i] + ); + // Open dialog for each node to copy + await pasteNodeDialog(newPos.toObject(), { + node: node, + flow: nodesToCopy.flow + }); + } + }, + [clipboard, pasteNodeDialog] + ); + + /** + * Toggle exposed port + */ + const handleToggleExposedPort = useCallback(() => { + const port = contextArgs.current; + getMainInterface().toggleExposedPort(port); + }, []); + + /** + * Open Callback + * @param {string} callbackName : Callback name + */ + const handleOpenCallback = useCallback( + callbackName => { + // If no callback name is passed -> returns + if (!callbackName) return; + // Open existing callback + const scope = CallbackModel.SCOPE; + call(PLUGINS.DOC_MANAGER.NAME, PLUGINS.DOC_MANAGER.CALL.READ, { + scope, + name: callbackName + }).then(doc => { + call(PLUGINS.TABS.NAME, PLUGINS.TABS.CALL.OPEN_EDITOR, { + id: doc.getUrl(), + name: doc.getName(), + scope + }); + }); + }, + [call] + ); + + /** + * Handle delete link + */ + const handleDeleteLink = useCallback(() => { + const link = selectedLinkRef.current ?? contextArgs.current; + link.id && getMainInterface().deleteLink(link.id); + }, []); /** * Subscribe to mainInterface and canvas events @@ -1138,107 +1295,6 @@ export const Flow = (props, ref) => { [activateKeyBind, workspaceManager] ); - /** - * Handle Delete : Show confirmation dialog before performing delete action - * @param {{nodeId: string, callback: function}} data - */ - const handleDelete = useCallback( - ({ message, callback }) => { - confirmationAlert({ - submitText: t("Delete"), - title: t("ConfirmDelete"), - onSubmit: callback, - onClose: setFlowsToDefault, - message - }); - }, - [confirmationAlert, t, setFlowsToDefault] - ); - - /** - * Handle copy node - */ - const handleCopyNode = useCallback( - evt => { - evt?.preventDefault?.(); - const selectedNodes = getSelectedNodes(); - const nodesPos = selectedNodes.map(n => - Vec2.of(n.center.xCenter, n.center.yCenter) - ); - let center = nodesPos.reduce((e, x) => e.add(x), Vec2.ZERO); - center = center.scale(1 / selectedNodes.length); - // Nodes to copy - const nodesToCopy = { - nodes: selectedNodes.map(n => n.data), - flow: data.id, - nodesPosFromCenter: nodesPos.map(pos => pos.sub(center)) - }; - // Write nodes to copy to clipboard - clipboard.write(KEYS.NODES_TO_COPY, nodesToCopy); - }, - [clipboard, getSelectedNodes, data.id] - ); - - /** - * Handle paste nodes in canvas - */ - const handlePasteNodes = useCallback( - async evt => { - evt?.preventDefault?.(); - const position = (contextArgs.current = - getMainInterface().canvas.mousePosition); - const nodesToCopy = clipboard.read(KEYS.NODES_TO_COPY); - if (!nodesToCopy) return; - - for (const [i, node] of nodesToCopy.nodes.entries()) { - const nodesPosFromCenter = nodesToCopy.nodesPosFromCenter || [ - Vec2.ZERO - ]; - const newPos = Vec2.of(position.x, position.y).add( - nodesPosFromCenter[i] - ); - // Open dialog for each node to copy - await pasteNodeDialog(newPos.toObject(), { - node: node, - flow: nodesToCopy.flow - }); - } - }, - [clipboard, pasteNodeDialog] - ); - - /** - * Handle delete node - */ - const handleDeleteNode = useCallback(() => { - const selectedNodes = getSelectedNodes(); - if (!selectedNodes.length) return; - // Callback to delete all nodes - const callback = () => { - selectedNodes.forEach(node => { - getMainInterface().deleteNode(node.data); - }); - unselectNode(); - }; - // Compose confirmation message - const message = t("NodeDeleteConfirmation", { - nodes: - selectedNodes.length === 1 - ? selectedNodes[0].data.id - : t("TheSelectedNodes") - }); - // Show confirmation before delete - handleDelete({ message, callback }); - }, [handleDelete, unselectNode, getSelectedNodes, t]); - - /** - * Handle delete link - */ - const handleDeleteLink = useCallback(() => { - const link = selectedLinkRef.current ?? contextArgs.current; - link.id && getMainInterface().deleteLink(link.id); - }, []); - /** * Triggers the correct deletion * (if a link is selected delete link, else delete nodes) @@ -1248,38 +1304,6 @@ export const Flow = (props, ref) => { else handleDeleteNode(); }, [handleDeleteLink, handleDeleteNode]); - /** - * Toggle exposed port - */ - const handleToggleExposedPort = useCallback(() => { - const port = contextArgs.current; - getMainInterface().toggleExposedPort(port); - }, []); - - /** - * Open Callback - * @param {string} callbackName : Callback name - */ - const handleOpenCallback = useCallback( - callbackName => { - // If no callback name is passed -> returns - if (!callbackName) return; - // Open existing callback - const scope = CallbackModel.SCOPE; - call(PLUGINS.DOC_MANAGER.NAME, PLUGINS.DOC_MANAGER.CALL.READ, { - scope, - name: callbackName - }).then(doc => { - call(PLUGINS.TABS.NAME, PLUGINS.TABS.CALL.OPEN_EDITOR, { - id: doc.getUrl(), - name: doc.getName(), - scope - }); - }); - }, - [call] - ); - /** * Handle zoom reset */ @@ -1323,16 +1347,6 @@ export const Flow = (props, ref) => { activateKeyBind(); }, [activateKeyBind]); - const getContextOptions = useCallback( - (mode, data, args) => { - const baseContextOptions = getBaseContextOptions(mode, data, args); - const contextOpts = contextOptions?.(baseContextOptions)?.[mode]?.(data); - - return contextOpts ?? baseContextOptions; - }, - [contextOptions] - ); - //======================================================================================== /* * * React Lifecycle * diff --git a/src/editors/_shared/KeyValueTable/KeyValueEditorDialog.jsx b/src/editors/_shared/KeyValueTable/KeyValueEditorDialog.jsx index 07467df6..5a6e94bd 100644 --- a/src/editors/_shared/KeyValueTable/KeyValueEditorDialog.jsx +++ b/src/editors/_shared/KeyValueTable/KeyValueEditorDialog.jsx @@ -16,7 +16,6 @@ import { DialogActions, Button } from "@material-ui/core"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import { DialogTitle } from "../../../plugins/Dialog/components/AppDialog/AppDialog"; import { keyValueEditorDialogStyles } from "./styles"; @@ -299,4 +298,4 @@ function arePropsEqual(prevProps, nextProps) { return _isEqual(prevProps, nextProps); } -export default memo(withTheme(KeyValueEditorDialog), arePropsEqual); +export default memo(KeyValueEditorDialog, arePropsEqual); diff --git a/src/editors/_shared/KeyValueTable/ParametersEditorDialog.jsx b/src/editors/_shared/KeyValueTable/ParametersEditorDialog.jsx index f9c5af8f..0d6a69d3 100644 --- a/src/editors/_shared/KeyValueTable/ParametersEditorDialog.jsx +++ b/src/editors/_shared/KeyValueTable/ParametersEditorDialog.jsx @@ -10,7 +10,6 @@ import { Radio, RadioGroup } from "@material-ui/core"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import { ERROR_MESSAGES } from "../../../utils/Messages"; import { DATA_TYPES, @@ -442,4 +441,4 @@ ParameterEditorDialog.propTypes = { alert: PropTypes.func }; -export default withAlerts(withTheme(ParameterEditorDialog)); +export default withAlerts(ParameterEditorDialog); diff --git a/src/models/Manager/Manager.test.js b/src/models/Manager/Manager.test.jsx similarity index 100% rename from src/models/Manager/Manager.test.js rename to src/models/Manager/Manager.test.jsx diff --git a/src/plugins/Dialog/Dialog.jsx b/src/plugins/Dialog/Dialog.jsx index 4ae58d98..cb617a6b 100644 --- a/src/plugins/Dialog/Dialog.jsx +++ b/src/plugins/Dialog/Dialog.jsx @@ -1,7 +1,6 @@ import { Utils } from "@mov-ai/mov-fe-lib-core"; import { SelectScopeModal } from "@mov-ai/mov-fe-lib-react"; import ReactDOM from "react-dom"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import IDEPlugin from "../../engine/IDEPlugin/IDEPlugin"; import i18n from "../../i18n/i18n"; import { @@ -276,7 +275,7 @@ class Dialog extends IDEPlugin { selectScopeModal(data) { const { onSubmit, message, selected, scopeList, onClose } = data; const targetElement = this._handleDialogOpen(); - const ThemedModal = withTheme(SelectScopeModal); + const ThemedModal = SelectScopeModal; // Handle submit const handleDialogSubmit = selectedItem => { diff --git a/src/plugins/Dialog/components/AppDialog/AppDialog.jsx b/src/plugins/Dialog/components/AppDialog/AppDialog.jsx index 45989bc4..bfe9d96e 100644 --- a/src/plugins/Dialog/components/AppDialog/AppDialog.jsx +++ b/src/plugins/Dialog/components/AppDialog/AppDialog.jsx @@ -5,7 +5,6 @@ import DialogActions from "@material-ui/core/DialogActions"; import DialogContent from "@material-ui/core/DialogContent"; import MuiDialogTitle from "@material-ui/core/DialogTitle"; import CloseIcon from "@material-ui/icons/Close"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import PropTypes from "prop-types"; import React, { useCallback, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -145,4 +144,4 @@ AppDialog.defaultProps = { closeOnBackdrop: false }; -export default withTheme(AppDialog); +export default AppDialog; diff --git a/src/plugins/Dialog/components/FormDialog/FormDialog.jsx b/src/plugins/Dialog/components/FormDialog/FormDialog.jsx index 5a6d5e6c..61dd8b1b 100644 --- a/src/plugins/Dialog/components/FormDialog/FormDialog.jsx +++ b/src/plugins/Dialog/components/FormDialog/FormDialog.jsx @@ -6,7 +6,6 @@ import TextField from "@material-ui/core/TextField"; import DialogActions from "@material-ui/core/DialogActions"; import DialogContentText from "@material-ui/core/DialogContentText"; import { CircularProgress } from "@material-ui/core"; -import { withTheme } from "@mov-ai/mov-fe-lib-react"; import AppDialog from "../AppDialog/AppDialog"; import { appDialogStyles } from "./styles"; @@ -236,4 +235,4 @@ FormDialog.defaultProps = { maxLength: 40 }; -export default withTheme(FormDialog); +export default FormDialog; diff --git a/src/utils/Constants.js b/src/utils/Constants.mjs similarity index 100% rename from src/utils/Constants.js rename to src/utils/Constants.mjs diff --git a/tsconfig.json b/tsconfig.json index 818bff3a..4d5a26ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es5", - "module": "es2020", + "module": "ESNext", "baseUrl": "./src", "rootDir": "./src", "moduleResolution": "node",