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

Introduce Resource Context #5456

Merged
merged 10 commits into from
Nov 3, 2020
Merged

Introduce Resource Context #5456

merged 10 commits into from
Nov 3, 2020

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Oct 29, 2020

Supersedes #5446

@djhi djhi added the WIP Work In Progress label Oct 29, 2020
@djhi djhi changed the base branch from master to next October 29, 2020 16:11
@djhi djhi added RFR Ready For Review and removed WIP Work In Progress labels Nov 2, 2020
@djhi djhi requested a review from fzaninotto November 2, 2020 13:52
const controllerProps = useReferenceArrayFieldController({
resource,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doesn't the useReferenceArrayFieldController call the useResourceContext itself?

const controllerProps = useReferenceManyFieldController({
page,
perPage,
resource,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

return children(useReferenceInputController(props)) as ReactElement;
const { resource } = useResourceContext(props);
return children(
useReferenceInputController({ resource, ...props })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -23,6 +23,7 @@ import {
Record,
Exporter,
} from '../types';
import { useResourceContext, useResourceDefinition } from '../core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer necessary

* Must be used within a <ResourceContextProvider> (e.g. as a descendent of <Resource>
* or any reference related components).
*
* @returns {ResourceContextValue} The resource informations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {ResourceContextValue} The resource informations
* @returns {ResourceContextValue} The resource information

import { ResourceContext, ResourceContextValue } from './ResourceContext';

/**
* Hook to read the resource informations from the ResourceContext.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Hook to read the resource informations from the ResourceContext.
* Hook to read the resource information from the ResourceContext.

redirect = 'list',
onSuccess,
onFailure,
...rest
} = props;
const translate = useTranslate();
const classes = useStyles(props);
const { resource } = useResourceContext(props);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -31,6 +31,7 @@ const DeleteWithUndoButton: FC<DeleteWithUndoButtonProps> = props => {
...rest
} = props;
const classes = useStyles(props);
const { resource } = useResourceContext(props);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@fzaninotto fzaninotto merged commit 779f058 into next Nov 3, 2020
@fzaninotto fzaninotto deleted the resource-context-2 branch November 3, 2020 12:49
@fzaninotto fzaninotto added this to the 3.10.0 milestone Nov 3, 2020
@fzaninotto
Copy link
Member

\o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants