From 5091eecedfca11ceb73c382716c4b091c7c2a6f9 Mon Sep 17 00:00:00 2001 From: Bogdan Bodnar Date: Wed, 15 Jan 2020 18:19:04 +0100 Subject: [PATCH 1/3] Use react-router-dom instead of react-router. --- package-lock.json | 14 ++++++++++++++ package.json | 2 +- src/form/components/ForisForm.js | 2 +- src/testUtils/customTestRender.js | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64c719c..c372f18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10212,6 +10212,20 @@ "tiny-warning": "^1.0.0" } }, + "react-router-dom": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.1.2.tgz", + "integrity": "sha512-7BPHAaIwWpZS074UKaw1FjVdZBSVWEk8IuDXdB+OkLb8vd/WRQIpA4ag9WQk61aEfQs47wHyjWUoUGGZxpQXew==", + "requires": { + "@babel/runtime": "^7.1.2", + "history": "^4.9.0", + "loose-envify": "^1.3.1", + "prop-types": "^15.6.2", + "react-router": "5.1.2", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + } + }, "react-simple-code-editor": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/react-simple-code-editor/-/react-simple-code-editor-0.10.0.tgz", diff --git a/package.json b/package.json index 682f730..23bbe39 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "pdfmake": "^0.1.63", "qrcode.react": "^0.9.3", "react-datetime": "^2.16.3", - "react-router": "^5.1.2", + "react-router-dom": "^5.1.2", "react-uid": "^2.2.0" }, "peerDependencies": { diff --git a/src/form/components/ForisForm.js b/src/form/components/ForisForm.js index c09edc5..89c087f 100644 --- a/src/form/components/ForisForm.js +++ b/src/form/components/ForisForm.js @@ -7,7 +7,7 @@ import React, { useEffect } from "react"; import PropTypes from "prop-types"; -import { Prompt } from "react-router"; +import { Prompt } from "react-router-dom"; import { ALERT_TYPES } from "../../bootstrap/Alert"; import { API_STATE } from "../../api/utils"; diff --git a/src/testUtils/customTestRender.js b/src/testUtils/customTestRender.js index fbf1718..2f55854 100644 --- a/src/testUtils/customTestRender.js +++ b/src/testUtils/customTestRender.js @@ -9,7 +9,7 @@ import React from "react"; import { UIDReset } from "react-uid"; -import { StaticRouter } from "react-router"; +import { StaticRouter } from "react-router-dom"; import { render } from "@testing-library/react"; import PropTypes from "prop-types"; From e7e389e843eb9446e29f0f6118b57b76e2656246 Mon Sep 17 00:00:00 2001 From: Bogdan Bodnar Date: Thu, 16 Jan 2020 12:23:02 +0100 Subject: [PATCH 2/3] Add react-router-dom to peer dep. --- package-lock.json | 25 +++++++++++++++++++------ package.json | 5 +++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index c372f18..9dfddf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1870,6 +1870,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.5.5.tgz", "integrity": "sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ==", + "dev": true, "requires": { "regenerator-runtime": "^0.13.2" } @@ -6579,7 +6580,8 @@ "gud": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz", - "integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==" + "integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==", + "dev": true }, "gzip-size": { "version": "5.1.1", @@ -6719,6 +6721,7 @@ "version": "4.10.1", "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", + "dev": true, "requires": { "@babel/runtime": "^7.1.2", "loose-envify": "^1.2.0", @@ -6732,6 +6735,7 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", "integrity": "sha512-wbg3bpgA/ZqWrZuMOeJi8+SKMhr7X9TesL/rXMjTzh0p0JUBo3II8DHboYbuIXWRlttrUFxwcu/5kygrCw8fJw==", + "dev": true, "requires": { "react-is": "^16.7.0" } @@ -8565,6 +8569,7 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.3.2.tgz", "integrity": "sha512-2v+OeetEyliMt5VHMXsBhABoJ0/M4RCe7fatd/fBy6SMiKazUSEt3gxxypfnk2SHMkdBYvorHRoQxuGoiwbzAw==", + "dev": true, "requires": { "@babel/runtime": "^7.4.0", "gud": "^1.0.0", @@ -9448,6 +9453,7 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "dev": true, "requires": { "isarray": "0.0.1" } @@ -10199,6 +10205,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.1.2.tgz", "integrity": "sha512-yjEuMFy1ONK246B+rsa0cUam5OeAQ8pyclRDgpxuSCrAlJ1qN9uZ5IgyKC7gQg0w8OM50NXHEegPh/ks9YuR2A==", + "dev": true, "requires": { "@babel/runtime": "^7.1.2", "history": "^4.9.0", @@ -10216,6 +10223,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.1.2.tgz", "integrity": "sha512-7BPHAaIwWpZS074UKaw1FjVdZBSVWEk8IuDXdB+OkLb8vd/WRQIpA4ag9WQk61aEfQs47wHyjWUoUGGZxpQXew==", + "dev": true, "requires": { "@babel/runtime": "^7.1.2", "history": "^4.9.0", @@ -10442,7 +10450,8 @@ "regenerator-runtime": { "version": "0.13.3", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", - "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==" + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "dev": true }, "regenerator-transform": { "version": "0.14.1", @@ -10779,7 +10788,8 @@ "resolve-pathname": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz", - "integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==" + "integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==", + "dev": true }, "resolve-url": { "version": "0.2.1", @@ -12131,12 +12141,14 @@ "tiny-invariant": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.0.6.tgz", - "integrity": "sha512-FOyLWWVjG+aC0UqG76V53yAWdXfH8bO6FNmyZOuUrzDzK8DI3/JRY25UD7+g49JWM1LXwymsKERB+DzI0dTEQA==" + "integrity": "sha512-FOyLWWVjG+aC0UqG76V53yAWdXfH8bO6FNmyZOuUrzDzK8DI3/JRY25UD7+g49JWM1LXwymsKERB+DzI0dTEQA==", + "dev": true }, "tiny-warning": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", - "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==", + "dev": true }, "tmp": { "version": "0.0.33", @@ -12727,7 +12739,8 @@ "value-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz", - "integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==" + "integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==", + "dev": true }, "vary": { "version": "1.1.2", diff --git a/package.json b/package.json index 23bbe39..242d52f 100644 --- a/package.json +++ b/package.json @@ -20,14 +20,14 @@ "pdfmake": "^0.1.63", "qrcode.react": "^0.9.3", "react-datetime": "^2.16.3", - "react-router-dom": "^5.1.2", "react-uid": "^2.2.0" }, "peerDependencies": { "bootstrap": "4.4.1", "prop-types": "15.7.2", "react": "16.9.0", - "react-dom": "16.9.0" + "react-dom": "16.9.0", + "react-router-dom": "^5.1.2" }, "devDependencies": { "@babel/cli": "^7.7.7", @@ -47,6 +47,7 @@ "prop-types": "15.7.2", "react": "16.9.0", "react-dom": "16.9.0", + "react-router-dom": "^5.1.2", "react-styleguidist": "^10.4.2", "snapshot-diff": "^0.5.1" }, From 532acf9d860f42ded38720d41bc852cc4711d62d Mon Sep 17 00:00:00 2001 From: Bogdan Bodnar Date: Fri, 17 Jan 2020 12:21:21 +0100 Subject: [PATCH 3/3] Add warning about using component in plugins. --- README.md | 17 +++++++++++++++++ src/form/components/ForisForm.js | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 79a6dfb..a0f03d1 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,20 @@ tagged `beta`. Versions names are based on commit SHA, e.g. unnecessary version 3. Create a merge request from `dev` to `master` branch 4. New version should be published automatically + +## Manually managed dependencies +Because of `` component it's required to use exposed `ReactRouterDOM` +object from `react-router-dom` library. `ReactRouterDOM` is exposed by +[reForis](https://gitlab.labs.nic.cz/turris/reforis/reforis/blob/master/js/webpack.config.js). +It can be done by following steps: + +1. Setting `react-router-dom` as `peerDependencies` and `devDependencies` in `package.json`. +2. Adding the following rules to `externals` in `webpack.conf.js` of the plugin: + +```js +externals: { + ... + "react-router-dom": "ReactRouterDOM", +} +``` + diff --git a/src/form/components/ForisForm.js b/src/form/components/ForisForm.js index 89c087f..65eff29 100644 --- a/src/form/components/ForisForm.js +++ b/src/form/components/ForisForm.js @@ -73,7 +73,12 @@ ForisForm.defaultProps = { disabled: false, }; -/** Serves as HOC for all foris forms components. */ +/** Serves as HOC for all foris forms components. + * + * As `` from `react-router-dom` is used in this component then it required to + * use exposed `ReactRouterDOM` object from `react-router-dom` library which is exposed by reForis. + * See README for more information. + * */ export function ForisForm({ ws, forisConfig,