Skip to content

Commit 6e5530b

Browse files
committed
fix(actions): Add row actions example
1 parent 1dd4eb2 commit 6e5530b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

packages/module/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableExample.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
33
import { ExclamationCircleIcon } from '@patternfly/react-icons';
44
import { Button } from '@patternfly/react-core';
5+
import { ActionsColumn } from '@patternfly/react-table';
56

67
interface Repository {
78
id: number;
@@ -21,14 +22,33 @@ const repositories: Repository[] = [
2122
{ id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
2223
];
2324

25+
const rowActions = [
26+
{
27+
title: 'Some action',
28+
onClick: () => console.log('clicked on Some action') // eslint-disable-line no-console
29+
},
30+
{
31+
title: <div>Another action</div>,
32+
onClick: () => console.log('clicked on Another action') // eslint-disable-line no-console
33+
},
34+
{
35+
isSeparator: true
36+
},
37+
{
38+
title: 'Third action',
39+
onClick: () => console.log('clicked on Third action') // eslint-disable-line no-console
40+
}
41+
];
42+
2443
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
2544
const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspaces, lastCommit }) => [
2645
{ id, cell: workspaces, props: { favorites: { isFavorited: true } } },
2746
{ cell: <Button href='#' variant='link' isInline>{name}</Button> },
2847
branches,
2948
prs,
3049
workspaces,
31-
lastCommit
50+
lastCommit,
51+
{ cell: <ActionsColumn items={rowActions}/>, props: { isActionCell: true } },
3252
]);
3353

3454
const columns: DataViewTh[] = [
@@ -37,7 +57,7 @@ const columns: DataViewTh[] = [
3757
{ cell: <>Branches<ExclamationCircleIcon className='pf-v5-u-ml-sm' color='var(--pf-v5-global--danger-color--100)'/></> },
3858
'Pull requests',
3959
{ cell: 'Workspaces', props: { info: { tooltip: 'More information' } } },
40-
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 } } }
60+
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 } } },
4161
];
4262

4363
const ouiaId = 'TableExample';

0 commit comments

Comments
 (0)