Skip to content

Commit

Permalink
Support different button kinds in Table toolbarButtons
Browse files Browse the repository at this point in the history
Update the Table component to support passing additional props to
the toolbar buttons, e.g. `kind` to have a mixture of primary and
secondary actions on the table.
  • Loading branch information
AlanGreene authored and tekton-robot committed May 13, 2022
1 parent 1e0ee7b commit a195d2f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions packages/components/src/components/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,15 @@ const Table = props => {
</TableBatchActions>
)}
<TableToolbarContent>
{toolbarButtons.map(button => (
{toolbarButtons.map(({ icon, onClick, text, ...rest }) => (
<Button
disabled={loading}
onClick={button.onClick}
renderIcon={button.icon}
key={`${button.text}Button`}
key={`${text}Button`}
onClick={onClick}
renderIcon={icon}
{...rest}
>
{button.text}
{text}
</Button>
))}
</TableToolbarContent>
Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/components/Table/Table.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,16 @@ export const Sorting = args => {
size={args.size}
title={args.title}
toolbarButtons={[
{ onClick: action('handleNew'), text: 'Add', icon: Add },
{
icon: RerunAll,
kind: 'secondary',
onClick: action('handleRerunAll'),
text: 'RerunAll',
icon: RerunAll
text: 'RerunAll'
},
{
icon: Add,
onClick: action('handleNew'),
text: 'Add'
}
]}
/>
Expand Down

0 comments on commit a195d2f

Please sign in to comment.