@finos/legend-query-builder 4.17.25 → 4.17.27

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.
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from 'react';
18
+ import { Handle, Position } from 'reactflow';
19
+ import { clsx } from '@finos/legend-art';
20
+
21
+ export interface PropertyOwnerNodeData {
22
+ label: string;
23
+ isPropertyOwner: boolean;
24
+ highlightedProperties?: Set<string> | undefined;
25
+ allProperties?:
26
+ | Array<{
27
+ name: string;
28
+ dataType?: string | undefined;
29
+ propertyType: string | undefined;
30
+ }>
31
+ | undefined;
32
+ isSelected?: boolean | undefined;
33
+ isHighlighted?: boolean | undefined;
34
+ }
35
+
36
+ export const PropertyOwnerNode = (props: { data: PropertyOwnerNodeData }) => {
37
+ const { data } = props;
38
+ const {
39
+ label,
40
+ isPropertyOwner,
41
+ highlightedProperties,
42
+ allProperties,
43
+ isSelected,
44
+ isHighlighted,
45
+ } = data;
46
+
47
+ const hasHighlightedProperties =
48
+ !!highlightedProperties && highlightedProperties.size > 0;
49
+ const showPropertyList = isPropertyOwner && hasHighlightedProperties;
50
+
51
+ const safeAllProperties = Array.isArray(allProperties) ? allProperties : [];
52
+
53
+ const filteredProperties = safeAllProperties
54
+ .filter((prop) => highlightedProperties?.has(prop.name))
55
+ .slice(0, 20);
56
+
57
+ const remainingCount = Math.max(
58
+ 0,
59
+ safeAllProperties.filter((prop) => highlightedProperties?.has(prop.name))
60
+ .length - 20,
61
+ );
62
+
63
+ const needsScrolling = filteredProperties.length > 4;
64
+
65
+ return (
66
+ <>
67
+ <Handle type="target" position={Position.Left} style={{ left: -5 }} />
68
+ <div
69
+ className={clsx('property-owner-node', {
70
+ 'property-owner-node--selected': isSelected,
71
+ 'property-owner-node--highlighted': isHighlighted,
72
+ 'property-owner-node--with-properties': showPropertyList,
73
+ 'property-owner-node--property-owner': isPropertyOwner,
74
+ 'property-owner-node--scrollable': needsScrolling,
75
+ })}
76
+ style={{
77
+ width: '100%',
78
+ height: '100%',
79
+ minHeight: showPropertyList ? '160px' : '80px',
80
+ overflow: 'hidden',
81
+ position: 'absolute',
82
+ top: 0,
83
+ left: 0,
84
+ margin: 0,
85
+ padding: 0,
86
+ boxSizing: 'border-box',
87
+ }}
88
+ >
89
+ <div className="property-owner-node__header">
90
+ <div className="property-owner-node__title">{label}</div>
91
+ {isPropertyOwner && (
92
+ <div className="property-owner-node__badge">
93
+ {safeAllProperties.length} properties
94
+ </div>
95
+ )}
96
+ </div>
97
+ {showPropertyList && (
98
+ <div className="property-owner-node__properties">
99
+ <div
100
+ className={clsx('property-owner-node__properties-list', {
101
+ 'property-owner-node__properties-list--scrollable':
102
+ needsScrolling,
103
+ })}
104
+ >
105
+ {filteredProperties.map((property) => {
106
+ const propertyIsSelected = highlightedProperties.has(
107
+ property.name,
108
+ );
109
+ return (
110
+ <div
111
+ key={property.name}
112
+ className={clsx('property-owner-node__property', {
113
+ 'property-owner-node__property--selected':
114
+ propertyIsSelected,
115
+ })}
116
+ >
117
+ <div className="property-owner-node__property-name">
118
+ {property.name}
119
+ </div>
120
+ <div className="property-owner-node__property-meta">
121
+ <span className="property-owner-node__property-type">
122
+ {property.dataType ?? 'Unknown'}
123
+ </span>
124
+ <span className="property-owner-node__property-scope">
125
+ {property.propertyType ?? 'Unknown'}
126
+ </span>
127
+ </div>
128
+ </div>
129
+ );
130
+ })}
131
+ {remainingCount > 0 && (
132
+ <div className="property-owner-node__property property-owner-node__property--more">
133
+ <div className="property-owner-node__property-name">
134
+ ... and {remainingCount} more
135
+ </div>
136
+ </div>
137
+ )}
138
+ </div>
139
+ </div>
140
+ )}
141
+ </div>
142
+ <Handle type="source" position={Position.Right} style={{ right: -5 }} />
143
+ </>
144
+ );
145
+ };
@@ -22,6 +22,7 @@ export enum LINEAGE_VIEW_MODE {
22
22
  CLASS_LINEAGE = 'CLASS_LINEAGE',
23
23
  DATABASE_LINEAGE = 'DATABASE_LINEAGE',
24
24
  REPORT_LINEAGE = 'REPORT_LINEAGE',
25
+ PROPERTY_LINEAGE = 'PROPERTY_LINEAGE',
25
26
  }
