diff --git a/browser/src/Routes.tsx b/browser/src/Routes.tsx index ec9202e..3476040 100644 --- a/browser/src/Routes.tsx +++ b/browser/src/Routes.tsx @@ -10,6 +10,7 @@ export class Paths { static GraphNode = "/:component/node/:node" static GraphClosure = "/:component/closure/:key" static SubComponent = "/:component/:subcomponent" + static SearchNode = "/search/:nodeName" } export class Routes { @@ -36,6 +37,11 @@ export class Routes { static SubComponent = (component: string, subcomponent: string): string => { return `/${encodeURIComponent(component)}/${encodeURIComponent(subcomponent)}`; } + + static SearchNode = (nodeName: string): string => { + return `/search/${encodeURIComponent(nodeName)}`; + } + } export default Routes; \ No newline at end of file diff --git a/browser/src/components/GraphBrowser.tsx b/browser/src/components/GraphBrowser.tsx index 8ba5fc2..081bef4 100644 --- a/browser/src/components/GraphBrowser.tsx +++ b/browser/src/components/GraphBrowser.tsx @@ -6,7 +6,7 @@ import NodeAutosuggest from "./NodeAutosuggest"; import { BrowserHeader } from "./BrowserHeader"; import Home from "src/components/Home"; import { ModuleSummary } from "src/components/ModuleSummary"; -import { NodeSummary } from "src/components/NodeSummary"; +import { NodeSearch, NodeSummary } from "src/components/NodeSummary"; import { ScopeSummary } from "./ScopeSummary"; import NodeClosure from "src/components/NodeClosure"; import SubcomponentSummary from "src/components/SubcomponentSummary"; @@ -107,6 +107,16 @@ export const GraphBrowser = ({ graphManager, weightServiceManager, componentName /> )} > + ( + + )} + > ( @@ -119,7 +129,7 @@ export const GraphBrowser = ({ graphManager, weightServiceManager, componentName )} > ( = ({ node, - onSelect, +onSelect, weight = undefined, scoped = false, kind diff --git a/browser/src/components/NodeSummary.tsx b/browser/src/components/NodeSummary.tsx index 706ad3b..f402b06 100644 --- a/browser/src/components/NodeSummary.tsx +++ b/browser/src/components/NodeSummary.tsx @@ -14,6 +14,12 @@ export type Props = { nodeName: string; }; +export type SearchProps = { + graphManager: GraphManager; + weightService: WeightService; + nodeName: string; +}; + function readableKind(kind: String) { // https://github.com/google/dagger/blob/master/java/dagger/model/BindingKind.java switch(kind) { @@ -87,6 +93,14 @@ function createdComponent(graphManager: GraphManager, componentName: string, nod return "" } +export function NodeSearch({ graphManager, weightService, nodeName }: SearchProps) { + var searchResult = graphManager.getMatches( "", nodeName.trim().toLowerCase(), 1, false)[0]; + var componentName = searchResult.componentName + var nodeName: string = searchResult.node.key + var prop: Props = {graphManager, weightService, componentName, nodeName} + return NodeSummary(prop) +} + export function NodeSummary({ graphManager, weightService, componentName, nodeName }: Props) { const history = useHistory(); const node = graphManager.getNode(componentName, nodeName); diff --git a/browser/src/models/GraphManager.tsx b/browser/src/models/GraphManager.tsx index 5d2eebc..859801f 100644 --- a/browser/src/models/GraphManager.tsx +++ b/browser/src/models/GraphManager.tsx @@ -106,10 +106,6 @@ export default class GraphManager { getComponent(componentName: string): Component { const component = this.componentMap[componentName]; - if (!component) { - throw Error(`Could not find ${componentName} component`); - } - return component; }