Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elm-git.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"git-dependencies": {
"direct": {
"https://github.com/unisonweb/ui-core": "9518fe75925e2a2d3828a4a5c2415ed0eac5d661"
"https://github.com/unisonweb/ui-core": "58d63fe0de338b9355a37262ccc8ed9fb486b806"
},
"indirect": {}
}
Expand Down
13 changes: 9 additions & 4 deletions src/UnisonShare/DefinitionDiffCard.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module UnisonShare.DefinitionDiffCard exposing (..)

import Code.Hash as Hash
import Code.Syntax.SyntaxConfig exposing (SyntaxConfig)
import Code.Syntax.SyntaxConfig as SyntaxConfig exposing (SyntaxConfig)
import Code.Syntax.SyntaxSegment as SyntaxSegment
import Html exposing (Html, code, div, header, pre, span, text)
import Html.Attributes exposing (class, style)
Expand Down Expand Up @@ -36,7 +36,7 @@ viewDiffSegment : SyntaxConfig msg -> DiffSegment -> List (Html msg)
viewDiffSegment syntaxConfig segment =
let
viewSegment =
SyntaxSegment.view syntaxConfig
SyntaxSegment.view (SyntaxConfig.withoutDependencyTooltip syntaxConfig)

viewSegments_ className =
viewSegments syntaxConfig className
Expand All @@ -61,7 +61,10 @@ viewDiffSegment syntaxConfig segment =
]
)
|> Tooltip.view
(span [ class "diff-segment annotation-change" ] [ viewSegment change.segment ])
(span [ class "diff-segment annotation-change" ]
[ viewSegment change.segment
]
)
]

SegmentChange { from, to } ->
Expand All @@ -72,7 +75,9 @@ viewDiffSegment syntaxConfig segment =
]
)
|> Tooltip.view
(span [ class "diff-segment segment-change" ] [ viewSegment to ])
(span [ class "diff-segment segment-change" ]
[ viewSegment to ]
)
]


Expand Down
92 changes: 76 additions & 16 deletions src/UnisonShare/Page/ProjectContributionChangesPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ port module UnisonShare.Page.ProjectContributionChangesPage exposing (..)

import Code.BranchRef as BranchRef
import Code.Definition.Reference exposing (Reference)
import Code.DefinitionSummaryTooltip as DefinitionSummaryTooltip
import Code.FullyQualifiedName as FQN
import Code.Hash as Hash
import Code.Perspective as Perspective
Expand Down Expand Up @@ -30,14 +31,15 @@ import UI.TabList as TabList
import UI.Tooltip as Tooltip
import UnisonShare.Account as Account
import UnisonShare.Api as ShareApi
import UnisonShare.AppContext exposing (AppContext)
import UnisonShare.AppContext as AppContext exposing (AppContext)
import UnisonShare.BranchDiff as BranchDiff exposing (BranchDiff)
import UnisonShare.BranchDiff.ChangeLine as ChangeLine exposing (ChangeLine)
import UnisonShare.BranchDiff.ChangeLineId as ChangeLineId exposing (ChangeLineId)
import UnisonShare.BranchDiff.DefinitionType as DefinitionType exposing (DefinitionType)
import UnisonShare.BranchDiff.LibDep as LibDep exposing (LibDep)
import UnisonShare.BranchDiff.ToggledChangeLines as ToggledChangeLines exposing (ToggledChangeLines)
import UnisonShare.BranchDiffState as BranchDiffState exposing (BranchDiffState)
import UnisonShare.CodeBrowsingContext as CodeBrowsingContext
import UnisonShare.Contribution exposing (ContributionDetails)
import UnisonShare.Contribution.ContributionRef exposing (ContributionRef)
import UnisonShare.DefinitionDiff as DefinitionDiff
Expand All @@ -57,6 +59,8 @@ type alias Model =
{ branchDiff : BranchDiffState
, toggledChangeLines : ToggledChangeLines
, urlFocusedChangeLineId : Maybe ChangeLineId
, oldDefinitionSummaryTooltip : DefinitionSummaryTooltip.Model
, newDefinitionSummaryTooltip : DefinitionSummaryTooltip.Model
}


