Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added data-element for service-link pagination #387

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

## Versione X.X.X (dd/mm/yyyy)

### Novità

- Aggiunto data-element al paginatore per validatore AGID per i blocchi Elenco per i quali viene impostata l'opzione service-link.

### Fix

- Nei template dei feed RSS ora viene mostrata la sorgente se presente.
Expand Down
13 changes: 11 additions & 2 deletions src/components/ItaliaTheme/Pagination/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Pagination extends Component {
/** Total number of pages. */
totalPages: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
.isRequired,

/** Lighthouse ID to set Agid data-element on pager link for CT Servizio*/
isServiceLink: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -69,8 +72,13 @@ class Pagination extends Component {
};

render() {
const { boundaryRange, ellipsisItem, siblingRange, totalPages } =
this.props;
const {
boundaryRange,
ellipsisItem,
siblingRange,
totalPages,
isServiceLink,
} = this.props;
const { activePage } = this.state;

const items = createPaginationItems({
Expand All @@ -96,6 +104,7 @@ class Pagination extends Component {
onClick={this.handleItemClick}
type={type}
ellipsisItem={ellipsisItem}
isServiceLink={isServiceLink}
>
{value}
</PaginationItem>
Expand Down
13 changes: 12 additions & 1 deletion src/components/ItaliaTheme/Pagination/PaginationItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class PaginationItem extends Component {
'nextItem',
'lastItem',
]),

/** Lighthouse ID to set Agid data-element on pager link for CT Servizio*/
isServiceLink: PropTypes.bool,
};

handleClick = (e) => {
Expand All @@ -59,7 +62,14 @@ class PaginationItem extends Component {
};

render() {
const { active, type, children, intl, ellipsisItem } = this.props;
const {
active,
type,
children,
intl,
ellipsisItem,
isServiceLink,
} = this.props;
const disabled = this.props.disabled || type === 'ellipsisItem';
return (
<PagerItem disabled={disabled}>
Expand All @@ -68,6 +78,7 @@ class PaginationItem extends Component {
onClick={this.handleClick}
onKeyDown={this.handleKeyDown}
aria-current={active ? 'page' : null}
data-element={isServiceLink ? 'pager-link' : null}
>
{type === 'prevItem' && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const ListingBody = React.memo(
// Also need to purge title from searchblock schema, it's the name of the listing template used
const listingBodyProps =
variation?.['@type'] !== 'search' ? data : { ...variation, title: '' };

// Need to know if data-element is "service-link"
// to add data-element="pager-link" to pagination links
const isServiceLink = data.id_lighthouse === 'service-link';

return (
<div className="public-ui">
{loadingQuery && (
Expand Down Expand Up @@ -123,6 +128,7 @@ const ListingBody = React.memo(
activePage={currentPage}
totalPages={totalPages}
onPageChange={onPaginationChange}
isServiceLink={isServiceLink}
/>
</div>
)}
Expand Down