1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00
Matthias Hannig 803ee883e8 link helper
2018-08-05 15:44:12 +02:00

48 lines
981 B
JavaScript

export const makeLinkProps = function(props) {
const linkPage = parseInt(props.page, 10);
let pr = props.pageReceived;
let pf = props.pageFiltered;
let pn = props.pageNotExported;
let ne = props.loadNotExported;
// Numeric flags
ne = ne ? 1 : 0;
// This here can be surely more elegant.
switch(props.anchor) {
case "routes-received":
pr = linkPage;
break;
case "routes-filtered":
pf = linkPage;
break;
case "routes-not-exported":
pn = linkPage;
break;
}
const query = props.routing.query.q || "";
const search = `?ne=${ne}&pr=${pr}&pf=${pf}&pn=${pn}&q=${query}`;
const hash = `#${props.anchor}`;
const linkTo = {
pathname: props.routing.pathname,
hash: hash,
search: search,
};
return linkTo;
}
export const makePeerLinkProps = function(rsId, protocolId) {
const linkTo = {
pathname: `/routeservers/${rsId}/protocols/${protocolId}/routes`,
};
return linkTo;
}