Skip to content

Commit 2e85c37

Browse files
committed
Add changeFrormMirrorModeToAdvanced function
1 parent f010c0b commit 2e85c37

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

client/directives/environment/modals/forms/formBuildfiles/viewFormBuildfiles.jade

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
)
1515

1616
.grid-block.shrink.align-center.well.gray.in.row-xxs(
17-
ng-if = "!SMC.state.advanced || !$root.featureFlags.dockerfileMirroring"
17+
ng-if = "(!SMC.state.advanced && !SMC.state.isMirroingDockerfile) || !$root.featureFlags.dockerfileMirroring"
1818
)
1919
svg.grid-content.row-xxs.shrink.iconnables.icons-dockerfile-lock
2020
use(
@@ -58,7 +58,7 @@
5858

5959
//- add logic for repository containers only
6060
.grid-block.shrink.align-center.well.gray.in.row-xxs(
61-
ng-if = "$root.featureFlags.dockerfileMirroring && SMC.state.advanced"
61+
ng-if = "$root.featureFlags.dockerfileMirroring && (SMC.state.advanced || SMC.state.isMirroingDockerfile)"
6262
)
6363
svg.grid-content.row-xxs.shrink.iconnables.icons-sync
6464
use(
@@ -69,10 +69,10 @@
6969
)
7070
div Mirror Dockerfile
7171
small.small(
72-
ng-if = "state.syncing"
72+
ng-if = "state.isMirroingDockerfile"
7373
)
7474
span.span.text-overflow.float-left(
75-
title = "reponame/path/to/dockerfile"
75+
ng-title = "state.contextVersion.attrs.buildDockerfilePath"
7676
) Mirroring from GitHub: reponame/path/to/dockerfile
7777
//- when there's an error
7878
//- svg.iconnables.icons-alert-alt.float-left
@@ -95,7 +95,7 @@
9595
internal-modal-helper = "changeMirrorView"
9696
) Change…
9797
small.small(
98-
ng-if = "!state.syncing"
98+
ng-if = "!state.isMirroingDockerfile"
9999
) Mirror with a Dockerfile from this repo on GitHub.
100100

101101
//- this should open the 'viewModalSync' view when syncing has not been set up

client/directives/environment/modals/modalSetupServer/setupMirroredServerModalController.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function SetupMirrorServerModalController(
2020
promisify,
2121
cardInfoTypes,
2222
OpenItems,
23+
updateDockerfileFromState,
2324
close,
2425
repo,
2526
build,
@@ -231,6 +232,32 @@ function SetupMirrorServerModalController(
231232
});
232233
};
233234

235+
SMC.changeFromMirrorModeToAdvanced = function () {
236+
SMC.state.advanced = true;
237+
SMC.state.isMirroingDockerfile = false;
238+
var dockerfileBody = SMC.state.dockerfile.attrs.body;
239+
return promisify(SMC.state.contextVersion, 'update')({
240+
advanced: SMC.state.advanced,
241+
buildDockerfilePath: null
242+
})
243+
.then(function () {
244+
return $q.all([
245+
promisify(SMC.state.contextVersion, 'fetch')(),
246+
SMC.openDockerfile(SMC.state, SMC.openItems)
247+
]);
248+
})
249+
.then(function () {
250+
return promisify(SMC.state.dockerfile, 'update')({
251+
json: {
252+
body: dockerfileBody
253+
}
254+
});
255+
})
256+
.then(function () {
257+
return SMC.resetStateContextVersion(SMC.state.contextVersion, false);
258+
});
259+
};
260+
234261
/**
235262
* This function determines if a tab chooser should be shown
236263
*

client/directives/environment/modals/modalSetupServer/setupServerModalController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ function SetupServerModalController(
410410

411411
SMC.isPrimaryButtonDisabled = function (serverFormInvalid) {
412412
return (
413-
(SMC.state.step === 2 && SMC.repositoryForm.$invalid) ||
413+
(SMC.state.step === 2 && SMC.repositoryForm && SMC.repositoryForm.$invalid) ||
414414
$filter('selectedStackInvalid')(SMC.state.selectedStack)
415415
);
416416
};

client/directives/environment/modals/serverModalController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ function ServerModalController(
325325
return SMC.state.promises.contextVersion
326326
.then(function (contextVersion) {
327327
// Only parse the Dockerfile info when no error has occurred
328-
if (shouldParseDockerfile && !SMC.state.advanced) {
328+
if (shouldParseDockerfile && !SMC.state.advanced) {
329329
return parseDockerfileForCardInfoFromInstance(SMC.instance, contextVersion)
330330
.then(function (data) {
331331
angular.extend(SMC, data);

0 commit comments

Comments
 (0)