Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose default branch full #2212

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/assets/styles/scss/modals/modals-forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
// max-width on buttons
> .btn,
.btn-wrapped {
@extend %btn-sm;
display: block;
font-size: 16px;
max-width: 360px;
Expand Down
13 changes: 13 additions & 0 deletions client/assets/styles/scss/views/views-new-service.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
}
}

// for branch selector
.btn-wrapped {
@extend %btn-md;
display: flex;
flex: 1 1 auto;
justify-content: space-between;
padding-left: 8px;

.icons-branch {
top: 9px;
}
}

// for the nested compose test file
.well > .label {
margin-bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -67,7 +75,7 @@ function addDockerfile(
$scope.dockerfile = dockerfile;
MDC.state.dockerfile = dockerfile;
return;
}
}
});

$scope.closeDockerFileInput = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ 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'"
)

//- default branch selector
label.grid-block.vertical.label(
ng-if = "NCC.state.dockerFileTab === 'compose' && $root.featureFlags.composeDefaultBranch"
ng-include = "'defaultBranchView'"
)

.grid-block.vertical.views-kubernetes-setup(
ng-if = "NCC.state.dockerFileTab === 'kubernetes'"
ng-include = "'kubernetesSetupView'"
Expand All @@ -72,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'"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.padding-xxs.small.label-sm Initial Branch
.grid-block(
auto-update = "true"
branch-selector
loading-promises-target = "editServerModal"
state = "NCC.state"
)
small.padding-xxs.small Select the first branch you want to add.
38 changes: 27 additions & 11 deletions client/directives/components/newContainer/newContainerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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 () {
Expand Down
1 change: 1 addition & 0 deletions client/services/featureFlagService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function featureFlags(
autoIsolationSetup: false,
backup: false,
cardStatus: false,
composeDefaultBranch: false,
composeEditing: false,
composeInstance: true,
composeNav: true,
Expand Down