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

Flow UI: display graphs for module components #6378

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Main (unreleased)

- Introduce the `remotecfg` service that enables loading configuration from a
remote endpoint. (@tpaschalis)

- Flow UI: Display graph for components defined in module. (@hainenber)

### Enhancements

Expand Down
4 changes: 2 additions & 2 deletions web/ui/src/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';

import Navbar from './features/layout/Navbar';
import PageClusteringPeers from './pages/Clustering';
import ComponentDetailPage from './pages/ComponentDetailPage';
import Graph from './pages/Graph';
import { Graph, ModuleGraph } from './pages/Graph';
import PageComponentList from './pages/PageComponentList';

interface Props {
Expand All @@ -20,6 +19,7 @@ const Router = ({ basePath }: Props) => {
<Route path="/" element={<PageComponentList />} />
<Route path="/component/*" element={<ComponentDetailPage />} />
<Route path="/graph" element={<Graph />} />
<Route path="/graph/*" element={<ModuleGraph />} />
<Route path="/clustering" element={<PageClusteringPeers />} />
</Routes>
</main>
Expand Down
7 changes: 7 additions & 0 deletions web/ui/src/features/component/ComponentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export const ComponentView: FC<ComponentViewProps> = (props) => {
</Link>
</li>
)}
{props.component.localID.startsWith('module') && (
<li>
<Link to={`/graph/${props.component.localID}`} target="_top">
Graph
</Link>
</li>
)}
</ul>
</nav>

Expand Down
2 changes: 2 additions & 0 deletions web/ui/src/hooks/componentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ export const useComponentInfo = (

return [components, setComponents];
};

export default useComponentInfo;
4 changes: 2 additions & 2 deletions web/ui/src/pages/ComponentDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const ComponentDetailPage: FC = () => {
cache: 'no-cache',
credentials: 'same-origin',
});
const moduleCompoents = (await moduleComponentsResp.json()) as ComponentInfo[];
const moduleComponents = (await moduleComponentsResp.json()) as ComponentInfo[];

data.moduleInfo = (data.moduleInfo || []).concat(moduleCompoents);
data.moduleInfo = (data.moduleInfo || []).concat(moduleComponents);
}

setComponent(data);
Expand Down
17 changes: 15 additions & 2 deletions web/ui/src/pages/Graph.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useParams } from 'react-router-dom';
import { faDiagramProject } from '@fortawesome/free-solid-svg-icons';

import { ComponentGraph } from '../features/graph/ComponentGraph';
import Page from '../features/layout/Page';
import { useComponentInfo } from '../hooks/componentInfo';
import { parseID } from '../utils/id';

function Graph() {
export function Graph() {
const [components] = useComponentInfo('');

return (
Expand All @@ -14,4 +16,15 @@ function Graph() {
);
}

export default Graph;
export function ModuleGraph() {
const { '*': id } = useParams();

const { localID } = parseID(id || '');
const [components] = useComponentInfo(localID);

return (
<Page name="Graph" desc={`Relationships between defined components in ${localID}`} icon={faDiagramProject}>
{components.length > 0 && <ComponentGraph components={components} />}
</Page>
);
}
Loading