Skip to content

Commit 81c359e

Browse files
committed
modify styling
1 parent d66e943 commit 81c359e

File tree

11 files changed

+421
-33
lines changed

11 files changed

+421
-33
lines changed

web/common/src/components/Lineage/LineageControlButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function LineageControlButton({
2121
side="left"
2222
sideOffset={8}
2323
delayDuration={0}
24-
className="px-2 py-1 text-xs rounded-sm font-semibold"
24+
className="px-2 py-1 text-xs rounded-sm font-semibold bg-lineage-control-button-tooltip-background text-lineage-control-button-tooltip-foreground"
2525
trigger={
2626
<div>
2727
<ControlButton

web/common/src/components/Lineage/help.test.ts

Lines changed: 290 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
getOnlySelectedNodes,
66
getTransformedNodes,
77
getTransformedModelEdges,
8+
getTransformedModelEdgesSourceTargets,
9+
getTransformedModelEdgesTargetSources,
810
createNode,
911
calculateNodeBaseHeight,
1012
calculateNodeDetailsHeight,
@@ -92,6 +94,7 @@ describe('Lineage Help Functions', () => {
9294

9395
const transformNode = (
9496
nodeId: NodeId,
97+
adjacencyListKey: string,
9598
data: { name: string; type: string },
9699
) =>
97100
({
@@ -125,7 +128,11 @@ describe('Lineage Help Functions', () => {
125128
test('should handle empty adjacency list', () => {
126129
const adjacencyListKeys: string[] = []
127130
const lineageDetails: LineageDetails<string, { name: string }> = {}
128-
const transformNode = (nodeId: NodeId, data: { name: string }) =>
131+
const transformNode = (
132+
nodeId: NodeId,
133+
adjacencyListKey: string,
134+
data: { name: string },
135+
) =>
129136
({
130137
id: nodeId,
131138
position: { x: 0, y: 0 },
@@ -283,6 +290,288 @@ describe('Lineage Help Functions', () => {
283290
})
284291
})
285292

293+
describe('getTransformedModelEdgesSourceTargets', () => {
294+
test('should transform edges from source to targets using the provided transform function', () => {
295+
const adjacencyListKeys = ['model1', 'model2', 'model3']
296+
const lineageAdjacencyList: LineageAdjacencyList = {
297+
model1: ['model2', 'model3'],
298+
model2: ['model3'],
299+
model3: [],
300+
}
301+
302+
const transformEdge = (
303+
type: string,
304+
edgeId: EdgeId,
305+
sourceId: NodeId,
306+
targetId: NodeId,
307+
) => ({
308+
id: edgeId,
309+
source: sourceId,
310+
target: targetId,
311+
type,
312+
zIndex: 1,
313+
})
314+
315+
const result = getTransformedModelEdgesSourceTargets(
316+
adjacencyListKeys,
317+
lineageAdjacencyList,
318+
transformEdge,
319+
)
320+
321+
expect(result).toHaveLength(3)
322+
323+
const model1Id = toNodeID('model1')
324+
const model2Id = toNodeID('model2')
325+
const model3Id = toNodeID('model3')
326+
327+
expect(result[0]).toEqual({
328+
id: toEdgeID('model1', 'model2'),
329+
source: model1Id,
330+
target: model2Id,
331+
type: 'edge',
332+
zIndex: 1,
333+
})
334+
expect(result[1]).toEqual({
335+
id: toEdgeID('model1', 'model3'),
336+
source: model1Id,
337+
target: model3Id,
338+
type: 'edge',
339+
zIndex: 1,
340+
})
341+
expect(result[2]).toEqual({
342+
id: toEdgeID('model2', 'model3'),
343+
source: model2Id,
344+
target: model3Id,
345+
type: 'edge',
346+
zIndex: 1,
347+
})
348+
})
349+
350+
test('should skip edges where target is not in adjacency list', () => {
351+
const adjacencyListKeys = ['model1']
352+
const lineageAdjacencyList: LineageAdjacencyList = {
353+
model1: ['model2'], // model2 is not in the adjacency list
354+
}
355+
356+
const transformEdge = (
357+
type: string,
358+
edgeId: EdgeId,
359+
sourceId: NodeId,
360+
targetId: NodeId,
361+
) => ({
362+
id: edgeId,
363+
source: sourceId,
364+
target: targetId,
365+
type,
366+
zIndex: 1,
367+
})
368+
369+
const result = getTransformedModelEdgesSourceTargets(
370+
adjacencyListKeys,
371+
lineageAdjacencyList,
372+
transformEdge,
373+
)
374+
375+
expect(result).toHaveLength(0)
376+
})
377+
378+
test('should handle empty adjacency list', () => {
379+
const adjacencyListKeys: string[] = []
380+
const lineageAdjacencyList: LineageAdjacencyList = {}
381+
382+
const transformEdge = (
383+
type: string,
384+
edgeId: EdgeId,
385+
sourceId: NodeId,
386+
targetId: NodeId,
387+
) => ({
388+
id: edgeId,
389+
source: sourceId,
390+
target: targetId,
391+
type,
392+
zIndex: 1,
393+
})
394+
395+
const result = getTransformedModelEdgesSourceTargets(
396+
adjacencyListKeys,
397+
lineageAdjacencyList,
398+
transformEdge,
399+
)
400+
401+
expect(result).toHaveLength(0)
402+
})
403+
404+
test('should handle nodes with no targets', () => {
405+
const adjacencyListKeys = ['model1', 'model2']
406+
const lineageAdjacencyList = {
407+
model1: [],
408+
model2: null,
409+
} as unknown as LineageAdjacencyList
410+
411+
const transformEdge = (
412+
type: string,
413+
edgeId: EdgeId,
414+
sourceId: NodeId,
415+
targetId: NodeId,
416+
) => ({
417+
id: edgeId,
418+
source: sourceId,
419+
target: targetId,
420+
type,
421+
zIndex: 1,
422+
})
423+
424+
const result = getTransformedModelEdgesSourceTargets(
425+
adjacencyListKeys,
426+
lineageAdjacencyList,
427+
transformEdge,
428+
)
429+
430+
expect(result).toHaveLength(0)
431+
})
432+
})
433+
434+
describe('getTransformedModelEdgesTargetSources', () => {
435+
test('should transform edges from target to sources using the provided transform function', () => {
436+
const adjacencyListKeys = ['model1', 'model2', 'model3']
437+
const lineageAdjacencyList: LineageAdjacencyList = {
438+
model1: [],
439+
model2: ['model1'],
440+
model3: ['model1', 'model2'],
441+
}
442+
443+
const transformEdge = (
444+
type: string,
445+
edgeId: EdgeId,
446+
sourceId: NodeId,
447+
targetId: NodeId,
448+
) => ({
449+
id: edgeId,
450+
source: sourceId,
451+
target: targetId,
452+
type,
453+
zIndex: 1,
454+
})
455+
456+
const result = getTransformedModelEdgesTargetSources(
457+
adjacencyListKeys,
458+
lineageAdjacencyList,
459+
transformEdge,
460+
)
461+
462+
expect(result).toHaveLength(3)
463+
464+
const model1Id = toNodeID('model1')
465+
const model2Id = toNodeID('model2')
466+
const model3Id = toNodeID('model3')
467+
468+
expect(result[0]).toEqual({
469+
id: toEdgeID('model1', 'model2'),
470+
source: model1Id,
471+
target: model2Id,
472+
type: 'edge',
473+
zIndex: 1,
474+
})
475+
expect(result[1]).toEqual({
476+
id: toEdgeID('model1', 'model3'),
477+
source: model1Id,
478+
target: model3Id,
479+
type: 'edge',
480+
zIndex: 1,
481+
})
482+
expect(result[2]).toEqual({
483+
id: toEdgeID('model2', 'model3'),
484+
source: model2Id,
485+
target: model3Id,
486+
type: 'edge',
487+
zIndex: 1,
488+
})
489+
})
490+
491+
test('should skip edges where source is not in adjacency list', () => {
492+
const adjacencyListKeys = ['model2']
493+
const lineageAdjacencyList: LineageAdjacencyList = {
494+
model2: ['model1'], // model1 is not in the adjacency list
495+
}
496+
497+
const transformEdge = (
498+
type: string,
499+
edgeId: EdgeId,
500+
sourceId: NodeId,
501+
targetId: NodeId,
502+
) => ({
503+
id: edgeId,
504+
source: sourceId,
505+
target: targetId,
506+
type,
507+
zIndex: 1,
508+
})
509+
510+
const result = getTransformedModelEdgesTargetSources(
511+
adjacencyListKeys,
512+
lineageAdjacencyList,
513+
transformEdge,
514+
)
515+
516+
expect(result).toHaveLength(0)
517+
})
518+
519+
test('should handle empty adjacency list', () => {
520+
const adjacencyListKeys: string[] = []
521+
const lineageAdjacencyList: LineageAdjacencyList = {}
522+
523+
const transformEdge = (
524+
type: string,
525+
edgeId: EdgeId,
526+
sourceId: NodeId,
527+
targetId: NodeId,
528+
) => ({
529+
id: edgeId,
530+
source: sourceId,
531+
target: targetId,
532+
type,
533+
zIndex: 1,
534+
})
535+
536+
const result = getTransformedModelEdgesTargetSources(
537+
adjacencyListKeys,
538+
lineageAdjacencyList,
539+
transformEdge,
540+
)
541+
542+
expect(result).toHaveLength(0)
543+
})
544+
545+
test('should handle nodes with no sources', () => {
546+
const adjacencyListKeys = ['model1', 'model2']
547+
const lineageAdjacencyList = {
548+
model1: [],
549+
model2: null,
550+
} as unknown as LineageAdjacencyList
551+
552+
const transformEdge = (
553+
type: string,
554+
edgeId: EdgeId,
555+
sourceId: NodeId,
556+
targetId: NodeId,
557+
) => ({
558+
id: edgeId,
559+
source: sourceId,
560+
target: targetId,
561+
type,
562+
zIndex: 1,
563+
})
564+
565+
const result = getTransformedModelEdgesTargetSources(
566+
adjacencyListKeys,
567+
lineageAdjacencyList,
568+
transformEdge,
569+
)
570+
571+
expect(result).toHaveLength(0)
572+
})
573+
})
574+
286575
describe('createNode', () => {
287576
test('should create a node with provided data', () => {
288577
const nodeId = 'test-node' as NodeId

0 commit comments

Comments
 (0)