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 SourceContext #9533

Merged
merged 28 commits into from
Jan 12, 2024
Merged

Introduce SourceContext #9533

merged 28 commits into from
Jan 12, 2024

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Dec 18, 2023

Problem

We need to prefix sources in multiple cases: ArrayInput + SimpleFormIterator, and many EE components.

To do that we currently clone children.

Solution

This is avoidable by introducing a context that useInput would use to set the source.

It’s a breaking change though for custom inputs that don’t use useInput.

@djhi djhi added RFR Ready For Review v5 labels Dec 18, 2023
@djhi djhi added WIP Work In Progress and removed RFR Ready For Review labels Dec 19, 2023
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/Upgrade.md Show resolved Hide resolved
packages/ra-core/src/form/FormDataConsumer.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/form/useApplyInputDefaultValues.ts Outdated Show resolved Hide resolved
packages/ra-core/src/util/FieldTitle.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/core/SourcePrefixContext.tsx Outdated Show resolved Hide resolved
docs/Inputs.md Outdated Show resolved Hide resolved
docs/SimpleFormIterator.md Outdated Show resolved Hide resolved
@adguernier adguernier self-requested a review December 20, 2023 10:25
Copy link
Contributor

@adguernier adguernier left a comment

Choose a reason for hiding this comment

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

Just two minor omissions in the documentation otherwise it looks good to me

docs/SimpleFormIterator.md Outdated Show resolved Hide resolved
docs/Inputs.md Outdated Show resolved Hide resolved
docs/Upgrade.md Show resolved Hide resolved
packages/ra-core/src/core/SourcePrefixContext.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/util/FieldTitle.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/core/SourcePrefixContext.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/core/SourcePrefixContext.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/form/FormDataConsumer.spec.tsx Outdated Show resolved Hide resolved
docs/SimpleFormIterator.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
packages/ra-core/src/core/SourceContext.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/form/useApplyInputDefaultValues.ts Outdated Show resolved Hide resolved
docs/Inputs.md Outdated Show resolved Hide resolved
docs/SimpleFormIterator.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
);
screen.getByText('Label for title');
});
});
Copy link
Member

Choose a reason for hiding this comment

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

I think we're missing tests cases for sources with dots and / or inside ArrayInputs.

packages/ra-core/src/util/getFieldLabelTranslationArgs.ts Outdated Show resolved Hide resolved
packages/ra-core/src/i18n/useTranslateLabel.ts Outdated Show resolved Hide resolved
Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

minor remarks

docs/Upgrade.md Outdated Show resolved Hide resolved
ret = children({ formData, scopedFormData, getSource, ...rest });
if (matches) {
const scopedFormData = get(formData, matches[0]);
ret = children({ formData, scopedFormData, ...rest });
Copy link
Member

Choose a reason for hiding this comment

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

sure

packages/ra-core/src/form/useInput.ts Outdated Show resolved Hide resolved
Co-authored-by: Francois Zaninotto <francois@marmelab.com>
Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

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

Otherwise it's good to me, we're so close!! 😁

Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

@slax57 slax57 merged commit 7f010a0 into next Jan 12, 2024
11 checks passed
@slax57 slax57 deleted the source-context branch January 12, 2024 10:14
@slax57 slax57 added this to the 5.0.0 milestone Jan 12, 2024
@fzaninotto fzaninotto mentioned this pull request Jan 17, 2024
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review v5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants