Skip to content

Commit a67dbc5

Browse files
committed
Update contribution UI to allow space for CI runs
1 parent b6b19b9 commit a67dbc5

File tree

4 files changed

+131
-153
lines changed

4 files changed

+131
-153
lines changed

elm-git.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"git-dependencies": {
33
"direct": {
4-
"https://github.com/unisonweb/ui-core": "58d63fe0de338b9355a37262ccc8ed9fb486b806"
4+
"https://github.com/unisonweb/ui-core": "339edb84a64211bbbfb7f9d2ce99e07ab9fb184a"
55
},
66
"indirect": {}
77
}

src/UnisonShare/Page/ProjectContributionOverviewPage.elm

Lines changed: 7 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module UnisonShare.Page.ProjectContributionOverviewPage exposing (..)
22

3-
import Code.BranchRef as BranchRef
4-
import Html exposing (Html, div, em, h3, header, p, text)
3+
import Html exposing (Html, div, em, header, text)
54
import Html.Attributes exposing (class)
65
import Http
76
import Json.Decode as Decode
@@ -11,11 +10,8 @@ import UI
1110
import UI.Button as Button
1211
import UI.ByAt as ByAt
1312
import UI.Card as Card
14-
import UI.CopyField as CopyField
1513
import UI.DateTime as DateTime
16-
import UI.Divider as Divider
1714
import UI.Icon as Icon
18-
import UI.Modal as Modal
1915
import UI.PageContent as PageContent exposing (PageContent)
2016
import UI.StatusBanner as StatusBanner
2117
import UI.TabList as TabList
@@ -33,7 +29,7 @@ import UnisonShare.DateTimeContext exposing (DateTimeContext)
3329
import UnisonShare.Link as Link
3430
import UnisonShare.Markdown as Markdown
3531
import UnisonShare.Project as Project exposing (ProjectDetails)
36-
import UnisonShare.Project.ProjectRef as ProjectRef exposing (ProjectRef)
32+
import UnisonShare.Project.ProjectRef exposing (ProjectRef)
3733
import UnisonShare.Session as Session exposing (Session)
3834
import UnisonShare.Timeline.TimelineEvent as TimelineEvent
3935

@@ -49,11 +45,6 @@ type UpdateStatus
4945
| UpdateStatusFailed Http.Error
5046

5147

52-
type ContributionOverviewModal
53-
= NoModal
54-
| ViewLocallyInstructionsModal
55-
56-
5748
type MergeStatus
5849
= Checking
5950
| Checked ContributionMergeability
@@ -67,7 +58,6 @@ type alias Model =
6758
{ timeline : ContributionTimeline.Model
6859
, updateStatus : UpdateStatus
6960
, mergeStatus : MergeStatus
70-
, modal : ContributionOverviewModal
7161
}
7262

7363

