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

Show|Create|EditGuesser viewComponent prop #527

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/CreateGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const IntrospectedCreateGuesser = ({
warnWhenUnsavedChanges,
sanitizeEmptyValues = true,
formComponent,
viewComponent,
children,
...props
}: IntrospectedCreateGuesserProps) => {
Expand Down Expand Up @@ -162,7 +163,7 @@ export const IntrospectedCreateGuesser = ({
const FormType = hasFormTab ? TabbedForm : SimpleForm;

return (
<Create resource={resource} {...props}>
<Create resource={resource} component={viewComponent} {...props}>
<FormType
onSubmit={save}
mode={mode}
Expand Down
2 changes: 2 additions & 0 deletions src/EditGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const IntrospectedEditGuesser = ({
toolbar,
warnWhenUnsavedChanges,
formComponent,
viewComponent,
sanitizeEmptyValues = true,
children,
...props
Expand Down Expand Up @@ -197,6 +198,7 @@ export const IntrospectedEditGuesser = ({
id={id}
mutationMode={mutationMode}
redirect={redirectTo}
component={viewComponent}
transform={(data: Partial<RaRecord>) => ({
...data,
extraInformation: { hasFileField },
Expand Down
3 changes: 2 additions & 1 deletion src/ShowGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const IntrospectedShowGuesser = ({
writableFields,
schema,
schemaAnalyzer,
viewComponent,
children,
...props
}: IntrospectedShowGuesserProps) => {
Expand All @@ -70,7 +71,7 @@ export const IntrospectedShowGuesser = ({
const ShowLayout = hasTab ? TabbedShowLayout : SimpleShowLayout;

return (
<Show {...props}>
<Show component={viewComponent} {...props}>
<ShowLayout>{fieldChildren}</ShowLayout>
</Show>
);
Expand Down
9 changes: 6 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ type CreateFormProps = Omit<
CreateProps & SimpleFormProps & TabbedFormProps,
'children'
> &
Partial<PickRename<CreateProps, 'component', 'viewComponent'>> &
Partial<
PickRename<SimpleFormProps & TabbedFormProps, 'component', 'formComponent'>
> & {
Expand All @@ -388,6 +389,7 @@ type EditFormProps = Omit<
EditProps & SimpleFormProps & TabbedFormProps,
'children'
> &
Partial<PickRename<EditProps, 'component', 'viewComponent'>> &
Partial<
PickRename<SimpleFormProps & TabbedFormProps, 'component', 'formComponent'>
> & {
Expand Down Expand Up @@ -421,9 +423,10 @@ export type ListGuesserProps = Omit<
type ShowFormProps = Omit<
ShowProps & SimpleFormProps & TabbedFormProps,
'children'
> & {
children?: ReactNode;
};
> &
Partial<PickRename<ShowProps, 'component', 'viewComponent'>> & {
children?: ReactNode;
};

export type IntrospectedShowGuesserProps = ShowFormProps &
IntrospectedGuesserProps;
Expand Down
Loading