26
27
 
27
28
  export class LineageState {
@@ -29,15 +30,25 @@ export class LineageState {
29
30
  selectedTab: LINEAGE_VIEW_MODE = LINEAGE_VIEW_MODE.DATABASE_LINEAGE;
30
31
  lineageData: LineageModel | undefined = undefined;
31
32
  isLineageViewerOpen = false;
33
+ selectedPropertyOwnerNode: string | undefined = undefined;
34
+ selectedProperty: string | undefined = undefined;
35
+ selectedSourcePropertiesMap: Map<string, Set<string>> | undefined = undefined;
32
36
 
33
37
  constructor(applicationStore: GenericLegendApplicationStore) {
34
38
  makeObservable(this, {
35
39
  selectedTab: observable,
36
40
  lineageData: observable,
37
41
  isLineageViewerOpen: observable,
42
+ selectedPropertyOwnerNode: observable,
43
+ selectedProperty: observable,
44
+ selectedSourcePropertiesMap: observable,
38
45
  setSelectedTab: action,
39
46
  setLineageData: action,
40
47
  setIsLineageViewerOpen: action,
48
+ setSelectedPropertyOwnerNode: action,
49
+ setSelectedProperty: action,
50
+ setSelectedSourcePropertiesMap: action,
51
+ clearPropertySelections: action,
41
52
  });
42
53
  this.applicationStore = applicationStore;
43
54
  }
@@ -53,4 +64,24 @@ export class LineageState {
53
64
  setIsLineageViewerOpen(isOpen: boolean): void {
54
65
  this.isLineageViewerOpen = isOpen;
55
66
  }
67
+
68
+ setSelectedPropertyOwnerNode(nodeId: string | undefined): void {
69
+ this.selectedPropertyOwnerNode = nodeId;
70
+ }
71
+
72
+ setSelectedProperty(propertyKey: string | undefined): void {
73
+ this.selectedProperty = propertyKey;
74
+ }
75
+
76
+ setSelectedSourcePropertiesMap(
77
+ map: Map<string, Set<string>> | undefined,
78
+ ): void {
79
+ this.selectedSourcePropertiesMap = map;
80
+ }
81
+
82
+ clearPropertySelections(): void {
83
+ this.selectedProperty = undefined;
84
+ this.selectedPropertyOwnerNode = undefined;
85
+ this.selectedSourcePropertiesMap = undefined;
86
+ }
56
87
  }
package/tsconfig.json CHANGED
@@ -267,6 +267,7 @@
267
267
  "./src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx",
268
268
  "./src/components/filter/QueryBuilderFilterPanel.tsx",
269
269
  "./src/components/lineage/LineageViewer.tsx",
270
+ "./src/components/lineage/PropertyOwnerNode.tsx",
270
271
  "./src/components/result/QueryBuilderResultPanel.tsx",
271
272
  "./src/components/result/tds/QueryBuilderTDSGridResult.tsx",
272
273
  "./src/components/result/tds/QueryBuilderTDSResultShared.tsx",