@@ -80,7 +70,6 @@ init appContext projectRef contribRef =
8070
( { timeline = timeline
8171
, updateStatus = Idle
8272
, mergeStatus = Checking
83-
, modal = NoModal
8473
}
8574
, Cmd.batch
8675
[ Cmd.map ContributionTimelineMsg timelineCmd
@@ -97,8 +86,6 @@ type Msg
9786
= NoOp
9887
| UpdateStatus ContributionStatus
9988
| UpdateStatusFinished ContributionStatus (HttpResult ())
100-
| ShowViewLocallyInstructionsModal
101-
| CloseModal
10289
| FetchMergeabilityFinished (HttpResult ContributionMergeability)
10390
| Merge
10491
| MergeFinished (HttpResult ())
@@ -201,12 +188,6 @@ update appContext projectRef contributionRef contribution msg model =
201188
Session.Anonymous ->
202189
( model, Cmd.none, NoOut )
203190

204-
ShowViewLocallyInstructionsModal ->
205-
( { model | modal = ViewLocallyInstructionsModal }, Cmd.none, NoOut )
206-
207-
CloseModal ->
208-
( { model | modal = NoModal }, Cmd.none, NoOut )
209-
210191
ContributionTimelineMsg timelineMsg ->
211192
let
212193
( timeline, timelineCmd ) =
@@ -281,17 +262,6 @@ viewContribution session project updateStatus contribution mergeStatus =
281262
|> Maybe.map Markdown.view
282263
|> Maybe.withDefault (em [ class "no-description" ] [ text "No description..." ])
283264

284-
browseButton =
285-
Button.iconThenLabel_
286-
(Link.projectBranchRoot contribution.projectRef contribution.sourceBranchRef)
287-
Icon.browse
288-
"Browse Code"
289-
|> Button.view
290-
291-
viewLocallyInstructionsButton =
292-
Button.iconThenLabel ShowViewLocallyInstructionsModal Icon.download "View locally"
293-
|> Button.view
294-
295265
archiveButton =
296266
if (canMaintain || isContributor) && updateStatus /= TimelineNotReady then
297267
Button.iconThenLabel (UpdateStatus ContributionStatus.Archived) Icon.archive "Archive"
@@ -373,10 +343,7 @@ viewContribution session project updateStatus contribution mergeStatus =
373343
actions =
374344
case contribution.status of
375345
ContributionStatus.Draft ->
376-
[ div [ class "left-actions" ]
377-
[ browseButton
378-
, viewLocallyInstructionsButton
379-
]
346+
[ div [ class "left-actions" ] []
380347
, div [ class "right-actions" ]
381348
[ Button.iconThenLabel (UpdateStatus ContributionStatus.InReview) Icon.conversation "Submit for review"
382349
|> Button.emphasized
@@ -385,26 +352,17 @@ viewContribution session project updateStatus contribution mergeStatus =
385352
]
386353

387354
ContributionStatus.InReview ->
388-
[ div [ class "left-actions" ]
389-
[ browseButton
390-
, viewLocallyInstructionsButton
391-
]
355+
[ div [ class "left-actions" ] []
392356
, div [ class "right-actions" ] [ archiveButton, mergeButton ]
393357
]
394358

395359
ContributionStatus.Merged ->
396-
[ div [ class "left-actions" ]
397-
[ browseButton
398-
, viewLocallyInstructionsButton
399-
]
360+
[ div [ class "left-actions" ] []
400361
, div [ class "right-actions" ] [ StatusBanner.good "Merged" ]
401362
]
402363

403364
ContributionStatus.Archived ->
404-
[ div [ class "left-actions" ]
405-
[ browseButton
406-
, viewLocallyInstructionsButton
407-
]
365+
[ div [ class "left-actions" ] []
408366
, div [ class "right-actions" ] [ reopenButton ]
409367
]
410368

@@ -520,94 +478,14 @@ viewPageContent appContext project updateStatus contribution mergeStatus timelin
520478
]
521479

522480

523-
viewViewLocallyInstructionsModal : ContributionDetails -> Html Msg
524-
viewViewLocallyInstructionsModal contribution =
525-
let
526-
projectRef =
527-
ProjectRef.toString contribution.projectRef
528-
529-
source =
530-
"/" ++ BranchRef.toString contribution.sourceBranchRef
531-
532-
target =
533-
"/" ++ BranchRef.toString contribution.targetBranchRef
534-
535-
mergeInstructions_ =
536-
[ Divider.divider |> Divider.small |> Divider.view
537-
, h3 [] [ text "Merge (and resolve conflicts) locally:" ]
538-
, div [ class "instructions" ]
539-
[ p [] [ text "Clone the contribution branch:" ]
540-
, CopyField.copyField (always NoOp) ("clone " ++ source)
541-
|> CopyField.withPrefix (projectRef ++ "/main>")
542-
|> CopyField.view
543-
, p [] [ text "Next, switch to the target branch (usually /main):" ]
544-
, CopyField.copyField (always NoOp) ("switch " ++ target)
545-
|> CopyField.withPrefix (projectRef ++ source ++ ">")
546-
|> CopyField.view
547-
, p [] [ text "Make sure the target branch is up to date:" ]
548-
, CopyField.copyField (always NoOp) "pull"
549-
|> CopyField.withPrefix (projectRef ++ "/main>")
550-
|> CopyField.view
551-
, p [] [ text "Merge the changes:" ]
552-
, CopyField.copyField (always NoOp) ("merge " ++ source)
553-
|> CopyField.withPrefix (projectRef ++ target ++ ">")
554-
|> CopyField.view
555-
, p [] [ text "Finally, push the project to share and mark the contribution as merged." ]
556-
]
557-
]
558-
559-
mergeInstructions =
560-
case contribution.status of
561-
ContributionStatus.Draft ->
562-
mergeInstructions_
563-
564-
ContributionStatus.InReview ->
565-
mergeInstructions_
566-
567-
_ ->
568-
[]
569-
570-
content =
571-
div []
572-
([ h3 [] [ text "View the contribution locally:" ]
573-
, div [ class "instructions" ]
574-
[ p [] [ text "Clone the contribution branch:" ]
575-
, CopyField.copyField (always NoOp) ("clone " ++ source)
576-
|> CopyField.withPrefix (projectRef ++ "/main>")
577-
|> CopyField.view
578-
]
579-
]
580-
++ mergeInstructions
581-
)
582-
in
583-
content
584-
|> Modal.content
585-
|> Modal.modal "project-contribution-view-locally-instructions-modal" CloseModal
586-
|> Modal.withActions
587-
[ Button.button CloseModal "Got it"
588-
|> Button.medium
589-
|> Button.emphasized
590-
]
591-
|> Modal.view
592-
593-
594481
view : AppContext -> ProjectDetails -> ContributionDetails -> Model -> ( PageContent Msg, Maybe (Html Msg) )
595482
view appContext project contribution model =
596-
let
597-
modal =
598-
case model.modal of
599-
NoModal ->
600-
Nothing
601-
602-
ViewLocallyInstructionsModal ->
603-
Just (viewViewLocallyInstructionsModal contribution)
604-
in
605483
( viewPageContent
606484
appContext
607485
project
608486
model.updateStatus
609487
contribution
610488
model.mergeStatus
611489
model.timeline
612-
, modal
490+
, Nothing
613491
)

0 commit comments

Comments
 (0)