Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to React 17 #108

Merged
merged 39 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0935b56
Update react and react-router
RoyAppeldoorn Jul 27, 2023
f478270
Replace <Responsive> with <Media>
RoyAppeldoorn Jul 27, 2023
033c213
Run formatter
RoyAppeldoorn Jul 27, 2023
489c458
Use useHistory hook
RoyAppeldoorn Jul 27, 2023
06c97f2
Migrate apollo to V3
RoyAppeldoorn Aug 8, 2023
b41d7b5
Set double quotes as the standard
RoyAppeldoorn Aug 8, 2023
8029896
Import gql from @apollo/client and fix tests
RoyAppeldoorn Aug 8, 2023
293eee7
Add prettier as linter and show as warnings
RoyAppeldoorn Aug 10, 2023
afff46d
Up node version
RoyAppeldoorn Aug 10, 2023
cad784f
Add prettier as dev dependency
RoyAppeldoorn Aug 10, 2023
97fd171
Add prettier as dev dependency
RoyAppeldoorn Aug 10, 2023
c3d18e5
Merge branch 'chore/update-react' of github.com:kabisa/kudos-frontend…
RoyAppeldoorn Aug 10, 2023
9423643
Add format option to script
RoyAppeldoorn Aug 10, 2023
785942b
Remove withRouter imports
RoyAppeldoorn Aug 10, 2023
44f69b6
Make ESLint happy
RoyAppeldoorn Aug 10, 2023
b0c3769
Add ignore
RoyAppeldoorn Aug 10, 2023
fe2f647
Use react 17 instead of 18 and fix minor errors
RoyAppeldoorn Aug 10, 2023
f7ad3de
Rewrite helper function to support Apollo V3
RoyAppeldoorn Aug 11, 2023
51a09e5
Fix getGraphqlError typings
RoyAppeldoorn Aug 11, 2023
d19580c
Use substring instead of deprecated substr
RoyAppeldoorn Aug 14, 2023
e6b6b72
Update part of tests after package updates
RoyAppeldoorn Aug 14, 2023
7cad1e0
Rework first tests to use RTL
RoyAppeldoorn Aug 16, 2023
dcce1f4
Fix some tests and use RTL
RoyAppeldoorn Aug 17, 2023
14c8454
Run localStorage fake on every test
RoyAppeldoorn Aug 17, 2023
7301f08
Minor changes
RoyAppeldoorn Aug 17, 2023
eccb02d
Remove .only from tests
RoyAppeldoorn Aug 17, 2023
0b4e1e9
Use correct types
RoyAppeldoorn Aug 17, 2023
8308498
Fix InMemoryCache configuration
sandercamp Aug 17, 2023
f3ce7ee
Use react-responsive instead of fresnel
RoyAppeldoorn Aug 17, 2023
f77defa
Delete unused component
RoyAppeldoorn Aug 17, 2023
6da2907
Merge branch 'chore/update-react' of github.com:kabisa/kudos-frontend…
RoyAppeldoorn Aug 17, 2023
2fb3af0
Fix LikeButton test
sandercamp Aug 18, 2023
c7216d1
Fix BackButton test
RoyAppeldoorn Aug 18, 2023
458fda7
Update nodejs version
RoyAppeldoorn Aug 18, 2023
72931c2
Fix eslint errors
RoyAppeldoorn Aug 18, 2023
8deee7f
Fix CreatePost test
sandercamp Aug 18, 2023
42e655b
Use current nodejs LTS
RoyAppeldoorn Aug 21, 2023
8720e69
retrigger checks
RoyAppeldoorn Aug 21, 2023
e69eeba
Again, retrigger checks..
RoyAppeldoorn Aug 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ coverage
src/__tests__
src/assets
src/config
src/serviceWorker.js
src/serviceWorker.js