Expand All @@ -71,6 +75,8 @@ init appContext projectRef contribRef changeLineId =
( { branchDiff = BranchDiffState.Loading
, toggledChangeLines = ToggledChangeLines.empty
, urlFocusedChangeLineId = changeLineId
, oldDefinitionSummaryTooltip = DefinitionSummaryTooltip.init
, newDefinitionSummaryTooltip = DefinitionSummaryTooltip.init
}
, fetchBranchDiff appContext projectRef contribRef 1
)
Expand All @@ -88,6 +94,8 @@ type Msg
| SetChangeLinePermalink ChangeLineId
| ScrollTo ChangeLineId
| ExpandCollapsedDiffSection ChangeLineId { index : Int }
| OldDefinitionSummaryTooltipMsg DefinitionSummaryTooltip.Msg
| NewDefinitionSummaryTooltipMsg DefinitionSummaryTooltip.Msg
| NoOp


Expand Down Expand Up @@ -220,6 +228,46 @@ update appContext projectRef contribRef msg model =
in
( { model | branchDiff = branchDiff }, Cmd.none )

OldDefinitionSummaryTooltipMsg tMsg ->
case model.branchDiff of
BranchDiffState.Computed bd ->
let
config =
AppContext.toCodeConfig
appContext
(CodeBrowsingContext.ProjectBranch projectRef bd.oldBranch.ref)
(Perspective.absoluteRootPerspective bd.oldBranch.hash)

( definitionSummaryTooltip, tCmd ) =
DefinitionSummaryTooltip.update config tMsg model.oldDefinitionSummaryTooltip
in
( { model | oldDefinitionSummaryTooltip = definitionSummaryTooltip }
, Cmd.map OldDefinitionSummaryTooltipMsg tCmd
)

_ ->
( model, Cmd.none )

NewDefinitionSummaryTooltipMsg tMsg ->
case model.branchDiff of
BranchDiffState.Computed bd ->
let
config =
AppContext.toCodeConfig
appContext
(CodeBrowsingContext.ProjectBranch projectRef bd.newBranch.ref)
(Perspective.absoluteRootPerspective bd.newBranch.hash)

( definitionSummaryTooltip, tCmd ) =
DefinitionSummaryTooltip.update config tMsg model.newDefinitionSummaryTooltip
in
( { model | newDefinitionSummaryTooltip = definitionSummaryTooltip }
, Cmd.map NewDefinitionSummaryTooltipMsg tCmd
)

_ ->
( model, Cmd.none )

NoOp ->
( model, Cmd.none )

Expand Down Expand Up @@ -433,9 +481,16 @@ viewNamespaceLine projectRef toggledChangeLines { name, lines } =
]


viewChangedDefinitionCard : ProjectRef -> ToggledChangeLines -> BranchDiff -> Int -> ChangeLine -> DefinitionType -> Html Msg -> Html Msg
viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLength changeLine type_ content =
viewChangedDefinitionCard : ProjectRef -> Model -> BranchDiff -> Int -> ChangeLine -> DefinitionType -> Html Msg -> Html Msg
viewChangedDefinitionCard projectRef model branchDiff maxBadgeLength changeLine type_ content =
let
toTooltipConfig isNew =
if isNew then
DefinitionSummaryTooltip.tooltipConfig NewDefinitionSummaryTooltipMsg model.newDefinitionSummaryTooltip

else
DefinitionSummaryTooltip.tooltipConfig OldDefinitionSummaryTooltipMsg model.oldDefinitionSummaryTooltip

toSyntaxConfig isNew =
let
diffBranchRef =
Expand All @@ -444,6 +499,9 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt

