-
Notifications
You must be signed in to change notification settings - Fork 902
/
editPipelineJson.module.js
54 lines (42 loc) · 1.43 KB
/
editPipelineJson.module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
import _ from 'lodash';
import {JSON_UTILITY_SERVICE} from 'core/utils/json/json.utility.service';
let angular = require('angular');
module.exports = angular.module('spinnaker.core.pipeline.config.actions.editJson', [
JSON_UTILITY_SERVICE
])
.controller('EditPipelineJsonModalCtrl', function($scope, pipeline, $uibModalInstance, jsonUtilityService) {
this.cancel = $uibModalInstance.dismiss;
function removeImmutableFields(obj) {
delete obj.name;
delete obj.application;
delete obj.index;
delete obj.id;
}
this.initialize = function() {
var pipelineCopy = _.cloneDeepWith(pipeline, function (value) {
if (value && value.$$hashKey) {
delete value.$$hashKey;
}
});
removeImmutableFields(pipelineCopy);
$scope.isStrategy = pipelineCopy.strategy || false;
$scope.command = {
pipelineJSON: jsonUtilityService.makeSortedStringFromObject(pipelineCopy),
locked: pipelineCopy.locked,
};
};
this.updatePipeline = function() {
try {
var parsed = JSON.parse($scope.command.pipelineJSON);
parsed.appConfig = parsed.appConfig || {};
removeImmutableFields(parsed);
angular.extend(pipeline, parsed);
$uibModalInstance.close();
} catch (e) {
$scope.command.invalid = true;
$scope.command.errorMessage = e.message;
}
};
this.initialize();
});