import _ from 'underscore' import React from 'react' import {connect} from 'react-redux' import {Link} from 'react-router' import FilterReason from 'components/routeservers/large-communities/filter-reason' import NoexportReason from 'components/routeservers/large-communities/noexport-reason' import {showBgpAttributes} from 'components/routeservers/routes/bgp-attributes-modal-actions' import BgpAttributesModal from 'components/routeservers/routes/bgp-attributes-modal' import LoadingIndicator from 'components/loading-indicator/small' class ResultsTableView extends React.Component { showAttributesModal(route) { this.props.dispatch( showBgpAttributes(route) ); } render() { if (this.props.routes.length == 0) { return null; } const routes = this.props.routes.map((route) => ( this.showAttributesModal(route)}>{route.network} {this.props.display_reasons == "filtered" && } this.showAttributesModal(route)}>{route.bgp.as_path.join(" ")} this.showAttributesModal(route)}> {route.gateway} {route.neighbour.description} {route.neighbour.asn} {route.routeserver.name} )); return (
{this.props.header} {routes}
Network AS Path Gateway Neighbour ASN RS
); } } const ResultsTable = connect()(ResultsTableView); class NoResultsView extends React.Component { render() { if (!this.props.show) { return null; } return (

No prefixes could be found for {this.props.query}

); } } const NoResults = connect( (state) => { let total = state.lookup.results; let query = state.lookup.query; let isLoading = state.lookup.isLoading; let show = false; if (total == 0 && query != "" && isLoading == false) { show = true; } return { show: show, query: state.lookup.query } } )(NoResultsView); class LookupResults extends React.Component { render() { if(this.props.isLoading) { return ( ); } const mkHeader = (color, action) => (

Routes {action}

); const filtdHeader = mkHeader("orange", "filtered"); const recvdHeader = mkHeader("green", "accepted"); const noexHeader = mkHeader("red", "not exported"); let filteredRoutes = this.props.routes.filtered; let importedRoutes = this.props.routes.imported; return (
) } } function selectRoutes(routes, state) { return _.where(routes, {state: state}); } export default connect( (state) => { let routes = state.lookup.results; let filteredRoutes = selectRoutes(routes, 'filtered'); let importedRoutes = selectRoutes(routes, 'imported'); return { routes: { filtered: filteredRoutes, imported: importedRoutes }, } } )(LookupResults);