@patternfly/react-table 6.0.0-alpha.2 → 6.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -1
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
- package/dist/dynamic/components/Table/utils/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/esm/components/Table/Caption.js +1 -1
- package/dist/esm/components/Table/Caption.js.map +1 -1
- package/dist/esm/components/Table/CollapseColumn.js +1 -1
- package/dist/esm/components/Table/CollapseColumn.js.map +1 -1
- package/dist/esm/components/Table/DraggableRowWrapper.js +2 -2
- package/dist/esm/components/Table/DraggableRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/EditColumn.js +1 -1
- package/dist/esm/components/Table/EditColumn.js.map +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js +2 -2
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/esm/components/Table/EditableTextCell.js +2 -2
- package/dist/esm/components/Table/EditableTextCell.js.map +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js.map +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/SortColumn.js +1 -1
- package/dist/esm/components/Table/SortColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.js +3 -3
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableText.js +1 -1
- package/dist/esm/components/Table/TableText.js.map +1 -1
- package/dist/esm/components/Table/Tbody.js +1 -1
- package/dist/esm/components/Table/Tbody.js.map +1 -1
- package/dist/esm/components/Table/Td.js +3 -3
- package/dist/esm/components/Table/Td.js.map +1 -1
- package/dist/esm/components/Table/Th.js +2 -2
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/Thead.js +1 -1
- package/dist/esm/components/Table/Thead.js.map +1 -1
- package/dist/esm/components/Table/Tr.js +2 -2
- package/dist/esm/components/Table/Tr.js.map +1 -1
- package/dist/esm/components/Table/TreeRowWrapper.js +2 -2
- package/dist/esm/components/Table/TreeRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/selectable.js +2 -2
- package/dist/esm/components/Table/utils/decorators/selectable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/treeRow.js +2 -2
- package/dist/esm/components/Table/utils/decorators/treeRow.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js.map +1 -1
- package/dist/esm/demos/index.d.ts +2 -0
- package/dist/esm/demos/index.d.ts.map +1 -0
- package/dist/esm/demos/index.js +2 -0
- package/dist/esm/demos/index.js.map +1 -0
- package/dist/esm/demos/sampleData.d.ts +13 -0
- package/dist/esm/demos/sampleData.d.ts.map +1 -0
- package/dist/esm/demos/sampleData.js +764 -0
- package/dist/esm/demos/sampleData.js.map +1 -0
- package/dist/esm/deprecated/components/Table/Table.js +1 -1
- package/dist/esm/deprecated/components/Table/Table.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/js/demos/index.d.ts +2 -0
- package/dist/js/demos/index.d.ts.map +1 -0
- package/dist/js/demos/index.js +5 -0
- package/dist/js/demos/index.js.map +1 -0
- package/dist/js/demos/sampleData.d.ts +13 -0
- package/dist/js/demos/sampleData.d.ts.map +1 -0
- package/dist/js/demos/sampleData.js +767 -0
- package/dist/js/demos/sampleData.js.map +1 -0
- package/dist/js/index.d.ts +1 -0
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -0
- package/dist/js/index.js.map +1 -1
- package/dist/umd/react-table.min.js +3 -3
- package/package.json +6 -6
- package/src/components/Table/examples/TableStickyColumnsAndHeader.tsx +5 -4
- package/src/components/Table/utils/transformers.test.tsx +1 -0
- package/src/demos/Table.md +159 -0
- package/src/demos/examples/TableAutomaticPagination.tsx +101 -0
- package/src/{docs/demos/table-demos/BulkSelect.jsx → demos/examples/TableBulkSelect.tsx} +41 -20
- package/src/demos/examples/TableColumnManagement.tsx +486 -0
- package/src/demos/examples/TableColumnManagementWithDraggable.tsx +641 -0
- package/src/{docs/demos/table-demos/Compact.jsx → demos/examples/TableCompact.tsx} +32 -16
- package/src/{docs/demos/table-demos/CompoundExpansion.jsx → demos/examples/TableCompoundExpansion.tsx} +25 -12
- package/src/demos/examples/TableEmptyStateDefault.tsx +60 -0
- package/src/demos/examples/TableEmptyStateError.tsx +53 -0
- package/src/demos/examples/TableEmptyStateLoading.tsx +43 -0
- package/src/{docs/demos/table-demos/ExpandCollapseAll.jsx → demos/examples/TableExpandCollapseAll.tsx} +17 -10
- package/src/demos/examples/TableFilterable.tsx +394 -0
- package/src/{docs/demos/table-demos/SortableResponsive.jsx → demos/examples/TableSortableResponsive.tsx} +29 -27
- package/src/{docs/demos/table-demos/StaticBottomPagination.jsx → demos/examples/TableStaticBottomPagination.tsx} +22 -9
- package/src/{docs/demos/table-demos/StickyFirstColumn.jsx → demos/examples/TableStickyFirstColumn.tsx} +31 -9
- package/src/{docs/demos/table-demos/StickyHeader.jsx → demos/examples/TableStickyHeader.tsx} +3 -3
- package/src/demos/index.ts +1 -0
- package/src/{docs/demos/table-demos/sampleData.js → demos/sampleData.tsx} +88 -77
- package/src/deprecated/components/Table/__tests__/Table.test.tsx +4 -9
- package/src/index.ts +1 -0
- package/src/docs/demos/Table.md +0 -1620
- package/src/docs/demos/table-demos/ColumnManagement.jsx +0 -471
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
3
|
Button,
|
|
5
4
|
Card,
|
|
6
|
-
Label,
|
|
7
5
|
MenuToggle,
|
|
8
6
|
MenuToggleElement,
|
|
9
7
|
Pagination,
|
|
@@ -13,29 +11,45 @@ import {
|
|
|
13
11
|
Toolbar,
|
|
14
12
|
ToolbarContent,
|
|
15
13
|
ToolbarGroup,
|
|
16
|
-
ToolbarItem
|
|
14
|
+
ToolbarItem,
|
|
15
|
+
Label,
|
|
16
|
+
PaginationVariant
|
|
17
17
|
} from '@patternfly/react-core';
|
|
18
18
|
import { Table, TableText, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
19
19
|
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { rows, columns } from '@patternfly/react-table/dist/esm/demos/sampleData';
|
|
21
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
22
22
|
|
|
23
|
-
export const
|
|
24
|
-
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
|
25
|
-
const [page, setPage] = React.useState(1);
|
|
26
|
-
const [perPage, setPerPage] = React.useState(10);
|
|
23
|
+
export const TableCompact: React.FunctionComponent = () => {
|
|
24
|
+
const [isSelectOpen, setIsSelectOpen] = React.useState<boolean>(false);
|
|
25
|
+
const [page, setPage] = React.useState<number>(1);
|
|
26
|
+
const [perPage, setPerPage] = React.useState<number>(10);
|
|
27
27
|
const [paginatedRows, setPaginatedRows] = React.useState(rows.slice(0, 10));
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
const handleSetPage = (
|
|
30
|
+
_evt: React.MouseEvent | React.KeyboardEvent | MouseEvent,
|
|
31
|
+
newPage: number,
|
|
32
|
+
_perPage: number,
|
|
33
|
+
startIdx: number,
|
|
34
|
+
endIdx: number
|
|
35
|
+
) => {
|
|
29
36
|
setPaginatedRows(rows.slice(startIdx, endIdx));
|
|
30
37
|
setPage(newPage);
|
|
31
38
|
};
|
|
32
|
-
|
|
39
|
+
|
|
40
|
+
const handlePerPageSelect = (
|
|
41
|
+
_evt: React.MouseEvent | React.KeyboardEvent | MouseEvent,
|
|
42
|
+
newPerPage: number,
|
|
43
|
+
newPage: number,
|
|
44
|
+
startIdx: number,
|
|
45
|
+
endIdx: number
|
|
46
|
+
) => {
|
|
33
47
|
setPaginatedRows(rows.slice(startIdx, endIdx));
|
|
34
48
|
setPage(newPage);
|
|
35
49
|
setPerPage(newPerPage);
|
|
36
50
|
};
|
|
37
51
|
|
|
38
|
-
const renderPagination = (variant, isCompact) => (
|
|
52
|
+
const renderPagination = (variant: string, isCompact: boolean) => (
|
|
39
53
|
<Pagination
|
|
40
54
|
isCompact={isCompact}
|
|
41
55
|
itemCount={rows.length}
|
|
@@ -43,7 +57,7 @@ export const CompactTable = () => {
|
|
|
43
57
|
perPage={perPage}
|
|
44
58
|
onSetPage={handleSetPage}
|
|
45
59
|
onPerPageSelect={handlePerPageSelect}
|
|
46
|
-
variant={variant}
|
|
60
|
+
variant={variant as PaginationVariant}
|
|
47
61
|
titles={{
|
|
48
62
|
paginationAriaLabel: `${variant} pagination`
|
|
49
63
|
}}
|
|
@@ -63,7 +77,7 @@ export const CompactTable = () => {
|
|
|
63
77
|
</MenuToggle>
|
|
64
78
|
)}
|
|
65
79
|
isOpen={isSelectOpen}
|
|
66
|
-
onOpenChange={(isOpen) => setIsSelectOpen(isOpen)}
|
|
80
|
+
onOpenChange={(isOpen: boolean) => setIsSelectOpen(isOpen)}
|
|
67
81
|
onSelect={() => setIsSelectOpen(!isSelectOpen)}
|
|
68
82
|
>
|
|
69
83
|
{[
|
|
@@ -92,7 +106,7 @@ export const CompactTable = () => {
|
|
|
92
106
|
</Toolbar>
|
|
93
107
|
);
|
|
94
108
|
|
|
95
|
-
const renderLabel = (labelText) => {
|
|
109
|
+
const renderLabel = (labelText: string) => {
|
|
96
110
|
switch (labelText) {
|
|
97
111
|
case 'Running':
|
|
98
112
|
return <Label color="green">{labelText}</Label>;
|
|
@@ -102,8 +116,11 @@ export const CompactTable = () => {
|
|
|
102
116
|
return <Label color="blue">{labelText}</Label>;
|
|
103
117
|
case 'Down':
|
|
104
118
|
return <Label color="red">{labelText}</Label>;
|
|
119
|
+
default:
|
|
120
|
+
return <></>;
|
|
105
121
|
}
|
|
106
122
|
};
|
|
123
|
+
|
|
107
124
|
return (
|
|
108
125
|
<React.Fragment>
|
|
109
126
|
<DashboardWrapper hasPageTemplateTitle>
|
|
@@ -146,7 +163,6 @@ export const CompactTable = () => {
|
|
|
146
163
|
))}
|
|
147
164
|
</Tbody>
|
|
148
165
|
</Table>
|
|
149
|
-
{renderPagination('bottom', false)}
|
|
150
166
|
</Card>
|
|
151
167
|
</PageSection>
|
|
152
168
|
</DashboardWrapper>
|
|
@@ -14,16 +14,17 @@ import {
|
|
|
14
14
|
Pagination,
|
|
15
15
|
PageSection,
|
|
16
16
|
Select,
|
|
17
|
-
SelectOption
|
|
17
|
+
SelectOption,
|
|
18
|
+
PaginationVariant
|
|
18
19
|
} from '@patternfly/react-core';
|
|
19
20
|
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
20
21
|
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
21
22
|
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
22
|
-
import { DashboardWrapper } from '@patternfly/react-core/
|
|
23
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
23
24
|
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
24
25
|
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
25
26
|
|
|
26
|
-
export const
|
|
27
|
+
export const TableCompoundExpansion: React.FunctionComponent = () => {
|
|
27
28
|
// In real usage, this data would come from some external source like an API via props.
|
|
28
29
|
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
|
29
30
|
|
|
@@ -55,7 +56,7 @@ export const CompoundExpandable = () => {
|
|
|
55
56
|
</Thead>
|
|
56
57
|
<Tbody>
|
|
57
58
|
{items.map((item) => (
|
|
58
|
-
<Tr key={item.
|
|
59
|
+
<Tr key={item.description}>
|
|
59
60
|
<Td dataLabel={columnNames.description}>{item.description}</Td>
|
|
60
61
|
<Td dataLabel={columnNames.date}>{item.date}</Td>
|
|
61
62
|
<Td dataLabel={columnNames.status}>{item.status}</Td>
|
|
@@ -69,7 +70,7 @@ export const CompoundExpandable = () => {
|
|
|
69
70
|
);
|
|
70
71
|
};
|
|
71
72
|
|
|
72
|
-
const renderPagination = (variant, isCompact) => (
|
|
73
|
+
const renderPagination = (variant: 'top' | 'bottom' | PaginationVariant, isCompact: boolean) => (
|
|
73
74
|
<Pagination
|
|
74
75
|
isCompact={isCompact}
|
|
75
76
|
itemCount={36}
|
|
@@ -95,7 +96,7 @@ export const CompoundExpandable = () => {
|
|
|
95
96
|
</MenuToggle>
|
|
96
97
|
)}
|
|
97
98
|
isOpen={isSelectOpen}
|
|
98
|
-
onOpenChange={(isOpen) => setIsSelectOpen(isOpen)}
|
|
99
|
+
onOpenChange={(isOpen: boolean) => setIsSelectOpen(isOpen)}
|
|
99
100
|
onSelect={() => setIsSelectOpen(!isSelectOpen)}
|
|
100
101
|
>
|
|
101
102
|
{[
|
|
@@ -137,7 +138,19 @@ export const CompoundExpandable = () => {
|
|
|
137
138
|
}
|
|
138
139
|
];
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
interface Repo {
|
|
142
|
+
name: string;
|
|
143
|
+
branches: number;
|
|
144
|
+
prs: number;
|
|
145
|
+
workspaces: number;
|
|
146
|
+
lastCommit: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface IDictionary<T> {
|
|
150
|
+
[Key: string]: T;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const repositories: Repo[] = [
|
|
141
154
|
{
|
|
142
155
|
name: 'siemur/test-space',
|
|
143
156
|
branches: 10,
|
|
@@ -148,7 +161,7 @@ export const CompoundExpandable = () => {
|
|
|
148
161
|
{ name: 'siemur/test-space-2', branches: 3, prs: 4, workspaces: 4, lastCommit: '20 minutes' }
|
|
149
162
|
];
|
|
150
163
|
|
|
151
|
-
const columnNames = {
|
|
164
|
+
const columnNames: IDictionary<string> = {
|
|
152
165
|
name: 'Repositories',
|
|
153
166
|
branches: 'Branches',
|
|
154
167
|
prs: 'Pull requests',
|
|
@@ -159,11 +172,11 @@ export const CompoundExpandable = () => {
|
|
|
159
172
|
// In this example, expanded cells are tracked by the repo and property names from each row. This could be any pair of unique identifiers.
|
|
160
173
|
// This is to prevent state from being based on row and column order index in case we later add sorting and rearranging columns.
|
|
161
174
|
// Note that this behavior is very similar to selection state.
|
|
162
|
-
const [expandedCells, setExpandedCells] = React.useState({
|
|
175
|
+
const [expandedCells, setExpandedCells] = React.useState<IDictionary<string>>({
|
|
163
176
|
'siemur/test-space': 'branches' // Default to the first cell of the first row being expanded
|
|
164
177
|
});
|
|
165
|
-
const setCellExpanded = (repo, columnKey, isExpanding = true) => {
|
|
166
|
-
const newExpandedCells = { ...expandedCells };
|
|
178
|
+
const setCellExpanded = (repo: Repo, columnKey: string, isExpanding = true) => {
|
|
179
|
+
const newExpandedCells: IDictionary<string> = { ...expandedCells };
|
|
167
180
|
if (isExpanding) {
|
|
168
181
|
newExpandedCells[repo.name] = columnKey;
|
|
169
182
|
} else {
|
|
@@ -171,7 +184,7 @@ export const CompoundExpandable = () => {
|
|
|
171
184
|
}
|
|
172
185
|
setExpandedCells(newExpandedCells);
|
|
173
186
|
};
|
|
174
|
-
const compoundExpandParams = (repo, columnKey, rowIndex, columnIndex) => ({
|
|
187
|
+
const compoundExpandParams = (repo: Repo, columnKey: string, rowIndex: number, columnIndex: number) => ({
|
|
175
188
|
isExpanded: expandedCells[repo.name] === columnKey,
|
|
176
189
|
onToggle: () => setCellExpanded(repo, columnKey, expandedCells[repo.name] !== columnKey),
|
|
177
190
|
expandId: 'compound-expandable-demo',
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
3
|
+
import {
|
|
4
|
+
Bullseye,
|
|
5
|
+
Button,
|
|
6
|
+
Card,
|
|
7
|
+
EmptyState,
|
|
8
|
+
EmptyStateVariant,
|
|
9
|
+
EmptyStateIcon,
|
|
10
|
+
EmptyStateBody,
|
|
11
|
+
EmptyStateHeader,
|
|
12
|
+
EmptyStateFooter,
|
|
13
|
+
EmptyStateActions,
|
|
14
|
+
PageSection
|
|
15
|
+
} from '@patternfly/react-core';
|
|
16
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
17
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
18
|
+
|
|
19
|
+
export const TableEmptyStateDefault: React.FunctionComponent = () => (
|
|
20
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
21
|
+
<PageSection padding={{ default: 'noPadding', xl: 'padding' }}>
|
|
22
|
+
<Card component="div">
|
|
23
|
+
<Table aria-label="Empty state table">
|
|
24
|
+
<Thead>
|
|
25
|
+
<Tr>
|
|
26
|
+
<Th>Repositories</Th>
|
|
27
|
+
<Th>Branches</Th>
|
|
28
|
+
<Th>Pull requests</Th>
|
|
29
|
+
<Th>Workspaces</Th>
|
|
30
|
+
<Th>Last commit</Th>
|
|
31
|
+
</Tr>
|
|
32
|
+
</Thead>
|
|
33
|
+
<Tbody>
|
|
34
|
+
<Tr>
|
|
35
|
+
<Td colSpan={8}>
|
|
36
|
+
<Bullseye>
|
|
37
|
+
<EmptyState variant={EmptyStateVariant.sm}>
|
|
38
|
+
<EmptyStateHeader
|
|
39
|
+
icon={<EmptyStateIcon icon={SearchIcon} />}
|
|
40
|
+
titleText="No results found"
|
|
41
|
+
headingLevel="h2"
|
|
42
|
+
/>
|
|
43
|
+
<EmptyStateBody>
|
|
44
|
+
No results match this filter criteria. Clear all filters and try again.
|
|
45
|
+
</EmptyStateBody>
|
|
46
|
+
<EmptyStateFooter>
|
|
47
|
+
<EmptyStateActions>
|
|
48
|
+
<Button variant="link">Clear all filters</Button>
|
|
49
|
+
</EmptyStateActions>
|
|
50
|
+
</EmptyStateFooter>
|
|
51
|
+
</EmptyState>
|
|
52
|
+
</Bullseye>
|
|
53
|
+
</Td>
|
|
54
|
+
</Tr>
|
|
55
|
+
</Tbody>
|
|
56
|
+
</Table>
|
|
57
|
+
</Card>
|
|
58
|
+
</PageSection>
|
|
59
|
+
</DashboardWrapper>
|
|
60
|
+
);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
3
|
+
import {
|
|
4
|
+
Bullseye,
|
|
5
|
+
Card,
|
|
6
|
+
EmptyState,
|
|
7
|
+
EmptyStateVariant,
|
|
8
|
+
EmptyStateIcon,
|
|
9
|
+
EmptyStateBody,
|
|
10
|
+
EmptyStateHeader,
|
|
11
|
+
PageSection
|
|
12
|
+
} from '@patternfly/react-core';
|
|
13
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
14
|
+
import globalDangerColor200 from '@patternfly/react-tokens/dist/esm/global_danger_color_200';
|
|
15
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
16
|
+
|
|
17
|
+
export const TableEmptyStateError: React.FunctionComponent = () => (
|
|
18
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
19
|
+
<PageSection padding={{ default: 'noPadding', xl: 'padding' }}>
|
|
20
|
+
<Card component="div">
|
|
21
|
+
<Table aria-label="Loading table demo">
|
|
22
|
+
<Thead>
|
|
23
|
+
<Tr>
|
|
24
|
+
<Th>Repositories</Th>
|
|
25
|
+
<Th>Branches</Th>
|
|
26
|
+
<Th>Pull requests</Th>
|
|
27
|
+
<Th>Workspaces</Th>
|
|
28
|
+
<Th>Last commit</Th>
|
|
29
|
+
</Tr>
|
|
30
|
+
</Thead>
|
|
31
|
+
<Tbody>
|
|
32
|
+
<Tr>
|
|
33
|
+
<Td colSpan={8}>
|
|
34
|
+
<Bullseye>
|
|
35
|
+
<EmptyState variant={EmptyStateVariant.sm}>
|
|
36
|
+
<EmptyStateHeader
|
|
37
|
+
titleText="Unable to connect"
|
|
38
|
+
icon={<EmptyStateIcon icon={ExclamationCircleIcon} color={globalDangerColor200.value} />}
|
|
39
|
+
headingLevel="h2"
|
|
40
|
+
/>
|
|
41
|
+
<EmptyStateBody>
|
|
42
|
+
There was an error retrieving data. Check your connection and reload the page.
|
|
43
|
+
</EmptyStateBody>
|
|
44
|
+
</EmptyState>
|
|
45
|
+
</Bullseye>
|
|
46
|
+
</Td>
|
|
47
|
+
</Tr>
|
|
48
|
+
</Tbody>
|
|
49
|
+
</Table>
|
|
50
|
+
</Card>
|
|
51
|
+
</PageSection>
|
|
52
|
+
</DashboardWrapper>
|
|
53
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
3
|
+
import {
|
|
4
|
+
Bullseye,
|
|
5
|
+
Card,
|
|
6
|
+
EmptyState,
|
|
7
|
+
EmptyStateIcon,
|
|
8
|
+
EmptyStateHeader,
|
|
9
|
+
PageSection,
|
|
10
|
+
Spinner
|
|
11
|
+
} from '@patternfly/react-core';
|
|
12
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
13
|
+
|
|
14
|
+
export const TableEmptyStateLoading: React.FunctionComponent = () => (
|
|
15
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
16
|
+
<PageSection padding={{ default: 'noPadding', xl: 'padding' }}>
|
|
17
|
+
<Card component="div">
|
|
18
|
+
<Table aria-label="Loading table demo">
|
|
19
|
+
<Thead>
|
|
20
|
+
<Tr>
|
|
21
|
+
<Th>Repositories</Th>
|
|
22
|
+
<Th>Branches</Th>
|
|
23
|
+
<Th>Pull requests</Th>
|
|
24
|
+
<Th>Workspaces</Th>
|
|
25
|
+
<Th>Last commit</Th>
|
|
26
|
+
</Tr>
|
|
27
|
+
</Thead>
|
|
28
|
+
<Tbody>
|
|
29
|
+
<Tr>
|
|
30
|
+
<Td colSpan={8}>
|
|
31
|
+
<Bullseye>
|
|
32
|
+
<EmptyState>
|
|
33
|
+
<EmptyStateHeader titleText="Loading" headingLevel="h2" icon={<EmptyStateIcon icon={Spinner} />} />
|
|
34
|
+
</EmptyState>
|
|
35
|
+
</Bullseye>
|
|
36
|
+
</Td>
|
|
37
|
+
</Tr>
|
|
38
|
+
</Tbody>
|
|
39
|
+
</Table>
|
|
40
|
+
</Card>
|
|
41
|
+
</PageSection>
|
|
42
|
+
</DashboardWrapper>
|
|
43
|
+
);
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { Card, Label, PageSection, TextVariants, Text, TextContent } from '@patternfly/react-core';
|
|
3
3
|
import { Table, Thead, Tbody, Tr, Th, Td, ExpandableRowContent } from '@patternfly/react-table';
|
|
4
|
-
import { DashboardWrapper } from '@patternfly/react-core/
|
|
4
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
5
5
|
|
|
6
6
|
const expandableColumns = ['Servers', 'Threads', 'Applications', 'Workspaces', 'Status'];
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
interface Server {
|
|
9
|
+
name: string;
|
|
10
|
+
threads: number;
|
|
11
|
+
applications: number;
|
|
12
|
+
workspaces: number;
|
|
13
|
+
status: { title: ReactNode };
|
|
14
|
+
details: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const serverData: Server[] = [
|
|
9
18
|
{
|
|
10
19
|
name: 'US-Node 1',
|
|
11
20
|
threads: 18,
|
|
@@ -110,7 +119,7 @@ const serverData = [
|
|
|
110
119
|
|
|
111
120
|
const initialExpandedServerNames = ['US-Node 2']; // Default to expanded
|
|
112
121
|
|
|
113
|
-
const
|
|
122
|
+
export const TableExpandCollapseAll: React.FunctionComponent = () => {
|
|
114
123
|
const [areAllExpanded, setAreAllExpanded] = React.useState(false);
|
|
115
124
|
const [collapseAllAriaLabel, setCollapseAllAriaLabel] = React.useState('Expand all');
|
|
116
125
|
const [expandedServerNames, setExpandedServerNames] = React.useState(initialExpandedServerNames);
|
|
@@ -121,20 +130,18 @@ const ExpandCollapseAllTableDemo = () => {
|
|
|
121
130
|
setCollapseAllAriaLabel(allExpanded ? 'Collapse all' : 'Expand all');
|
|
122
131
|
}, [expandedServerNames]);
|
|
123
132
|
|
|
124
|
-
const setServerExpanded = (server, isExpanding) => {
|
|
133
|
+
const setServerExpanded = (server: Server, isExpanding: boolean) => {
|
|
125
134
|
const otherExpandedServerNames = expandedServerNames.filter((r) => r !== server.name);
|
|
126
135
|
setExpandedServerNames(isExpanding ? [...otherExpandedServerNames, server.name] : otherExpandedServerNames);
|
|
127
136
|
};
|
|
128
137
|
|
|
129
|
-
const isServerExpanded = (server) =>
|
|
130
|
-
return expandedServerNames.includes(server.name);
|
|
131
|
-
};
|
|
138
|
+
const isServerExpanded = (server: Server) => expandedServerNames.includes(server.name);
|
|
132
139
|
|
|
133
140
|
// We want to be able to reference the original data object based on row index. But because an expanded
|
|
134
141
|
// row takes up two row indexes, servers[rowIndex] will not be accurate like it would in a normal table.
|
|
135
142
|
// One solution to this is to create an array of data objects indexed by the displayed row index.
|
|
136
143
|
|
|
137
|
-
const onCollapseAll = (_event, _rowIndex, isOpen) => {
|
|
144
|
+
const onCollapseAll = (_event: any, _rowIndex: number, isOpen: boolean) => {
|
|
138
145
|
setExpandedServerNames(isOpen ? [...serverData.map((server) => server.name)] : []);
|
|
139
146
|
};
|
|
140
147
|
|
|
@@ -154,7 +161,7 @@ const ExpandCollapseAllTableDemo = () => {
|
|
|
154
161
|
<Th
|
|
155
162
|
expand={{
|
|
156
163
|
areAllExpanded: !areAllExpanded,
|
|
157
|
-
collapseAllAriaLabel
|
|
164
|
+
collapseAllAriaLabel,
|
|
158
165
|
onToggle: onCollapseAll
|
|
159
166
|
}}
|
|
160
167
|
></Th>
|