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

Add queryOptions prop to ReferenceField #8892

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eb5903a
Update DataProviderList.md
nazirov91 Apr 28, 2023
d8e0aff
Prepare changelog for v4.10.0
fzaninotto Apr 28, 2023
65189b7
v4.10.0
fzaninotto Apr 28, 2023
23eb060
Fix yarn dependencies
fzaninotto Apr 28, 2023
5832501
make create-react-admin private
fzaninotto Apr 28, 2023
2cd1da1
v4.10.1
fzaninotto Apr 28, 2023
b100535
add changelog
fzaninotto Apr 28, 2023
56f90ba
Fix yarn.lock
fzaninotto Apr 28, 2023
7ef0d7c
Update changelog to announce the publication of create-react-admin
fzaninotto May 2, 2023
6ae02f6
Add links to sponsors.
fzaninotto May 2, 2023
1e8601e
Fix create-react-admin bin declaration
djhi May 4, 2023
a0c70a3
Merge pull request #8880 from marmelab/fix-create-react-admin
slax57 May 4, 2023
755553c
Merge pull request #8865 from nazirov91/patch-1
slax57 May 4, 2023
9f837e3
Update tutorial to use create-react-admin
djhi May 4, 2023
135f234
Update tutorial
djhi May 4, 2023
7be2832
Add CLI chapter
djhi May 4, 2023
cd8047a
fix
slax57 May 4, 2023
c8da6c8
add tests
slax57 May 4, 2023
011c76f
update comment
slax57 May 4, 2023
cdcfaa1
Add screencast
djhi May 5, 2023
ac9ac0f
fix: swap `Menu.ResourceItem` from `to` to `name`
antoinefricker May 5, 2023
f8e0e9e
Merge pull request #8886 from marmelab/rao-8885
djhi May 5, 2023
257ab0b
Merge pull request #8882 from marmelab/warnWhenUnsavedChanges-isSubmi…
djhi May 5, 2023
6aa2273
Update changelog for v4.10.2
slax57 May 5, 2023
e936ff2
v4.10.2
slax57 May 5, 2023
ed65aad
update packages.json
slax57 May 5, 2023
ac073b4
update yarn.lock
slax57 May 5, 2023
87da0a9
Fix login background
fzaninotto May 5, 2023
5b5f365
Added queryOptions to ReferenceField
WiXSL May 8, 2023
8694f8f
Added documentation
WiXSL May 8, 2023
1863b77
Updated documentation
WiXSL May 8, 2023
7d7cf32
Remove unused import
WiXSL May 8, 2023
c8fcdac
Remove .only from test
WiXSL May 8, 2023
4a9f0d1
[Doc] Add Supabase realtime adapter
fzaninotto May 8, 2023
deef4f0
Fix syntax highlighting
fzaninotto May 8, 2023
c82cd66
Fix and reorder authProvider backends
fzaninotto May 8, 2023
dfb0d75
Merge pull request #8881 from marmelab/update-tutorial
fzaninotto May 9, 2023
de99140
Merge pull request #8893 from marmelab/realtime-supabase
djhi May 9, 2023
e972189
Merge branch 'marmelab:master' into referencefield-queryoptions
WiXSL May 9, 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
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## v4.10.2

