diff --git a/src/elm/Main.elm b/src/elm/Main.elm index 11b070685..4410defd3 100644 --- a/src/elm/Main.elm +++ b/src/elm/Main.elm @@ -1401,7 +1401,11 @@ update msg model = RepoResponse response -> case response of Ok ( _, repoResponse ) -> - ( { model | repo = updateRepo (RemoteData.succeed repoResponse) rm }, Cmd.none ) + let + dm = + model.deploymentModel + in + ( { model | repo = updateRepo (RemoteData.succeed repoResponse) rm, deploymentModel = { dm | repo_settings = RemoteData.succeed repoResponse } }, Cmd.none ) Err error -> ( { model | repo = updateRepo (toFailure error) rm }, addError error ) @@ -3452,7 +3456,7 @@ loadRepoSubPage model org repo toPage = { dm | org = org , repo = repo - , repo_settings = rm.repo + , repo_settings = model.repo.repo , form = form } , repo = @@ -3605,6 +3609,9 @@ loadRepoSubPage model org repo toPage = Pages.PromoteDeployment o r deploymentNumber -> ( model, getDeployment model o r deploymentNumber ) + Pages.AddDeployment o r -> + ( model, getRepo model o r ) + -- page is not a repo subpage _ -> ( model, Cmd.none ) diff --git a/src/elm/Pages/Deployments/Update.elm b/src/elm/Pages/Deployments/Update.elm index 8b8b14687..70917c484 100644 --- a/src/elm/Pages/Deployments/Update.elm +++ b/src/elm/Pages/Deployments/Update.elm @@ -199,18 +199,8 @@ applyDefaults form = form.description ) form.payload - (if form.ref == "" then - "refs/heads/master" - - else - form.ref - ) - (if form.target == "" then - "production" - - else - form.target - ) + form.ref + form.target (if form.task == "" then "deploy:vela" diff --git a/src/elm/Pages/Deployments/View.elm b/src/elm/Pages/Deployments/View.elm index 821bb173e..6af0491aa 100644 --- a/src/elm/Pages/Deployments/View.elm +++ b/src/elm/Pages/Deployments/View.elm @@ -48,12 +48,22 @@ addForm deploymentModel = let deployment = deploymentModel.form + + branch = + case deploymentModel.repo_settings of + RemoteData.Success repo -> + repo.branch + + _ -> + "" in div [ class "deployment-form" ] [ h2 [ class "deployment-header" ] [ text "Add Deployment" ] , viewDeployEnabled deploymentModel.repo_settings + + -- GitHub default is "production". If we support more SCMs, this line may need tweaking , viewValueInput "Target" deployment.target "provide the name for the target deployment environment (default: \"production\")" - , viewValueInput "Ref" deployment.ref "provide the reference to deploy - this can be a branch, commit (SHA) or tag (default: \"refs/heads/master\")" + , viewValueInput "Ref" deployment.ref <| "provide the reference to deploy - this can be a branch, commit (SHA) or tag (default: " ++ branch ++ ")" , viewValueInput "Description" deployment.description "provide the description for the deployment (default: \"Deployment request from Vela\")" , viewValueInput "Task" deployment.task "Provide the task for the deployment (default: \"deploy:vela\")" , viewParameterInput deployment