General cleanup.

- Fix tests.
- Update snapshots.
- Remove old import statement.
- Add element ids for Sort and Search Components.
This commit is contained in:
Kia Lam
2019-05-13 14:56:36 -04:00
parent 3322123dd4
commit 457c6287a2
8 changed files with 2317 additions and 1274 deletions

View File

@@ -57,10 +57,9 @@ describe('<DataListToolbar />', () => {
});
test('dropdown items sortable columns work', () => {
const sortDropdownToggleSelector = '.pf-l-toolbar__group.sortDropdownGroup .pf-l-toolbar__item button';
const sortDropdownItemsSelector = '.pf-l-toolbar__group.sortDropdownGroup button.pf-c-dropdown__menu-item';
const searchDropdownToggleSelector = '.pf-c-dropdown.searchKeyDropdown .pf-c-dropdown__toggle';
const searchDropdownItemsSelector = '.pf-c-dropdown.searchKeyDropdown button.pf-c-dropdown__menu-item';
const sortDropdownToggleSelector = 'button[id="awx-sort"]';
const searchDropdownToggleSelector = 'button[id="awx-search"]';
const dropdownMenuItems = 'DropdownMenu > ul';
const multipleColumns = [
{ name: 'Foo', key: 'foo', isSortable: true },
@@ -80,12 +79,10 @@ describe('<DataListToolbar />', () => {
/>
);
const sortDropdownToggle = toolbar.find(sortDropdownToggleSelector);
expect(sortDropdownToggle.length).toBe(2);
sortDropdownToggle.at(1).simulate('click');
sortDropdownToggle.at(0).simulate('click');
expect(sortDropdownToggle.length).toBe(1);
sortDropdownToggle.simulate('click');
toolbar.update();
const sortDropdownItems = toolbar.find(sortDropdownItemsSelector);
const sortDropdownItems = toolbar.find(dropdownMenuItems).children();
expect(sortDropdownItems.length).toBe(2);
const mockedSortEvent = { target: { innerText: 'Bar' } };
@@ -101,13 +98,13 @@ describe('<DataListToolbar />', () => {
toolbar.update();
const sortDropdownToggleDescending = toolbar.find(sortDropdownToggleSelector);
expect(sortDropdownToggleDescending.length).toBe(2);
sortDropdownToggleDescending.at(1).simulate('click');
sortDropdownToggleDescending.at(0).simulate('click');
expect(sortDropdownToggleDescending.length).toBe(1);
sortDropdownToggleDescending.simulate('click');
toolbar.update();
const sortDropdownItemsDescending = toolbar.find(sortDropdownItemsSelector);
const sortDropdownItemsDescending = toolbar.find(dropdownMenuItems).children();
expect(sortDropdownItemsDescending.length).toBe(2);
sortDropdownToggleDescending.simulate('click'); // toggle close the sort dropdown
const mockedSortEventDescending = { target: { innerText: 'Bar' } };
sortDropdownItems.at(0).simulate('click', mockedSortEventDescending);
@@ -115,10 +112,10 @@ describe('<DataListToolbar />', () => {
const searchDropdownToggle = toolbar.find(searchDropdownToggleSelector);
expect(searchDropdownToggle.length).toBe(1);
searchDropdownToggle.at(0).simulate('click');
searchDropdownToggle.simulate('click');
toolbar.update();
const searchDropdownItems = toolbar.find(searchDropdownItemsSelector);
const searchDropdownItems = toolbar.find(dropdownMenuItems).children();
expect(searchDropdownItems.length).toBe(3);
const mockedSearchEvent = { target: { innerText: 'Bar' } };

View File

@@ -68,10 +68,45 @@ exports[`<ToolbarDeleteButton /> should render button 1`] = `
theme="pf-tippy"
trigger="mouseenter focus"
zIndex={9999}
>
<ToolbarDeleteButton__Button
aria-label="Delete"
isDisabled={true}
onClick={[Function]}
variant="plain"
>
<StyledComponent
aria-label="Delete"
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "ToolbarDeleteButton__Button-sc-1e3r0eg-0",
"isStatic": true,
"lastClassName": "iyjqWq",
"rules": Array [
"width:30px;height:30px;display:flex;justify-content:center;margin-right:20px;border-radius:3px;padding:0;&:disabled{cursor:not-allowed;&:hover{background-color:white;> svg{color:#d2d2d2;}}}&:hover{background-color:#d9534f;> svg{color:white;}}",
],
},
"displayName": "ToolbarDeleteButton__Button",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "ToolbarDeleteButton__Button-sc-1e3r0eg-0",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
isDisabled={true}
onClick={[Function]}
variant="plain"
>
<Button
aria-label="Delete"
className="awx-ToolBarBtn"
className="ToolbarDeleteButton__Button-sc-1e3r0eg-0 iyjqWq"
component="button"
isActive={false}
isBlock={false}
@@ -85,14 +120,13 @@ exports[`<ToolbarDeleteButton /> should render button 1`] = `
<button
aria-disabled={null}
aria-label="Delete"
className="pf-c-button pf-m-plain pf-m-disabled awx-ToolBarBtn"
className="pf-c-button pf-m-plain pf-m-disabled ToolbarDeleteButton__Button-sc-1e3r0eg-0 iyjqWq"
disabled={true}
onClick={[Function]}
tabIndex={null}
type="button"
>
<TrashAltIcon
className="awx-ToolBarTrashCanIcon"
color="currentColor"
size="sm"
title={null}
@@ -100,7 +134,6 @@ exports[`<ToolbarDeleteButton /> should render button 1`] = `
<svg
aria-hidden={true}
aria-labelledby={null}
className="awx-ToolBarTrashCanIcon"
fill="currentColor"
height="1em"
role="img"
@@ -120,6 +153,8 @@ exports[`<ToolbarDeleteButton /> should render button 1`] = `
</TrashAltIcon>
</button>
</Button>
</StyledComponent>
</ToolbarDeleteButton__Button>
<Portal
containerInfo={
<div>

View File

@@ -41,20 +41,8 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
className=""
dataListCells={
Array [
<DataListCell
alignRight={false}
className=""
isFilled={true}
isIcon={false}
width={1}
>
<Link
replace={false}
style={
Object {
"marginRight": "1.5em",
}
}
<ForwardRef>
<ForwardRef
to={
Object {
"pathname": "/foo",
@@ -66,51 +54,33 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
>
Foo
</b>
</Link>
<Badge
className=""
</ForwardRef>
<ForwardRef
isRead={true}
style={
Object {
"textTransform": "capitalize",
}
}
>
slack
</Badge>
</DataListCell>,
<DataListCell
alignRight={false}
className=""
isFilled={true}
isIcon={false}
style={
Object {
"display": "flex",
"justifyContent": "flex-end",
}
}
width={1}
</ForwardRef>
</ForwardRef>,
<ForwardRef
righthalf="true"
>
<Switch
<ForwardRef
aria-label="Toggle notification success"
className=""
id="notification-9000-success-toggle"
isChecked={false}
isDisabled={false}
label="Successful"
onChange={[Function]}
/>
<Switch
<ForwardRef
aria-label="Toggle notification failure"
className=""
id="notification-9000-error-toggle"
isChecked={false}
isDisabled={false}
label="Failure"
onChange={[Function]}
/>
</DataListCell>,
</ForwardRef>,
]
}
key=".0"
@@ -118,25 +88,91 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
>
<div
className="pf-c-data-list__item-content"
>
<NotificationListItem__DataListCell
key="name"
>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "NotificationListItem__DataListCell-j7c411-0",
"isStatic": false,
"lastClassName": "hoXOpW",
"rules": Array [
"display:flex;justify-content:",
[Function],
";padding-bottom:",
[Function],
";@media screen and (min-width:768px){justify-content:",
[Function],
";padding-bottom:0;}",
],
},
"displayName": "NotificationListItem__DataListCell",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "NotificationListItem__DataListCell-j7c411-0",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<DataListCell
alignRight={false}
className=""
className="NotificationListItem__DataListCell-j7c411-0 kIdLtz"
isFilled={true}
isIcon={false}
key="name"
width={1}
>
<div
className="pf-c-data-list__cell"
className="pf-c-data-list__cell NotificationListItem__DataListCell-j7c411-0 kIdLtz"
>
<Styled(Link)
to={
Object {
"pathname": "/foo",
}
}
>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "sc-bdVaJa",
"isStatic": true,
"lastClassName": "eBseNd",
"rules": Array [
"margin-right: 1.5em;",
],
},
"displayName": "Styled(Link)",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "sc-bdVaJa",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
to={
Object {
"pathname": "/foo",
}
}
>
<Link
className="sc-bdVaJa eBseNd"
replace={false}
style={
Object {
"marginRight": "1.5em",
}
}
to={
Object {
"pathname": "/foo",
@@ -144,12 +180,8 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
}
>
<a
className="sc-bdVaJa eBseNd"
onClick={[Function]}
style={
Object {
"marginRight": "1.5em",
}
}
>
<b
id="items-list-item-9000"
@@ -158,54 +190,143 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
</b>
</a>
</Link>
<Badge
className=""
</StyledComponent>
</Styled(Link)>
<Styled(Badge)
isRead={true}
style={
>
<StyledComponent
forwardedComponent={
Object {
"textTransform": "capitalize",
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "sc-bwzfXH",
"isStatic": true,
"lastClassName": "chTbOZ",
"rules": Array [
"text-transform: capitalize;",
],
},
"displayName": "Styled(Badge)",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "sc-bwzfXH",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
isRead={true}
>
<Badge
className="sc-bwzfXH chTbOZ"
isRead={true}
>
<span
className="pf-c-badge pf-m-read"
style={
Object {
"textTransform": "capitalize",
}
}
className="pf-c-badge pf-m-read sc-bwzfXH chTbOZ"
>
slack
</span>
</Badge>
</StyledComponent>
</Styled(Badge)>
</div>
</DataListCell>
</StyledComponent>
</NotificationListItem__DataListCell>
<NotificationListItem__DataListCell
key="toggles"
righthalf="true"
>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "NotificationListItem__DataListCell-j7c411-0",
"isStatic": false,
"lastClassName": "hoXOpW",
"rules": Array [
"display:flex;justify-content:",
[Function],
";padding-bottom:",
[Function],
";@media screen and (min-width:768px){justify-content:",
[Function],
";padding-bottom:0;}",
],
},
"displayName": "NotificationListItem__DataListCell",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "NotificationListItem__DataListCell-j7c411-0",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
righthalf="true"
>
<DataListCell
alignRight={false}
className=""
className="NotificationListItem__DataListCell-j7c411-0 hoXOpW"
isFilled={true}
isIcon={false}
key="toggles"
style={
Object {
"display": "flex",
"justifyContent": "flex-end",
}
}
righthalf="true"
width={1}
>
<div
className="pf-c-data-list__cell"
style={
className="pf-c-data-list__cell NotificationListItem__DataListCell-j7c411-0 hoXOpW"
righthalf="true"
>
<NotificationListItem__Switch
aria-label="Toggle notification success"
id="notification-9000-success-toggle"
isChecked={false}
isDisabled={false}
label="Successful"
onChange={[Function]}
>
<StyledComponent
aria-label="Toggle notification success"
forwardedComponent={
Object {
"display": "flex",
"justifyContent": "flex-end",
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "NotificationListItem__Switch-j7c411-1",
"isStatic": true,
"lastClassName": "ceuHGn",
"rules": Array [
"display:flex;flex-wrap:no-wrap;",
],
},
"displayName": "NotificationListItem__Switch",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "NotificationListItem__Switch-j7c411-1",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
id="notification-9000-success-toggle"
isChecked={false}
isDisabled={false}
label="Successful"
onChange={[Function]}
>
<Switch
aria-label="Toggle notification success"
className=""
className="NotificationListItem__Switch-j7c411-1 ceuHGn"
id="notification-9000-success-toggle"
isChecked={false}
isDisabled={false}
@@ -213,7 +334,7 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
onChange={[Function]}
>
<label
className="pf-c-switch"
className="pf-c-switch NotificationListItem__Switch-j7c411-1 ceuHGn"
htmlFor="notification-9000-success-toggle"
>
<input
@@ -242,9 +363,50 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
</span>
</label>
</Switch>
</StyledComponent>
</NotificationListItem__Switch>
<NotificationListItem__Switch
aria-label="Toggle notification failure"
id="notification-9000-error-toggle"
isChecked={false}
isDisabled={false}
label="Failure"
onChange={[Function]}
>
<StyledComponent
aria-label="Toggle notification failure"
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "NotificationListItem__Switch-j7c411-1",
"isStatic": true,
"lastClassName": "ceuHGn",
"rules": Array [
"display:flex;flex-wrap:no-wrap;",
],
},
"displayName": "NotificationListItem__Switch",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "NotificationListItem__Switch-j7c411-1",
"target": [Function],
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
id="notification-9000-error-toggle"
isChecked={false}
isDisabled={false}
label="Failure"
onChange={[Function]}
>
<Switch
aria-label="Toggle notification failure"
className=""
className="NotificationListItem__Switch-j7c411-1 ceuHGn"
id="notification-9000-error-toggle"
isChecked={false}
isDisabled={false}
@@ -252,7 +414,7 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
onChange={[Function]}
>
<label
className="pf-c-switch"
className="pf-c-switch NotificationListItem__Switch-j7c411-1 ceuHGn"
htmlFor="notification-9000-error-toggle"
>
<input
@@ -281,8 +443,12 @@ exports[`<NotificationListItem canToggleNotifications /> initially renders succe
</span>
</label>
</Switch>
</StyledComponent>
</NotificationListItem__Switch>
</div>
</DataListCell>
</StyledComponent>
</NotificationListItem__DataListCell>
</div>
</DataListItemCells>
</div>

View File

@@ -33,7 +33,7 @@ const AWXToolbar = styled.div`
const Toolbar = styled(PFToolbar)`
flex-grow: 1;
margin-left: ${props => (props.noleftmargin ? '0' : '20px')};
margin-left: ${props => (props.marginleft ? '0' : '20px')};
`;
const ToolbarGroup = styled(PFToolbarGroup)`
@@ -55,7 +55,6 @@ const ColumnLeft = styled.div`
`;
const ColumnRight = styled(ColumnLeft)`
margin-left: 60px;
padding: 8px 0 10px 0;
@media screen and (min-width: 980px) {
@@ -93,10 +92,10 @@ class DataListToolbar extends React.Component {
<I18n>
{({ i18n }) => (
<AWXToolbar>
<Toolbar noleftmargin={noLeftMargin}>
<Toolbar marginleft={noLeftMargin ? 1 : 0}>
<ColumnLeft>
{ showSelectAll && (
<Fragment>
<ColumnLeft>
<ToolbarItem>
<Checkbox
checked={isAllSelected}
@@ -106,6 +105,8 @@ class DataListToolbar extends React.Component {
/>
</ToolbarItem>
<VerticalSeparator />
</Fragment>
)}
<ToolbarItem css="flex-grow: 1;">
<Search
columns={columns}
@@ -145,8 +146,6 @@ class DataListToolbar extends React.Component {
{additionalControls}
</AdditionalControlsWrapper>
</ColumnRight>
</Fragment>
)}
</Toolbar>
</AWXToolbar>

View File

@@ -118,6 +118,7 @@ class Search extends React.Component {
isOpen={isSearchDropdownOpen}
toggle={(
<DropdownToggle
id="awx-search"
onToggle={this.handleDropdownToggle}
>
{searchColumnName}

View File

@@ -31,7 +31,7 @@ const Dropdown = styled(PFDropdown)`
width: auto;
}
> svg { /* carret icon */
> svg { /* caret icon */
margin: 0px;
padding-top: 3px;
padding-left: 3px;
@@ -121,6 +121,7 @@ class Sort extends React.Component {
isOpen={isSortDropdownOpen}
toggle={(
<DropdownToggle
id="awx-sort"
onToggle={this.handleDropdownToggle}
>
{sortedColumnName}

View File

@@ -13,7 +13,6 @@ import { t } from '@lingui/macro';
import '@patternfly/react-core/dist/styles/base.css';
import './app.scss';
import './components/Pagination/styles.scss';
import './components/DataListToolbar/styles.scss';
import './components/SelectedList/styles.scss';
import './components/AddRole/styles.scss';