Skip to content

Commit bb6076c

Browse files
committed
Conditionally show merge instructions based on status
1 parent e004410 commit bb6076c

File tree

1 file changed

+52
-30
lines changed

1 file changed

+52
-30
lines changed

src/UnisonShare/Page/ProjectContributionOverviewPage.elm

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ viewContribution session projectRef updateStatus contribution mergeStatus =
372372
actions =
373373
case contribution.status of
374374
ContributionStatus.Draft ->
375-
[ browseButton
376-
, viewLocallyInstructionsButton
375+
[ div [ class "left-actions" ]
376+
[ browseButton
377+
, viewLocallyInstructionsButton
378+
]
377379
, div [ class "right-actions" ]
378380
[ Button.iconThenLabel (UpdateStatus ContributionStatus.InReview) Icon.conversation "Submit for review"
379381
|> Button.emphasized
@@ -390,14 +392,18 @@ viewContribution session projectRef updateStatus contribution mergeStatus =
390392
]
391393

392394
ContributionStatus.Merged ->
393-
[ browseButton
394-
, viewLocallyInstructionsButton
395+
[ div [ class "left-actions" ]
396+
[ browseButton
397+
, viewLocallyInstructionsButton
398+
]
395399
, div [ class "right-actions" ] [ StatusBanner.good "Merged" ]
396400
]
397401

398402
ContributionStatus.Archived ->
399-
[ browseButton
400-
, viewLocallyInstructionsButton
403+
[ div [ class "left-actions" ]
404+
[ browseButton
405+
, viewLocallyInstructionsButton
406+
]
401407
, div [ class "right-actions" ] [ reopenButton ]
402408
]
403409

@@ -525,37 +531,53 @@ viewViewLocallyInstructionsModal contribution =
525531
target =
526532
"/" ++ BranchRef.toString contribution.targetBranchRef
527533

534+
mergeInstructions_ =
535+
[ h3 [] [ text "Merge (and resolve conflicts) locally:" ]
536+
, div [ class "instructions" ]
537+
[ p [] [ text "Clone the contribution branch:" ]
538+
, CopyField.copyField (always NoOp) ("clone " ++ source)
539+
|> CopyField.withPrefix (projectRef ++ "/main>")
540+
|> CopyField.view
541+
, p [] [ text "Next, switch to the target branch (usually /main):" ]
542+
, CopyField.copyField (always NoOp) ("switch " ++ target)
543+
|> CopyField.withPrefix (projectRef ++ source ++ ">")
544+
|> CopyField.view
545+
, p [] [ text "Make sure the target branch is up to date:" ]
546+
, CopyField.copyField (always NoOp) "pull"
547+
|> CopyField.withPrefix (projectRef ++ "/main>")
548+
|> CopyField.view
549+
, p [] [ text "Merge the changes:" ]
550+
, CopyField.copyField (always NoOp) ("merge " ++ source)
551+
|> CopyField.withPrefix (projectRef ++ target ++ ">")
552+
|> CopyField.view
553+
, p [] [ text "Finally, push the project to share and mark the contribution as merged." ]
554+
]
555+
]
556+
557+
mergeInstructions =
558+
case contribution.status of
559+
ContributionStatus.Draft ->
560+
mergeInstructions_
561+
562+
ContributionStatus.InReview ->
563+
mergeInstructions_
564+
565+
_ ->
566+
[]
567+
528568
content =
529569
div []
530-
[ h3 [] [ text "View the contribution locally:" ]
531-
, div [ class "instructions" ]
532-
[ p [] [ text "Clone the contribution branch:" ]
533-
, CopyField.copyField (always NoOp) ("clone " ++ source)
534-
|> CopyField.withPrefix (projectRef ++ "/main>")
535-
|> CopyField.view
536-
]
537-
, Divider.divider |> Divider.small |> Divider.view
538-
, h3 [] [ text "Merge (and resolve conflicts) locally:" ]
539-
, div [ class "instructions" ]
570+
([ h3 [] [ text "View the contribution locally:" ]
571+
, div [ class "instructions" ]
540572
[ p [] [ text "Clone the contribution branch:" ]
541573
, CopyField.copyField (always NoOp) ("clone " ++ source)
542574
|> CopyField.withPrefix (projectRef ++ "/main>")
543575
|> CopyField.view
544-
, p [] [ text "Next, switch to the target branch (usually /main):" ]
545-
, CopyField.copyField (always NoOp) ("switch " ++ target)
546-
|> CopyField.withPrefix (projectRef ++ source ++ ">")
547-
|> CopyField.view
548-
, p [] [ text "Make sure the target branch is up to date:" ]
549-
, CopyField.copyField (always NoOp) "pull"
550-
|> CopyField.withPrefix (projectRef ++ "/main>")
551-
|> CopyField.view
552-
, p [] [ text "Merge the changes:" ]
553-
, CopyField.copyField (always NoOp) ("merge " ++ source)
554-
|> CopyField.withPrefix (projectRef ++ target ++ ">")
555-
|> CopyField.view
556-
, p [] [ text "Finally, push the project to share and mark the contribution as merged." ]
557576
]
558-
]
577+
, Divider.divider |> Divider.small |> Divider.view
578+
]
579+
++ mergeInstructions
580+
)
559581
in
560582
content
561583
|> Modal.content

0 commit comments

Comments
 (0)