Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

demo #28

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions browser/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
14 changes: 12 additions & 2 deletions browser/src/components/GraphBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -107,6 +107,16 @@ export const GraphBrowser = ({ graphManager, weightServiceManager, componentName
/>
)}
></Route>
<Route
path={Paths.SearchNode}
render={props => (
<NodeSearch
graphManager={graphManager}
weightService={weightService}
nodeName={decodeURIComponent(props.match.params.nodeName as string)}
/>
)}
></Route>
<Route
path={Paths.GraphNode}
render={props => (
Expand All @@ -119,7 +129,7 @@ export const GraphBrowser = ({ graphManager, weightServiceManager, componentName
)}
></Route>
<Route
path={Paths.SubComponent}
path={Paths.SubComponent}
render={props => (
<SubcomponentSummary
graphManager={graphManager}
Expand Down
1 change: 1 addition & 0 deletions browser/src/components/ModuleSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Props = {
};

export function ModuleSummary({ componentName, moduleName, graphManager, weightService }: Props) {
// Get auto suggestion result from graphManager
const graphModule = graphManager.getModule(componentName, moduleName);
const history = useHistory();

Expand Down
2 changes: 1 addition & 1 deletion browser/src/components/NodeLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getDisplayName(key: string): string {

const NodeLink: React.FC<Props> = ({
node,
onSelect,
onSelect,
weight = undefined,
scoped = false,
kind
Expand Down
14 changes: 14 additions & 0 deletions browser/src/components/NodeSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions browser/src/models/GraphManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down