@@ -2,6 +2,7 @@ port module UnisonShare.Page.ProjectContributionChangesPage exposing (..)
22
33import Code.BranchRef as BranchRef
44import Code.Definition.Reference exposing (Reference )
5+ import Code.DefinitionSummaryTooltip as DefinitionSummaryTooltip
56import Code.FullyQualifiedName as FQN
67import Code.Hash as Hash
78import Code.Perspective as Perspective
@@ -30,14 +31,15 @@ import UI.TabList as TabList
3031import UI.Tooltip as Tooltip
3132import UnisonShare.Account as Account
3233import UnisonShare.Api as ShareApi
33- import UnisonShare.AppContext exposing (AppContext )
34+ import UnisonShare.AppContext as AppContext exposing (AppContext )
3435import UnisonShare.BranchDiff as BranchDiff exposing (BranchDiff )
3536import UnisonShare.BranchDiff.ChangeLine as ChangeLine exposing (ChangeLine )
3637import UnisonShare.BranchDiff.ChangeLineId as ChangeLineId exposing (ChangeLineId )
3738import UnisonShare.BranchDiff.DefinitionType as DefinitionType exposing (DefinitionType )
3839import UnisonShare.BranchDiff.LibDep as LibDep exposing (LibDep )
3940import UnisonShare.BranchDiff.ToggledChangeLines as ToggledChangeLines exposing (ToggledChangeLines )
4041import UnisonShare.BranchDiffState as BranchDiffState exposing (BranchDiffState )
42+ import UnisonShare.CodeBrowsingContext as CodeBrowsingContext
4143import UnisonShare.Contribution exposing (ContributionDetails )
4244import UnisonShare.Contribution.ContributionRef exposing (ContributionRef )
4345import UnisonShare.DefinitionDiff as DefinitionDiff
@@ -57,6 +59,8 @@ type alias Model =
5759 { branchDiff : BranchDiffState
5860 , toggledChangeLines : ToggledChangeLines
5961 , urlFocusedChangeLineId : Maybe ChangeLineId
62+ , oldDefinitionSummaryTooltip : DefinitionSummaryTooltip . Model
63+ , newDefinitionSummaryTooltip : DefinitionSummaryTooltip . Model
6064 }
6165
6266
@@ -71,6 +75,8 @@ init appContext projectRef contribRef changeLineId =
7175 ( { branchDiff = BranchDiffState . Loading
7276 , toggledChangeLines = ToggledChangeLines . empty
7377 , urlFocusedChangeLineId = changeLineId
78+ , oldDefinitionSummaryTooltip = DefinitionSummaryTooltip . init
79+ , newDefinitionSummaryTooltip = DefinitionSummaryTooltip . init
7480 }
7581 , fetchBranchDiff appContext projectRef contribRef 1
7682 )
@@ -88,6 +94,8 @@ type Msg
8894 | SetChangeLinePermalink ChangeLineId
8995 | ScrollTo ChangeLineId
9096 | ExpandCollapsedDiffSection ChangeLineId { index : Int }
97+ | OldDefinitionSummaryTooltipMsg DefinitionSummaryTooltip . Msg
98+ | NewDefinitionSummaryTooltipMsg DefinitionSummaryTooltip . Msg
9199 | NoOp
92100
93101
@@ -220,6 +228,46 @@ update appContext projectRef contribRef msg model =
220228 in
221229 ( { model | branchDiff = branchDiff }, Cmd . none )
222230
231+ OldDefinitionSummaryTooltipMsg tMsg ->
232+ case model. branchDiff of
233+ BranchDiffState . Computed bd ->
234+ let
235+ config =
236+ AppContext . toCodeConfig
237+ appContext
238+ ( CodeBrowsingContext . ProjectBranch projectRef bd. oldBranch. ref)
239+ ( Perspective . absoluteRootPerspective bd. oldBranch. hash)
240+
241+ ( definitionSummaryTooltip, tCmd ) =
242+ DefinitionSummaryTooltip . update config tMsg model. oldDefinitionSummaryTooltip
243+ in
244+ ( { model | oldDefinitionSummaryTooltip = definitionSummaryTooltip }
245+ , Cmd . map OldDefinitionSummaryTooltipMsg tCmd
246+ )
247+
248+ _ ->
249+ ( model, Cmd . none )
250+
251+ NewDefinitionSummaryTooltipMsg tMsg ->
252+ case model. branchDiff of
253+ BranchDiffState . Computed bd ->
254+ let
255+ config =
256+ AppContext . toCodeConfig
257+ appContext
258+ ( CodeBrowsingContext . ProjectBranch projectRef bd. newBranch. ref)
259+ ( Perspective . absoluteRootPerspective bd. newBranch. hash)
260+
261+ ( definitionSummaryTooltip, tCmd ) =
262+ DefinitionSummaryTooltip . update config tMsg model. newDefinitionSummaryTooltip
263+ in
264+ ( { model | newDefinitionSummaryTooltip = definitionSummaryTooltip }
265+ , Cmd . map NewDefinitionSummaryTooltipMsg tCmd
266+ )
267+
268+ _ ->
269+ ( model, Cmd . none )
270+
223271 NoOp ->
224272 ( model, Cmd . none )
225273
@@ -433,9 +481,16 @@ viewNamespaceLine projectRef toggledChangeLines { name, lines } =
433481 ]
434482
435483
436- viewChangedDefinitionCard : ProjectRef -> ToggledChangeLines -> BranchDiff -> Int -> ChangeLine -> DefinitionType -> Html Msg -> Html Msg
437- viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLength changeLine type_ content =
484+ viewChangedDefinitionCard : ProjectRef -> Model -> BranchDiff -> Int -> ChangeLine -> DefinitionType -> Html Msg -> Html Msg
485+ viewChangedDefinitionCard projectRef model branchDiff maxBadgeLength changeLine type_ content =
438486 let
487+ toTooltipConfig isNew =
488+ if isNew then
489+ DefinitionSummaryTooltip . tooltipConfig NewDefinitionSummaryTooltipMsg model. newDefinitionSummaryTooltip
490+
491+ else
492+ DefinitionSummaryTooltip . tooltipConfig OldDefinitionSummaryTooltipMsg model. oldDefinitionSummaryTooltip
493+
439494 toSyntaxConfig isNew =
440495 let
441496 diffBranchRef =
@@ -444,6 +499,9 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
444499
445500 else
446501 branchDiff. oldBranch
502+
503+ tooltipConfig =
504+ toTooltipConfig isNew
447505 in
448506 SyntaxConfig . empty
449507 |> SyntaxConfig . withToClick
@@ -452,9 +510,10 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
452510 diffBranchRef. ref
453511 ( Perspective . absoluteRootPerspective diffBranchRef. hash)
454512 )
513+ |> SyntaxConfig . withDependencyTooltip tooltipConfig
455514
456515 ( expanded, toggleIcon ) =
457- if ToggledChangeLines . isCollapsed toggledChangeLines changeLine then
516+ if ToggledChangeLines . isCollapsed model . toggledChangeLines changeLine then
458517 ( Nothing , Icon . expandDown )
459518
460519 else
@@ -477,21 +536,22 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
477536 case ChangeLine . source changeLine of
478537 Just source ->
479538 let
480- ( branchRef, gutterIndicator ) =
539+ ( branchRef, gutterIndicator, isNew ) =
481540 case changeLine of
482541 ChangeLine . Removed _ _ ->
483- ( branchDiff. oldBranch. ref, " -" )
542+ ( branchDiff. oldBranch. ref, " -" , False )
484543
485544 ChangeLine . Added _ _ ->
486- ( branchDiff. newBranch. ref, " +" )
545+ ( branchDiff. newBranch. ref, " +" , True )
487546
488547 _ ->
489- ( branchDiff. newBranch. ref, " " )
548+ ( branchDiff. newBranch. ref, " " , True )
490549
491550 linked =
492551 SyntaxConfig . empty
493552 |> SyntaxConfig . withToClick
494553 ( Link . projectBranchDefinition projectRef branchRef)
554+ |> SyntaxConfig . withDependencyTooltip ( toTooltipConfig isNew)
495555
496556 gutter =
497557 let
@@ -577,13 +637,13 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
577637 |> Card . view
578638
579639
580- viewChangedDefinitionsCards : ProjectRef -> ToggledChangeLines -> Int -> BranchDiff -> List (Html Msg )
581- viewChangedDefinitionsCards projectRef toggledChangeLines maxBadgeLength branchDiff =
640+ viewChangedDefinitionsCards : ProjectRef -> Model -> Int -> BranchDiff -> List (Html Msg )
641+ viewChangedDefinitionsCards projectRef model maxBadgeLength branchDiff =
582642 let
583643 view_ =
584644 viewChangedDefinitionCard
585645 projectRef
586- toggledChangeLines
646+ model
587647 branchDiff
588648 maxBadgeLength
589649
@@ -773,8 +833,8 @@ viewLibDeps maxBadgeLength deps =
773833 |> List . map ( viewLibDep maxBadgeLength)
774834
775835
776- viewBranchDiff : ProjectRef -> ToggledChangeLines -> BranchDiff -> Html Msg
777- viewBranchDiff projectRef toggledChangeLines diff =
836+ viewBranchDiff : ProjectRef -> Model -> BranchDiff -> Html Msg
837+ viewBranchDiff projectRef model diff =
778838 let
779839 summary =
780840 BranchDiff . summary diff
@@ -789,7 +849,7 @@ viewBranchDiff projectRef toggledChangeLines diff =
789849 tree =
790850 if BranchDiff . size diff > 1 then
791851 Card . card
792- [ viewContributionChangesGroup projectRef toggledChangeLines diff. lines
852+ [ viewContributionChangesGroup projectRef model . toggledChangeLines diff. lines
793853 ]
794854 |> Card . withClassName " change-tree"
795855 |> Card . asContained
@@ -806,7 +866,7 @@ viewBranchDiff projectRef toggledChangeLines diff =
806866 [ tree
807867 , div [ id " definition-changes" , class " definition-changes" ]
808868 ( viewLibDeps maxBadgeLength diff. libDeps
809- ++ viewChangedDefinitionsCards projectRef toggledChangeLines maxBadgeLength diff
869+ ++ viewChangedDefinitionsCards projectRef model maxBadgeLength diff
810870 )
811871 ]
812872 ]
@@ -912,7 +972,7 @@ view appContext projectRef contribution model =
912972 [ tabs
913973 , div
914974 [ class " project-contribution-changes-page" ]
915- [ viewBranchDiff projectRef model. toggledChangeLines diff ]
975+ [ viewBranchDiff projectRef model diff ]
916976 ]
917977
918978 BranchDiffState . Uncomputable error ->
0 commit comments