forked from patternfly/react-data-view
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataViewTableEmptyExample.tsx
More file actions
57 lines (50 loc) · 1.92 KB
/
DataViewTableEmptyExample.tsx
File metadata and controls
57 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { FunctionComponent } from 'react';
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
import { CubesIcon } from '@patternfly/react-icons';
import { Button, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter } from '@patternfly/react-core';
import { Tbody, Td, Tr } from '@patternfly/react-table';
interface Repository {
id: number;
name: string;
branches: string | null;
prs: string | null;
workspaces: string;
lastCommit: string;
}
const repositories: Repository[] = [];
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
const rows: DataViewTr[] = repositories.map((repository) => Object.values(repository));
const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit' ];
const ouiaId = 'TableExample';
const empty = (
<Tbody>
<Tr key="loading" ouiaId={`${ouiaId}-tr-loading`}>
<Td colSpan={columns.length}>
<EmptyState headingLevel="h4" icon={CubesIcon} titleText="No data found">
<EmptyStateBody>There are no matching data to be displayed.</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary">Primary action</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant="link">Multiple</Button>
<Button variant="link">Action Buttons</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
</Td>
</Tr>
</Tbody>
);
export const BasicExample: FunctionComponent = () => (
<DataView activeState={DataViewState.empty}>
<DataViewTable
aria-label="Repositories table"
ouiaId={ouiaId}
columns={columns}
rows={rows}
bodyStates={{ empty }}
/>
</DataView>
);