Skip to content

Commit

Permalink
Merge pull request #1200 from swaterkamp/Pagination
Browse files Browse the repository at this point in the history
Fix Pagination
  • Loading branch information
bjoernricks authored Mar 5, 2019
2 parents 77c46ac + 83f604f commit 3d9b630
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
4 changes: 1 addition & 3 deletions gsa/src/web/components/icon/restoreicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import withSvgIcon from './withSvgIcon';

import {ReactComponent as Icon} from './svg/restore.svg';

const RestoreIcon = withSvgIcon({
active: true,
})(Icon);
const RestoreIcon = withSvgIcon()(Icon);

export default RestoreIcon;

Expand Down
12 changes: 10 additions & 2 deletions gsa/src/web/components/icon/svgicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@ const Styled = styled.span`
}
`;

const SvgIcon = ({active = true, children, to, value, onClick, ...other}) => (
const SvgIcon = ({
disabled = false,
active = !disabled,
children,
to,
value,
onClick,
...other
}) => (
<Styled
{...other}
active={active}
onClick={
isDefined(onClick)
isDefined(onClick) && !disabled
? event => {
event.preventDefault();
event.stopPropagation();
Expand Down
18 changes: 18 additions & 0 deletions gsa/src/web/components/icon/testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import React from 'react';

import {render, fireEvent} from 'web/utils/testing';
import Theme from 'web/utils/theme';

import {ICON_SIZE_SMALL_PIXELS} from './withIconSize';

Expand All @@ -42,6 +43,23 @@ export const testIcon = Icon => {

expect(handler).toHaveBeenCalledWith('1');
});

test('should change appearance when disabled', () => {
const {element} = render(<Icon disabled={true} />);

expect(element).toHaveStyleRule('fill', Theme.inputBorderGray, {
modifier: '& svg path',
});
});

test('should not call clickhandler when disabled', () => {
const handler = jest.fn();
const {element} = render(<Icon disabled={true} onClick={handler} />);

fireEvent.click(element);

expect(handler).not.toHaveBeenCalled();
});
};

// vim: set ts=2 sw=2 tw=80:
8 changes: 4 additions & 4 deletions gsa/src/web/components/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ const Pagination = ({
<PaginationLayout flex align={['end', 'center']}>
<IconDivider>
<FirstIcon
active={counts.hasPrevious()}
disabled={!counts.hasPrevious()}
title={_('First')}
onClick={onFirstClick}
/>
<PreviousIcon
active={counts.hasPrevious()}
disabled={!counts.hasPrevious()}
title={_('Previous')}
onClick={onPreviousClick}
/>
Expand All @@ -78,12 +78,12 @@ const Pagination = ({
</PaginationText>
<IconDivider>
<NextIcon
active={counts.hasNext()}
disabled={!counts.hasNext()}
title={_('Next')}
onClick={onNextClick}
/>
<LastIcon
active={counts.hasNext()}
disabled={!counts.hasNext()}
title={_('Last')}
onClick={onLastClick}
/>
Expand Down

0 comments on commit 3d9b630

Please sign in to comment.