2018-10-18 17:37:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Manage state
|
|
|
|
*/
|
|
|
|
|
2018-10-18 18:25:40 +02:00
|
|
|
import {
|
|
|
|
filtersUrlEncode
|
2018-10-23 19:40:36 +02:00
|
|
|
} from 'components/filters/encoding'
|
2018-10-18 18:25:40 +02:00
|
|
|
|
2018-10-19 09:57:24 +02:00
|
|
|
import {
|
|
|
|
FILTER_GROUP_SOURCES,
|
|
|
|
FILTER_GROUP_ASNS,
|
|
|
|
FILTER_GROUP_COMMUNITIES,
|
|
|
|
FILTER_GROUP_EXT_COMMUNITIES,
|
|
|
|
FILTER_GROUP_LARGE_COMMUNITIES,
|
2018-10-23 19:40:36 +02:00
|
|
|
} from 'components/filters/groups'
|
2018-10-18 18:25:40 +02:00
|
|
|
|
2018-10-19 09:57:24 +02:00
|
|
|
/*
|
|
|
|
* Maybe this can be customized and injected into
|
2018-10-18 18:25:40 +02:00
|
|
|
* the PageLink component.
|
|
|
|
*/
|
|
|
|
export function makeLinkProps(props) {
|
|
|
|
const linkPage = parseInt(props.page, 10);
|
|
|
|
|
|
|
|
let pr = props.pageReceived;
|
|
|
|
let pf = props.pageFiltered;
|
|
|
|
|
|
|
|
// This here can be surely more elegant.
|
|
|
|
switch(props.anchor) {
|
|
|
|
case "received":
|
|
|
|
pr = linkPage;
|
|
|
|
break;
|
|
|
|
case "filtered":
|
|
|
|
pf = linkPage;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-10-19 09:57:24 +02:00
|
|
|
let pagination = "";
|
|
|
|
if (pr) {
|
|
|
|
pagination += `pr=${pr}`
|
|
|
|
}
|
|
|
|
if (pf) {
|
|
|
|
pagination += `pf=${pf}`
|
|
|
|
}
|
|
|
|
|
2018-10-18 18:25:40 +02:00
|
|
|
let filtering = "";
|
|
|
|
if (props.filtersApplied) {
|
|
|
|
filtering = filtersUrlEncode(props.filtersApplied);
|
|
|
|
}
|
|
|
|
|
|
|
|
const query = props.routing.query.q || "";
|
|
|
|
|
2018-10-19 09:57:24 +02:00
|
|
|
const search = `?${pagination}&q=${query}${filtering}`;
|
|
|
|
let hash = "";
|
|
|
|
if (props.anchor) {
|
|
|
|
hash += `#routes-${props.anchor}`;
|
|
|
|
}
|
|
|
|
|
2018-10-18 18:25:40 +02:00
|
|
|
const linkTo = {
|
|
|
|
pathname: props.routing.pathname,
|
|
|
|
hash: hash,
|
|
|
|
search: search,
|
|
|
|
};
|
|
|
|
|
|
|
|
return linkTo;
|
2018-10-18 17:37:07 +02:00
|
|
|
}
|
|
|
|
|