@teambit/graph 0.0.554 → 0.0.558
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graph.ui.runtime.d.ts +7 -0
- package/dist/ui/dependencies-graph/calc-elements.d.ts +3 -0
- package/dist/ui/dependencies-graph/calc-layout.d.ts +3 -0
- package/dist/ui/dependencies-graph/graph-context.d.ts +1 -0
- package/dist/ui/query/use-graph-query.d.ts +1 -0
- package/package.json +20 -12
- package/tsconfig.json +1 -2
- package/component-graph/component-graph.ts +0 -105
- package/component-graph/index.ts +0 -2
- package/duplicate-dependency.ts +0 -18
- package/edge-type.ts +0 -5
- package/graph-builder.ts +0 -56
- package/graph.aspect.ts +0 -7
- package/graph.docs.md +0 -7
- package/graph.graphql.ts +0 -94
- package/graph.main.runtime.ts +0 -15
- package/graph.provider.ts +0 -14
- package/graph.ui.runtime.tsx +0 -41
- package/index.ts +0 -11
- package/model/dependency/dependency.ts +0 -11
- package/model/dependency/index.ts +0 -1
- package/model/graph-filters/graph-filters.ts +0 -1
- package/model/graph-filters/index.ts +0 -1
- package/object-list-to-graph.ts +0 -54
- package/package-tar/teambit-graph-0.0.554.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/ui/component-node/component-node.module.scss +0 -63
- package/ui/component-node/component-node.tsx +0 -61
- package/ui/component-node/index.ts +0 -3
- package/ui/component-node/variants.module.scss +0 -43
- package/ui/component-node/variants.ts +0 -5
- package/ui/dependencies-graph/calc-elements.tsx +0 -47
- package/ui/dependencies-graph/calc-layout.tsx +0 -36
- package/ui/dependencies-graph/dep-edge/dep-edge.tsx +0 -28
- package/ui/dependencies-graph/dep-edge/edge.module.scss +0 -10
- package/ui/dependencies-graph/dep-edge/index.ts +0 -1
- package/ui/dependencies-graph/dependencies-graph.module.scss +0 -83
- package/ui/dependencies-graph/dependencies-graph.tsx +0 -98
- package/ui/dependencies-graph/graph-context.ts +0 -9
- package/ui/dependencies-graph/index.ts +0 -3
- package/ui/dependencies-graph/minimap.ts +0 -15
- package/ui/graph-page/graph-filters.tsx +0 -27
- package/ui/graph-page/graph-page.module.scss +0 -35
- package/ui/graph-page/graph-page.tsx +0 -54
- package/ui/graph-page/index.ts +0 -1
- package/ui/graph.section.tsx +0 -19
- package/ui/query/edge-model.ts +0 -16
- package/ui/query/get-graph.query.ts +0 -73
- package/ui/query/graph-model.ts +0 -12
- package/ui/query/index.ts +0 -6
- package/ui/query/node-model.ts +0 -16
- package/ui/query/use-graph-query.ts +0 -29
- package/ui/query/use-graph.tsx +0 -12
package/types/style.d.ts
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
declare module '*.module.css' {
|
2
|
-
const classes: { readonly [key: string]: string };
|
3
|
-
export default classes;
|
4
|
-
}
|
5
|
-
declare module '*.module.scss' {
|
6
|
-
const classes: { readonly [key: string]: string };
|
7
|
-
export default classes;
|
8
|
-
}
|
9
|
-
declare module '*.module.sass' {
|
10
|
-
const classes: { readonly [key: string]: string };
|
11
|
-
export default classes;
|
12
|
-
}
|
13
|
-
|
14
|
-
declare module '*.module.less' {
|
15
|
-
const classes: { readonly [key: string]: string };
|
16
|
-
export default classes;
|
17
|
-
}
|
18
|
-
|
19
|
-
declare module '*.less' {
|
20
|
-
const classes: { readonly [key: string]: string };
|
21
|
-
export default classes;
|
22
|
-
}
|
23
|
-
|
24
|
-
declare module '*.css' {
|
25
|
-
const classes: { readonly [key: string]: string };
|
26
|
-
export default classes;
|
27
|
-
}
|
28
|
-
|
29
|
-
declare module '*.sass' {
|
30
|
-
const classes: { readonly [key: string]: string };
|
31
|
-
export default classes;
|
32
|
-
}
|
33
|
-
|
34
|
-
declare module '*.scss' {
|
35
|
-
const classes: { readonly [key: string]: string };
|
36
|
-
export default classes;
|
37
|
-
}
|
38
|
-
|
39
|
-
declare module '*.mdx' {
|
40
|
-
const component: any;
|
41
|
-
export default component;
|
42
|
-
}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
.compNode {
|
2
|
-
max-width: 300px;
|
3
|
-
min-width: 200px;
|
4
|
-
border-width: 2px;
|
5
|
-
border-style: solid;
|
6
|
-
padding: 16px;
|
7
|
-
background: white;
|
8
|
-
|
9
|
-
text-align: left;
|
10
|
-
}
|
11
|
-
|
12
|
-
.firstRow {
|
13
|
-
display: flex;
|
14
|
-
align-items: center;
|
15
|
-
margin-bottom: 4px;
|
16
|
-
}
|
17
|
-
|
18
|
-
.envIcon {
|
19
|
-
margin-right: 8px;
|
20
|
-
}
|
21
|
-
|
22
|
-
.breadcrumbs {
|
23
|
-
color: #6c707c;
|
24
|
-
font-size: 12px;
|
25
|
-
}
|
26
|
-
|
27
|
-
.nameLine {
|
28
|
-
display: flex;
|
29
|
-
align-items: center;
|
30
|
-
}
|
31
|
-
|
32
|
-
.name {
|
33
|
-
font-weight: bold;
|
34
|
-
margin-right: 8px;
|
35
|
-
|
36
|
-
overflow: hidden;
|
37
|
-
text-overflow: ellipsis;
|
38
|
-
white-space: nowrap;
|
39
|
-
}
|
40
|
-
|
41
|
-
.version {
|
42
|
-
margin-right: 8px;
|
43
|
-
max-width: 80px;
|
44
|
-
}
|
45
|
-
|
46
|
-
.buffs {
|
47
|
-
display: flex;
|
48
|
-
margin-left: auto;
|
49
|
-
line-height: 1;
|
50
|
-
font-size: 15px;
|
51
|
-
line-height: 16px;
|
52
|
-
|
53
|
-
> * {
|
54
|
-
margin-right: 8px;
|
55
|
-
}
|
56
|
-
> *:last-child {
|
57
|
-
margin-right: 0px;
|
58
|
-
}
|
59
|
-
|
60
|
-
&:empty {
|
61
|
-
display: none;
|
62
|
-
}
|
63
|
-
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
2
|
-
import classnames from 'classnames';
|
3
|
-
import { mutedText } from '@teambit/base-ui.text.muted-text';
|
4
|
-
import { ComponentID } from '@teambit/component';
|
5
|
-
import { DeprecationIcon } from '@teambit/component.ui.deprecation-icon';
|
6
|
-
import { EnvIcon } from '@teambit/envs.ui.env-icon';
|
7
|
-
import { ellipsis } from '@teambit/design.ui.styles.ellipsis';
|
8
|
-
import { Card, CardProps } from '@teambit/base-ui.surfaces.card';
|
9
|
-
import { NodeModel } from '../query/node-model';
|
10
|
-
import { ComponentGraphContext } from '../dependencies-graph/';
|
11
|
-
|
12
|
-
// keep order: styles, then variants
|
13
|
-
import styles from './component-node.module.scss';
|
14
|
-
import variants from './variants.module.scss';
|
15
|
-
|
16
|
-
export interface ComponentNode extends CardProps {
|
17
|
-
node: NodeModel;
|
18
|
-
type: string;
|
19
|
-
}
|
20
|
-
|
21
|
-
export function ComponentNode({ node, type = 'defaultNode', ...rest }: ComponentNode) {
|
22
|
-
const graphContext = useContext(ComponentGraphContext);
|
23
|
-
const { component } = node;
|
24
|
-
const { id } = component;
|
25
|
-
|
26
|
-
return (
|
27
|
-
<Card className={classnames(styles.compNode, variants[type])} elevation="none" {...rest}>
|
28
|
-
<div className={styles.firstRow}>
|
29
|
-
<EnvIcon component={component} className={styles.envIcon} />
|
30
|
-
<Breadcrumbs componentId={id} className={mutedText} />
|
31
|
-
</div>
|
32
|
-
<div className={styles.nameLine}>
|
33
|
-
<span className={classnames(styles.name, ellipsis)}>{id.name}</span>
|
34
|
-
{id.version && <span className={classnames(styles.version, ellipsis)}>{id.version}</span>}
|
35
|
-
|
36
|
-
<div className={styles.buffs}>
|
37
|
-
<DeprecationIcon component={component} />
|
38
|
-
{graphContext &&
|
39
|
-
graphContext.componentWidgets
|
40
|
-
.toArray()
|
41
|
-
.map(([widgetId, Widget]) => <Widget key={widgetId} component={component} />)}
|
42
|
-
</div>
|
43
|
-
</div>
|
44
|
-
</Card>
|
45
|
-
);
|
46
|
-
}
|
47
|
-
|
48
|
-
type BreadcrumbsProps = { componentId: ComponentID } & React.HTMLAttributes<HTMLDivElement>;
|
49
|
-
|
50
|
-
function Breadcrumbs({ componentId, className, ...rest }: BreadcrumbsProps) {
|
51
|
-
const { scope, namespace } = componentId;
|
52
|
-
const showSep = !!scope && !!namespace;
|
53
|
-
|
54
|
-
return (
|
55
|
-
<div {...rest} className={classnames(styles.breadcrumbs, ellipsis, className)}>
|
56
|
-
{scope}
|
57
|
-
{showSep && '/'}
|
58
|
-
{namespace}
|
59
|
-
</div>
|
60
|
-
);
|
61
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
$success: #37b26c;
|
2
|
-
$regularNodeColor: #3a95ff;
|
3
|
-
$br20: #f3faff;
|
4
|
-
$d40: #6c707c;
|
5
|
-
|
6
|
-
$borderLabelHeight: 20px;
|
7
|
-
|
8
|
-
.root {
|
9
|
-
border-color: $success;
|
10
|
-
border-top-width: 20px;
|
11
|
-
|
12
|
-
border-radius: 10px;
|
13
|
-
box-shadow: 0px 0px 0px 2px #d0f1de, var(--bit-shadow-hover-medium);
|
14
|
-
|
15
|
-
&:before {
|
16
|
-
content: 'Current component';
|
17
|
-
position: absolute;
|
18
|
-
top: 1px;
|
19
|
-
left: 10px;
|
20
|
-
|
21
|
-
font-size: $borderLabelHeight / 2;
|
22
|
-
color: white;
|
23
|
-
line-height: $borderLabelHeight;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
.defaultNode {
|
28
|
-
border-color: $regularNodeColor;
|
29
|
-
|
30
|
-
box-shadow: 0px 0px 0px 2px $br20;
|
31
|
-
}
|
32
|
-
|
33
|
-
.external {
|
34
|
-
border-color: $d40;
|
35
|
-
|
36
|
-
box-shadow: 0px 0px 0px 2px var(border--color);
|
37
|
-
}
|
38
|
-
|
39
|
-
:export {
|
40
|
-
rootNodeColor: $success;
|
41
|
-
defaultNodeColor: $regularNodeColor;
|
42
|
-
externalNodeColor: $d40;
|
43
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import { Node, Edge, ArrowHeadType } from 'react-flow-renderer';
|
3
|
-
import { ComponentID } from '@teambit/component';
|
4
|
-
import { calcLayout } from './calc-layout';
|
5
|
-
import { GraphModel } from '../query';
|
6
|
-
|
7
|
-
import { depTypeToClass, depTypeToLabel } from './dep-edge';
|
8
|
-
|
9
|
-
type ElementsOptions = {
|
10
|
-
rootNode?: ComponentID;
|
11
|
-
};
|
12
|
-
|
13
|
-
/**
|
14
|
-
* generate Nodes and Edges for the ReactFlowRenderer graph renderer
|
15
|
-
*/
|
16
|
-
export function calcElements(graph: GraphModel | undefined, { rootNode }: ElementsOptions) {
|
17
|
-
return useMemo(() => {
|
18
|
-
if (!graph) return [];
|
19
|
-
|
20
|
-
const positions = calcLayout(graph);
|
21
|
-
|
22
|
-
const nodes: Node[] = Array.from(graph.nodes.values()).map((x) => {
|
23
|
-
return {
|
24
|
-
id: x.id,
|
25
|
-
type: 'ComponentNode',
|
26
|
-
data: {
|
27
|
-
node: x,
|
28
|
-
type: rootNode && x.component.id.isEqual(rootNode, { ignoreVersion: true }) ? 'root' : undefined,
|
29
|
-
},
|
30
|
-
position: positions.get(x.id) || { x: 0, y: 0 },
|
31
|
-
};
|
32
|
-
});
|
33
|
-
|
34
|
-
const edges: Edge[] = graph.edges.map((e) => ({
|
35
|
-
id: `_${e.sourceId}__${e.targetId}`,
|
36
|
-
source: e.sourceId,
|
37
|
-
target: e.targetId,
|
38
|
-
label: depTypeToLabel(e.dependencyLifecycleType),
|
39
|
-
labelBgPadding: [4, 4],
|
40
|
-
type: 'smoothstep',
|
41
|
-
className: depTypeToClass(e.dependencyLifecycleType),
|
42
|
-
arrowHeadType: ArrowHeadType.Arrow,
|
43
|
-
}));
|
44
|
-
|
45
|
-
return [...nodes, ...edges];
|
46
|
-
}, [graph]);
|
47
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import dagre, { graphlib } from 'dagre';
|
2
|
-
import { GraphModel } from '../query';
|
3
|
-
|
4
|
-
const NODE_WIDTH = 260;
|
5
|
-
const NODE_HEIGHT = 90;
|
6
|
-
|
7
|
-
const BOTTOM_TO_TOP = 'BT';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* calculate the specific location of each node in the graph
|
11
|
-
*/
|
12
|
-
export function calcLayout(graph: GraphModel) {
|
13
|
-
const g = new graphlib.Graph();
|
14
|
-
g.setGraph({ rankdir: BOTTOM_TO_TOP });
|
15
|
-
g.setDefaultEdgeLabel(() => ({}));
|
16
|
-
|
17
|
-
// make a new instance of { width, height } per node, or dagre will get confused and place all nodes in the same spot
|
18
|
-
graph.nodes.forEach((n) => g.setNode(n.id, { width: NODE_WIDTH, height: NODE_HEIGHT }));
|
19
|
-
graph.edges.forEach((e) => g.setEdge({ v: e.sourceId, w: e.targetId }));
|
20
|
-
|
21
|
-
// position items in graph
|
22
|
-
dagre.layout(g);
|
23
|
-
|
24
|
-
const positionsArr: [string, { x: number; y: number }][] = g.nodes().map((nodeId) => {
|
25
|
-
const node = g.node(nodeId);
|
26
|
-
|
27
|
-
const pos = {
|
28
|
-
x: node.x - node.width / 2,
|
29
|
-
y: node.y - node.height / 2,
|
30
|
-
};
|
31
|
-
|
32
|
-
return [nodeId, pos];
|
33
|
-
});
|
34
|
-
|
35
|
-
return new Map(positionsArr);
|
36
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { EdgeType } from '@teambit/graph';
|
2
|
-
import edgeStyles from './edge.module.scss';
|
3
|
-
|
4
|
-
export function depTypeToClass(depType: string) {
|
5
|
-
switch (depType) {
|
6
|
-
case 'DEV':
|
7
|
-
return edgeStyles.dev;
|
8
|
-
case 'PEER':
|
9
|
-
return edgeStyles.peer;
|
10
|
-
case 'RUNTIME':
|
11
|
-
return edgeStyles.runtime;
|
12
|
-
default:
|
13
|
-
return undefined;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
export function depTypeToLabel(type: EdgeType) {
|
18
|
-
switch (type) {
|
19
|
-
case EdgeType.peer:
|
20
|
-
return 'Peer Dependency';
|
21
|
-
case EdgeType.dev:
|
22
|
-
return 'Development Dependency';
|
23
|
-
case EdgeType.runtime:
|
24
|
-
return 'Dependency';
|
25
|
-
default:
|
26
|
-
return (type as string).toLowerCase();
|
27
|
-
}
|
28
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export { depTypeToClass, depTypeToLabel } from './dep-edge';
|
@@ -1,83 +0,0 @@
|
|
1
|
-
$d30: #878c9a;
|
2
|
-
$b70: #0d2de3;
|
3
|
-
|
4
|
-
.graph {
|
5
|
-
:global {
|
6
|
-
.react-flow__edge-path {
|
7
|
-
stroke: $d30;
|
8
|
-
stroke-width: 2px;
|
9
|
-
}
|
10
|
-
|
11
|
-
// creates space between the handles and lines
|
12
|
-
.react-flow__handle {
|
13
|
-
background: none;
|
14
|
-
border: none;
|
15
|
-
|
16
|
-
&-bottom {
|
17
|
-
bottom: -4px;
|
18
|
-
}
|
19
|
-
&-top {
|
20
|
-
top: -4px;
|
21
|
-
}
|
22
|
-
&-left {
|
23
|
-
left: -4px;
|
24
|
-
}
|
25
|
-
&-right {
|
26
|
-
right: -4px;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
.react-flow__arrowhead polyline {
|
31
|
-
stroke: $d30;
|
32
|
-
stroke-width: 2px;
|
33
|
-
}
|
34
|
-
|
35
|
-
// show labels for labels, on hover
|
36
|
-
.react-flow__edge {
|
37
|
-
pointer-events: all !important;
|
38
|
-
&:hover {
|
39
|
-
.react-flow__edge-textbg,
|
40
|
-
.react-flow__edge-text {
|
41
|
-
transition: all 300ms;
|
42
|
-
opacity: 1;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
.react-flow__edge-textbg {
|
48
|
-
fill: #414141;
|
49
|
-
}
|
50
|
-
|
51
|
-
.react-flow__edge-text {
|
52
|
-
fill: white;
|
53
|
-
}
|
54
|
-
|
55
|
-
.react-flow__edge-textbg,
|
56
|
-
.react-flow__edge-text {
|
57
|
-
opacity: 0;
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
.minimap {
|
63
|
-
right: 24px;
|
64
|
-
bottom: 24px;
|
65
|
-
box-shadow: var(--bit-shadow-faint);
|
66
|
-
background: white !important; // override inline styles from package
|
67
|
-
border-radius: 5px;
|
68
|
-
|
69
|
-
:global {
|
70
|
-
.react-flow__minimap-mask {
|
71
|
-
stroke: $b70;
|
72
|
-
stroke-width: 4px;
|
73
|
-
fill: transparent;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
.controls {
|
79
|
-
box-shadow: var(--bit-shadow-faint);
|
80
|
-
|
81
|
-
left: 24px;
|
82
|
-
bottom: 24px;
|
83
|
-
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
import React, { useMemo, useCallback, useRef, useEffect } from 'react';
|
2
|
-
import classnames from 'classnames';
|
3
|
-
import ReactFlow, {
|
4
|
-
Controls,
|
5
|
-
Background,
|
6
|
-
MiniMap,
|
7
|
-
OnLoadParams,
|
8
|
-
NodeTypesType,
|
9
|
-
Handle,
|
10
|
-
Position,
|
11
|
-
NodeProps,
|
12
|
-
ReactFlowProps,
|
13
|
-
} from 'react-flow-renderer';
|
14
|
-
import { ComponentID } from '@teambit/component';
|
15
|
-
|
16
|
-
import { ComponentWidgetSlot } from '../../graph.ui.runtime';
|
17
|
-
import { ComponentNode } from '../component-node';
|
18
|
-
import { GraphModel } from '../query';
|
19
|
-
import { calcElements } from './calc-elements';
|
20
|
-
import { calcMinimapColors } from './minimap';
|
21
|
-
import { ComponentGraphContext } from './graph-context';
|
22
|
-
|
23
|
-
import styles from './dependencies-graph.module.scss';
|
24
|
-
|
25
|
-
function ComponentNodeContainer(props: NodeProps) {
|
26
|
-
const { sourcePosition = Position.Top, targetPosition = Position.Bottom, data, id } = props;
|
27
|
-
|
28
|
-
return (
|
29
|
-
<div key={id}>
|
30
|
-
<Handle type="target" position={targetPosition} isConnectable={false} />
|
31
|
-
<Handle type="source" position={sourcePosition} isConnectable={false} />
|
32
|
-
<ComponentNode node={data.node} type={data.type} />
|
33
|
-
</div>
|
34
|
-
);
|
35
|
-
}
|
36
|
-
|
37
|
-
const NodeTypes: NodeTypesType = { ComponentNode: ComponentNodeContainer };
|
38
|
-
|
39
|
-
export type DependenciesGraphProps = {
|
40
|
-
rootNode: ComponentID;
|
41
|
-
graph: GraphModel;
|
42
|
-
componentWidgets: ComponentWidgetSlot;
|
43
|
-
onLoad?: (instance: OnLoadParams) => void;
|
44
|
-
} & Omit<ReactFlowProps, 'elements'>;
|
45
|
-
|
46
|
-
export function DependenciesGraph({
|
47
|
-
graph,
|
48
|
-
rootNode,
|
49
|
-
componentWidgets,
|
50
|
-
className,
|
51
|
-
onLoad,
|
52
|
-
children,
|
53
|
-
...rest
|
54
|
-
}: DependenciesGraphProps) {
|
55
|
-
const graphRef = useRef<OnLoadParams>();
|
56
|
-
const elements = calcElements(graph, { rootNode });
|
57
|
-
const context = useMemo(() => ({ componentWidgets }), [componentWidgets]);
|
58
|
-
|
59
|
-
const handleLoad = useCallback(
|
60
|
-
(instance: OnLoadParams) => {
|
61
|
-
graphRef.current = instance;
|
62
|
-
instance.fitView();
|
63
|
-
onLoad?.(instance);
|
64
|
-
},
|
65
|
-
[onLoad]
|
66
|
-
);
|
67
|
-
|
68
|
-
// clear ref on unmount
|
69
|
-
useEffect(() => () => (graphRef.current = undefined), []);
|
70
|
-
|
71
|
-
useEffect(() => {
|
72
|
-
graphRef.current?.fitView();
|
73
|
-
}, [graph]);
|
74
|
-
|
75
|
-
return (
|
76
|
-
<ComponentGraphContext.Provider value={context}>
|
77
|
-
<ReactFlow
|
78
|
-
draggable={false}
|
79
|
-
nodesDraggable={true}
|
80
|
-
selectNodesOnDrag={false}
|
81
|
-
nodesConnectable={false}
|
82
|
-
zoomOnDoubleClick={false}
|
83
|
-
elementsSelectable={false}
|
84
|
-
maxZoom={1}
|
85
|
-
{...rest}
|
86
|
-
className={classnames(styles.graph, className)}
|
87
|
-
elements={elements}
|
88
|
-
nodeTypes={NodeTypes}
|
89
|
-
onLoad={handleLoad}
|
90
|
-
>
|
91
|
-
<Background />
|
92
|
-
<Controls className={styles.controls} />
|
93
|
-
<MiniMap nodeColor={calcMinimapColors} className={styles.minimap} />
|
94
|
-
{children}
|
95
|
-
</ReactFlow>
|
96
|
-
</ComponentGraphContext.Provider>
|
97
|
-
);
|
98
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { createContext } from 'react';
|
2
|
-
import { ComponentWidgetSlot } from '../../graph.ui.runtime';
|
3
|
-
|
4
|
-
/** internal context, to pass shared information to all nodes */
|
5
|
-
export type ComponentGraph = {
|
6
|
-
componentWidgets: ComponentWidgetSlot;
|
7
|
-
};
|
8
|
-
|
9
|
-
export const ComponentGraphContext = createContext<ComponentGraph | undefined>(undefined);
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { Node } from 'react-flow-renderer';
|
2
|
-
import { rootNodeColor, defaultNodeColor, externalNodeColor } from '../component-node';
|
3
|
-
|
4
|
-
export function calcMinimapColors(node: Node) {
|
5
|
-
const type = node.data?.type;
|
6
|
-
|
7
|
-
switch (type) {
|
8
|
-
case 'root':
|
9
|
-
return rootNodeColor;
|
10
|
-
case 'external':
|
11
|
-
return externalNodeColor;
|
12
|
-
default:
|
13
|
-
return defaultNodeColor;
|
14
|
-
}
|
15
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Card, CardProps } from '@teambit/base-ui.surfaces.card';
|
3
|
-
import { CheckboxLabel } from '@teambit/evangelist.input.checkbox.label';
|
4
|
-
|
5
|
-
type GraphFilters = {
|
6
|
-
isFiltered: boolean;
|
7
|
-
onChangeFilter: (isFiltered: boolean) => void;
|
8
|
-
disable?: boolean;
|
9
|
-
} & CardProps;
|
10
|
-
|
11
|
-
export function GraphFilters({ onChangeFilter, isFiltered, disable, ...rest }: GraphFilters) {
|
12
|
-
return (
|
13
|
-
<Card {...rest}>
|
14
|
-
<div>
|
15
|
-
{/* show non-runtime === !isFiltered */}
|
16
|
-
<CheckboxLabel
|
17
|
-
checked={!isFiltered}
|
18
|
-
disabled={disable}
|
19
|
-
onInputChanged={(e) => onChangeFilter(!e.target.checked)}
|
20
|
-
>
|
21
|
-
{' '}
|
22
|
-
show non-runtime
|
23
|
-
</CheckboxLabel>
|
24
|
-
</div>
|
25
|
-
</Card>
|
26
|
-
);
|
27
|
-
}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
.page {
|
2
|
-
display: flex;
|
3
|
-
flex-direction: column;
|
4
|
-
height: 100%;
|
5
|
-
padding: 24px;
|
6
|
-
|
7
|
-
h2 {
|
8
|
-
margin-bottom: 24px;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
.graph {
|
13
|
-
flex-grow: 1;
|
14
|
-
height: 100%;
|
15
|
-
width: unset;
|
16
|
-
|
17
|
-
border-radius: 5px;
|
18
|
-
border: solid 1px var(--bit-border-color-lightest, #ededed);
|
19
|
-
background: var(--bit-bg-dent, #f6f6f6);
|
20
|
-
}
|
21
|
-
|
22
|
-
.summery {
|
23
|
-
margin-bottom: 24px;
|
24
|
-
}
|
25
|
-
|
26
|
-
.filters {
|
27
|
-
position: absolute;
|
28
|
-
top: 8px;
|
29
|
-
right: 8px;
|
30
|
-
padding: 8px;
|
31
|
-
|
32
|
-
font-size: 0.75em;
|
33
|
-
box-shadow: var(--bit-shadow-faint);
|
34
|
-
z-index: 8; // position above the abs positioned graph items
|
35
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import React, { useContext, useState } from 'react';
|
2
|
-
|
3
|
-
import { H2 } from '@teambit/documenter.ui.heading';
|
4
|
-
import { NotFoundPage } from '@teambit/design.ui.pages.not-found';
|
5
|
-
import { ServerErrorPage } from '@teambit/design.ui.pages.server-error';
|
6
|
-
import { ComponentContext } from '@teambit/component';
|
7
|
-
import { FullLoader } from '@teambit/legacy/dist/to-eject/full-loader';
|
8
|
-
|
9
|
-
import { useGraphQuery } from '../query';
|
10
|
-
import { DependenciesGraph } from '../dependencies-graph';
|
11
|
-
import { ComponentWidgetSlot } from '../../graph.ui.runtime';
|
12
|
-
import type { GraphFilter } from '../../model/graph-filters';
|
13
|
-
|
14
|
-
import { GraphFilters } from './graph-filters';
|
15
|
-
|
16
|
-
import styles from './graph-page.module.scss';
|
17
|
-
|
18
|
-
type GraphPageProps = {
|
19
|
-
componentWidgets: ComponentWidgetSlot;
|
20
|
-
};
|
21
|
-
|
22
|
-
export function GraphPage({ componentWidgets }: GraphPageProps) {
|
23
|
-
const component = useContext(ComponentContext);
|
24
|
-
|
25
|
-
const [filter, setFilter] = useState<GraphFilter>('runtimeOnly');
|
26
|
-
const onCheckFilter = (isFiltered: boolean) => {
|
27
|
-
setFilter(isFiltered ? 'runtimeOnly' : undefined);
|
28
|
-
};
|
29
|
-
|
30
|
-
const { graph, error, loading } = useGraphQuery([component.id.toString()], filter);
|
31
|
-
if (error) return error.code === 404 ? <NotFoundPage /> : <ServerErrorPage />;
|
32
|
-
if (!graph) return <FullLoader />;
|
33
|
-
|
34
|
-
const isFiltered = filter === 'runtimeOnly';
|
35
|
-
|
36
|
-
return (
|
37
|
-
<div className={styles.page}>
|
38
|
-
<H2 size="xs">Component Dependencies</H2>
|
39
|
-
<DependenciesGraph
|
40
|
-
componentWidgets={componentWidgets}
|
41
|
-
graph={graph}
|
42
|
-
rootNode={component.id}
|
43
|
-
className={styles.graph}
|
44
|
-
>
|
45
|
-
<GraphFilters
|
46
|
-
className={styles.filters}
|
47
|
-
disable={loading}
|
48
|
-
isFiltered={isFiltered}
|
49
|
-
onChangeFilter={onCheckFilter}
|
50
|
-
/>
|
51
|
-
</DependenciesGraph>
|
52
|
-
</div>
|
53
|
-
);
|
54
|
-
}
|
package/ui/graph-page/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { GraphPage } from './graph-page';
|