convert NotificationList to tables

This commit is contained in:
Keith Grant
2021-02-04 14:46:29 -08:00
committed by Keith J. Grant
parent eb66a03a30
commit 2419a592b4
7 changed files with 607 additions and 542 deletions

View File

@@ -6,7 +6,7 @@ import { t } from '@lingui/macro';
import AlertModal from '../AlertModal'; import AlertModal from '../AlertModal';
import ErrorDetail from '../ErrorDetail'; import ErrorDetail from '../ErrorDetail';
import NotificationListItem from './NotificationListItem'; import NotificationListItem from './NotificationListItem';
import PaginatedDataList from '../PaginatedDataList'; import PaginatedTable, { HeaderRow, HeaderCell } from '../PaginatedTable';
import { getQSConfig, parseQueryString } from '../../util/qs'; import { getQSConfig, parseQueryString } from '../../util/qs';
import useRequest from '../../util/useRequest'; import useRequest from '../../util/useRequest';
import { NotificationTemplatesAPI } from '../../api'; import { NotificationTemplatesAPI } from '../../api';
@@ -169,7 +169,7 @@ function NotificationList({
return ( return (
<> <>
<PaginatedDataList <PaginatedTable
contentError={contentError} contentError={contentError}
hasContentLoading={isLoading} hasContentLoading={isLoading}
items={notifications} items={notifications}
@@ -211,19 +211,18 @@ function NotificationList({
key: 'modified_by__username__icontains', key: 'modified_by__username__icontains',
}, },
]} ]}
toolbarSortColumns={[
{
name: i18n._(t`Name`),
key: 'name',
},
{
name: i18n._(t`Type`),
key: 'notification_type',
},
]}
toolbarSearchableKeys={searchableKeys} toolbarSearchableKeys={searchableKeys}
toolbarRelatedSearchableKeys={relatedSearchableKeys} toolbarRelatedSearchableKeys={relatedSearchableKeys}
renderItem={notification => ( headerRow={
<HeaderRow qsConfig={QS_CONFIG} isSelectable={false}>
<HeaderCell sortKey="name">{i18n._(t`Name`)}</HeaderCell>
<HeaderCell sortKey="notification_type">
{i18n._(t`Type`)}
</HeaderCell>
<HeaderCell>{i18n._(t`Options`)}</HeaderCell>
</HeaderRow>
}
renderRow={(notification, index) => (
<NotificationListItem <NotificationListItem
key={notification.id} key={notification.id}
notification={notification} notification={notification}
@@ -239,6 +238,7 @@ function NotificationList({
successTurnedOn={successTemplateIds.includes(notification.id)} successTurnedOn={successTemplateIds.includes(notification.id)}
typeLabels={typeLabels} typeLabels={typeLabels}
showApprovalsToggle={showApprovalsToggle} showApprovalsToggle={showApprovalsToggle}
rowIndex={index}
/> />
)} )}
/> />

View File

@@ -87,10 +87,6 @@ describe('<NotificationList />', () => {
wrapper.unmount(); wrapper.unmount();
}); });
test('initially renders succesfully', () => {
expect(wrapper.find('PaginatedDataList')).toHaveLength(1);
});
test('should render list fetched of items', () => { test('should render list fetched of items', () => {
expect(NotificationTemplatesAPI.read).toHaveBeenCalled(); expect(NotificationTemplatesAPI.read).toHaveBeenCalled();
expect(NotificationTemplatesAPI.readOptions).toHaveBeenCalled(); expect(NotificationTemplatesAPI.readOptions).toHaveBeenCalled();

View File

@@ -3,25 +3,9 @@ import { shape, number, string, bool, func } from 'prop-types';
import { withI18n } from '@lingui/react'; import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { import { Switch } from '@patternfly/react-core';
DataListAction as _DataListAction, import { Tr, Td } from '@patternfly/react-table';
DataListItem, import { ActionsTd, ActionItem } from '../PaginatedTable';
DataListItemCells,
DataListItemRow,
Switch,
} from '@patternfly/react-core';
import styled from 'styled-components';
import DataListCell from '../DataListCell';
const DataListAction = styled(_DataListAction)`
align-items: center;
display: grid;
grid-gap: 16px;
grid-template-columns: ${props => `repeat(${props.columns}, max-content)`};
`;
const Label = styled.b`
margin-right: 20px;
`;
function NotificationListItem({ function NotificationListItem({
canToggleNotifications, canToggleNotifications,
@@ -37,54 +21,37 @@ function NotificationListItem({
showApprovalsToggle, showApprovalsToggle,
}) { }) {
return ( return (
<DataListItem <Tr id={`notification-row-${notification.id}`}>
aria-labelledby={`items-list-item-${notification.id}`} <Td id={`notification-${notification.id}`} dataLabel={i18n._(t`Name`)}>
key={notification.id} <Link to={`${detailUrl}`}>
id={`${notification.id}`} <b>{notification.name}</b>
> </Link>
<DataListItemRow> </Td>
<DataListItemCells <Td dataLabel={i18n._(t`Type`)}>
dataListCells={[ {typeLabels[notification.notification_type]}
<DataListCell key="name"> </Td>
<Link <ActionsTd
to={{ dataLabel={i18n._(t`Options`)}
pathname: detailUrl, gridColumns="120px 120px 120px 120px"
}} >
> <ActionItem visible={showApprovalsToggle}>
<b id={`items-list-item-${notification.id}`}> <Switch
{notification.name} id={`notification-${notification.id}-approvals-toggle`}
</b> label={i18n._(t`Approval`)}
</Link> labelOff={i18n._(t`Approval`)}
</DataListCell>, isChecked={approvalsTurnedOn}
<DataListCell key="type"> isDisabled={!canToggleNotifications}
<Label>{i18n._(t`Type `)}</Label> onChange={() =>
{typeLabels[notification.notification_type]} toggleNotification(
</DataListCell>, notification.id,
]} approvalsTurnedOn,
/> 'approvals'
<DataListAction )
aria-label={i18n._(t`actions`)} }
aria-labelledby={`items-list-item-${notification.id}`} aria-label={i18n._(t`Toggle notification approvals`)}
id={`items-list-item-${notification.id}`} />
columns={showApprovalsToggle ? 4 : 3} </ActionItem>
> <ActionItem visible>
{showApprovalsToggle && (
<Switch
id={`notification-${notification.id}-approvals-toggle`}
label={i18n._(t`Approval`)}
labelOff={i18n._(t`Approval`)}
isChecked={approvalsTurnedOn}
isDisabled={!canToggleNotifications}
onChange={() =>
toggleNotification(
notification.id,
approvalsTurnedOn,
'approvals'
)
}
aria-label={i18n._(t`Toggle notification approvals`)}
/>
)}
<Switch <Switch
id={`notification-${notification.id}-started-toggle`} id={`notification-${notification.id}-started-toggle`}
label={i18n._(t`Start`)} label={i18n._(t`Start`)}
@@ -96,6 +63,8 @@ function NotificationListItem({
} }
aria-label={i18n._(t`Toggle notification start`)} aria-label={i18n._(t`Toggle notification start`)}
/> />
</ActionItem>
<ActionItem visible>
<Switch <Switch
id={`notification-${notification.id}-success-toggle`} id={`notification-${notification.id}-success-toggle`}
label={i18n._(t`Success`)} label={i18n._(t`Success`)}
@@ -107,6 +76,8 @@ function NotificationListItem({
} }
aria-label={i18n._(t`Toggle notification success`)} aria-label={i18n._(t`Toggle notification success`)}
/> />
</ActionItem>
<ActionItem visible>
<Switch <Switch
id={`notification-${notification.id}-error-toggle`} id={`notification-${notification.id}-error-toggle`}
label={i18n._(t`Failure`)} label={i18n._(t`Failure`)}
@@ -118,9 +89,9 @@ function NotificationListItem({
} }
aria-label={i18n._(t`Toggle notification failure`)} aria-label={i18n._(t`Toggle notification failure`)}
/> />
</DataListAction> </ActionItem>
</DataListItemRow> </ActionsTd>
</DataListItem> </Tr>
); );
} }

View File

@@ -30,13 +30,17 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('initially renders succesfully and displays correct label', () => { test('initially renders succesfully and displays correct label', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
toggleNotification={toggleNotification} <NotificationListItem
detailUrl="/foo" notification={mockNotif}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
expect(wrapper.find('NotificationListItem')).toMatchSnapshot(); expect(wrapper.find('NotificationListItem')).toMatchSnapshot();
expect(wrapper.find('Switch').length).toBe(3); expect(wrapper.find('Switch').length).toBe(3);
@@ -44,46 +48,55 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('shows approvals toggle when configured', () => { test('shows approvals toggle when configured', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
toggleNotification={toggleNotification} <NotificationListItem
detailUrl="/foo" notification={mockNotif}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
showApprovalsToggle canToggleNotifications
/> typeLabels={typeLabels}
showApprovalsToggle
/>
</tbody>
</table>
); );
expect(wrapper.find('Switch').length).toBe(4); expect(wrapper.find('Switch').length).toBe(4);
}); });
test('displays correct label in correct column', () => { test('displays correct type', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
toggleNotification={toggleNotification} <NotificationListItem
detailUrl="/foo" notification={mockNotif}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
const typeCell = wrapper const typeCell = wrapper.find('Td').at(1);
.find('DataListCell')
.at(1)
.find('div');
expect(typeCell.text()).toContain('Slack'); expect(typeCell.text()).toContain('Slack');
}); });
test('handles approvals click when toggle is on', () => { test('handles approvals click when toggle is on', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
approvalsTurnedOn <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" approvalsTurnedOn
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
showApprovalsToggle canToggleNotifications
/> typeLabels={typeLabels}
showApprovalsToggle
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification approvals"]') .find('Switch[aria-label="Toggle notification approvals"]')
@@ -95,15 +108,19 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles approvals click when toggle is off', () => { test('handles approvals click when toggle is off', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
approvalsTurnedOn={false} <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" approvalsTurnedOn={false}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
showApprovalsToggle canToggleNotifications
/> typeLabels={typeLabels}
showApprovalsToggle
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification approvals"]') .find('Switch[aria-label="Toggle notification approvals"]')
@@ -114,14 +131,18 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles started click when toggle is on', () => { test('handles started click when toggle is on', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
startedTurnedOn <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" startedTurnedOn
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification start"]') .find('Switch[aria-label="Toggle notification start"]')
@@ -132,14 +153,18 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles started click when toggle is off', () => { test('handles started click when toggle is off', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
startedTurnedOn={false} <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" startedTurnedOn={false}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification start"]') .find('Switch[aria-label="Toggle notification start"]')
@@ -150,14 +175,18 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles success click when toggle is on', () => { test('handles success click when toggle is on', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
successTurnedOn <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" successTurnedOn
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification success"]') .find('Switch[aria-label="Toggle notification success"]')
@@ -168,14 +197,18 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles success click when toggle is off', () => { test('handles success click when toggle is off', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
successTurnedOn={false} <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" successTurnedOn={false}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification success"]') .find('Switch[aria-label="Toggle notification success"]')
@@ -186,14 +219,18 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles error click when toggle is on', () => { test('handles error click when toggle is on', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
errorTurnedOn <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" errorTurnedOn
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification failure"]') .find('Switch[aria-label="Toggle notification failure"]')
@@ -204,14 +241,18 @@ describe('<NotificationListItem canToggleNotifications />', () => {
test('handles error click when toggle is off', () => { test('handles error click when toggle is off', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<NotificationListItem <table>
notification={mockNotif} <tbody>
errorTurnedOn={false} <NotificationListItem
toggleNotification={toggleNotification} notification={mockNotif}
detailUrl="/foo" errorTurnedOn={false}
canToggleNotifications toggleNotification={toggleNotification}
typeLabels={typeLabels} detailUrl="/foo"
/> canToggleNotifications
typeLabels={typeLabels}
/>
</tbody>
</table>
); );
wrapper wrapper
.find('Switch[aria-label="Toggle notification failure"]') .find('Switch[aria-label="Toggle notification failure"]')

View File

@@ -24,398 +24,442 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
} }
} }
> >
<DataListItem <Tr
aria-labelledby="items-list-item-9000" id="notification-row-9000"
className=""
id="9000"
isExpanded={false}
key="9000"
> >
<li <TrBase
aria-labelledby="items-list-item-9000" id="notification-row-9000"
className="pf-c-data-list__item" innerRef={null}
id="9000"
> >
<DataListItemRow <tr
key=".0" className=""
rowid="items-list-item-9000" data-ouia-component-id="OUIA-Generated-TableRow-1"
data-ouia-component-type="PF4/TableRow"
data-ouia-safe={true}
hidden={false}
id="notification-row-9000"
> >
<div <Td
className="pf-c-data-list__item-row" dataLabel="Name"
id="notification-9000"
> >
<DataListItemCells <TdBase
dataListCells={ dataLabel="Name"
Array [ id="notification-9000"
<ForwardRef(Styled(PFDataListCell))> innerRef={null}
<ForwardRef >
to={ <td
Object { className=""
"pathname": "/foo", data-label="Name"
} id="notification-9000"
} >
<Link
to="/foo"
>
<LinkAnchor
href="/foo"
navigate={[Function]}
>
<a
href="/foo"
onClick={[Function]}
> >
<b <b>
id="items-list-item-9000"
>
Foo Foo
</b> </b>
</ForwardRef> </a>
</ForwardRef(Styled(PFDataListCell))>, </LinkAnchor>
<ForwardRef(Styled(PFDataListCell))> </Link>
<ForwardRef(styled.b)> </td>
Type </TdBase>
</ForwardRef(styled.b)> </Td>
Slack <Td
</ForwardRef(Styled(PFDataListCell))>, dataLabel="Type"
] >
} <TdBase
key=".0" dataLabel="Type"
rowid="items-list-item-9000" innerRef={null}
> >
<div <td
className="pf-c-data-list__item-content" className=""
data-label="Type"
> >
<DataListCell Slack
key="name" </td>
> </TdBase>
<StyledComponent </Td>
forwardedComponent={ <ActionsTd
Object { dataLabel="Options"
"$$typeof": Symbol(react.forward_ref), gridColumns="120px 120px 120px 120px"
"attrs": Array [], >
"componentStyle": ComponentStyle { <ActionsTd___StyledTd
"componentId": "sc-bdVaJa", _css={160}
"isStatic": false, dataLabel="Options"
"lastClassName": "kruorc",
"rules": Array [
"
word-break: break-word;
",
],
},
"displayName": "DataListCell",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "sc-bdVaJa",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<PFDataListCell
className="sc-bdVaJa kruorc"
>
<div
className="pf-c-data-list__cell sc-bdVaJa kruorc"
>
<Link
to={
Object {
"pathname": "/foo",
}
}
>
<LinkAnchor
href="/foo"
navigate={[Function]}
>
<a
href="/foo"
onClick={[Function]}
>
<b
id="items-list-item-9000"
>
Foo
</b>
</a>
</LinkAnchor>
</Link>
</div>
</PFDataListCell>
</StyledComponent>
</DataListCell>
<DataListCell
key="type"
>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "sc-bdVaJa",
"isStatic": false,
"lastClassName": "kruorc",
"rules": Array [
"
word-break: break-word;
",
],
},
"displayName": "DataListCell",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "sc-bdVaJa",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<PFDataListCell
className="sc-bdVaJa kruorc"
>
<div
className="pf-c-data-list__cell sc-bdVaJa kruorc"
>
<styled.b>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "sc-htpNat",
"isStatic": false,
"lastClassName": "jyYvCB",
"rules": Array [
"
margin-right: 20px;
",
],
},
"displayName": "styled.b",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "sc-htpNat",
"target": "b",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<b
className="sc-htpNat jyYvCB"
>
Type
</b>
</StyledComponent>
</styled.b>
Slack
</div>
</PFDataListCell>
</StyledComponent>
</DataListCell>
</div>
</DataListItemCells>
<Styled(DataListAction)
aria-label="actions"
aria-labelledby="items-list-item-9000"
columns={3}
id="items-list-item-9000"
key=".1"
rowid="items-list-item-9000"
> >
<StyledComponent <StyledComponent
aria-label="actions" _css={160}
aria-labelledby="items-list-item-9000" dataLabel="Options"
columns={3}
forwardedComponent={ forwardedComponent={
Object { Object {
"$$typeof": Symbol(react.forward_ref), "$$typeof": Symbol(react.forward_ref),
"attrs": Array [], "attrs": Array [],
"componentStyle": ComponentStyle { "componentStyle": ComponentStyle {
"componentId": "sc-bwzfXH", "componentId": "ActionsTd___StyledTd-sc-1ys3lw-1",
"isStatic": false, "isStatic": false,
"lastClassName": "llKtln", "lastClassName": "dIDjZI",
"rules": Array [ "rules": Array [
" "text-align:right;--pf-c-table--cell--Width:",
align-items: center;
display: grid;
grid-gap: 16px;
grid-template-columns: ",
[Function], [Function],
"; "px;",
",
], ],
}, },
"displayName": "Styled(DataListAction)", "displayName": "ActionsTd___StyledTd",
"foldedComponentIds": Array [], "foldedComponentIds": Array [],
"render": [Function], "render": [Function],
"styledComponentId": "sc-bwzfXH", "styledComponentId": "ActionsTd___StyledTd-sc-1ys3lw-1",
"target": [Function], "target": Object {
"$$typeof": Symbol(react.forward_ref),
"displayName": "Td",
"render": [Function],
},
"toString": [Function], "toString": [Function],
"warnTooManyClasses": [Function], "warnTooManyClasses": [Function],
"withComponent": [Function], "withComponent": [Function],
} }
} }
forwardedRef={null} forwardedRef={null}
id="items-list-item-9000"
rowid="items-list-item-9000"
> >
<DataListAction <Td
aria-label="actions" _css={160}
aria-labelledby="items-list-item-9000" className="ActionsTd___StyledTd-sc-1ys3lw-1 dIDjZI"
className="sc-bwzfXH llKtln" dataLabel="Options"
columns={3}
id="items-list-item-9000"
rowid="items-list-item-9000"
> >
<div <TdBase
className="pf-c-data-list__item-action sc-bwzfXH llKtln" _css={160}
columns={3} className="ActionsTd___StyledTd-sc-1ys3lw-1 dIDjZI"
rowid="items-list-item-9000" dataLabel="Options"
innerRef={null}
> >
<Switch <td
aria-label="Toggle notification start" _css={160}
id="notification-9000-started-toggle" className="ActionsTd___StyledTd-sc-1ys3lw-1 dIDjZI"
isChecked={false} data-label="Options"
isDisabled={false}
label="Start"
labelOff="Start"
onChange={[Function]}
> >
<label <ActionsGrid
className="pf-c-switch" gridColumns="120px 120px 120px 120px"
data-ouia-component-id="OUIA-Generated-Switch-1" numActions={4}
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="notification-9000-started-toggle"
> >
<input <StyledComponent
aria-label="Toggle notification start" forwardedComponent={
aria-labelledby={null} Object {
checked={false} "$$typeof": Symbol(react.forward_ref),
className="pf-c-switch__input" "attrs": Array [],
disabled={false} "componentStyle": ComponentStyle {
id="notification-9000-started-toggle" "componentId": "ActionsTd__ActionsGrid-sc-1ys3lw-0",
onChange={[Function]} "isStatic": false,
type="checkbox" "lastClassName": "dkSSIN",
/> "rules": Array [
<span "display:grid;grid-gap:16px;align-items:center;",
className="pf-c-switch__toggle" [Function],
/> ],
<span },
aria-hidden="true" "displayName": "ActionsGrid",
className="pf-c-switch__label pf-m-on" "foldedComponentIds": Array [],
id={null} "render": [Function],
"styledComponentId": "ActionsTd__ActionsGrid-sc-1ys3lw-0",
"target": "div",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
gridColumns="120px 120px 120px 120px"
numActions={4}
> >
Start <div
</span> className="ActionsTd__ActionsGrid-sc-1ys3lw-0 dkSSIN"
<span >
aria-hidden="true" <ActionItem
className="pf-c-switch__label pf-m-off" column={1}
id={null} key=".0"
> visible={false}
Start />
</span> <ActionItem
</label> column={2}
</Switch> key=".1"
<Switch visible={true}
aria-label="Toggle notification success" >
id="notification-9000-success-toggle" <ActionItem___StyledDiv
isChecked={false} _css={2}
isDisabled={false} >
label="Success" <StyledComponent
labelOff="Success" _css={2}
onChange={[Function]} forwardedComponent={
> Object {
<label "$$typeof": Symbol(react.forward_ref),
className="pf-c-switch" "attrs": Array [],
data-ouia-component-id="OUIA-Generated-Switch-2" "componentStyle": ComponentStyle {
data-ouia-component-type="PF4/Switch" "componentId": "ActionItem___StyledDiv-sc-1x1z9nz-0",
data-ouia-safe={true} "isStatic": false,
htmlFor="notification-9000-success-toggle" "lastClassName": "gydHvj",
> "rules": Array [
<input "grid-column:",
aria-label="Toggle notification success" [Function],
aria-labelledby={null} ";",
checked={false} ],
className="pf-c-switch__input" },
disabled={false} "displayName": "ActionItem___StyledDiv",
id="notification-9000-success-toggle" "foldedComponentIds": Array [],
onChange={[Function]} "render": [Function],
type="checkbox" "styledComponentId": "ActionItem___StyledDiv-sc-1x1z9nz-0",
/> "target": "div",
<span "toString": [Function],
className="pf-c-switch__toggle" "warnTooManyClasses": [Function],
/> "withComponent": [Function],
<span }
aria-hidden="true" }
className="pf-c-switch__label pf-m-on" forwardedRef={null}
id={null} >
> <div
Success className="ActionItem___StyledDiv-sc-1x1z9nz-0 cSmxUZ"
</span> >
<span <Switch
aria-hidden="true" aria-label="Toggle notification start"
className="pf-c-switch__label pf-m-off" id="notification-9000-started-toggle"
id={null} isChecked={false}
> isDisabled={false}
Success label="Start"
</span> labelOff="Start"
</label> onChange={[Function]}
</Switch> >
<Switch <label
aria-label="Toggle notification failure" className="pf-c-switch"
id="notification-9000-error-toggle" data-ouia-component-id="OUIA-Generated-Switch-1"
isChecked={false} data-ouia-component-type="PF4/Switch"
isDisabled={false} data-ouia-safe={true}
label="Failure" htmlFor="notification-9000-started-toggle"
labelOff="Failure" >
onChange={[Function]} <input
> aria-label="Toggle notification start"
<label aria-labelledby={null}
className="pf-c-switch" checked={false}
data-ouia-component-id="OUIA-Generated-Switch-3" className="pf-c-switch__input"
data-ouia-component-type="PF4/Switch" disabled={false}
data-ouia-safe={true} id="notification-9000-started-toggle"
htmlFor="notification-9000-error-toggle" onChange={[Function]}
> type="checkbox"
<input />
aria-label="Toggle notification failure" <span
aria-labelledby={null} className="pf-c-switch__toggle"
checked={false} />
className="pf-c-switch__input" <span
disabled={false} aria-hidden="true"
id="notification-9000-error-toggle" className="pf-c-switch__label pf-m-on"
onChange={[Function]} id={null}
type="checkbox" >
/> Start
<span </span>
className="pf-c-switch__toggle" <span
/> aria-hidden="true"
<span className="pf-c-switch__label pf-m-off"
aria-hidden="true" id={null}
className="pf-c-switch__label pf-m-on" >
id={null} Start
> </span>
Failure </label>
</span> </Switch>
<span </div>
aria-hidden="true" </StyledComponent>
className="pf-c-switch__label pf-m-off" </ActionItem___StyledDiv>
id={null} </ActionItem>
> <ActionItem
Failure column={3}
</span> key=".2"
</label> visible={true}
</Switch> >
</div> <ActionItem___StyledDiv
</DataListAction> _css={3}
>
<StyledComponent
_css={3}
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "ActionItem___StyledDiv-sc-1x1z9nz-0",
"isStatic": false,
"lastClassName": "gydHvj",
"rules": Array [
"grid-column:",
[Function],
";",
],
},
"displayName": "ActionItem___StyledDiv",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "ActionItem___StyledDiv-sc-1x1z9nz-0",
"target": "div",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<div
className="ActionItem___StyledDiv-sc-1x1z9nz-0 fZyHIW"
>
<Switch
aria-label="Toggle notification success"
id="notification-9000-success-toggle"
isChecked={false}
isDisabled={false}
label="Success"
labelOff="Success"
onChange={[Function]}
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-2"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="notification-9000-success-toggle"
>
<input
aria-label="Toggle notification success"
aria-labelledby={null}
checked={false}
className="pf-c-switch__input"
disabled={false}
id="notification-9000-success-toggle"
onChange={[Function]}
type="checkbox"
/>
<span
className="pf-c-switch__toggle"
/>
<span
aria-hidden="true"
className="pf-c-switch__label pf-m-on"
id={null}
>
Success
</span>
<span
aria-hidden="true"
className="pf-c-switch__label pf-m-off"
id={null}
>
Success
</span>
</label>
</Switch>
</div>
</StyledComponent>
</ActionItem___StyledDiv>
</ActionItem>
<ActionItem
column={4}
key=".3"
visible={true}
>
<ActionItem___StyledDiv
_css={4}
>
<StyledComponent
_css={4}
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "ActionItem___StyledDiv-sc-1x1z9nz-0",
"isStatic": false,
"lastClassName": "gydHvj",
"rules": Array [
"grid-column:",
[Function],
";",
],
},
"displayName": "ActionItem___StyledDiv",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "ActionItem___StyledDiv-sc-1x1z9nz-0",
"target": "div",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<div
className="ActionItem___StyledDiv-sc-1x1z9nz-0 gydHvj"
>
<Switch
aria-label="Toggle notification failure"
id="notification-9000-error-toggle"
isChecked={false}
isDisabled={false}
label="Failure"
labelOff="Failure"
onChange={[Function]}
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-3"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="notification-9000-error-toggle"
>
<input
aria-label="Toggle notification failure"
aria-labelledby={null}
checked={false}
className="pf-c-switch__input"
disabled={false}
id="notification-9000-error-toggle"
onChange={[Function]}
type="checkbox"
/>
<span
className="pf-c-switch__toggle"
/>
<span
aria-hidden="true"
className="pf-c-switch__label pf-m-on"
id={null}
>
Failure
</span>
<span
aria-hidden="true"
className="pf-c-switch__label pf-m-off"
id={null}
>
Failure
</span>
</label>
</Switch>
</div>
</StyledComponent>
</ActionItem___StyledDiv>
</ActionItem>
</div>
</StyledComponent>
</ActionsGrid>
</td>
</TdBase>
</Td>
</StyledComponent> </StyledComponent>
</Styled(DataListAction)> </ActionsTd___StyledTd>
</div> </ActionsTd>
</DataListItemRow> </tr>
</li> </TrBase>
</DataListItem> </Tr>
</NotificationListItem> </NotificationListItem>
`; `;

View File

@@ -13,9 +13,13 @@ export default function ActionItem({ column, tooltip, visible, children }) {
grid-column: ${column}; grid-column: ${column};
`} `}
> >
<Tooltip content={tooltip} position="top"> {tooltip ? (
<div>{children}</div> <Tooltip content={tooltip} position="top">
</Tooltip> <div>{children}</div>
</Tooltip>
) : (
children
)}
</div> </div>
); );
} }

View File

@@ -13,7 +13,12 @@ const Th = styled(PFTh)`
--pf-c-table--cell--Overflow: initial; --pf-c-table--cell--Overflow: initial;
`; `;
export default function HeaderRow({ qsConfig, isExpandable, children }) { export default function HeaderRow({
qsConfig,
isExpandable,
isSelectable,
children,
}) {
const location = useLocation(); const location = useLocation();
const history = useHistory(); const history = useHistory();
@@ -49,7 +54,7 @@ export default function HeaderRow({ qsConfig, isExpandable, children }) {
<Thead> <Thead>
<Tr> <Tr>
{isExpandable && <Th />} {isExpandable && <Th />}
<Th /> {isSelectable && <Th />}
{React.Children.map( {React.Children.map(
children, children,
child => child =>
@@ -66,6 +71,10 @@ export default function HeaderRow({ qsConfig, isExpandable, children }) {
); );
} }
HeaderRow.defaultProps = {
isSelectable: true,
};
export function HeaderCell({ export function HeaderCell({
sortKey, sortKey,
onSort, onSort,