/.eslintrc.js
/jest.config.js
47 changes: 26 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
parserOptions: {
project: './tsconfig.json',
},
extends: [
'airbnb-typescript',
],
rules: {
"react/jsx-props-no-spreading": 0,
"import/no-cycle": 0,
"react/destructuring-assignment": 0,
"import/prefer-default-export": 0,
"react/jsx-one-expression-per-line": 0,
"max-len": ["error", {"code": 120}],
"react/button-has-type": 0,
}
};
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
project: "./tsconfig.json",
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"prettier",
],
rules: {
"react/jsx-props-no-spreading": 0,
"import/no-cycle": 0,
"react/destructuring-assignment": 0,
"import/prefer-default-export": 0,
"max-len": ["error", { code: 120 }],
"react/button-has-type": 0,
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": 1,
},
};
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '18.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"tabWidth": 2,
"singleQuote": false,
"bracketSameLine": false
}
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.17.1
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts']
};
78 changes: 36 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,38 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@apollo/react-common": "^3.1.3",
"@apollo/react-components": "^3.1.3",
"@apollo/react-hooks": "^3.1.3",
"@apollo/react-testing": "^3.1.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/history": "^4.7.5",
"@types/jest": "^25.1.4",
"@types/node": "^13.9.0",
"@types/node-sass": "^4.11.0",
"@types/react": "^16.9.23",
"@types/react-click-outside": "^3.0.3",
"@types/react-dom": "^16.9.5",
"@types/react-router-dom": "^5.1.3",
"@types/sinon": "^7.5.2",
"apollo-cache-inmemory": "^1.6.5",
"apollo-client": "^2.6.8",
"apollo-link": "^1.2.13",
"apollo-link-error": "^1.1.12",
"apollo-link-http": "^1.5.16",
"@apollo/client": "^3.8.0",
"apollo-upload-client": "^14.1.3",
"chroma-js": "^2.1.0",
"copy-to-clipboard": "^3.3.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"graphql": "^14.6.0",
"graphql-tag": "^2.10.3",
"graphql": "^16.7.1",
"history": "^4.10.1",
"moment": "^2.24.0",
"moment-twitter": "^0.2.0",
"node-sass": "^4.13.1",
"prop-types": "^15.7.2",
"query-string": "^6.12.1",
"raven-js": "^3.27.2",
"rc-progress": "^2.5.2",
"react": "^16.13.0",
"react": "^17.0.2",
"react-click-outside": "^3.0.1",
"react-dom": "^16.13.0",
"react-dom": "^17.0.2",
"react-dropzone": "^11.3.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0",
"react-router-dom": "^5.1.3",
"react-scripts": "^5.0.1",
"react-test-renderer": "^16.13.0",
"react-toastify": "^5.5.0",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.88.2",
"simple-react-lightbox": "^3.6.5",
"typescript": "^3.8.3"
"sass": "^1.64.1",
"semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.4"
},
"scripts": {
"start": "PORT=9090 react-scripts start",
"build": "REACT_APP_VERSION=$npm_package_version REACT_APP_GIT_SHA=`git rev-parse --short HEAD` react-scripts build && mv build dist",
"test": "react-scripts test --testPathIgnorePatterns=src/config",
"eject": "react-scripts eject",
"lint:check": "eslint ./src --ext .js,.jsx,.ts,.tsx ./",
"lint:run": "eslint ./src --ext .js,.jsx,.ts,.tsx --fix"
"lint:run": "eslint ./src --ext .js,.jsx,.ts,.tsx --fix",
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -78,15 +52,35 @@
]
},
"devDependencies": {
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^14.4.3",
"@types/enzyme": "^3.10.5",
"@types/jest": "^29.5.3",
"@types/node": "^13.9.0",
"@types/react": "^17.0.2",
"@types/react-click-outside": "^3.0.3",
"@types/react-copy-to-clipboard": "^4.3.0",
"@typescript-eslint/eslint-plugin": "^2.19.0",
"@typescript-eslint/parser": "^2.23.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-typescript": "^7.0.0",
"@types/react-dom": "^17.0.2",
"@types/react-router-dom": "^5.1.3",
"@types/testing-library__dom": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"enzyme": "^3.11.0",
"eslint": "^7.1.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.15.1",
"eslint-plugin-react-hooks": "^1.7.0",
"ts-jest": "^25.2.1"
"jest-environment-jsdom": "^29.6.2",
"prettier": "^3.0.1",
"react-responsive": "^9.0.2",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"resolutions": {
"@types/react": "17.0.2"
}
}
134 changes: 83 additions & 51 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,94 @@
import React from 'react';
import { Responsive } from 'semantic-ui-react';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import React from "react";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { Router, Route, Switch } from "react-router-dom";
import * as routes from "./routes";
import history from "./support/history";
import {
Router, Route, Switch,
} from 'react-router-dom';
import * as routes from './routes';
import history from './support/history';
import {
FinishForgotPasswordPage, ForgotPasswordPage, LoginPage, RegisterPage,
} from './modules/login';
import { FeedPage } from './modules/feed';
import { NotificationsPage } from './modules/notifications';
import { ResetPasswordPage, UserPage } from './modules/user';
import { InvitePage, SettingsPage } from './modules/settings';
import { StatisticsPage } from './modules/statistics';
import { ChooseTeamPage, CreateTeamPage } from './modules/choose-team';
import { ManageTeamPage } from './modules/manage-team/ManageTeamPage';
import AuthenticatedRoute from './components/AuthenticatedRoute';
FinishForgotPasswordPage,
ForgotPasswordPage,
LoginPage,
RegisterPage,
} from "./modules/login";
import { FeedPage } from "./modules/feed";
import { NotificationsPage } from "./modules/notifications";
import { ResetPasswordPage, UserPage } from "./modules/user";
import { InvitePage, SettingsPage } from "./modules/settings";
import { StatisticsPage } from "./modules/statistics";
import { ChooseTeamPage, CreateTeamPage } from "./modules/choose-team";
import { ManageTeamPage } from "./modules/manage-team/ManageTeamPage";
import AuthenticatedRoute from "./components/AuthenticatedRoute";

