1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00

67 lines
1.9 KiB
React
Raw Normal View History

2018-08-05 12:27:42 +02:00
import React from 'react'
import {connect} from 'react-redux'
/*
* Quick links:
* Jump to anchors for: not exported, filtered and received
*/
const QuickLinks = function(props) {
const isLoading = props.routes.received.loading ||
props.routes.filtered.loading;
// Do no display some dangleing "go to:" text
if (isLoading) {
return null;
}
// Handle special not exported: Default just works like
// filtered or received. When loaded on demand, we override
// this.
let showNotExported = (!props.routes.notExported.loading &&
props.routes.notExported.totalResults > 0);
2018-10-02 10:28:25 +02:00
let excludeNotExported = props.excludeNotExported || false;
if (props.loadNotExportedOnDemand && !excludeNotExported) {
2018-08-05 12:27:42 +02:00
// Show the link when nothing else is loading anymore
showNotExported = !isLoading;
}
2018-10-02 10:28:25 +02:00
// Is there anything to show?
if (!isLoading &&
!showNotExported &&
props.routes.notExported.totalResults == 0 &&
props.routes.received.totalResults == 0 &&
props.routes.filtered.totalResults == 0) {
return null; // Nothing to do here.
}
2018-08-05 12:27:42 +02:00
return (
2018-09-09 19:19:47 +02:00
<div className="quick-links routes-quick-links">
2018-08-05 12:27:42 +02:00
<span>Go to:</span>
<ul>
{(!props.routes.filtered.loading &&
props.routes.filtered.totalResults > 0) &&
<li className="filtered">
<a href="#routes-filtered">Filtered</a></li>}
{(!props.routes.received.loading &&
props.routes.received.totalResults > 0) &&
<li className="received">
<a href="#routes-received">Accepted</a></li>}
{showNotExported &&
<li className="not-exported">
<a href="#routes-not-exported">Not Exported</a></li>}
</ul>
</div>
);
}
export default connect(
(state) => ({
"loadNotExportedOnDemand": state.config.noexport_load_on_demand,
})
)(QuickLinks);