11module 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 )
54import Html.Attributes exposing (class )
65import Http
76import Json.Decode as Decode
@@ -11,11 +10,8 @@ import UI
1110import UI.Button as Button
1211import UI.ByAt as ByAt
1312import UI.Card as Card
14- import UI.CopyField as CopyField
1513import UI.DateTime as DateTime
16- import UI.Divider as Divider
1714import UI.Icon as Icon
18- import UI.Modal as Modal
1915import UI.PageContent as PageContent exposing (PageContent )
2016import UI.StatusBanner as StatusBanner
2117import UI.TabList as TabList
@@ -33,7 +29,7 @@ import UnisonShare.DateTimeContext exposing (DateTimeContext)
3329import UnisonShare.Link as Link
3430import UnisonShare.Markdown as Markdown
3531import UnisonShare.Project as Project exposing (ProjectDetails )
36- import UnisonShare.Project.ProjectRef as ProjectRef exposing (ProjectRef )
32+ import UnisonShare.Project.ProjectRef exposing (ProjectRef )
3733import UnisonShare.Session as Session exposing (Session )
3834import 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-
5748type 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-
594481view : AppContext -> ProjectDetails -> ContributionDetails -> Model -> ( PageContent Msg , Maybe (Html Msg ) )
595482view 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