Skip to content

Commit

Permalink
Fix diff links correctly going to new and old branches
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Nov 22, 2024
1 parent 67dc63a commit aeec3d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/UnisonShare/DefinitionDiff.elm
Original file line number Diff line number Diff line change
Expand Up @@ -152,30 +152,30 @@ viewNewDiffSegment syntaxConfig segment =
]


viewDiff : SyntaxConfig msg -> NEL.Nonempty DiffSegment -> Html msg
viewDiff syntaxConfig segments =
viewDiff : (Bool -> SyntaxConfig msg) -> NEL.Nonempty DiffSegment -> Html msg
viewDiff toSyntaxConfig segments =
let
old =
segments
|> NEL.toList
|> List.concatMap (viewOldDiffSegment syntaxConfig)
|> List.concatMap (viewOldDiffSegment (toSyntaxConfig False))

new =
segments
|> NEL.toList
|> List.concatMap (viewNewDiffSegment syntaxConfig)
|> List.concatMap (viewNewDiffSegment (toSyntaxConfig True))
in
div [ class "diff-side-by-side" ]
[ pre [ class "monochrome diff-side" ] [ code [] old ]
, pre [ class "monochrome diff-side" ] [ code [] new ]
]


view : SyntaxConfig msg -> DefinitionDiff -> Html msg
view syntaxConfig defDiff =
view : (Bool -> SyntaxConfig msg) -> DefinitionDiff -> Html msg
view toSyntaxConfig defDiff =
case defDiff of
Diff _ diff ->
div [] [ viewDiff syntaxConfig diff ]
div [] [ viewDiff toSyntaxConfig diff ]

Mismatched _ ->
div [] [ text "TODO" ]
Expand Down
12 changes: 10 additions & 2 deletions src/UnisonShare/Page/ProjectContributionChangesPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,15 @@ viewLoadingExpandedContent =
viewChangedDefinitionCard : ProjectRef -> ChangedDefinitions -> BranchDiff -> ChangeLine -> DefinitionType -> Html Msg -> Html Msg
viewChangedDefinitionCard projectRef changedDefinitions branchDiff changeLine type_ content =
let
linked branchRef =
toSyntaxConfig isNew =
let
branchRef =
if isNew then
branchDiff.newBranch.ref

else
branchDiff.newBranch.ref
in
SyntaxConfig.empty
|> SyntaxConfig.withToClick
(Link.projectBranchDefinition projectRef branchRef)
Expand All @@ -508,7 +516,7 @@ viewChangedDefinitionCard projectRef changedDefinitions branchDiff changeLine ty

Success d ->
DefinitionDiff.view
(linked branchDiff.newBranch.ref)
toSyntaxConfig
d

Failure e ->
Expand Down

0 comments on commit aeec3d1

Please sign in to comment.