-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Simplify Buttons Props #7750
Simplify Buttons Props #7750
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,6 @@ import { | |
} from 'ra-core'; | ||
import { Path } from 'react-router'; | ||
|
||
export type LocationDescriptor = Partial<Path> & { | ||
redirect?: boolean; | ||
state?: any; | ||
replace?: boolean; | ||
}; | ||
|
||
/** | ||
* A generic Button with side icon. Only the icon is displayed on small screens. | ||
* | ||
|
@@ -38,7 +32,9 @@ export type LocationDescriptor = Partial<Path> & { | |
* </Button> | ||
* | ||
*/ | ||
export const Button = (props: ButtonProps) => { | ||
export const Button = <RecordType extends RaRecord = RaRecord>( | ||
props: ButtonProps<RecordType> | ||
) => { | ||
const { | ||
alignIcon = 'left', | ||
children, | ||
|
@@ -102,7 +98,7 @@ export const Button = (props: ButtonProps) => { | |
); | ||
}; | ||
|
||
interface Props { | ||
interface Props<RecordType extends RaRecord = RaRecord> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, I think this is a breaking change |
||
alignIcon?: 'left' | 'right'; | ||
children?: ReactElement; | ||
className?: string; | ||
|
@@ -114,13 +110,16 @@ interface Props { | |
size?: 'small' | 'medium' | 'large'; | ||
redirect?: RedirectionSideEffect; | ||
variant?: string; | ||
// May be injected by Toolbar | ||
record?: RaRecord; | ||
// May be provided manually | ||
record?: RecordType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, I fail to see what |
||
resource?: string; | ||
mutationMode?: MutationMode; | ||
} | ||
|
||
export type ButtonProps = Props & MuiButtonProps; | ||
export type ButtonProps<RecordType extends RaRecord = RaRecord> = Props< | ||
RecordType | ||
> & | ||
MuiButtonProps; | ||
|
||
export const sanitizeButtonRestProps = ({ | ||
// The next props are injected by Toolbar | ||
|
@@ -186,3 +185,9 @@ const getLinkParams = (locationDescriptor?: LocationDescriptor | string) => { | |
state, | ||
}; | ||
}; | ||
|
||
export type LocationDescriptor = Partial<Path> & { | ||
redirect?: boolean; | ||
state?: any; | ||
replace?: boolean; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should default to any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I failt to see why there is a
record
prop. This should be handled by the specialized buttons only imo