const ToastWrapper = () => (
<ToastContainer bodyClassName="toast-body" toastClassName="toast" autoClose={4000} pauseOnHover />
<ToastContainer
bodyClassName="toast-body"
toastClassName="toast"
autoClose={4000}
pauseOnHover
/>
);

function App() {
return (
<div>
<Responsive>
<Router history={history}>
<Switch>
<Route path={routes.PATH_LOGIN}>
<LoginPage />
</Route>
<AuthenticatedRoute allowNoTeam path={routes.PATH_NOTIFICATIONS} component={NotificationsPage} />
<AuthenticatedRoute allowNoTeam path={routes.PATH_USER} component={UserPage} />
<AuthenticatedRoute path={routes.PATH_STATISTICS} component={StatisticsPage} />
<AuthenticatedRoute allowNoTeam path={routes.PATH_SETTINGS} component={SettingsPage} />
<AuthenticatedRoute path={routes.PATH_INVITE} component={InvitePage} />
<AuthenticatedRoute allowNoTeam path={routes.PATH_CHOOSE_TEAM} component={ChooseTeamPage} />
<AuthenticatedRoute allowNoTeam path={routes.PATH_CREATE_TEAM} component={CreateTeamPage} />
<AuthenticatedRoute path={routes.PATH_MANAGE_TEAM} component={ManageTeamPage} />
<Route path={routes.PATH_RESET_PASSWORD}>
<ResetPasswordPage />
</Route>
<Route path={routes.PATH_FINISH_RESET_PASSWORD}>
<FinishForgotPasswordPage />
</Route>
<Route path={routes.PATH_FORGOT_PASSWORD}>
<ForgotPasswordPage />
</Route>
<Route path={routes.PATH_REGISTER}>
<RegisterPage />
</Route>
<AuthenticatedRoute path={routes.PATH_FEED} component={FeedPage} />
</Switch>
</Router>
<ToastWrapper />
</Responsive>
<Router history={history}>
<Switch>
<Route path={routes.PATH_LOGIN}>
<LoginPage />
</Route>
<AuthenticatedRoute
allowNoTeam
path={routes.PATH_NOTIFICATIONS}
component={NotificationsPage}
/>
<AuthenticatedRoute
allowNoTeam
path={routes.PATH_USER}
component={UserPage}
/>
<AuthenticatedRoute
path={routes.PATH_STATISTICS}
component={StatisticsPage}
/>
<AuthenticatedRoute
allowNoTeam
path={routes.PATH_SETTINGS}
component={SettingsPage}
/>
<AuthenticatedRoute
path={routes.PATH_INVITE}
component={InvitePage}
/>
<AuthenticatedRoute
allowNoTeam
path={routes.PATH_CHOOSE_TEAM}
component={ChooseTeamPage}
/>
<AuthenticatedRoute
allowNoTeam
path={routes.PATH_CREATE_TEAM}
component={CreateTeamPage}
/>
<AuthenticatedRoute
path={routes.PATH_MANAGE_TEAM}
component={ManageTeamPage}
/>
<Route path={routes.PATH_RESET_PASSWORD}>
<ResetPasswordPage />
</Route>
<Route path={routes.PATH_FINISH_RESET_PASSWORD}>
<FinishForgotPasswordPage />
</Route>
<Route path={routes.PATH_FORGOT_PASSWORD}>
<ForgotPasswordPage />
</Route>
<Route path={routes.PATH_REGISTER}>
<RegisterPage />
</Route>
<AuthenticatedRoute path={routes.PATH_FEED} component={FeedPage} />
</Switch>
</Router>
<ToastWrapper />
</div>
);
}
Expand Down
Loading
Loading