From 95c99253a4b2a2084aa56ac6c4ac07454840f64c Mon Sep 17 00:00:00 2001 From: ecrupper Date: Thu, 14 Sep 2023 11:20:45 -0500 Subject: [PATCH 1/2] enhance(deployments): use scm default for target and adjust ref resolution --- src/elm/Main.elm | 10 +++++++--- src/elm/Pages/Deployments/Update.elm | 14 ++------------ src/elm/Pages/Deployments/View.elm | 12 +++++++++++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/elm/Main.elm b/src/elm/Main.elm index 11b070685..b1005bed1 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 = @@ -3607,7 +3611,7 @@ loadRepoSubPage model org repo toPage = -- page is not a repo subpage _ -> - ( model, Cmd.none ) + ( model, getRepo model org repo ) in ( { loadModel | page = toPage }, loadCmd ) 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 From 1b6d611f95129f16a02a7ebc62644a4b9ce03ebf Mon Sep 17 00:00:00 2001 From: ecrupper Date: Mon, 18 Sep 2023 15:14:59 -0500 Subject: [PATCH 2/2] correct switch case fallthrough --- src/elm/Main.elm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/elm/Main.elm b/src/elm/Main.elm index b1005bed1..4410defd3 100644 --- a/src/elm/Main.elm +++ b/src/elm/Main.elm @@ -3609,9 +3609,12 @@ 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, getRepo model org repo ) + ( model, Cmd.none ) in ( { loadModel | page = toPage }, loadCmd )