@patternfly/react-table 4.67.10 → 4.67.13

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.
@@ -1,5 +1,6 @@
1
1
  import { calculateColumns, mapOpenedRows } from './headerUtils';
2
2
  import { ICell, IRow } from '../TableTypes';
3
+ import { HeaderType } from '../base/types';
3
4
 
4
5
  describe('headerUtils', () => {
5
6
  describe('calculateColumns', () => {
@@ -80,7 +81,7 @@ describe('headerUtils', () => {
80
81
  {
81
82
  header: {
82
83
  someData: 'test'
83
- }
84
+ } as HeaderType
84
85
  }
85
86
  ] as ICell[],
86
87
  {}
@@ -167,6 +167,13 @@ To make a cell an action cell, render an `ActionsColumn` component inside a row'
167
167
  ```ts file="ComposableTableActions.tsx"
168
168
  ```
169
169
 
170
+ ### Composable: Actions Overflow
171
+
172
+ Useing an `OverflowMenu` in the actions column, allowing the actions to condense into a dropdown if necessary for space.
173
+
174
+ ```ts file="ComposableTableActionsOverflow.tsx"
175
+ ```
176
+
170
177
  ### Composable: Expandable
171
178
 
172
179
  To make a parent/child row pair expandable:
@@ -0,0 +1,119 @@
1
+ /* eslint-disable no-console */
2
+ import React from 'react';
3
+ import {
4
+ Button,
5
+ OverflowMenu,
6
+ OverflowMenuControl,
7
+ OverflowMenuContent,
8
+ OverflowMenuGroup,
9
+ OverflowMenuItem,
10
+ OverflowMenuDropdownItem,
11
+ Dropdown,
12
+ KebabToggle
13
+ } from '@patternfly/react-core';
14
+ import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
15
+
16
+ interface Repository {
17
+ name: string;
18
+ branches: string;
19
+ prs: string;
20
+ workspaces: string;
21
+ lastCommit: string;
22
+ isMenuOpen: boolean;
23
+ }
24
+
25
+ export const ComposableTableActions: React.FunctionComponent = () => {
26
+ // In real usage, this data would come from some external source like an API via props.
27
+ const repositories: Repository[] = [
28
+ { name: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five', isMenuOpen: false },
29
+ { name: 'a', branches: 'two', prs: 'k', workspaces: 'four', lastCommit: 'five', isMenuOpen: false },
30
+ { name: 'p', branches: 'two', prs: 'b', workspaces: 'four', lastCommit: 'five', isMenuOpen: false },
31
+ { name: '4', branches: '2', prs: 'b', workspaces: 'four', lastCommit: 'five', isMenuOpen: false },
32
+ { name: '5', branches: '2', prs: 'b', workspaces: 'four', lastCommit: 'five', isMenuOpen: false }
33
+ ];
34
+
35
+ const [repos, setRepos] = React.useState(repositories);
36
+
37
+ const columnNames = {
38
+ name: 'Repositories',
39
+ branches: 'Branches',
40
+ prs: 'Pull requests',
41
+ workspaces: 'Workspaces',
42
+ lastCommit: 'Last commit'
43
+ };
44
+
45
+ const dropdownItems = [
46
+ <OverflowMenuDropdownItem key="item1" isShared>
47
+ Pimary
48
+ </OverflowMenuDropdownItem>,
49
+ <OverflowMenuDropdownItem key="item2" isShared>
50
+ Secondary
51
+ </OverflowMenuDropdownItem>,
52
+ <OverflowMenuDropdownItem key="item3" isShared>
53
+ Tertiary
54
+ </OverflowMenuDropdownItem>
55
+ ];
56
+
57
+ return (
58
+ <React.Fragment>
59
+ <TableComposable aria-label="Actions table">
60
+ <Thead>
61
+ <Tr>
62
+ <Th>{columnNames.name}</Th>
63
+ <Th>{columnNames.branches}</Th>
64
+ <Th>{columnNames.prs}</Th>
65
+ <Th>{columnNames.workspaces}</Th>
66
+ <Th>{columnNames.lastCommit}</Th>
67
+ <Td></Td>
68
+ </Tr>
69
+ </Thead>
70
+ <Tbody>
71
+ {repos.map(repo => (
72
+ <Tr key={repo.name}>
73
+ <Td dataLabel={columnNames.name}>{repo.name}</Td>
74
+ <Td dataLabel={columnNames.branches}>{repo.branches}</Td>
75
+ <Td dataLabel={columnNames.prs}>{repo.prs}</Td>
76
+ <Td dataLabel={columnNames.workspaces}>{repo.workspaces}</Td>
77
+ <Td dataLabel={columnNames.lastCommit}>{repo.lastCommit}</Td>
78
+ <Td isActionCell>
79
+ <OverflowMenu breakpoint="lg">
80
+ <OverflowMenuContent>
81
+ <OverflowMenuGroup groupType="button">
82
+ <OverflowMenuItem>
83
+ <Button variant="primary">Primary</Button>
84
+ </OverflowMenuItem>
85
+ <OverflowMenuItem>
86
+ <Button variant="secondary">Secondary</Button>
87
+ </OverflowMenuItem>
88
+ <OverflowMenuItem>
89
+ <Button variant="tertiary">Tertiary</Button>
90
+ </OverflowMenuItem>
91
+ </OverflowMenuGroup>
92
+ </OverflowMenuContent>
93
+ <OverflowMenuControl>
94
+ <Dropdown
95
+ position="right"
96
+ onSelect={() =>
97
+ setRepos(repos.map(r => (r.name !== repo.name ? r : { ...r, isMenuOpen: !r.isMenuOpen })))
98
+ }
99
+ toggle={
100
+ <KebabToggle
101
+ onToggle={open =>
102
+ setRepos(repos.map(r => (r.name !== repo.name ? r : { ...r, isMenuOpen: open })))
103
+ }
104
+ />
105
+ }
106
+ isOpen={repo.isMenuOpen}
107
+ isPlain
108
+ dropdownItems={dropdownItems}
109
+ />
110
+ </OverflowMenuControl>
111
+ </OverflowMenu>
112
+ </Td>
113
+ </Tr>
114
+ ))}
115
+ </Tbody>
116
+ </TableComposable>
117
+ </React.Fragment>
118
+ );
119
+ };
@@ -13,6 +13,7 @@ import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
13
13
  import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
14
14
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
15
15
  import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
16
+ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
16
17
  import globalDangerColor200 from '@patternfly/react-tokens/dist/esm/global_danger_color_200';
17
18
  import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
18
19
  import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
@@ -2097,6 +2098,7 @@ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amou
2097
2098
  import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
2098
2099
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
2099
2100
  import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
2101
+ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
2100
2102
  import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
2101
2103
 
2102
2104
  ComposableTableSortable = () => {
@@ -2220,7 +2222,7 @@ ComposableTableSortable = () => {
2220
2222
  </ToolbarItem>
2221
2223
  <ToolbarItem>
2222
2224
  <Button aria-label="Help actions" variant={ButtonVariant.plain}>
2223
- <HelpIcon />
2225
+ <QuestionCircleIcon />
2224
2226
  </Button>
2225
2227
  </ToolbarItem>
2226
2228
  </ToolbarGroup>
@@ -2740,6 +2742,7 @@ import {
2740
2742
  } from '@patternfly/react-core';
2741
2743
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
2742
2744
  import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
2745
+ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
2743
2746
  import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
2744
2747
  import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
2745
2748
  import { Table, TableHeader, TableBody } from '@patternfly/react-table';
@@ -2852,7 +2855,7 @@ class PageLayoutDefaultNav extends React.Component {
2852
2855
  </PageHeaderToolsItem>
2853
2856
  <PageHeaderToolsItem>
2854
2857
  <Button aria-label="Help actions" variant={ButtonVariant.plain}>
2855
- <HelpIcon />
2858
+ <QuestionCircleIcon />
2856
2859
  </Button>
2857
2860
  </PageHeaderToolsItem>
2858
2861
  </PageHeaderToolsGroup>