From 9bf5782f9729e6d163b951a67c860866352e0f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Velarde?= Date: Mon, 22 Mar 2021 19:56:34 +0100 Subject: [PATCH] Adapt to carto-lib with workers (#219) * chore: adapt to carto-lib with workers (rc.2) * chore: remove UserMenuLogin module from skeleton app * chore: remove unused property from KpiLayer * chore: remove pending todos --- CHANGELOG.md | 3 +- template-sample-app/package.json | 2 +- template-sample-app/template.json | 15 +++--- .../cypress/integration/stores_page_spec.js | 8 ---- template-sample-app/template/package.dev.json | 21 +++++---- .../template/src/components/common/Map.js | 2 +- .../template/src/components/views/Kpi.js | 3 +- template-skeleton/package.json | 2 +- template-skeleton/template.json | 15 +++--- template-skeleton/template/package.dev.json | 21 +++++---- .../template/src/components/common/Map.js | 2 +- .../components/views/login/UserMenuLogin.js | 46 ------------------- 12 files changed, 45 insertions(+), 95 deletions(-) delete mode 100644 template-skeleton/template/src/components/views/login/UserMenuLogin.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c118bc..14cc2fbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # CHANGELOG ## Unreleased +- Fix general React warning on SharedArrayBuffer [#218](https://github.com/CartoDB/carto-react-template/pull/218) +- Integrate carto-react lib with workers support [#219](https://github.com/CartoDB/carto-react-template/pull/219) ## 1.0.0-rc.2 (2021-03-12) - Add improved htmlForFeature in skeleton [#215](https://github.com/CartoDB/carto-react-template/pull/215) - Fix immutable/serializable checks for redux middleware in skeleton [#216](https://github.com/CartoDB/carto-react-template/pull/216) -- Fix general React warning on SharedArrayBuffer [#218](https://github.com/CartoDB/carto-react-template/pull/218) ## 1.0.0-rc.1 (2021-03-11) - Add cypress e2e tests in CI [#194](https://github.com/CartoDB/carto-react-template/pull/194) diff --git a/template-sample-app/package.json b/template-sample-app/package.json index 31bfacd1..69c05ff1 100644 --- a/template-sample-app/package.json +++ b/template-sample-app/package.json @@ -1,6 +1,6 @@ { "name": "@carto/cra-template-sample-app", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "keywords": [ "react", "create-react-app", diff --git a/template-sample-app/template.json b/template-sample-app/template.json index 88dacc00..28c9f30a 100644 --- a/template-sample-app/template.json +++ b/template-sample-app/template.json @@ -1,13 +1,14 @@ { "package": { "dependencies": { - "@carto/react-api": "1.0.0-rc.1", - "@carto/react-auth": "1.0.0-rc.1", - "@carto/react-basemaps": "1.0.0-rc.1", - "@carto/react-core": "1.0.0-rc.1", - "@carto/react-redux": "1.0.0-rc.1", - "@carto/react-ui": "1.0.0-rc.1", - "@carto/react-widgets": "1.0.0-rc.1", + "@carto/react-api": "1.0.0-rc.2", + "@carto/react-auth": "1.0.0-rc.2", + "@carto/react-basemaps": "1.0.0-rc.2", + "@carto/react-core": "1.0.0-rc.2", + "@carto/react-redux": "1.0.0-rc.2", + "@carto/react-ui": "1.0.0-rc.2", + "@carto/react-widgets": "1.0.0-rc.2", + "@carto/react-workers": "1.0.0-rc.2", "@formatjs/intl-getcanonicallocales": "^1.5.3", "@formatjs/intl-locale": "^2.4.14", "@formatjs/intl-numberformat": "^6.1.4", diff --git a/template-sample-app/template/cypress/integration/stores_page_spec.js b/template-sample-app/template/cypress/integration/stores_page_spec.js index 787f06f5..aca3822b 100644 --- a/template-sample-app/template/cypress/integration/stores_page_spec.js +++ b/template-sample-app/template/cypress/integration/stores_page_spec.js @@ -56,14 +56,6 @@ describe('Stores Page', () => { }); describe('Detail', () => { - // TODO: temporary, while fixing issue on page - beforeEach(() => { - cy.on('uncaught:exception', (err, runnable) => { - // temporary ignore console.errors - return false; - }); - }); - it('successfully loads one store', () => { cy.visit(STORE_DETAIL_PAGE); }); diff --git a/template-sample-app/template/package.dev.json b/template-sample-app/template/package.dev.json index ff41b34e..3532aa8b 100644 --- a/template-sample-app/template/package.dev.json +++ b/template-sample-app/template/package.dev.json @@ -1,15 +1,16 @@ { "name": "carto-for-react", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "private": true, "dependencies": { - "@carto/react-api": "1.0.0-rc.1", - "@carto/react-auth": "1.0.0-rc.1", - "@carto/react-basemaps": "1.0.0-rc.1", - "@carto/react-core": "1.0.0-rc.1", - "@carto/react-redux": "1.0.0-rc.1", - "@carto/react-ui": "1.0.0-rc.1", - "@carto/react-widgets": "1.0.0-rc.1", + "@carto/react-api": "1.0.0-rc.2", + "@carto/react-auth": "1.0.0-rc.2", + "@carto/react-basemaps": "1.0.0-rc.2", + "@carto/react-core": "1.0.0-rc.2", + "@carto/react-redux": "1.0.0-rc.2", + "@carto/react-ui": "1.0.0-rc.2", + "@carto/react-widgets": "1.0.0-rc.2", + "@carto/react-workers": "1.0.0-rc.2", "@formatjs/intl-getcanonicallocales": "^1.5.3", "@formatjs/intl-locale": "^2.4.14", "@formatjs/intl-numberformat": "^6.1.4", @@ -57,8 +58,8 @@ "cy:run": "npx cypress run", "cy:ci": "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3000 cy:run", "eject": "react-scripts eject", - "link-carto-react": "yarn link @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets", - "unlink-carto-react": "yarn unlink @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets", + "link-carto-react": "yarn link @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets @carto/react-workers", + "unlink-carto-react": "yarn unlink @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets @carto/react-workers", "lint": "eslint './src/**/*.{js,jsx}'", "lint:fix": "eslint './src/**/*.{js,jsx}' --fix", "format": "prettier --write \"**/*.+(js|jsx|json|css|md)\" --ignore-path .gitignore", diff --git a/template-sample-app/template/src/components/common/Map.js b/template-sample-app/template/src/components/common/Map.js index f3216204..400b2766 100644 --- a/template-sample-app/template/src/components/common/Map.js +++ b/template-sample-app/template/src/components/common/Map.js @@ -31,7 +31,7 @@ const useStyles = makeStyles((theme) => ({ padding: theme.spacing(1, 1.5), borderRadius: theme.shape.borderRadius, backgroundColor: theme.palette.other.tooltip, - color: 'rgba(255, 255, 255, 0.75)', // TODO: Add emphasis colors to theme + color: 'rgba(255, 255, 255, 0.75)', transform: `translate(-50%, calc(-100% - ${theme.spacing(2.5)}px))`, '& .arrow': { diff --git a/template-sample-app/template/src/components/views/Kpi.js b/template-sample-app/template/src/components/views/Kpi.js index adbb8c65..a7e4976c 100644 --- a/template-sample-app/template/src/components/views/Kpi.js +++ b/template-sample-app/template/src/components/views/Kpi.js @@ -41,8 +41,7 @@ function Kpi() { dispatch( addLayer({ id: KPI_LAYER_ID, - source: kpiSource.id, - selectedStore: null, + source: kpiSource.id }) ); diff --git a/template-skeleton/package.json b/template-skeleton/package.json index ed3f3342..846a31b0 100644 --- a/template-skeleton/package.json +++ b/template-skeleton/package.json @@ -1,6 +1,6 @@ { "name": "@carto/cra-template", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "keywords": [ "react", "create-react-app", diff --git a/template-skeleton/template.json b/template-skeleton/template.json index 88dacc00..28c9f30a 100644 --- a/template-skeleton/template.json +++ b/template-skeleton/template.json @@ -1,13 +1,14 @@ { "package": { "dependencies": { - "@carto/react-api": "1.0.0-rc.1", - "@carto/react-auth": "1.0.0-rc.1", - "@carto/react-basemaps": "1.0.0-rc.1", - "@carto/react-core": "1.0.0-rc.1", - "@carto/react-redux": "1.0.0-rc.1", - "@carto/react-ui": "1.0.0-rc.1", - "@carto/react-widgets": "1.0.0-rc.1", + "@carto/react-api": "1.0.0-rc.2", + "@carto/react-auth": "1.0.0-rc.2", + "@carto/react-basemaps": "1.0.0-rc.2", + "@carto/react-core": "1.0.0-rc.2", + "@carto/react-redux": "1.0.0-rc.2", + "@carto/react-ui": "1.0.0-rc.2", + "@carto/react-widgets": "1.0.0-rc.2", + "@carto/react-workers": "1.0.0-rc.2", "@formatjs/intl-getcanonicallocales": "^1.5.3", "@formatjs/intl-locale": "^2.4.14", "@formatjs/intl-numberformat": "^6.1.4", diff --git a/template-skeleton/template/package.dev.json b/template-skeleton/template/package.dev.json index ff41b34e..3532aa8b 100644 --- a/template-skeleton/template/package.dev.json +++ b/template-skeleton/template/package.dev.json @@ -1,15 +1,16 @@ { "name": "carto-for-react", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "private": true, "dependencies": { - "@carto/react-api": "1.0.0-rc.1", - "@carto/react-auth": "1.0.0-rc.1", - "@carto/react-basemaps": "1.0.0-rc.1", - "@carto/react-core": "1.0.0-rc.1", - "@carto/react-redux": "1.0.0-rc.1", - "@carto/react-ui": "1.0.0-rc.1", - "@carto/react-widgets": "1.0.0-rc.1", + "@carto/react-api": "1.0.0-rc.2", + "@carto/react-auth": "1.0.0-rc.2", + "@carto/react-basemaps": "1.0.0-rc.2", + "@carto/react-core": "1.0.0-rc.2", + "@carto/react-redux": "1.0.0-rc.2", + "@carto/react-ui": "1.0.0-rc.2", + "@carto/react-widgets": "1.0.0-rc.2", + "@carto/react-workers": "1.0.0-rc.2", "@formatjs/intl-getcanonicallocales": "^1.5.3", "@formatjs/intl-locale": "^2.4.14", "@formatjs/intl-numberformat": "^6.1.4", @@ -57,8 +58,8 @@ "cy:run": "npx cypress run", "cy:ci": "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3000 cy:run", "eject": "react-scripts eject", - "link-carto-react": "yarn link @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets", - "unlink-carto-react": "yarn unlink @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets", + "link-carto-react": "yarn link @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets @carto/react-workers", + "unlink-carto-react": "yarn unlink @carto/react-api @carto/react-auth @carto/react-basemaps @carto/react-core @carto/react-redux @carto/react-ui @carto/react-widgets @carto/react-workers", "lint": "eslint './src/**/*.{js,jsx}'", "lint:fix": "eslint './src/**/*.{js,jsx}' --fix", "format": "prettier --write \"**/*.+(js|jsx|json|css|md)\" --ignore-path .gitignore", diff --git a/template-skeleton/template/src/components/common/Map.js b/template-skeleton/template/src/components/common/Map.js index 074120de..6d3b85ed 100644 --- a/template-skeleton/template/src/components/common/Map.js +++ b/template-skeleton/template/src/components/common/Map.js @@ -31,7 +31,7 @@ const useStyles = makeStyles((theme) => ({ padding: theme.spacing(1, 1.5), borderRadius: theme.shape.borderRadius, backgroundColor: theme.palette.grey[900], - color: 'rgba(255, 255, 255, 0.75)', // TODO: Add emphasis colors to theme + color: 'rgba(255, 255, 255, 0.75)', transform: `translate(-50%, calc(-100% - ${theme.spacing(2.5)}px))`, '& .arrow': { diff --git a/template-skeleton/template/src/components/views/login/UserMenuLogin.js b/template-skeleton/template/src/components/views/login/UserMenuLogin.js deleted file mode 100644 index a9de3151..00000000 --- a/template-skeleton/template/src/components/views/login/UserMenuLogin.js +++ /dev/null @@ -1,46 +0,0 @@ -import { useSelector, useDispatch } from 'react-redux'; -import { Button, Hidden, IconButton } from '@material-ui/core'; -import AccountCircleOutlinedIcon from '@material-ui/icons/AccountCircleOutlined'; -import { useOAuthLogin } from '@carto/react-auth'; -import { setTokenAndUserInfoAsync } from '@carto/react-redux'; - -import { setError } from 'store/appSlice'; - -/** - * Shows a login button. - * When this button is clicked, the OAuth protocol flow is handled - * by the `useOAuthLogin` hook. - * - * @exports OAuthLogin - */ -function UserMenuLogin() { - const dispatch = useDispatch(); - const oauthApp = useSelector((state) => state.oauth.oauthApp); - - const onParamsRefreshed = (oauthParams) => { - if (oauthParams.error) { - dispatch(setError(`OAuth error: ${oauthParams.error}`)); - } else { - dispatch(setTokenAndUserInfoAsync(oauthParams)); - } - }; - - const [handleLogin] = useOAuthLogin(oauthApp, onParamsRefreshed); - - return ( - <> - - - - - - - - - - ); -} - -export default UserMenuLogin;