Add Link to Stories from Sites

This commit is contained in:
Jerko Steiner 2019-04-06 14:11:55 +08:00
parent e18fa89b26
commit 582d36de02

View File

@ -12,10 +12,16 @@ export interface ICRUDListProps<T> {
onRemove?: (t: T) => void onRemove?: (t: T) => void
title: string title: string
Info?: React.ComponentType<ICRUDItemInfoProps<T>> Info?: React.ComponentType<ICRUDItemInfoProps<T>>
RowButtons?: React.ComponentType<ICRUDRowButtons<T>>
}
export interface ICRUDRowButtons<T> {
item: T
} }
export interface ICRUDItemRowProps<T> { export interface ICRUDItemRowProps<T> {
Info?: React.ComponentType<ICRUDItemInfoProps<T>> Info?: React.ComponentType<ICRUDItemInfoProps<T>>
RowButtons?: React.ComponentType<ICRUDRowButtons<T>>
nameKey: keyof T nameKey: keyof T
editLink?: string editLink?: string
item: T item: T
@ -54,6 +60,10 @@ export class CRUDItemRow<T> extends React.PureComponent<ICRUDItemRowProps<T>> {
} }
</div> </div>
<div className='ml-auto'> <div className='ml-auto'>
{!!this.props.RowButtons && (
<this.props.RowButtons item={item} />
)}
&nbsp;
{!!editLink && ( {!!editLink && (
<Link to={editLink}> <Link to={editLink}>
<Button isInverted isColor='link' aria-label='Edit'> <Button isInverted isColor='link' aria-label='Edit'>
@ -103,6 +113,7 @@ export class CRUDList<T> extends React.PureComponent<ICRUDListProps<T>> {
<PanelBlock key={itemId}> <PanelBlock key={itemId}>
<CRUDItemRow<T> <CRUDItemRow<T>
Info={this.props.Info} Info={this.props.Info}
RowButtons={this.props.RowButtons}
nameKey={nameKey} nameKey={nameKey}
editLink={editLink && editLink(item)} editLink={editLink && editLink(item)}
item={item} item={item}