({ graphManager, weightServiceManager, componentName }: Props)
| 25 | } |
| 26 | |
| 27 | export const GraphBrowser = ({ graphManager, weightServiceManager, componentName }: Props) => { |
| 28 | const graph = useMemo(() => componentName && graphManager.getComponent(componentName), [ |
| 29 | graphManager, |
| 30 | componentName |
| 31 | ]); |
| 32 | |
| 33 | const history = useHistory(); |
| 34 | |
| 35 | const weightService = weightServiceManager.getWeightService(); |
| 36 | |
| 37 | const includeWeightSelector = weightServiceManager.getWeightServiceNames().length > 1; |
| 38 | |
| 39 | return ( |
| 40 | <div> |
| 41 | <div className="container"> |
| 42 | <div className="row search-bar"> |
| 43 | <div className={classNames("col", includeWeightSelector ? "s9": "s12")}> |
| 44 | <NodeAutosuggest |
| 45 | graphManager={graphManager} |
| 46 | weightService={weightService} |
| 47 | componentName={graph && graph.name} |
| 48 | onSelect={(componentName, node) => |
| 49 | history.push(Routes.GraphNode(componentName || "", node)) |
| 50 | } |
| 51 | /> |
| 52 | </div> |
| 53 | {includeWeightSelector && |
| 54 | <div className="col s3"> |
| 55 | <WeightSelector |
| 56 | weightServiceManager={weightServiceManager} |
| 57 | onSelectWeight={weight => { |
| 58 | weightServiceManager.selectWeightService(weight); |
| 59 | // Refresh the app state without affecting history. |
| 60 | history.replace('#'); |
| 61 | } |
| 62 | } |
| 63 | /> |
| 64 | </div> |
| 65 | } |
| 66 | </div> |
| 67 | <Switch> |
| 68 | <Route |
| 69 | path={Paths.Module} |
| 70 | render={props => ( |
| 71 | <ModuleSummary |
| 72 | graphManager={graphManager} |
| 73 | weightService={weightService} |
| 74 | moduleName={decodeURIComponent(props.match.params.module as string)} |
| 75 | componentName={componentName} |
| 76 | /> |
| 77 | )} |
| 78 | ></Route> |
| 79 | <Route |
| 80 | path={Paths.GraphModule} |
| 81 | render={props => ( |
| 82 | <ModuleSummary |
| 83 | graphManager={graphManager} |
| 84 | weightService={weightService} |
nothing calls this directly
no test coverage detected