From c44152da624151096bc177291b848c246b24a9a9 Mon Sep 17 00:00:00 2001 From: Taylor Dolan Date: Tue, 23 May 2017 15:09:38 -0700 Subject: [PATCH 1/9] add default branch selector --- client/assets/styles/scss/modals/modals-forms.scss | 1 + .../styles/scss/views/views-new-service.scss | 14 ++++++++++++++ .../branchSelector/branchSelectorView.jade | 2 +- .../forms/configureNewServiceView.jade | 6 +++++- .../newContainer/forms/defaultBranchView.jade | 9 +++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 client/directives/components/newContainer/forms/defaultBranchView.jade diff --git a/client/assets/styles/scss/modals/modals-forms.scss b/client/assets/styles/scss/modals/modals-forms.scss index 6a94fd52c..c23f3ec24 100644 --- a/client/assets/styles/scss/modals/modals-forms.scss +++ b/client/assets/styles/scss/modals/modals-forms.scss @@ -157,6 +157,7 @@ // max-width on buttons > .btn, .btn-wrapped { + @extend %btn-sm; display: block; font-size: 16px; max-width: 360px; diff --git a/client/assets/styles/scss/views/views-new-service.scss b/client/assets/styles/scss/views/views-new-service.scss index a475c86ca..b22cbfba4 100644 --- a/client/assets/styles/scss/views/views-new-service.scss +++ b/client/assets/styles/scss/views/views-new-service.scss @@ -14,6 +14,11 @@ max-width: 330px; } + // for "name" form + + .label { + margin-bottom: 0; + } + .btn-radio { border-radius: $input-border-radius-lg; flex: 1 1 50%; @@ -44,6 +49,15 @@ } } + // for branch selector + .btn-wrapped { + @extend %btn-md; + display: block; + font-weight: 400; + padding-left: 8px; + width: 100%; + } + // for the nested compose test file .well > .label { margin-bottom: 0; diff --git a/client/directives/components/fancySelectors/branchSelector/branchSelectorView.jade b/client/directives/components/fancySelectors/branchSelector/branchSelectorView.jade index d4d9bbc7b..0a914b421 100644 --- a/client/directives/components/fancySelectors/branchSelector/branchSelectorView.jade +++ b/client/directives/components/fancySelectors/branchSelector/branchSelectorView.jade @@ -1,4 +1,4 @@ -fancy-select.btn-sm.white.btn-wrapped( +fancy-select.white.btn-wrapped( ng-disabled = "branchFetching || !state.repo.branches.models.length" ng-required = "true" on-update = "onBranchChange" diff --git a/client/directives/components/newContainer/forms/configureNewServiceView.jade b/client/directives/components/newContainer/forms/configureNewServiceView.jade index 99b1a128e..f8ee84b3a 100644 --- a/client/directives/components/newContainer/forms/configureNewServiceView.jade +++ b/client/directives/components/newContainer/forms/configureNewServiceView.jade @@ -51,11 +51,15 @@ section.grid-block.vertical.modal-body( ) //- form for naming the environment - form.grid-block.vertical.label( + form.grid-block.vertical.label.label-name( name = "NCC.nameForm" ng-include = "'nameNewServiceView'" ) + form.grid-block.vertical.label( + ng-include = "'defaultBranchView'" + ) + .grid-block.vertical.views-kubernetes-setup( ng-if = "NCC.state.dockerFileTab === 'kubernetes'" ng-include = "'kubernetesSetupView'" diff --git a/client/directives/components/newContainer/forms/defaultBranchView.jade b/client/directives/components/newContainer/forms/defaultBranchView.jade new file mode 100644 index 000000000..5fb43f36c --- /dev/null +++ b/client/directives/components/newContainer/forms/defaultBranchView.jade @@ -0,0 +1,9 @@ +label + .padding-xxs.small.label-sm Branch + div( + auto-update = "true" + branch-selector + loading-promises-target = "editServerModal" + state = "state" + ) + small.padding-xxs.small Select the branch you want to add first. From 2d61e5ec45f553b2411aac30144492027cf4ec2f Mon Sep 17 00:00:00 2001 From: Taylor Dolan Date: Tue, 23 May 2017 15:17:52 -0700 Subject: [PATCH 2/9] show branch selector only in compose tab --- .../components/newContainer/forms/configureNewServiceView.jade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/directives/components/newContainer/forms/configureNewServiceView.jade b/client/directives/components/newContainer/forms/configureNewServiceView.jade index f8ee84b3a..da9d1b66a 100644 --- a/client/directives/components/newContainer/forms/configureNewServiceView.jade +++ b/client/directives/components/newContainer/forms/configureNewServiceView.jade @@ -56,7 +56,9 @@ section.grid-block.vertical.modal-body( ng-include = "'nameNewServiceView'" ) + //- default branch selector form.grid-block.vertical.label( + ng-if = "NCC.state.dockerFileTab === 'compose'" ng-include = "'defaultBranchView'" ) From f6dac3a656d0f4a2d804f1ffd0652268cfd1a69d Mon Sep 17 00:00:00 2001 From: Taylor Dolan Date: Tue, 23 May 2017 15:23:16 -0700 Subject: [PATCH 3/9] add feature flag for branch selector --- client/assets/styles/scss/views/views-new-service.scss | 9 ++++----- .../newContainer/forms/configureNewServiceView.jade | 4 ++-- client/services/featureFlagService.js | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/assets/styles/scss/views/views-new-service.scss b/client/assets/styles/scss/views/views-new-service.scss index b22cbfba4..552910e89 100644 --- a/client/assets/styles/scss/views/views-new-service.scss +++ b/client/assets/styles/scss/views/views-new-service.scss @@ -14,11 +14,6 @@ max-width: 330px; } - // for "name" form - + .label { - margin-bottom: 0; - } - .btn-radio { border-radius: $input-border-radius-lg; flex: 1 1 50%; @@ -49,6 +44,10 @@ } } + .label-branch { + margin-top: -$sm; + } + // for branch selector .btn-wrapped { @extend %btn-md; diff --git a/client/directives/components/newContainer/forms/configureNewServiceView.jade b/client/directives/components/newContainer/forms/configureNewServiceView.jade index da9d1b66a..638abebec 100644 --- a/client/directives/components/newContainer/forms/configureNewServiceView.jade +++ b/client/directives/components/newContainer/forms/configureNewServiceView.jade @@ -57,8 +57,8 @@ section.grid-block.vertical.modal-body( ) //- default branch selector - form.grid-block.vertical.label( - ng-if = "NCC.state.dockerFileTab === 'compose'" + form.grid-block.vertical.label.label-branch( + ng-if = "NCC.state.dockerFileTab === 'compose' && $root.featureFlags.composeDefaultBranch" ng-include = "'defaultBranchView'" ) diff --git a/client/services/featureFlagService.js b/client/services/featureFlagService.js index 17d618fc9..e883ec04f 100644 --- a/client/services/featureFlagService.js +++ b/client/services/featureFlagService.js @@ -14,6 +14,7 @@ function featureFlags( autoIsolationSetup: false, backup: false, cardStatus: false, + composeDefaultBranch: false, composeEditing: false, composeInstance: true, composeNav: true, From 6282255fa14d9b5e2893552d5641ea4c6e82c706 Mon Sep 17 00:00:00 2001 From: Taylor Dolan Date: Tue, 23 May 2017 15:24:10 -0700 Subject: [PATCH 4/9] update copy --- .../components/newContainer/forms/defaultBranchView.jade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/directives/components/newContainer/forms/defaultBranchView.jade b/client/directives/components/newContainer/forms/defaultBranchView.jade index 5fb43f36c..bd7da1a76 100644 --- a/client/directives/components/newContainer/forms/defaultBranchView.jade +++ b/client/directives/components/newContainer/forms/defaultBranchView.jade @@ -6,4 +6,4 @@ label loading-promises-target = "editServerModal" state = "state" ) - small.padding-xxs.small Select the branch you want to add first. + small.padding-xxs.small Select the first branch you want to add. From db706183d659171a67b560b746239aecea1e9322 Mon Sep 17 00:00:00 2001 From: Taylor Dolan Date: Tue, 23 May 2017 17:04:03 -0700 Subject: [PATCH 5/9] clean up --- .../styles/scss/views/views-new-service.scss | 14 +++++++------- .../forms/configureNewServiceView.jade | 2 +- .../newContainer/forms/defaultBranchView.jade | 17 ++++++++--------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/client/assets/styles/scss/views/views-new-service.scss b/client/assets/styles/scss/views/views-new-service.scss index 552910e89..1ba50d754 100644 --- a/client/assets/styles/scss/views/views-new-service.scss +++ b/client/assets/styles/scss/views/views-new-service.scss @@ -44,17 +44,17 @@ } } - .label-branch { - margin-top: -$sm; - } - // for branch selector .btn-wrapped { @extend %btn-md; - display: block; - font-weight: 400; + display: flex; + flex: 1 1 auto; + justify-content: space-between; padding-left: 8px; - width: 100%; + + .icons-branch { + top: 9px; + } } // for the nested compose test file diff --git a/client/directives/components/newContainer/forms/configureNewServiceView.jade b/client/directives/components/newContainer/forms/configureNewServiceView.jade index 638abebec..4311d6468 100644 --- a/client/directives/components/newContainer/forms/configureNewServiceView.jade +++ b/client/directives/components/newContainer/forms/configureNewServiceView.jade @@ -57,7 +57,7 @@ section.grid-block.vertical.modal-body( ) //- default branch selector - form.grid-block.vertical.label.label-branch( + label.grid-block.vertical.label( ng-if = "NCC.state.dockerFileTab === 'compose' && $root.featureFlags.composeDefaultBranch" ng-include = "'defaultBranchView'" ) diff --git a/client/directives/components/newContainer/forms/defaultBranchView.jade b/client/directives/components/newContainer/forms/defaultBranchView.jade index bd7da1a76..658c8c196 100644 --- a/client/directives/components/newContainer/forms/defaultBranchView.jade +++ b/client/directives/components/newContainer/forms/defaultBranchView.jade @@ -1,9 +1,8 @@ -label - .padding-xxs.small.label-sm Branch - div( - auto-update = "true" - branch-selector - loading-promises-target = "editServerModal" - state = "state" - ) - small.padding-xxs.small Select the first branch you want to add. +.padding-xxs.small.label-sm Initial Branch +.grid-block( + auto-update = "true" + branch-selector + loading-promises-target = "editServerModal" + state = "state" +) +small.padding-xxs.small Select the first branch you want to add. From 02368bf691f22a885573bd10dfcd6444b0b92efd Mon Sep 17 00:00:00 2001 From: thejsj Date: Wed, 24 May 2017 18:21:54 -0700 Subject: [PATCH 6/9] Hook state for branches to new branch selector --- .../addDockerfileDirective.js | 24 ++++++++++++------- .../forms/configureNewServiceView.jade | 2 +- .../newContainer/forms/defaultBranchView.jade | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/client/directives/components/mirrorDockerfile/addDockerfileDirective.js b/client/directives/components/mirrorDockerfile/addDockerfileDirective.js index 669073f24..0f5069f64 100644 --- a/client/directives/components/mirrorDockerfile/addDockerfileDirective.js +++ b/client/directives/components/mirrorDockerfile/addDockerfileDirective.js @@ -46,13 +46,21 @@ function addDockerfile( MDC.loadDefaultDockerfile($scope.fullRepo, $scope.branchName, path, $scope.fileType); } - fetchRepoDockerfile($scope.fullRepo, $scope.branchName, path) - .then(doesDockerfileExist) - .then(function (file) { - if (file) { - $scope.newDockerfile = $scope.fileName; - } - }); + + function populateNewDockerfile () { + return fetchRepoDockerfile($scope.fullRepo, $scope.branchName, path) + .then(doesDockerfileExist) + .then(function (file) { + if (file) { + $scope.newDockerfile = $scope.fileName; + } else { + // Account for files not found + $scope.newDockerfile = undefined; + } + }); + } + $scope.$watch('branchName', populateNewDockerfile); + populateNewDockerfile(); $scope.$on('dockerfileExistsValidator', function ($event, path, fileType, dockerfile) { if (fileType === 'Dockerfile') { @@ -67,7 +75,7 @@ function addDockerfile( $scope.dockerfile = dockerfile; MDC.state.dockerfile = dockerfile; return; - } + } }); $scope.closeDockerFileInput = function () { diff --git a/client/directives/components/newContainer/forms/configureNewServiceView.jade b/client/directives/components/newContainer/forms/configureNewServiceView.jade index 4311d6468..d9f55e2fa 100644 --- a/client/directives/components/newContainer/forms/configureNewServiceView.jade +++ b/client/directives/components/newContainer/forms/configureNewServiceView.jade @@ -78,7 +78,7 @@ section.grid-block.vertical.modal-body( //- form for dockerfile setup .grid-block.vertical.label.views-dockerfile-setup( - branch-name = "NCC.state.repo.attrs.default_branch" + branch-name = "NCC.state.branch.attrs.name" mirror-dockerfile name = "'newContainer'" ng-if = "NCC.state.dockerFileTab !== 'kubernetes'" diff --git a/client/directives/components/newContainer/forms/defaultBranchView.jade b/client/directives/components/newContainer/forms/defaultBranchView.jade index 658c8c196..e64d1a58b 100644 --- a/client/directives/components/newContainer/forms/defaultBranchView.jade +++ b/client/directives/components/newContainer/forms/defaultBranchView.jade @@ -3,6 +3,6 @@ auto-update = "true" branch-selector loading-promises-target = "editServerModal" - state = "state" + state = "NCC.state" ) small.padding-xxs.small Select the first branch you want to add. From 276ca9323046a37ba26e2876eba9ea936632df51 Mon Sep 17 00:00:00 2001 From: thejsj Date: Wed, 24 May 2017 18:22:12 -0700 Subject: [PATCH 7/9] Remove unused methods --- .../mirrorDockerfileController.js | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/client/directives/components/mirrorDockerfile/mirrorDockerfileController.js b/client/directives/components/mirrorDockerfile/mirrorDockerfileController.js index e3fad7b8b..8f7e02264 100644 --- a/client/directives/components/mirrorDockerfile/mirrorDockerfileController.js +++ b/client/directives/components/mirrorDockerfile/mirrorDockerfileController.js @@ -32,31 +32,6 @@ function MirrorDockerfileController( MDC.branchName = MDC.branchName || keypather.get(MDC.repo, 'attrs.default_branch'); MDC.state.configurationMethod = null; - MDC.fetchRepoDockerfiles = function () { - return fetchRepoDockerfiles(MDC.getFullRepo(), MDC.branchName, MDC.newDockerfilePaths) - .then(function (dockerfiles) { - // remove any dead paths by replacing them with the results - MDC.newDockerfilePaths = dockerfiles.map(function (dockerfile) { - return dockerfile.path; - }); - MDC.repo.dockerfiles = dockerfiles; - return dockerfiles; - }) - .catch(errs.handler); - }; - - MDC.fetchRepoDockerComposeFiles = function () { - return fetchRepoDockerfiles(MDC.getFullRepo(), MDC.branchName, MDC.newDockerComposeFilePaths) - .then(function (dockerfiles) { - MDC.newDockerComposeFilePaths = dockerfiles.map(function (dockerfile) { - return dockerfile.path; - }); - MDC.repo.dockerComposeFiles = dockerfiles; - return dockerfiles; - }) - .catch(errs.handler); - }; - MDC.loadDefaultDockerfile = function (repo, branchName, filePath, fileType) { return fetchRepoDockerfile(repo, branchName, filePath) .then(doesDockerfileExist) From 3c41439584e79edd0c4f992bc20eaf08ffa07b6c Mon Sep 17 00:00:00 2001 From: thejsj Date: Wed, 24 May 2017 18:48:15 -0700 Subject: [PATCH 8/9] Improving readbility of function --- .../newContainer/newContainerController.js | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/client/directives/components/newContainer/newContainerController.js b/client/directives/components/newContainer/newContainerController.js index 567915c45..17a08df13 100644 --- a/client/directives/components/newContainer/newContainerController.js +++ b/client/directives/components/newContainer/newContainerController.js @@ -383,17 +383,33 @@ function NewContainerController( }; NCC.canCreateBuild = function () { - return keypather.get(NCC, 'state.instanceName.length') && !keypather.get(NCC, 'nameForm.$invalid') && - !$rootScope.isLoading.newContainerSingleRepo && !$rootScope.isLoading.creatingDockerCompose && (NCC.state.templateSource || - !$scope.$root.featureFlags.composeNewService || NCC.validateDockerComposeBuild()); + var hasInstances = keypather.get(NCC, 'state.instanceName.length'); + var isLoading = $rootScope.isLoading.newContainerSingleRepo || $rootScope.isLoading.creatingDockerCompose; + var isFormValid = !keypather.get(NCC, 'nameForm.$invalid'); + var isTemplate = NCC.state.templateSource; + var isValidCompose = !$scope.$root.featureFlags.composeNewService || NCC.validateDockerComposeBuild(); + return hasInstances && + isFormValid && + !isLoading && + (isTemplate || isValidCompose); }; NCC.validateDockerComposeBuild = function () { - return ((NCC.state.configurationMethod === 'new' || NCC.state.configurationMethod === 'blankDockerfile') || - (NCC.state.configurationMethod === 'dockerfile' && NCC.state.dockerfile) || - (NCC.state.configurationMethod === 'dockerComposeFile' && - ((NCC.state.types.test ? NCC.state.dockerComposeTestFile && NCC.state.testReporter : NCC.state.types.stage) && - (NCC.state.types.stage ? NCC.state.dockerComposeFile : NCC.state.types.test)))); + var isNewBlankDockerfile = ['new', 'blankDockerfile'].includes(NCC.state.configurationMethod); + var isValidDockerfile = NCC.state.configurationMethod === 'dockerfile' && NCC.state.dockerfile; + var isValidComposeFile = false; + if (NCC.state.configurationMethod === 'dockerComposeFile') { + var isValidTestCompose = true, isValidStagingCompose = true; + var hasTestOrStaging = NCC.state.types.test || NCC.state.types.stage; + if (NCC.state.types.test) { + isValidTestCompose = NCC.state.dockerComposeTestFile && NCC.state.testReporter; + } + if (NCC.state.types.stage) { + isValidStagingCompose = NCC.state.dockerComposeFile; + } + isValidComposeFile = hasTestOrStaging && isValidTestCompose && isValidStagingCompose; + } + return isNewBlankDockerfile || isValidDockerfile || isValidComposeFile; }; NCC.isSaving = function () { From 4d369d543338f8b0d5e6a08cbf786a17ab5a7c98 Mon Sep 17 00:00:00 2001 From: thejsj Date: Thu, 25 May 2017 11:05:43 -0700 Subject: [PATCH 9/9] Change branch used to create cluster --- .../components/newContainer/newContainerController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/directives/components/newContainer/newContainerController.js b/client/directives/components/newContainer/newContainerController.js index 17a08df13..47975f38f 100644 --- a/client/directives/components/newContainer/newContainerController.js +++ b/client/directives/components/newContainer/newContainerController.js @@ -332,7 +332,7 @@ function NewContainerController( if (NCC.state.dockerComposeFile && (!$rootScope.featureFlags.composeNewService || NCC.state.types.stage)) { return createNewCluster( NCC.state.repo.attrs.full_name, - NCC.state.repo.attrs.default_branch, + NCC.state.branch.attrs.name, NCC.state.dockerComposeFile.path, NCC.state.instanceName, currentOrg.github.attrs.id @@ -348,7 +348,7 @@ function NewContainerController( var instanceName = NCC.state.instanceName + '-test'; return createNewCluster( NCC.state.repo.attrs.full_name, - NCC.state.repo.attrs.default_branch, + NCC.state.branch.attrs.name, NCC.state.dockerComposeTestFile.path, instanceName, currentOrg.github.attrs.id, @@ -363,7 +363,7 @@ function NewContainerController( return createNewCluster( NCC.state.repo.attrs.full_name, - NCC.state.repo.attrs.default_branch, + NCC.state.branch.attrs.name, NCC.state.dockerComposeTestFile.path, NCC.state.instanceName, currentOrg.github.attrs.id,