Skip to content

Commit 5483bb6

Browse files
committed
make provenance overwrites origin-aware
1 parent b26ce43 commit 5483bb6

19 files changed

Lines changed: 846 additions & 418 deletions

src/Components/src/Page/ProvenanceGrouping/ConnectorMeasurement.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ module ConnectorHandles =
328328
ParentGroupId = Some groupId
329329
}
330330

331-
let propertyHeader side header : ConnectionHandleRef = {
331+
let propertyHeader side property : ConnectionHandleRef = {
332332
Kind = ConnectionHandleKind.PropertyHeader
333333
Side = side
334-
Id = DragDrop.propertyHeaderIdentity header
334+
Id = DragDrop.propertyKeyIdentity property
335335
ParentGroupId = None
336336
}
337337

src/Components/src/Page/ProvenanceGrouping/ConnectorPaths.fs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,15 @@ module ConnectorPaths =
278278
overlayState
279279
=
280280
railProjection.Headers
281-
|> List.filter (fun header -> not (ConnectorOverlayState.isPropertyExpanded layerId side header overlayState))
282-
|> List.collect (fun header ->
281+
|> List.filter (fun property ->
282+
not (ConnectorOverlayState.isPropertyExpanded layerId side property overlayState)
283+
)
284+
|> List.collect (fun property ->
283285
let color =
284286
railProjection.ColorByHeader
285-
|> Map.tryFind header
287+
|> Map.tryFind property
286288
|> Option.bind id
287-
|> Option.orElseWith (fun () -> colorByHeader |> Map.tryFind header |> Option.bind id)
289+
|> Option.orElseWith (fun () -> colorByHeader |> Map.tryFind property.Header |> Option.bind id)
288290

289291
groups
290292
|> List.collect (
@@ -293,13 +295,13 @@ module ConnectorPaths =
293295
inputGroups
294296
outputGroups
295297
connections
296-
(fun propertyValue -> propertyValue.Header = header)
298+
(ProvenancePropertyValue.belongsTo property)
297299
side
298300
overlayState
299301
)
300302
|> List.map (fun target ->
301303
spec
302-
$"property:{side}:{DragDrop.propertyHeaderIdentity header}:{target.KeySuffix}"
304+
$"property:{side}:{DragDrop.propertyKeyIdentity property}:{target.KeySuffix}"
303305
"provenance-property-connection"
304306
"swt:text-secondary swt:pointer-events-none"
305307
1.75
@@ -308,13 +310,13 @@ module ConnectorPaths =
308310
None
309311
color
310312
true
311-
(ConnectorHandles.propertyHeader side header)
313+
(ConnectorHandles.propertyHeader side property)
312314
target.Handle
313315
)
314316
)
315317

316-
let private propertyValueMatches header value unit' (propertyValue: ProvenancePropertyValue) =
317-
propertyValue.Header = header
318+
let private propertyValueMatches property value unit' (propertyValue: ProvenancePropertyValue) =
319+
ProvenancePropertyValue.belongsTo property propertyValue
318320
&& propertyValue.Value = value
319321
&& propertyValue.Unit = unit'
320322

@@ -331,16 +333,16 @@ module ConnectorPaths =
331333
overlayState
332334
=
333335
railProjection.Headers
334-
|> List.filter (fun header -> ConnectorOverlayState.isPropertyExpanded layerId side header overlayState)
335-
|> List.collect (fun header ->
336+
|> List.filter (fun property -> ConnectorOverlayState.isPropertyExpanded layerId side property overlayState)
337+
|> List.collect (fun property ->
336338
let color =
337339
railProjection.ColorByHeader
338-
|> Map.tryFind header
340+
|> Map.tryFind property
339341
|> Option.bind id
340-
|> Option.orElseWith (fun () -> colorByHeader |> Map.tryFind header |> Option.bind id)
342+
|> Option.orElseWith (fun () -> colorByHeader |> Map.tryFind property.Header |> Option.bind id)
341343

342344
railProjection.ValuesByHeader
343-
|> Map.tryFind header
345+
|> Map.tryFind property
344346
|> Option.defaultValue []
345347
|> List.collect (fun propertyValue ->
346348
groups
@@ -350,13 +352,13 @@ module ConnectorPaths =
350352
inputGroups
351353
outputGroups
352354
connections
353-
(propertyValueMatches header propertyValue.Value propertyValue.Unit)
355+
(propertyValueMatches property propertyValue.Value propertyValue.Unit)
354356
side
355357
overlayState
356358
)
357359
|> List.map (fun target ->
358360
spec
359-
$"value:{side}:{DragDrop.propertyHeaderIdentity header}:{Formatting.formatValue propertyValue.Value propertyValue.Unit}:{target.KeySuffix}"
361+
$"value:{side}:{DragDrop.propertyKeyIdentity property}:{Formatting.formatValue propertyValue.Value propertyValue.Unit}:{target.KeySuffix}"
360362
"provenance-value-connection"
361363
"swt:text-accent swt:pointer-events-none"
362364
2.0

src/Components/src/Page/ProvenanceGrouping/ConnectorTypes.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ module ConnectorOverlayState =
8484
/// exact cards open.
8585
let followsExpandedNeighbors state = state.ExpandedGroups.Count = 1
8686

87-
let isPropertyExpanded layerId side header state =
88-
state.ExpandedProperties.Contains(layerId, side, { Header = header })
87+
let isPropertyExpanded layerId side property state =
88+
state.ExpandedProperties.Contains(layerId, side, property)
8989

9090
type ConnectorMeasureContext = {
9191
Container: HTMLElement

src/Components/src/Page/ProvenanceGrouping/Controls.fs

Lines changed: 69 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,9 @@ type Controls =
588588

589589
[<ReactComponent>]
590590
static member private PropertySwapButton
591-
(
592-
side: ProvenanceSide,
593-
header: ProvenancePropertyHeader,
594-
onSwitch: ProvenancePropertyHeader -> unit,
595-
?debug: bool
596-
) =
591+
(side: ProvenanceSide, property: ProvenancePropertyKey, onSwitch: ProvenancePropertyKey -> unit, ?debug: bool)
592+
=
593+
let header = property.Header
597594
let sideName = SideLabels.sideName side
598595

599596
Html.button [
@@ -603,8 +600,8 @@ type Controls =
603600
prop.ariaLabel $"Move {header.Category.Name} from {sideName}"
604601
if defaultArg debug false then
605602
prop.testId $"provenance-property-drag-{side}-{header.Category.Name}"
606-
prop.onPointerUp (fun _ -> onSwitch header)
607-
prop.onClick (fun _ -> onSwitch header)
603+
prop.onPointerUp (fun _ -> onSwitch property)
604+
prop.onClick (fun _ -> onSwitch property)
608605
prop.children [
609606
Html.i [
610607
prop.className "swt:iconify swt:fluent--arrow-swap-20-regular swt:size-4"
@@ -617,16 +614,16 @@ type Controls =
617614
(
618615
side: ProvenanceSide,
619616
activeSourceId: ProvenanceSourceId,
620-
header: ProvenancePropertyHeader,
617+
property: ProvenancePropertyKey,
621618
propertyValues: ProvenancePropertyValue list,
622619
active: GroupingAssignment list,
623620
canSwitch: bool,
624621
expanded: bool,
625-
onToggleSide: ProvenancePropertyHeader -> unit,
626-
onToggleBoth: ProvenancePropertyHeader -> unit,
627-
onSwitch: ProvenancePropertyHeader -> unit,
628-
onToggleExpanded: ProvenancePropertyHeader -> unit,
629-
onAddValue: ProvenancePropertyHeader -> ProvenanceValue -> ProvenanceTerm option -> unit,
622+
onToggleSide: ProvenancePropertyKey -> unit,
623+
onToggleBoth: ProvenancePropertyKey -> unit,
624+
onSwitch: ProvenancePropertyKey -> unit,
625+
onToggleExpanded: ProvenancePropertyKey -> unit,
626+
onAddValue: ProvenancePropertyKey -> ProvenanceValue -> ProvenanceTerm option -> unit,
630627
setIsValueChipDragging: bool -> unit,
631628
?debug: bool,
632629
?key: string,
@@ -640,10 +637,12 @@ type Controls =
640637
?onApplyValueToSelection: ProvenancePropertyValue -> unit,
641638
?applySelectionLabel: string
642639
) =
640+
let header = property.Header
641+
643642
let draggable =
644643
DndKit.useDraggable (
645644
{|
646-
id = DragDrop.propertyDragId side header
645+
id = DragDrop.propertyDragId side property
647646
data = {| label = header.Category.Name |}
648647
|}
649648
)
@@ -658,11 +657,11 @@ type Controls =
658657

659658
let sideSelected =
660659
active
661-
|> List.exists (fun assignment -> assignment.Key.Header = header && assignment.Scope = sideScope)
660+
|> List.exists (fun assignment -> assignment.Key = property && assignment.Scope = sideScope)
662661

663662
let bothSelected =
664663
active
665-
|> List.exists (fun assignment -> assignment.Key.Header = header && assignment.Scope = GroupingScope.Both)
664+
|> List.exists (fun assignment -> assignment.Key = property && assignment.Scope = GroupingScope.Both)
666665

667666
let sideName = SideLabels.sideName side
668667

@@ -675,7 +674,7 @@ type Controls =
675674
{
676675
Kind = ConnectionHandleKind.PropertyHeader
677676
Side = side
678-
Id = DragDrop.propertyHeaderIdentity header
677+
Id = DragDrop.propertyKeyIdentity property
679678
ParentGroupId = None
680679
},
681680
(match side with
@@ -725,7 +724,8 @@ type Controls =
725724
prop.custom ("data-tutorial-group-by", $"{side}:{header.Category.Name}")
726725
if defaultArg debug false then
727726
prop.testId $"provenance-property-{side}-{header.Category.Name}"
728-
prop.onClick (fun _ -> onToggleSide header)
727+
prop.custom ("data-provenance-property-origin", property.OriginSource.Id)
728+
prop.onClick (fun _ -> onToggleSide property)
729729
prop.children [
730730
propertyAnchor
731731
match color with
@@ -817,7 +817,7 @@ type Controls =
817817
else
818818
$"Expand {header.Category.Name} values"
819819
)
820-
prop.onClick (fun _ -> onToggleExpanded header)
820+
prop.onClick (fun _ -> onToggleExpanded property)
821821
prop.children [
822822
Html.i [
823823
prop.className [
@@ -862,7 +862,7 @@ type Controls =
862862
if defaultArg debug false then
863863
prop.testId $"provenance-property-both-{side}-{header.Category.Name}"
864864
prop.ariaLabel $"Group {header.Category.Name} on both sides"
865-
prop.onClick (fun _ -> onToggleBoth header)
865+
prop.onClick (fun _ -> onToggleBoth property)
866866
prop.children [
867867
Html.i [
868868
prop.className "swt:iconify swt:fluent--link-multiple-20-regular swt:size-4"
@@ -872,7 +872,7 @@ type Controls =
872872

873873
let swapButton =
874874
if canSwitch then
875-
Controls.PropertySwapButton(side, header, onSwitch, ?debug = debug)
875+
Controls.PropertySwapButton(side, property, onSwitch, ?debug = debug)
876876
else
877877
Html.button [
878878
prop.type'.button
@@ -999,7 +999,7 @@ type Controls =
999999
)
10001000
Controls.AddValuePopover(
10011001
Some header,
1002-
(fun addedHeader value unit -> onAddValue addedHeader value unit),
1002+
(fun _ value unit -> onAddValue property value unit),
10031003
label = "Add value",
10041004
?debug = debug
10051005
)
@@ -1016,25 +1016,25 @@ type Controls =
10161016
static member PropertyRail
10171017
(
10181018
side: ProvenanceSide,
1019-
activeSourceId: ProvenanceSourceId,
1020-
headers: ProvenancePropertyHeader list,
1019+
activeSource: ProvenanceSourceRef,
1020+
headers: ProvenancePropertyKey list,
10211021
active: GroupingAssignment list,
1022-
valuesForHeader: ProvenancePropertyHeader -> ProvenancePropertyValue list,
1023-
isExpanded: ProvenancePropertyHeader -> bool,
1024-
onToggleSide: ProvenancePropertyHeader -> unit,
1025-
onToggleBoth: ProvenancePropertyHeader -> unit,
1026-
onSwitch: ProvenancePropertyHeader -> unit,
1027-
onToggleExpanded: ProvenancePropertyHeader -> unit,
1028-
onAddValue: ProvenancePropertyHeader -> ProvenanceValue -> ProvenanceTerm option -> unit,
1029-
canSwitch: ProvenancePropertyHeader -> bool,
1022+
valuesForHeader: ProvenancePropertyKey -> ProvenancePropertyValue list,
1023+
isExpanded: ProvenancePropertyKey -> bool,
1024+
onToggleSide: ProvenancePropertyKey -> unit,
1025+
onToggleBoth: ProvenancePropertyKey -> unit,
1026+
onSwitch: ProvenancePropertyKey -> unit,
1027+
onToggleExpanded: ProvenancePropertyKey -> unit,
1028+
onAddValue: ProvenancePropertyKey -> ProvenanceValue -> ProvenanceTerm option -> unit,
1029+
canSwitch: ProvenancePropertyKey -> bool,
10301030
isDropRejected: bool,
10311031
isDropAvailable: bool,
10321032
setIsValueChipDragging: bool -> unit,
1033-
statsForHeader: ProvenancePropertyHeader -> PropertyStats option,
1034-
badgeForHeader: ProvenancePropertyHeader -> PropertyCountBadge option,
1035-
colorForHeader: ProvenancePropertyHeader -> ProvenanceColor option,
1036-
originsForHeader: ProvenancePropertyHeader -> Set<ProvenancePropertyOrigin> option,
1037-
onSetColor: ProvenancePropertyHeader -> ProvenanceColor option -> unit,
1033+
statsForHeader: ProvenancePropertyKey -> PropertyStats option,
1034+
badgeForHeader: ProvenancePropertyKey -> PropertyCountBadge option,
1035+
colorForHeader: ProvenancePropertyKey -> ProvenanceColor option,
1036+
originsForHeader: ProvenancePropertyKey -> Set<ProvenancePropertyOrigin> option,
1037+
onSetColor: ProvenancePropertyKey -> ProvenanceColor option -> unit,
10381038
sourceInfoForValue: ProvenancePropertyValue -> PropertyValueSourceInfo option,
10391039
?sideId: ProvenanceLayerSideId,
10401040
?isUnassignedValue: ProvenancePropertyValue -> bool,
@@ -1056,7 +1056,7 @@ type Controls =
10561056
let collapseThreshold = 6
10571057

10581058
let isPinned header =
1059-
active |> List.exists (fun assignment -> assignment.Key.Header = header)
1059+
active |> List.exists (fun assignment -> assignment.Key = header)
10601060
|| isExpanded header
10611061

10621062
let visibleHeaders =
@@ -1116,7 +1116,20 @@ type Controls =
11161116
Html.div [
11171117
prop.className "swt:w-fit"
11181118
prop.children [
1119-
Controls.AddValuePopover(None, onAddValue, label = "Add annotation", ?debug = debug)
1119+
Controls.AddValuePopover(
1120+
None,
1121+
(fun header value unit ->
1122+
onAddValue
1123+
{
1124+
Header = header
1125+
OriginSource = activeSource
1126+
}
1127+
value
1128+
unit
1129+
),
1130+
label = "Add annotation",
1131+
?debug = debug
1132+
)
11201133
]
11211134
]
11221135
else
@@ -1133,7 +1146,7 @@ type Controls =
11331146
for header in visibleHeaders do
11341147
Controls.PropertyRailItem(
11351148
side,
1136-
activeSourceId,
1149+
activeSource.Id,
11371150
header,
11381151
valuesForHeader header,
11391152
active,
@@ -1155,7 +1168,7 @@ type Controls =
11551168
?onApplyValueToSelection = onApplyValueToSelection,
11561169
?applySelectionLabel = applySelectionLabel,
11571170
debug = defaultArg debug false,
1158-
key = DragDrop.propertyHeaderIdentity header
1171+
key = DragDrop.propertyKeyIdentity header
11591172
)
11601173

11611174
if hiddenHeaderCount > 0 || showAllHeaders && headers.Length > collapseThreshold then
@@ -1184,7 +1197,20 @@ type Controls =
11841197
"swt:self-end"
11851198
]
11861199
prop.children [
1187-
Controls.AddValuePopover(None, onAddValue, label = "Add annotation", ?debug = debug)
1200+
Controls.AddValuePopover(
1201+
None,
1202+
(fun header value unit ->
1203+
onAddValue
1204+
{
1205+
Header = header
1206+
OriginSource = activeSource
1207+
}
1208+
value
1209+
unit
1210+
),
1211+
label = "Add annotation",
1212+
?debug = debug
1213+
)
11881214
]
11891215
]
11901216
]

0 commit comments

Comments
 (0)