* Fix custom redirect in pessimistic `<Edit>` or `<Create>` when using `warnWhenUnsavedChanges` ([#8882](https://github.com/marmelab/react-admin/pull/8882)) ([slax57](https://github.com/slax57))
* Fix `create-react-admin` package manifest ([#8888](https://github.com/marmelab/react-admin/pull/8888)) ([djhi](https://github.com/djhi))
* [Doc] Fix `<Menu.ResourceItem>` example should use the `name` prop ([#8886](https://github.com/marmelab/react-admin/pull/8886)) ([septentrion-730n](https://github.com/septentrion-730n))
* [Doc] Update DataProvider List with `ra-strapi-rest` v4 ([#8865](https://github.com/marmelab/react-admin/pull/8865)) ([nazirov91](https://github.com/nazirov91))

## v4.10.1

* Republish all packages, including the `create-react-admin` installer ([fzaninotto](https://github.com/fzaninotto))

## v4.10.0

Note: This release wasn't published to npm, use version 4.10.1 or higher.

* Add `create-react-admin` installer ([#8833](https://github.com/marmelab/react-admin/pull/8833)) ([djhi](https://github.com/djhi))
* Add `<InfiniteList>` and `<InfinitePagination>` components ([#8781](https://github.com/marmelab/react-admin/pull/8781)) ([fzaninotto](https://github.com/fzaninotto))
* Add ability to change the sort, filter and selection of `<ArrayField>` ([#8802](https://github.com/marmelab/react-admin/pull/8802)) ([fzaninotto](https://github.com/fzaninotto))
* Add ability to configure the remove icon of `<FileInputPreview>` ([#8756](https://github.com/marmelab/react-admin/pull/8756)) ([PennyJeans](https://github.com/PennyJeans))
* Fix `<Datagrid>` does not apply `className` to its root element (minor BC) ([#8804](https://github.com/marmelab/react-admin/pull/8804)) ([slax57](https://github.com/slax57))
* Fix `useHandleCallback` sometimes causes infinite redirection loop ([#8861](https://github.com/marmelab/react-admin/pull/8861)) ([djhi](https://github.com/djhi))
* Fix `<AppBar alwaysOn>` hides sidebar menu on scroll ([#8856](https://github.com/marmelab/react-admin/pull/8856)) ([slax57](https://github.com/slax57))
* Fix `<SimpleFormIterator>` new item's fields default empty string instead of null ([#8792](https://github.com/marmelab/react-admin/pull/8792)) ([kriskw1999](https://github.com/kriskw1999))
* [Doc] Fix reference to Material UI ([#8857](https://github.com/marmelab/react-admin/pull/8857)) ([oliviertassinari](https://github.com/oliviertassinari))
* [Doc] Fix Show documentation misses the `aside` prop ([#8855](https://github.com/marmelab/react-admin/pull/8855)) ([fzaninotto](https://github.com/fzaninotto))
* [Doc] Convert GIF files to WebM ([#8767](https://github.com/marmelab/react-admin/pull/8767)) ([slax57](https://github.com/slax57))
* [TypeScript] Add some utilities to improve generics ([#8815](https://github.com/marmelab/react-admin/pull/8815)) ([IAmVisco](https://github.com/IAmVisco))
* [TypeScript] Improve `useRedirect` and `useCreatePath` types ([#8811](https://github.com/marmelab/react-admin/pull/8811)) ([djhi](https://github.com/djhi))

## v4.9.4

* Fix GraphQL data provider when using different a custom credential type ([#8847](https://github.com/marmelab/react-admin/pull/8847)) ([@rlucia](https://github.com/rlucia))
Expand Down
2 changes: 1 addition & 1 deletion cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "e2e",
"version": "4.9.0",
"version": "4.10.0",
"scripts": {
"start": "cypress open",
"test": "yarn node ./start.js"
Expand Down
4 changes: 2 additions & 2 deletions docs/CustomRoutes.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ import PeopleIcon from '@mui/icons-material/People';
export const MyMenu = () => (
<Menu>
<Menu.DashboardItem />
<Menu.ResourceItem to="/posts" />
<Menu.ResourceItem to="/comments" />
<Menu.ResourceItem name="posts" />
<Menu.ResourceItem name="comments" />
<Menu.Item to="/settings" primaryText="Users" leftIcon={<SettingsIcon />}/>
<Menu.Item to="/profile" primaryText="Miscellaneous" leftIcon={<PeopleIcon />}/>
</Menu>
Expand Down
2 changes: 1 addition & 1 deletion docs/DataProviderList.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ If you can't find a Data Provider for your backend below, no worries! [Writing a
* **[SQLite](https://www.sqlite.org/index.html)**: [marmelab/ra-sqlite-dataprovider](https://github.com/marmelab/ra-sqlite-dataprovider)
* **[REST](https://en.wikipedia.org/wiki/Representational_state_transfer)**: [marmelab/ra-data-simple-rest](https://github.com/marmelab/react-admin/tree/master/packages/ra-data-simple-rest)
* **[Spring Boot](https://spring.io/projects/spring-boot)**: [vishpat/ra-data-springboot-rest](https://github.com/vishpat/ra-data-springboot-rest)
* **[Strapi v3](https://strapi.io/)**: [nazirov91/ra-strapi-rest](https://github.com/nazirov91/ra-strapi-rest)
* **[Strapi v3/v4](https://strapi.io/)**: [nazirov91/ra-strapi-rest](https://github.com/nazirov91/ra-strapi-rest)
* **[Strapi v4](https://strapi.io/)**: [garridorafa/ra-strapi-v4-rest](https://github.com/garridorafa/ra-strapi-v4-rest)
* **[Supabase](https://supabase.io/)**: [marmelab/ra-supabase](https://github.com/marmelab/ra-supabase)
- **[SurrealDB](https://surrealdb.com/)**: [djedi23/ra-surrealdb](https://github.com/djedi23/ra-surrealdb)
Expand Down
17 changes: 17 additions & 0 deletions docs/ReferenceField.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ With this configuration, `<ReferenceField>` wraps the user's name in a link to t
| `emptyText` | Optional | `string` | '' | Defines a text to be shown when the field has no value or when the reference is missing |
| `label` | Optional | `string | Function` | `resources.[resource].fields.[source]` | Label to use for the field when rendered in layout components |
| `link` | Optional | `string | Function` | `edit` | Target of the link wrapping the rendered child. Set to `false` to disable the link. |
| `queryOptions` | Optional | [`UseQueryOptions`](https://tanstack.com/query/v4/docs/reference/useQuery?from=reactQueryV3&original=https://react-query-v3.tanstack.com/reference/useQuery) | `{}` | `react-query` client options |
| `sortBy` | Optional | `string | Function` | `source` | Name of the field to use for sorting when used in a Datagrid |

`<ReferenceField>` also accepts the [common field props](./Fields.md#common-field-props).
Expand Down Expand Up @@ -143,6 +144,22 @@ You can also use a custom `link` function to get a custom path for the children.
/>
```

## `queryOptions`

Use the `queryOptions` prop to pass options to the `dataProvider.getMany()` query that fetches the referenced record.

For instance, to pass [a custom `meta`](./Actions.md#meta-parameter):

```jsx
<ReferenceField
source="user_id"
reference="users"
queryOptions={{ meta: { foo: 'bar' } }}
>
<TextField source="name" />
</ReferenceField>
```

## `reference`

The resource to fetch for the related record.
Expand Down
6 changes: 3 additions & 3 deletions examples/crm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-admin-crm",
"version": "4.9.4",
"version": "4.10.2",
"private": true,
"dependencies": {
"@mui/icons-material": "^5.0.1",
Expand All @@ -12,9 +12,9 @@
"faker": "~5.4.0",
"lodash": "~4.17.5",
"prop-types": "^15.7.2",
"ra-data-fakerest": "^4.9.3",
"ra-data-fakerest": "^4.10.2",
"react": "^17.0.0",
"react-admin": "^4.9.4",
"react-admin": "^4.10.2",
"react-beautiful-dnd": "^13.0.0",
"react-dom": "^17.0.0",
"react-error-boundary": "^3.1.4",
Expand Down
6 changes: 3 additions & 3 deletions examples/data-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-generator-retail",
"version": "4.9.3",
"version": "4.10.2",
"homepage": "https://github.com/marmelab/react-admin/tree/master/examples/data-generator",
"bugs": "https://github.com/marmelab/react-admin/issues",
"license": "MIT",
Expand All @@ -19,12 +19,12 @@
},
"devDependencies": {
"cross-env": "^5.2.0",
"ra-core": "^4.9.3",
"ra-core": "^4.10.2",
"rimraf": "^3.0.2",
"typescript": "^4.4.0"
},
"peerDependencies": {
"ra-core": "^4.0.0"
},
"gitHead": "8748248e40742bbd367338e0573a00213e17d3ab"
"gitHead": "e936ff2c3f887d2e98ef136cf3b3f3d254725fc4"
}
22 changes: 11 additions & 11 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "4.9.4",
"version": "4.10.2",
"private": true,
"dependencies": {
"@apollo/client": "^3.3.19",
Expand All @@ -10,7 +10,7 @@
"@types/recharts": "^1.8.10",
"@vitejs/plugin-react": "^2.2.0",
"clsx": "^1.1.1",
"data-generator-retail": "^4.9.3",
"data-generator-retail": "^4.10.2",
"date-fns": "^2.19.0",
"fakerest": "^3.0.0",
"fetch-mock": "~9.11.0",
Expand All @@ -21,16 +21,16 @@
"prop-types": "^15.6.1",
"proxy-polyfill": "^0.3.0",
"query-string": "^7.1.1",
"ra-data-fakerest": "^4.9.3",
"ra-data-graphql": "^4.9.4",
"ra-data-graphql-simple": "^4.9.4",
"ra-data-simple-rest": "^4.9.3",
"ra-i18n-polyglot": "^4.9.3",
"ra-input-rich-text": "^4.9.4",
"ra-language-english": "^4.9.3",
"ra-language-french": "^4.9.3",
"ra-data-fakerest": "^4.10.2",
"ra-data-graphql": "^4.10.1",
"ra-data-graphql-simple": "^4.10.1",
"ra-data-simple-rest": "^4.10.2",
"ra-i18n-polyglot": "^4.10.2",
"ra-input-rich-text": "^4.10.2",
"ra-language-english": "^4.10.2",
"ra-language-french": "^4.10.2",
"react": "^17.0.0",
"react-admin": "^4.9.4",
"react-admin": "^4.10.2",
"react-app-polyfill": "^2.0.0",
"react-dom": "^17.0.0",
"react-router": "^6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/layout/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Login = () => {
alignItems: 'center',
justifyContent: 'flex-start',
background:
'url(https://source.unsplash.com/random/1600x900)',
'url(https://source.unsplash.com/featured/1600x900)',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
}}
Expand Down
8 changes: 4 additions & 4 deletions examples/no-code/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "no-code",
"version": "4.9.4",
"version": "4.10.2",
"private": true,
"scripts": {
"dev": "yarn vite",
Expand All @@ -9,10 +9,10 @@
},
"dependencies": {
"@mui/material": "^5.0.2",
"ra-data-local-storage": "^4.9.3",
"ra-no-code": "^4.9.4",
"ra-data-local-storage": "^4.10.2",
"ra-no-code": "^4.10.2",
"react": "^17.0.0",
"react-admin": "^4.9.4",
"react-admin": "^4.10.2",
"react-dom": "^17.0.0"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple",
"version": "4.9.4",
"version": "4.10.2",
"private": true,
"scripts": {
"dev": "vite",
Expand All @@ -17,13 +17,13 @@
"lodash": "~4.17.5",
"prop-types": "^15.7.2",
"proxy-polyfill": "^0.3.0",
"ra-data-fakerest": "^4.9.3",
"ra-i18n-polyglot": "^4.9.3",
"ra-input-rich-text": "^4.9.4",
"ra-language-english": "^4.9.3",
"ra-language-french": "^4.9.3",
"ra-data-fakerest": "^4.10.2",
"ra-i18n-polyglot": "^4.10.2",
"ra-input-rich-text": "^4.10.2",
"ra-language-english": "^4.10.2",
"ra-language-french": "^4.10.2",
"react": "^17.0.0",
"react-admin": "^4.9.4",
"react-admin": "^4.10.2",
"react-dom": "^17.0.0",
"react-hook-form": "^7.40.0",
"react-query": "^3.32.1",
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tutorial",
"version": "4.9.4",
"version": "4.10.2",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -9,9 +9,9 @@
"preview": "vite preview"
},
"dependencies": {
"ra-data-json-server": "^4.9.3",
"ra-data-json-server": "^4.10.2",
"react": "^18.2.0",
"react-admin": "^4.9.4",
"react-admin": "^4.10.2",
"react-dom": "^18.2.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"examples/simple",
"packages/*"
],
"version": "4.9.4",
"version": "4.10.2",
"useWorkspaces": true
}
6 changes: 5 additions & 1 deletion packages/create-react-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ In another directory, run:
./react-admin/node_modules/.bin/create-react-admin my-admin
```

The above command assume you cloned react-admin in the `react-admin` directory and you are running the command in this directory parent.
The above command assume you cloned react-admin in the `react-admin` directory and you are running the command in this directory parent.

## Miscellaneous

This package is MIT licensed. Sponsored by [Marmelab](https://marmelab.com) and [Anthony Chan](https://github.com/ckanthony).
7 changes: 4 additions & 3 deletions packages/create-react-admin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-react-admin",
"description": "A CLI to quickly start a new react-admin project",
"version": "0.0.1",
"version": "4.10.2",
"license": "MIT",
"bin": "lib/cli.js",
"authors": [
Expand All @@ -15,7 +15,7 @@
"test": "prettier --check . && xo && ava"
},
"files": [
"dist"
"lib"
],
"dependencies": {
"execa": "^5.1.1",
Expand All @@ -30,5 +30,6 @@
"devDependencies": {
"@types/react": ">=17.0.0",
"typescript": "^4.4.0"
}
},
"gitHead": "e936ff2c3f887d2e98ef136cf3b3f3d254725fc4"
}
4 changes: 2 additions & 2 deletions packages/ra-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ra-core",
"version": "4.9.3",
"version": "4.10.2",
"description": "Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React",
"files": [
"*.md",
Expand Down Expand Up @@ -67,5 +67,5 @@
"react-is": "^17.0.2",
"react-query": "^3.32.1"
},
"gitHead": "8748248e40742bbd367338e0573a00213e17d3ab"
"gitHead": "e936ff2c3f887d2e98ef136cf3b3f3d254725fc4"
}
Loading