@redocly/theme 0.57.0-next.1 → 0.57.0-next.2

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.
Files changed (65) hide show
  1. package/lib/components/Catalog/CatalogCardView/CatalogCard.js +1 -0
  2. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +36 -25
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsEdge.d.ts +6 -0
  4. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsEdge.js +38 -0
  5. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.d.ts +6 -0
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +83 -0
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.d.ts +2 -0
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.js +29 -0
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsLinkedNode.d.ts +8 -0
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsLinkedNode.js +33 -0
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsNode.d.ts +16 -0
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsNode.js +24 -0
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsRootNode.d.ts +7 -0
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsRootNode.js +30 -0
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.js +5 -2
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.d.ts +1 -0
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +7 -3
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +3 -8
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +22 -0
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.js +18 -0
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +2 -2
  22. package/lib/components/Catalog/CatalogEntityIcon.d.ts +2 -1
  23. package/lib/components/Catalog/CatalogEntityIcon.js +4 -6
  24. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +1 -1
  25. package/lib/components/Catalog/variables.js +42 -0
  26. package/lib/components/CatalogClassic/CatalogClassicVirtualizedGroups.js +13 -8
  27. package/lib/core/constants/catalog.d.ts +10 -0
  28. package/lib/core/constants/catalog.js +14 -1
  29. package/lib/core/hooks/catalog/useGraph.d.ts +15 -0
  30. package/lib/core/hooks/catalog/useGraph.js +165 -0
  31. package/lib/core/hooks/index.d.ts +1 -0
  32. package/lib/core/hooks/index.js +1 -0
  33. package/lib/core/openapi/index.d.ts +1 -0
  34. package/lib/core/openapi/index.js +3 -1
  35. package/lib/core/styles/index.d.ts +1 -0
  36. package/lib/core/styles/index.js +3 -0
  37. package/lib/core/styles/xyflow.d.ts +1 -0
  38. package/lib/core/styles/xyflow.js +623 -0
  39. package/lib/core/utils/dynamic.d.ts +5 -3
  40. package/lib/core/utils/dynamic.js +1 -1
  41. package/package.json +3 -2
  42. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +1 -0
  43. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +60 -42
  44. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsEdge.tsx +63 -0
  45. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.tsx +7 -0
  46. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.tsx +91 -0
  47. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsLinkedNode.tsx +48 -0
  48. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsNode.tsx +45 -0
  49. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsRootNode.tsx +49 -0
  50. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +6 -2
  51. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +8 -2
  52. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +24 -43
  53. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +76 -0
  54. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +2 -2
  55. package/src/components/Catalog/CatalogEntityIcon.tsx +7 -5
  56. package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +1 -1
  57. package/src/components/Catalog/variables.ts +42 -0
  58. package/src/components/CatalogClassic/CatalogClassicVirtualizedGroups.tsx +29 -18
  59. package/src/core/constants/catalog.ts +13 -0
  60. package/src/core/hooks/catalog/useGraph.ts +236 -0
  61. package/src/core/hooks/index.ts +1 -0
  62. package/src/core/openapi/index.ts +1 -0
  63. package/src/core/styles/index.ts +1 -0
  64. package/src/core/styles/xyflow.ts +620 -0
  65. package/src/core/utils/dynamic.tsx +17 -15
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config';
4
+ import { Route, Routes, useLocation, matchPath } from 'react-router-dom';
4
5
 
5
6
  import type { BffCatalogEntity, BffCatalogRelatedEntityList } from '@redocly/theme/core/types';
6
7
 
@@ -19,6 +20,7 @@ import { useThemeHooks } from '@redocly/theme/core/hooks';
19
20
  import { SidebarActions } from '@redocly/theme/components/SidebarActions/SidebarActions';
20
21
  import { CatalogEntitySchema } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntitySchema';
21
22
  import { CatalogEntityMethodAndPath } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath';
23
+ import { CatalogEntityRelationsGraph } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy';
22
24
 
