Skip to content

Commit

Permalink
Conditionally show merge instructions based on status
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Oct 24, 2024
1 parent e004410 commit bb6076c
Showing 1 changed file with 52 additions and 30 deletions.
82 changes: 52 additions & 30 deletions src/UnisonShare/Page/ProjectContributionOverviewPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ viewContribution session projectRef updateStatus contribution mergeStatus =
actions =
case contribution.status of
ContributionStatus.Draft ->
[ browseButton
, viewLocallyInstructionsButton
[ div [ class "left-actions" ]
[ browseButton
, viewLocallyInstructionsButton
]
, div [ class "right-actions" ]
[ Button.iconThenLabel (UpdateStatus ContributionStatus.InReview) Icon.conversation "Submit for review"
|> Button.emphasized
Expand All @@ -390,14 +392,18 @@ viewContribution session projectRef updateStatus contribution mergeStatus =
]

ContributionStatus.Merged ->
[ browseButton
, viewLocallyInstructionsButton
[ div [ class "left-actions" ]
[ browseButton
, viewLocallyInstructionsButton
]
, div [ class "right-actions" ] [ StatusBanner.good "Merged" ]
]

ContributionStatus.Archived ->
[ browseButton
, viewLocallyInstructionsButton
[ div [ class "left-actions" ]
[ browseButton
, viewLocallyInstructionsButton
]
, div [ class "right-actions" ] [ reopenButton ]
]

Expand Down Expand Up @@ -525,37 +531,53 @@ viewViewLocallyInstructionsModal contribution =
target =
"/" ++ BranchRef.toString contribution.targetBranchRef

mergeInstructions_ =
[ h3 [] [ text "Merge (and resolve conflicts) locally:" ]
, div [ class "instructions" ]
[ p [] [ text "Clone the contribution branch:" ]
, CopyField.copyField (always NoOp) ("clone " ++ source)
|> CopyField.withPrefix (projectRef ++ "/main>")
|> CopyField.view
, p [] [ text "Next, switch to the target branch (usually /main):" ]
, CopyField.copyField (always NoOp) ("switch " ++ target)
|> CopyField.withPrefix (projectRef ++ source ++ ">")
|> CopyField.view
, p [] [ text "Make sure the target branch is up to date:" ]
, CopyField.copyField (always NoOp) "pull"
|> CopyField.withPrefix (projectRef ++ "/main>")
|> CopyField.view
, p [] [ text "Merge the changes:" ]
, CopyField.copyField (always NoOp) ("merge " ++ source)
|> CopyField.withPrefix (projectRef ++ target ++ ">")
|> CopyField.view
, p [] [ text "Finally, push the project to share and mark the contribution as merged." ]
]
]

mergeInstructions =
case contribution.status of
ContributionStatus.Draft ->
mergeInstructions_

ContributionStatus.InReview ->
mergeInstructions_

_ ->
[]

content =
div []
[ h3 [] [ text "View the contribution locally:" ]
, div [ class "instructions" ]
[ p [] [ text "Clone the contribution branch:" ]
, CopyField.copyField (always NoOp) ("clone " ++ source)
|> CopyField.withPrefix (projectRef ++ "/main>")
|> CopyField.view
]
, Divider.divider |> Divider.small |> Divider.view
, h3 [] [ text "Merge (and resolve conflicts) locally:" ]
, div [ class "instructions" ]
([ h3 [] [ text "View the contribution locally:" ]
, div [ class "instructions" ]
[ p [] [ text "Clone the contribution branch:" ]
, CopyField.copyField (always NoOp) ("clone " ++ source)
|> CopyField.withPrefix (projectRef ++ "/main>")
|> CopyField.view
, p [] [ text "Next, switch to the target branch (usually /main):" ]
, CopyField.copyField (always NoOp) ("switch " ++ target)
|> CopyField.withPrefix (projectRef ++ source ++ ">")
|> CopyField.view
, p [] [ text "Make sure the target branch is up to date:" ]
, CopyField.copyField (always NoOp) "pull"
|> CopyField.withPrefix (projectRef ++ "/main>")
|> CopyField.view
, p [] [ text "Merge the changes:" ]
, CopyField.copyField (always NoOp) ("merge " ++ source)
|> CopyField.withPrefix (projectRef ++ target ++ ">")
|> CopyField.view
, p [] [ text "Finally, push the project to share and mark the contribution as merged." ]
]
]
, Divider.divider |> Divider.small |> Divider.view
]
++ mergeInstructions
)
in
content
|> Modal.content
Expand Down

0 comments on commit bb6076c

Please sign in to comment.