Skip to content

Commit

Permalink
Merge pull request #3 from erwanMarmelab/main
Browse files Browse the repository at this point in the history
Upgrade to RA v5
  • Loading branch information
erwanMarmelab authored Aug 30, 2024
2 parents 87ba47e + a76dd02 commit fb6af40
Show file tree
Hide file tree
Showing 37 changed files with 1,740 additions and 3,667 deletions.
45 changes: 45 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"warnOnUnsupportedTypeScriptVersion": false
},
"extends": ["react-app", "plugin:prettier/recommended"],
"plugins": [
"@typescript-eslint",
"import",
"jsx-a11y",
"prettier",
"react",
"react-hooks"
],
"rules": {
"no-use-before-define": "off",
"prettier/prettier": "error",
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "@mui/material",
"importNames": ["makeStyles", "createMuiTheme"],
"message": "Please import from @mui/material/styles instead. See https://material-ui.com/guides/minimizing-bundle-size/#option-2 for more information"
}
]
}
],
"no-redeclare": "off",
"import/no-anonymous-default-export": "off",
"@typescript-eslint/no-redeclare": ["error"],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn", // or "error"
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
]
}
}
15 changes: 15 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
bracketSameLine: false,
jsxSingleQuote: false,
printWidth: 80,
quoteProps: 'as-needed',
rangeStart: 0,
rangeEnd: Infinity,
semi: true,
singleQuote: true,
tabWidth: 4,
trailingComma: 'es5',
useTabs: false
}
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
## 2.0.0

- Upgrade `react-admin` to v5
- Remove prop-types

### Breaking Changes

The `initGoogleAuthProvider` helper has been replaced by a hook -- `useGoogleAuthProvider` -- and a React Context Provider -- `<GoogleAuthContextProvider>`.

Here is how to use them in replacement of the `initGoogleAuthProvider` helper:

```diff
// in src/App.tsx
import React from "react";
import { Admin, Resource, Login, CustomRoutes } from "react-admin";
import { Route } from "react-router-dom";
-import { initGoogleAuthProvider } from "ra-auth-google";
+import { useGoogleAuthProvider, LoginButton, OneTapButton, GoogleAuthContextProvider } from "ra-auth-google";
import dataProvider from "./dataProvider";
import posts from "./posts";

const App = () => {
- const { authProvider, LoginButton, OneTapButton } = initGoogleAuthProvider();
+ const { authProvider, gsiParams } = useGoogleAuthProvider();

const LoginPage = () => (
<Login>
<LoginButton />
</Login>
);

return (
+ <GoogleAuthContextProvider value={gsiParams}>
<Admin
authProvider={authProvider}
dataProvider={dataProvider}
title="Example Admin"
loginPage={LoginPage}
>
<Resource name="posts" {...posts} />
<CustomRoutes>
<Route
path="/custom"
element={
<div>
<OneTapButton />
<h1>My Page</h1>
</div>
}
/>
</CustomRoutes>
</Admin>
+ </GoogleAuthContextProvider>
);
};
export default App;
```

**Tip:** The `useGoogleAuthProvider` hook accepts the same parameters as the `initGoogleAuthProvider` helper.

The (internal) `<GoogleLoginButton>` component was renamed to `<LoginButton>`.
The (internal) `<GoogleOneTapButton>` component was renamed to `<OneTapButton>`.

Both components now expect to be rendered inside a `<GoogleAuthContextProvider>`.

## 1.0.0

* Initial release
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build-demo-react-admin:
build: build-ra-auth-google build-demo-react-admin ## compile ES6 files to JS

start-demo: ## Start the demo
@cd ./packages/demo-react-admin && yarn start
@cd ./packages/demo-react-admin && yarn dev

start-fake-api: ## Start the fake API
@cd ./packages/demo-fake-api && yarn start
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
"author": "Jean-Baptiste Kaiser <jb@marmelab.com> (https://marmelab.com/)",
"license": "MIT",
"devDependencies": {
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^29.1.0",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.28.5",
"babel-jest": "^27.1.0",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-react-app": "^5.2.1",
Expand All @@ -26,16 +22,20 @@
"prettier": "~2.1.1",
"raf": "^3.4.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
"typescript": "^5.4.4"
},
"scripts": {
"build": "yarn workspaces run build",
"build-demo": "cd packages/demo-react-admin && yarn build",
"run-demo": "cd packages/demo-react-admin && yarn start",
"run-demo": "cd packages/demo-react-admin && yarn dev",
"test-unit": "cd packages/ra-auth-google && yarn test-unit",
"lint": "eslint --fix --ext .js,.ts,.tsx \"./packages/**/src/**/*.{js,ts,tsx}\"",
"prettier": "prettier --write \"./packages/**/src/**/*.{js,ts,tsx}\""
},
"resolutions": {
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^6.21.0"
},
"workspaces": [
"packages/*"
]
Expand Down
9 changes: 8 additions & 1 deletion packages/demo-react-admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
body {
margin: 0;
}
</style>
/*
Because the style prop no longer exist in TanStack Query v5,
we have to use this rule to customize ReactQueryDevtools button size:
*/
.tsqd-transitions-container>div {
height: 30px;
width: 30px;
} </style>
<script async defer src="https://accounts.google.com/gsi/client"></script>
</head>
<body>
Expand Down
41 changes: 16 additions & 25 deletions packages/demo-react-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"scripts": {
"start": "vite --force",
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"type-check": "tsc --noEmit"
Expand All @@ -13,38 +13,29 @@
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.0.1",
"@mui/material": "^5.0.2",
"@tanstack/react-query": "^5.8.4",
"@tanstack/react-query-devtools": "^5.8.4",
"jsonexport": "^3.2.0",
"lodash": "~4.17.5",
"prop-types": "^15.7.2",
"proxy-polyfill": "^0.3.0",
"ra-auth-google": "*",
"ra-data-fakerest": "^4.12.1",
"ra-data-json-server": "^4.12.1",
"ra-i18n-polyglot": "^4.12.1",
"ra-language-english": "^4.12.1",
"ra-language-french": "^4.12.1",
"react": "^18.2.0",
"react-admin": "^4.12.1",
"react-dom": "^18.2.0",
"react-hook-form": "^7.34.2",
"react-query": "^3.32.1",
"react-router": "^6.1.0",
"react-router-dom": "^6.1.0"
"ra-data-fakerest": "^5.1.1",
"ra-data-json-server": "^5.1.1",
"ra-i18n-polyglot": "^5.1.1",
"ra-language-english": "^5.1.1",
"ra-language-french": "^5.1.1",
"react": "^18.3.1",
"react-admin": "^5.1.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.2",
"react-router": "^6.26.0",
"react-router-dom": "^6.26.0"
},
"devDependencies": {
"@hookform/devtools": "^4.0.2",
"@types/jest": "^29.2.3",
"@vitejs/plugin-react-refresh": "^1.3.3",
"html-loader": "~3.1.0",
"html-webpack-plugin": "~5.5.0",
"ignore-not-found-export-plugin": "^1.0.1",
"react-app-polyfill": "^1.0.4",
"style-loader": "~3.3.1",
"ts-loader": "^9.2.8",
"typescript": "^4.4.0",
"vite": "^2.2.3",
"webpack": "~5.70.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "~4.7.4"
"typescript": "^5.5.4",
"vite": "^5.4.0"
}
}
Loading

0 comments on commit fb6af40

Please sign in to comment.