23
25
  export type CatalogEntityProps = {
24
26
  entity: BffCatalogEntity;
@@ -27,6 +29,17 @@ export type CatalogEntityProps = {
27
29
  initialRelations: BffCatalogRelatedEntityList;
28
30
  };
29
31
 
32
+ const renderEntityContent = (entity: BffCatalogEntity): React.ReactElement => {
33
+ switch (entity.type) {
34
+ case 'data-schema':
35
+ return <CatalogEntitySchema entity={entity} />;
36
+ case 'api-operation':
37
+ return <CatalogEntityMethodAndPath entity={entity} />;
38
+ default:
39
+ return <CatalogEntityMetadata entity={entity} />;
40
+ }
41
+ };
42
+
30
43
  export function CatalogEntity({
31
44
  entity,
32
45
  entitiesCatalogConfig,
@@ -37,7 +50,6 @@ export function CatalogEntity({
37
50
  const { translate } = useTranslate();
38
51
  const linkToMainCatalog = `catalogs/${catalogConfig.slug}`;
39
52
  const linkToMainCatalogLabel = translate(catalogConfig.titleTranslationKey);
40
-
41
53
  const {
42
54
  layout,
43
55
  collapsedSidebar,
@@ -47,16 +59,19 @@ export function CatalogEntity({
47
59
  setSearchQuery,
48
60
  } = useCatalog();
49
61
 
50
- const renderEntityContent = (): React.ReactElement => {
51
- switch (entity.type) {
52
- case 'data-schema':
53
- return <CatalogEntitySchema entity={entity} />;
54
- case 'api-operation':
55
- return <CatalogEntityMethodAndPath entity={entity} />;
56
- default:
57
- return <CatalogEntityMetadata entity={entity} />;
58
- }
59
- };
62
+ const { pathname } = useLocation();
63
+ const linkBase = `${linkToMainCatalog}/entities/${entity.key}`;
64
+ const menuItemDefs = [
65
+ { label: 'Overview', path: linkBase, end: true },
66
+ { label: 'Relations Graph', path: `${linkBase}/relations-graph`, end: true },
67
+ ];
68
+ const sidebarMenuItems = menuItemDefs.map(({ label, path, end }) => ({
69
+ label,
70
+ link: path,
71
+ active: Boolean(matchPath({ path: `/${path}`, end }, pathname)),
72
+ items: [],
73
+ hasActiveSubItem: false,
74
+ }));
60
75
 
61
76
  return (
62
77
  <CatalogPageWrapper data-component-name="Catalog/CatalogEntity/CatalogEntity">
@@ -80,19 +95,7 @@ export function CatalogEntity({
80
95
  )}
81
96
  </BackLink>
82
97
  }
83
- menu={
84
- <Menu
85
- items={[
86
- {
87
- label: 'Overview',
88
- link: `${linkToMainCatalog}/entities/${entity.key}`,
89
- active: true,
90
- items: [],
91
- hasActiveSubItem: false,
92
- },
93
- ]}
94
- />
95
- }
98
+ menu={<Menu items={sidebarMenuItems} />}
96
99
  footer={
97
100
  <SidebarActions
98
101
  layout={layout}
@@ -111,24 +114,39 @@ export function CatalogEntity({
111
114
  ]}
112
115
  />
113
116
  <CatalogEntityPageWrapper>
114
- <CatalogPageDescription
115
- title={entity.title}
116
- description={entity.summary ?? ''}
117
- tag={entity.key}
118
- />
119
- <CatalogEntityProperties entity={entity} />
120
- <CatalogTwoColumnsSection>
121
- {renderEntityContent()}
122
- <CatalogEntityLinks entity={entity} />
123
- </CatalogTwoColumnsSection>
124
- <CatalogEntityRelations
125
- entity={entity}
126
- entitiesCatalogConfig={entitiesCatalogConfig}
127
- catalogConfig={catalogConfig}
128
- initialRelations={initialRelations}
129
- searchQuery={searchQuery}
130
- setSearchQuery={setSearchQuery}
131
- />
117
+ <Routes>
118
+ <Route path={`${catalogConfig.slug}/entities/${entity.key}`}>
119
+ <Route
120
+ index
121
+ element={
122
+ <>
123
+ <CatalogPageDescription
124
+ title={entity.title}
125
+ description={entity.summary ?? ''}
126
+ tag={entity.key}
127
+ />
128
+ <CatalogEntityProperties entity={entity} />
129
+ <CatalogTwoColumnsSection>
130
+ {renderEntityContent(entity)}
131
+ <CatalogEntityLinks entity={entity} />
132
+ </CatalogTwoColumnsSection>
133
+ <CatalogEntityRelations
134
+ entity={entity}
135
+ entitiesCatalogConfig={entitiesCatalogConfig}
136
+ catalogConfig={catalogConfig}
137
+ initialRelations={initialRelations}
138
+ searchQuery={searchQuery}
139
+ setSearchQuery={setSearchQuery}
140
+ />
141
+ </>
142
+ }
143
+ />
144
+ <Route
145
+ path="relations-graph"
146
+ element={<CatalogEntityRelationsGraph entity={entity} />}
147
+ />
148
+ </Route>
149
+ </Routes>
132
150
  </CatalogEntityPageWrapper>
133
151
  </CatalogPageContent>
134
152
  </CatalogPageWrapper>
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath, type EdgeProps } from '@xyflow/react';
3
+ import styled from 'styled-components';
4
+
5
+ export type CatalogEntityRelationsEdgeProps = EdgeProps & { className?: string };
6
+
7
+ export function CatalogEntityRelationsEdge(
8
+ props: CatalogEntityRelationsEdgeProps,
9
+ ): React.ReactElement {
10
+ const {
11
+ id,
12
+ sourceX,
13
+ sourceY,
14
+ sourcePosition,
15
+ targetX,
16
+ targetY,
17
+ targetPosition,
18
+ style,
19
+ label,
20
+ markerEnd,
21
+ className,
22
+ } = props;
23
+
24
+ const [edgePath, labelX, labelY] = getSmoothStepPath({
25
+ sourceX,
26
+ sourceY,
27
+ sourcePosition,
28
+ targetX,
29
+ targetY,
30
+ targetPosition,
31
+ borderRadius: 12,
32
+ });
33
+
34
+ return (
35
+ <>
36
+ <BaseEdge id={id} path={edgePath} style={style} markerEnd={markerEnd} />
37
+ {label ? (
38
+ <EdgeLabelRenderer>
39
+ <EdgeLabel
40
+ className={className ? `nopan ${className}` : 'nopan'}
41
+ style={{ transform: `translate(-50%, 0%) translate(${labelX}px, ${labelY - 10}px)` }}
42
+ data-component-name="Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsEdge"
43
+ >
44
+ {label}
45
+ </EdgeLabel>
46
+ </EdgeLabelRenderer>
47
+ ) : null}
48
+ </>
49
+ );
50
+ }
51
+
52
+ const EdgeLabel = styled.div`
53
+ position: absolute;
54
+ background: var(--catalog-entity-relations-edge-label-bg-color);
55
+ color: var(--catalog-entity-relations-edge-label-text-color);
56
+ border: var(--catalog-entity-relations-edge-label-border-width)
57
+ var(--catalog-entity-relations-edge-label-border-style)
58
+ var(--catalog-entity-relations-edge-label-border-color);
59
+ border-radius: var(--catalog-entity-relations-edge-label-border-radius);
60
+ padding: var(--catalog-entity-relations-edge-label-padding);
61
+ font-size: var(--catalog-entity-relations-edge-label-font-size);
62
+ line-height: var(--catalog-entity-relations-edge-label-line-height);
63
+ `;
@@ -0,0 +1,7 @@
1
+ import type { CatalogEntityRelationsGraphProps } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph';
2
+
3
+ import { dynamic } from '@redocly/theme/core/utils';
4
+
5
+ export const CatalogEntityRelationsGraph = dynamic<CatalogEntityRelationsGraphProps>(() =>
6
+ import('./CatalogEntityRelationsGraph').then((mod) => mod.CatalogEntityRelationsGraph),
7
+ );
@@ -0,0 +1,91 @@
1
+ import React, { JSX, useMemo } from 'react';
2
+ import { Background, ColorMode, Controls, ReactFlow } from '@xyflow/react';
3
+ import styled from 'styled-components';
4
+
5
+ import { BffCatalogEntity } from '@redocly/theme/core/types';
6
+ import { useColorSwitcher, useThemeHooks } from '@redocly/theme/core/hooks';
7
+ import { useGraph } from '@redocly/theme/core/hooks/catalog/useGraph';
8
+ import { CatalogEntityRelationsNode } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsNode';
9
+ import { CatalogEntityRelationsEdge } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsEdge';
10
+ import { xyflow } from '@redocly/theme/core/styles';
11
+ import { CatalogPageDescription } from '@redocly/theme/components/Catalog/CatalogPageDescription';
12
+ import { GraphCustomEdgeType, GraphCustomNodeType } from '@redocly/theme/core/constants/catalog';
13
+
14
+ export type CatalogEntityRelationsGraphProps = {
15
+ entity: BffCatalogEntity;
16
+ };
17
+
18
+ const commonReactFlowConfig = {
19
+ fitView: true,
20
+ proOptions: {
21
+ hideAttribution: true,
22
+ },
23
+ style: {
24
+ border:
25
+ 'var(--catalog-card-border-width) var(--catalog-card-border-style) var(--catalog-card-border-color)',
26
+ borderRadius: 'var(--catalog-card-border-radius, 8px)',
27
+ },
28
+ };
29
+
30
+ export function CatalogEntityRelationsGraph({
31
+ entity,
32
+ }: CatalogEntityRelationsGraphProps): JSX.Element {
33
+ const { useFetchCatalogEntitiesRelations } = useThemeHooks();
34
+ const { activeColorMode } = useColorSwitcher();
35
+ const { items: allRelations } = useFetchCatalogEntitiesRelations({
36
+ entityKey: entity.key,
37
+ });
38
+
39
+ const { nodes, edges, onNodesChange, onEdgesChange, onConnect } = useGraph({
40
+ entity,
41
+ relations: allRelations ?? [],
42
+ });
43
+
44
+ const nodeTypes = useMemo(
45
+ () => ({ [GraphCustomNodeType.CatalogEntity]: CatalogEntityRelationsNode }),
46
+ [],
47
+ );
48
+ const edgeTypes = useMemo(
49
+ () => ({ [GraphCustomEdgeType.CatalogEdge]: CatalogEntityRelationsEdge }),
50
+ [],
51
+ );
52
+
53
+ const reactFlowConfig = allRelations.length
54
+ ? {
55
+ key: entity.id,
56
+ nodes,
57
+ edges,
58
+ nodeTypes,
59
+ edgeTypes,
60
+ onNodesChange,
61
+ onEdgesChange,
62
+ onConnect,
63
+ colorMode: activeColorMode as ColorMode,
64
+ ...commonReactFlowConfig,
65
+ }
66
+ : {
67
+ ...commonReactFlowConfig,
68
+ };
69
+
70
+ return (
71
+ <>
72
+ <CatalogPageDescription
73
+ title={entity.title}
74
+ description={entity.summary ?? ''}
75
+ tag={entity.key}
76
+ />
77
+ <GraphWrapper>
78
+ <ReactFlow {...reactFlowConfig}>
79
+ <Background bgColor="var(--catalog-card-bg-color)" />
80
+ <Controls />
81
+ </ReactFlow>
82
+ </GraphWrapper>
83
+ </>
84
+ );
85
+ }
86
+
87
+ const GraphWrapper = styled.div`
88
+ height: 700px;
89
+ width: 100%;
90
+ ${xyflow}
91
+ `;
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { Handle, Position } from '@xyflow/react';
3
+ import styled from 'styled-components';
4
+
5
+ import { CatalogEntityIcon } from '@redocly/theme/components/Catalog/CatalogEntityIcon';
6
+ import { Link } from '@redocly/theme/components/Link/Link';
7
+ import { GraphHandleType } from '@redocly/theme/core/constants/catalog';
8
+
9
+ export type CatalogEntityRelationsLinkedNodeProps = {
10
+ label: string;
11
+ entityType: string;
12
+ className?: string;
13
+ to: string;
14
+ };
15
+
16
+ export function CatalogEntityRelationsLinkedNode({
17
+ label,
18
+ entityType,
19
+ className,
20
+ to,
21
+ }: CatalogEntityRelationsLinkedNodeProps): React.ReactElement {
22
+ return (
23
+ <RelationsLinkedNodeWrapper
24
+ className={className}
25
+ to={to}
26
+ data-component-name="Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsLinkedNode"
27
+ >
28
+ <Handle type={GraphHandleType.Target} position={Position.Top} id={GraphHandleType.Target} />
29
+ <CatalogEntityIcon entityType={entityType} defaultColor={false} />
30
+ <div>{label}</div>
31
+ </RelationsLinkedNodeWrapper>
32
+ );
33
+ }
34
+
35
+ const RelationsLinkedNodeWrapper = styled(Link)`
36
+ display: flex;
37
+ align-items: center;
38
+ gap: var(--catalog-entity-relations-node-gap);
39
+ padding: var(--catalog-entity-relations-node-padding);
40
+ border-radius: var(--catalog-entity-relations-node-border-radius);
41
+ font-style: normal;
42
+ font-weight: var(--catalog-entity-relations-node-font-weight);
43
+ background: var(--catalog-entity-relations-node-bg-color);
44
+ color: var(--catalog-entity-relations-node-text-color);
45
+ border: var(--catalog-entity-relations-node-border-width)
46
+ var(--catalog-entity-relations-node-border-style)
47
+ var(--catalog-entity-relations-node-border-color);
48
+ `;
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+
3
+ import { CatalogEntityRelationsRootNode } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsRootNode';
4
+ import { CatalogEntityRelationsLinkedNode } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsLinkedNode';
5
+
6
+ export type CatalogEntityNodeData = {
7
+ label: string;
8
+ entityType: string;
9
+ entityKey: string;
10
+ isRoot?: boolean;
11
+ };
12
+
13
+ export type CatalogEntityRelationsNodeProps = { data: CatalogEntityNodeData; className?: string };
14
+
15
+ export enum HandleType {
16
+ Target = 'target',
17
+ Source = 'source',
18
+ }
19
+
20
+ export function CatalogEntityRelationsNode({
21
+ data,
22
+ className,
23
+ }: CatalogEntityRelationsNodeProps): React.ReactElement {
24
+ const { label, entityType, isRoot, entityKey } = data;
25
+ const mergedClassName = `nopan${className ? ` ${className}` : ''}`;
26
+
27
+ if (isRoot) {
28
+ return (
29
+ <CatalogEntityRelationsRootNode
30
+ className={mergedClassName}
31
+ label={label}
32
+ entityType={entityType}
33
+ />
34
+ );
35
+ }
36
+
37
+ return (
38
+ <CatalogEntityRelationsLinkedNode
39
+ className={mergedClassName}
40
+ label={label}
41
+ entityType={entityType}
42
+ to={`/catalogs/all/entities/${entityKey}`}
43
+ />
44
+ );
45
+ }
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { Handle, Position } from '@xyflow/react';
3
+ import styled from 'styled-components';
4
+
5
+ import { CatalogEntityIcon } from '@redocly/theme/components/Catalog/CatalogEntityIcon';
6
+ import { GraphHandleType } from '@redocly/theme/core/constants/catalog';
7
+
8
+ export type CatalogEntityRelationsRootNodeProps = {
9
+ label: string;
10
+ entityType: string;
11
+ className?: string;
12
+ };
13
+
14
+ export function CatalogEntityRelationsRootNode({
15
+ label,
16
+ entityType,
17
+ className,
18
+ }: CatalogEntityRelationsRootNodeProps): React.ReactElement {
19
+ return (
20
+ <RelationsRootNodeWrapper
21
+ className={className}
22
+ data-component-name="Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsRootNode"
23
+ >
24
+ <CatalogEntityIcon
25
+ entityType={entityType}
26
+ forceColor="var(--catalog-entity-relations-node-root-icon-color)"
27
+ />
28
+ <div>{label}</div>
29
+ <Handle
30
+ type={GraphHandleType.Source}
31
+ position={Position.Bottom}
32
+ id={GraphHandleType.Source}
33
+ />
34
+ </RelationsRootNodeWrapper>
35
+ );
36
+ }
37
+
38
+ const RelationsRootNodeWrapper = styled.div`
39
+ display: flex;
40
+ align-items: center;
41
+ gap: var(--catalog-entity-relations-node-gap);
42
+ padding: var(--catalog-entity-relations-node-padding);
43
+ border-radius: var(--catalog-entity-relations-node-border-radius);
44
+ font-style: normal;
45
+ font-weight: var(--catalog-entity-relations-node-font-weight-root);
46
+ background: var(--catalog-entity-relations-node-root-bg-color);
47
+ color: var(--catalog-entity-relations-node-root-text-color);
48
+ border: none;
49
+ `;
@@ -24,7 +24,7 @@ export function CatalogEntityMethodAndPath({ entity }: CatalogEntityMethodAndPat
24
24
  leftContent={
25
25
  <Label>
26
26
  <MethodTag color={method.toLowerCase()}>{method}</MethodTag>
27
- {path}
27
+ <PathLabel>{path}</PathLabel>
28
28
  </Label>
29
29
  }
30
30
  withSeparator={false}
@@ -36,7 +36,10 @@ export function CatalogEntityMethodAndPath({ entity }: CatalogEntityMethodAndPat
36
36
  const MethodTag = styled(HttpTag)`
37
37
  width: auto;
38
38
  justify-content: start;
39
- margin-right: var(--spacing-xxs);
39
+ `;
40
+
41
+ const PathLabel = styled.label`
42
+ margin-left: var(--spacing-xxs);
40
43
  `;
41
44
 
42
45
  const LinksWrapper = styled.div`
@@ -51,6 +54,7 @@ const LinksWrapper = styled.div`
51
54
 
52
55
  const Label = styled.div`
53
56
  display: flex;
57
+ width: 100%;
54
58
  `;
55
59
 
56
60
  const Heading = styled.h2`
@@ -11,6 +11,7 @@ export type CatalogEntityRelationsProps = {
11
11
  entitiesCatalogConfig: EntitiesCatalogConfig;
12
12
  catalogConfig: CatalogEntityConfig;
13
13
  initialRelations: BffCatalogRelatedEntityList;
14
+ initialFilter?: string;
14
15
  searchQuery: string;
15
16
  setSearchQuery: (query: string) => void;
16
17
  };
@@ -29,10 +30,15 @@ export function CatalogEntityRelations({
29
30
  }: CatalogEntityRelationsProps): JSX.Element | null {
30
31
  const { useCatalogSort, useFetchCatalogEntitiesRelations } = useThemeHooks();
31
32
  const { sortOption, setSortOption, handleSortClick, isColumnSorted } = useCatalogSort();
32
- const [filter, setFilter] = useState<string>(ENTITY_DEFAULT_FILTERS[entity.type] ?? '');
33
+ const [filter, setFilter] = useState<string>();
33
34
 
34
35
  const { items: relations, query } = useFetchCatalogEntitiesRelations(
35
- { entityKey: entity.key, search: searchQuery, sort: sortOption ?? undefined, filter },
36
+ {
37
+ entityKey: entity.key,
38
+ search: searchQuery,
39
+ sort: sortOption ?? undefined,
40
+ filter: filter ?? ENTITY_DEFAULT_FILTERS[entity.type],
41
+ },
36
42
  initialRelations,
37
43
  );
38
44
 
@@ -2,16 +2,11 @@ import React, { JSX } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config';
4
4
 
5
- import { ArrowDownIcon } from '@redocly/theme/icons/ArrowDownIcon/ArrowDownIcon';
6
5
  import { BffCatalogEntity, BffCatalogRelatedEntity, SortOption } from '@redocly/theme/core/types';
7
- import { LoadMore } from '@redocly/theme/components/LoadMore/LoadMore';
8
- import {
9
- CatalogColumn,
10
- CatalogTableView,
11
- } from '@redocly/theme/components/Catalog/CatalogTableView/CatalogTableView';
6
+ import { CatalogColumn } from '@redocly/theme/components/Catalog/CatalogTableView/CatalogTableView';
12
7
  import { CatalogActionsRow } from '@redocly/theme/components/Catalog/CatalogActionsRow';
13
- import { HighlightContext } from '@redocly/theme/components/Catalog/CatalogHighlight';
14
- import { CatalogEntitiesEmptyState } from '@redocly/theme/components/Catalog/CatalogEntitiesEmptyState';
8
+
9
+ import { CatalogEntityRelationsTableContent } from './CatalogEntityRelationsTableContent';
15
10
 
16
11
  export type CatalogEntityRelationsTableProps = {
17
12
  entity: BffCatalogEntity;
@@ -53,41 +48,27 @@ export function CatalogEntityRelationsTable({
53
48
  return (
54
49
  <div data-component-name="Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable">
55
50
  {heading && <Heading>{heading}</Heading>}
56
- {(searchQuery || relations.length > 0) && (
57
- <CatalogActionsRow
58
- searchQuery={searchQuery}
59
- setSearchQuery={setSearchQuery}
60
- sortOption={sortOption}
61
- setSortOption={setSortOption}
62
- style={{ marginBottom: '12px' }}
63
- />
64
- )}
65
- <HighlightContext.Provider value={[searchQuery]}>
66
- {relations.length > 0 ? (
67
- <CatalogTableView
68
- entities={relations}
69
- entitiesCatalogConfig={entitiesCatalogConfig}
70
- catalogConfig={catalogConfig}
71
- columns={columns}
72
- setSortOption={setSortOption}
73
- currentSortOption={sortOption}
74
- handleSortClick={handleSortClick}
75
- isColumnSorted={isColumnSorted}
76
- style={{ marginTop: 0 }}
77
- />
78
- ) : (
79
- <CatalogEntitiesEmptyState listType={listType} />
80
- )}
81
- </HighlightContext.Provider>
82
- {shouldShowLoadMore && (
83
- <LoadMore
84
- icon={<ArrowDownIcon size="var(--catalog-load-more-icon-size)" />}
85
- onClick={query.fetchNextPage}
86
- disabled={query.isFetchingNextPage}
87
- blinking={query.isFetchingNextPage}
88
- label={query.isFetchingNextPage ? 'Loading...' : 'Load More'}
89
- />
90
- )}
51
+ <CatalogActionsRow
52
+ searchQuery={searchQuery}
53
+ setSearchQuery={setSearchQuery}
54
+ sortOption={sortOption}
55
+ setSortOption={setSortOption}
56
+ style={{ marginBottom: '12px' }}
57
+ />
58
+ <CatalogEntityRelationsTableContent
59
+ entitiesCatalogConfig={entitiesCatalogConfig}
60
+ catalogConfig={catalogConfig}
61
+ relations={relations}
62
+ query={query}
63
+ searchQuery={searchQuery}
64
+ columns={columns}
65
+ setSortOption={setSortOption}
66
+ sortOption={sortOption}
67
+ handleSortClick={handleSortClick}
68
+ isColumnSorted={isColumnSorted}
69
+ shouldShowLoadMore={shouldShowLoadMore}
70
+ listType={listType}
71
+ />
91
72
  </div>
92
73
  );
93
74
  }
@@ -0,0 +1,76 @@
1
+ import React, { JSX } from 'react';
2
+ import { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config';
3
+
4
+ import { ArrowDownIcon } from '@redocly/theme/icons/ArrowDownIcon/ArrowDownIcon';
5
+ import { BffCatalogRelatedEntity, SortOption } from '@redocly/theme/core/types';
6
+ import { LoadMore } from '@redocly/theme/components/LoadMore/LoadMore';
7
+ import {
8
+ CatalogColumn,
9
+ CatalogTableView,
10
+ } from '@redocly/theme/components/Catalog/CatalogTableView/CatalogTableView';
11
+ import { HighlightContext } from '@redocly/theme/components/Catalog/CatalogHighlight';
12
+ import { CatalogEntitiesEmptyState } from '@redocly/theme/components/Catalog/CatalogEntitiesEmptyState';
13
+
14
+ export type CatalogEntityRelationsTableContentProps = {
15
+ entitiesCatalogConfig: EntitiesCatalogConfig;
16
+ catalogConfig: CatalogEntityConfig;
17
+ relations: BffCatalogRelatedEntity[];
18
+ query: {
19
+ fetchNextPage: () => void;
20
+ isFetchingNextPage: boolean;
21
+ };
22
+ searchQuery: string;
23
+ columns: CatalogColumn<BffCatalogRelatedEntity>[];
24
+ sortOption: SortOption | null;
25
+ setSortOption: (sortOption: SortOption | null) => void;
26
+ handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
27
+ isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
28
+ shouldShowLoadMore: boolean;
29
+ listType?: 'default' | 'team';
30
+ };
31
+
32
+ export function CatalogEntityRelationsTableContent({
33
+ entitiesCatalogConfig,
34
+ catalogConfig,
35
+ relations,
36
+ query,
37
+ searchQuery,
38
+ columns,
39
+ setSortOption,
40
+ sortOption,
41
+ handleSortClick,
42
+ isColumnSorted,
43
+ shouldShowLoadMore,
44
+ listType,
45
+ }: CatalogEntityRelationsTableContentProps): JSX.Element {
46
+ return (
47
+ <div data-component-name="Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent">
48
+ <HighlightContext.Provider value={[searchQuery]}>
49
+ {relations.length > 0 ? (
50
+ <CatalogTableView
51
+ entities={relations}
52
+ entitiesCatalogConfig={entitiesCatalogConfig}
53
+ catalogConfig={catalogConfig}
54
+ columns={columns}
55
+ setSortOption={setSortOption}
56
+ currentSortOption={sortOption}
57
+ handleSortClick={handleSortClick}
58
+ isColumnSorted={isColumnSorted}
59
+ style={{ marginTop: 0 }}
60
+ />
61
+ ) : (
62
+ <CatalogEntitiesEmptyState listType={listType} />
63
+ )}
64
+ </HighlightContext.Provider>
65
+ {shouldShowLoadMore && (
66
+ <LoadMore
67
+ icon={<ArrowDownIcon size="var(--catalog-load-more-icon-size)" />}
68
+ onClick={query.fetchNextPage}
69
+ disabled={query.isFetchingNextPage}
70
+ blinking={query.isFetchingNextPage}
71
+ label={query.isFetchingNextPage ? 'Loading...' : 'Load More'}
72
+ />
73
+ )}
74
+ </div>
75
+ );
76
+ }