else
branchDiff.oldBranch

tooltipConfig =
toTooltipConfig isNew
in
SyntaxConfig.empty
|> SyntaxConfig.withToClick
Expand All @@ -452,9 +510,10 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
diffBranchRef.ref
(Perspective.absoluteRootPerspective diffBranchRef.hash)
)
|> SyntaxConfig.withDependencyTooltip tooltipConfig

( expanded, toggleIcon ) =
if ToggledChangeLines.isCollapsed toggledChangeLines changeLine then
if ToggledChangeLines.isCollapsed model.toggledChangeLines changeLine then
( Nothing, Icon.expandDown )

else
Expand All @@ -477,21 +536,22 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
case ChangeLine.source changeLine of
Just source ->
let
( branchRef, gutterIndicator ) =
( branchRef, gutterIndicator, isNew ) =
case changeLine of
ChangeLine.Removed _ _ ->
( branchDiff.oldBranch.ref, "-" )
( branchDiff.oldBranch.ref, "-", False )

ChangeLine.Added _ _ ->
( branchDiff.newBranch.ref, "+" )
( branchDiff.newBranch.ref, "+", True )

_ ->
( branchDiff.newBranch.ref, "" )
( branchDiff.newBranch.ref, "", True )

linked =
SyntaxConfig.empty
|> SyntaxConfig.withToClick
(Link.projectBranchDefinition projectRef branchRef)
|> SyntaxConfig.withDependencyTooltip (toTooltipConfig isNew)

gutter =
let
Expand Down Expand Up @@ -577,13 +637,13 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
|> Card.view


viewChangedDefinitionsCards : ProjectRef -> ToggledChangeLines -> Int -> BranchDiff -> List (Html Msg)
viewChangedDefinitionsCards projectRef toggledChangeLines maxBadgeLength branchDiff =
viewChangedDefinitionsCards : ProjectRef -> Model -> Int -> BranchDiff -> List (Html Msg)
viewChangedDefinitionsCards projectRef model maxBadgeLength branchDiff =
let
view_ =
viewChangedDefinitionCard
projectRef
toggledChangeLines
model
branchDiff
maxBadgeLength

Expand Down Expand Up @@ -773,8 +833,8 @@ viewLibDeps maxBadgeLength deps =
|> List.map (viewLibDep maxBadgeLength)


viewBranchDiff : ProjectRef -> ToggledChangeLines -> BranchDiff -> Html Msg
viewBranchDiff projectRef toggledChangeLines diff =
viewBranchDiff : ProjectRef -> Model -> BranchDiff -> Html Msg
viewBranchDiff projectRef model diff =
let
summary =
BranchDiff.summary diff
Expand All @@ -789,7 +849,7 @@ viewBranchDiff projectRef toggledChangeLines diff =
tree =
if BranchDiff.size diff > 1 then
Card.card
[ viewContributionChangesGroup projectRef toggledChangeLines diff.lines
[ viewContributionChangesGroup projectRef model.toggledChangeLines diff.lines
]
|> Card.withClassName "change-tree"
|> Card.asContained
Expand All @@ -806,7 +866,7 @@ viewBranchDiff projectRef toggledChangeLines diff =
[ tree
, div [ id "definition-changes", class "definition-changes" ]
(viewLibDeps maxBadgeLength diff.libDeps
++ viewChangedDefinitionsCards projectRef toggledChangeLines maxBadgeLength diff
++ viewChangedDefinitionsCards projectRef model maxBadgeLength diff
)
]
]
Expand Down Expand Up @@ -912,7 +972,7 @@ view appContext projectRef contribution model =
[ tabs
, div
[ class "project-contribution-changes-page" ]
[ viewBranchDiff projectRef model.toggledChangeLines diff ]
[ viewBranchDiff projectRef model diff ]
]

BranchDiffState.Uncomputable error ->
Expand Down
Loading