Skip to content

Commit fe5fdfe

Browse files
Merge pull request #2378 from cdcabrera/issue-envfrom-reveal
Automatic merge from submit-queue. EnvFrom reveal/hide secrets within display modal Reveal and hide secret value display within the EnvFrom modal. Related to issue #2182 ![31894776-594d38c0-b7dd-11e7-89b2-ae614d5a5d6e](https://user-images.githubusercontent.com/3761375/32013910-8ee61cbe-b98a-11e7-97df-f147f35037ec.gif)
2 parents 39494d0 + 782f6e6 commit fe5fdfe

File tree

4 files changed

+84
-49
lines changed

4 files changed

+84
-49
lines changed

app/scripts/directives/editEnvironmentFrom.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'$attrs',
66
'$filter',
77
'keyValueEditorUtils',
8+
'SecretsService',
89
EditEnvironmentFrom
910
],
1011
bindings: {
@@ -17,7 +18,8 @@
1718

1819
function EditEnvironmentFrom($attrs,
1920
$filter,
20-
utils) {
21+
utils,
22+
SecretsService) {
2123
var ctrl = this;
2224
var canI = $filter('canI');
2325
var humanizeKind = $filter('humanizeKind');
@@ -26,11 +28,18 @@
2628
ctrl.setFocusClass = 'edit-environment-from-set-focus-' + uniqueId;
2729

2830
ctrl.viewOverlayPanel = function(entry) {
31+
ctrl.decodedData = entry.data;
2932
ctrl.overlayPaneEntryDetails = entry;
33+
34+
if (entry.kind === 'Secret') {
35+
ctrl.decodedData = SecretsService.decodeSecretData(entry.data);
36+
}
37+
3038
ctrl.overlayPanelVisible = true;
3139
};
3240

3341
ctrl.closeOverlayPanel = function() {
42+
ctrl.showSecret = false;
3443
ctrl.overlayPanelVisible = false;
3544
};
3645

app/views/directives/edit-environment-from.html

+20-4
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,16 @@
129129

130130
<overlay-panel class="add-config-to-application" show-panel="$ctrl.overlayPanelVisible" show-close="true" handle-close="$ctrl.closeOverlayPanel">
131131
<div class="dialog-title">
132-
<h3>Value Details</h3>
132+
<h3>{{$ctrl.overlayPaneEntryDetails.kind | humanizeKind : true}} Details</h3>
133133
</div>
134134
<div class="modal-body">
135135
<h4>{{$ctrl.overlayPaneEntryDetails.metadata.name}}
136-
<small class="muted">&ndash; {{$ctrl.overlayPaneEntryDetails.kind | humanizeKind : true}}</small></h4>
136+
<small ng-if="$ctrl.overlayPaneEntryDetails.kind === 'Secret'" class="mar-left-sm">
137+
<a href=""
138+
role="button"
139+
ng-click="$ctrl.showSecret = !$ctrl.showSecret">{{$ctrl.showSecret ? "Hide" : "Reveal"}} Secret</a>
140+
</small>
141+
</h4>
137142

138143
<div ng-if="!($ctrl.overlayPaneEntryDetails.data | size)" class="empty-state-message text-center">
139144
The {{$ctrl.overlayPaneEntryDetails.kind | humanizeKind}} has no properties.
@@ -142,7 +147,7 @@ <h4>{{$ctrl.overlayPaneEntryDetails.metadata.name}}
142147
<div ng-if="$ctrl.overlayPaneEntryDetails.data | size" class="table-responsive scroll-shadows-horizontal">
143148
<table class="table table-bordered table-bordered-columns config-map-table key-value-table">
144149
<tbody>
145-
<tr ng-repeat="(prop, value) in $ctrl.overlayPaneEntryDetails.data">
150+
<tr ng-repeat="(prop, value) in $ctrl.decodedData">
146151
<td class="key">{{prop}}</td>
147152
<td class="value">
148153
<truncate-long-text
@@ -153,7 +158,18 @@ <h4>{{$ctrl.overlayPaneEntryDetails.metadata.name}}
153158
expandable="true">
154159
</truncate-long-text>
155160

156-
<span ng-if="$ctrl.overlayPaneEntryDetails.kind === 'Secret'">&#42;&#42;&#42;&#42;&#42;</span>
161+
<span ng-if="!$ctrl.showSecret && $ctrl.overlayPaneEntryDetails.kind === 'Secret'">&#42;&#42;&#42;&#42;&#42;</span>
162+
<div ng-if="$ctrl.showSecret && $ctrl.overlayPaneEntryDetails.kind === 'Secret'">
163+
<truncate-long-text
164+
content="value"
165+
limit="50"
166+
newline-limit="2"
167+
expandable="true">
168+
</truncate-long-text>
169+
<div ng-if="decodedData.$$nonprintable[prop]" class="help-block">
170+
This secret value contains non-printable characters and is displayed as a Base64-encoded string.
171+
</div>
172+
</div>
157173
</td>
158174
</tr>
159175
</tbody>

dist/scripts/scripts.js

+40-40
Original file line numberDiff line numberDiff line change
@@ -9219,60 +9219,60 @@ n[e.key] = e.value;
92199219
};
92209220
} ]), function() {
92219221
angular.module("openshiftConsole").component("editEnvironmentFrom", {
9222-
controller: [ "$attrs", "$filter", "keyValueEditorUtils", function(e, t, n) {
9223-
var a = this, r = t("canI"), o = t("humanizeKind"), i = _.uniqueId();
9224-
a.setFocusClass = "edit-environment-from-set-focus-" + i, a.viewOverlayPanel = function(e) {
9225-
a.overlayPaneEntryDetails = e, a.overlayPanelVisible = !0;
9226-
}, a.closeOverlayPanel = function() {
9227-
a.overlayPanelVisible = !1;
9222+
controller: [ "$attrs", "$filter", "keyValueEditorUtils", "SecretsService", function(e, t, n, a) {
9223+
var r = this, o = t("canI"), i = t("humanizeKind"), s = _.uniqueId();
9224+
r.setFocusClass = "edit-environment-from-set-focus-" + s, r.viewOverlayPanel = function(e) {
9225+
r.decodedData = e.data, r.overlayPaneEntryDetails = e, "Secret" === e.kind && (r.decodedData = a.decodeSecretData(e.data)), r.overlayPanelVisible = !0;
9226+
}, r.closeOverlayPanel = function() {
9227+
r.showSecret = !1, r.overlayPanelVisible = !1;
92289228
};
9229-
var s = function(e, t) {
9229+
var c = function(e, t) {
92309230
e && e.push(t || {});
92319231
};
9232-
a.onAddRow = function() {
9233-
s(a.envFromEntries), n.setFocusOn("." + a.setFocusClass);
9234-
}, a.deleteEntry = function(e, t) {
9235-
a.envFromEntries && !a.envFromEntries.length || (a.envFromEntries.splice(e, t), a.envFromEntries.length || s(a.envFromEntries), a.updateEntries(a.envFromEntries), a.editEnvironmentFromForm.$setDirty());
9236-
}, a.hasOptions = function() {
9237-
return !_.isEmpty(a.envFromSelectorOptions);
9238-
}, a.hasEntries = function() {
9239-
return _.some(a.entries, function(e) {
9232+
r.onAddRow = function() {
9233+
c(r.envFromEntries), n.setFocusOn("." + r.setFocusClass);
9234+
}, r.deleteEntry = function(e, t) {
9235+
r.envFromEntries && !r.envFromEntries.length || (r.envFromEntries.splice(e, t), r.envFromEntries.length || c(r.envFromEntries), r.updateEntries(r.envFromEntries), r.editEnvironmentFromForm.$setDirty());
9236+
}, r.hasOptions = function() {
9237+
return !_.isEmpty(r.envFromSelectorOptions);
9238+
}, r.hasEntries = function() {
9239+
return _.some(r.entries, function(e) {
92409240
return _.get(e, "configMapRef.name") || _.get(e, "secretRef.name");
92419241
});
9242-
}, a.isEnvFromReadonly = function(e) {
9243-
return !0 === a.isReadonly || e && !0 === e.isReadonly;
9244-
}, a.groupByKind = function(e) {
9245-
return o(e.kind);
9246-
}, a.dragControlListeners = {
9242+
}, r.isEnvFromReadonly = function(e) {
9243+
return !0 === r.isReadonly || e && !0 === e.isReadonly;
9244+
}, r.groupByKind = function(e) {
9245+
return i(e.kind);
9246+
}, r.dragControlListeners = {
92479247
accept: function(e, t) {
92489248
return e.itemScope.sortableScope.$id === t.$id;
92499249
},
92509250
orderChanged: function() {
9251-
a.editEnvironmentFromForm.$setDirty();
9251+
r.editEnvironmentFromForm.$setDirty();
92529252
}
9253-
}, a.envFromObjectSelected = function(e, t, n) {
9254-
var r = {};
9253+
}, r.envFromObjectSelected = function(e, t, n) {
9254+
var a = {};
92559255
switch (n.kind) {
92569256
case "Secret":
9257-
r.secretRef = {
9257+
a.secretRef = {
92589258
name: n.metadata.name
9259-
}, delete a.envFromEntries[e].configMapRef;
9259+
}, delete r.envFromEntries[e].configMapRef;
92609260
break;
92619261

92629262
case "ConfigMap":
9263-
r.configMapRef = {
9263+
a.configMapRef = {
92649264
name: n.metadata.name
9265-
}, delete a.envFromEntries[e].secretRef;
9265+
}, delete r.envFromEntries[e].secretRef;
92669266
}
9267-
t.prefix && (r.prefix = t.prefix), _.assign(a.envFromEntries[e], r), a.updateEntries(a.envFromEntries);
9268-
}, a.updateEntries = function(e) {
9269-
a.entries = _.filter(e, function(e) {
9267+
t.prefix && (a.prefix = t.prefix), _.assign(r.envFromEntries[e], a), r.updateEntries(r.envFromEntries);
9268+
}, r.updateEntries = function(e) {
9269+
r.entries = _.filter(e, function(e) {
92709270
return e.secretRef || e.configMapRef;
92719271
});
92729272
};
9273-
var c = function() {
9273+
var l = function() {
92749274
var e = {}, t = {};
9275-
a.envFromEntries = a.entries || [], a.envFromEntries.length || s(a.envFromEntries), _.each(a.envFromSelectorOptions, function(n) {
9275+
r.envFromEntries = r.entries || [], r.envFromEntries.length || c(r.envFromEntries), _.each(r.envFromSelectorOptions, function(n) {
92769276
switch (n.kind) {
92779277
case "ConfigMap":
92789278
e[n.metadata.name] = n;
@@ -9281,18 +9281,18 @@ break;
92819281
case "Secret":
92829282
t[n.metadata.name] = n;
92839283
}
9284-
}), _.each(a.envFromEntries, function(n) {
9285-
var a, o;
9286-
if (n.configMapRef && (a = "configMapRef", o = "configmaps"), n.secretRef && (a = "secretRef", o = "secrets"), a && o) {
9284+
}), _.each(r.envFromEntries, function(n) {
9285+
var a, r;
9286+
if (n.configMapRef && (a = "configMapRef", r = "configmaps"), n.secretRef && (a = "secretRef", r = "secrets"), a && r) {
92879287
var i = n[a].name;
9288-
n.configMapRef && i in e && (n.selectedEnvFrom = e[i]), n.secretRef && i in t && (n.selectedEnvFrom = t[i]), r(o, "get") || (n.isReadonly = !0);
9288+
n.configMapRef && i in e && (n.selectedEnvFrom = e[i]), n.secretRef && i in t && (n.selectedEnvFrom = t[i]), o(r, "get") || (n.isReadonly = !0);
92899289
}
92909290
});
92919291
};
9292-
a.$onInit = function() {
9293-
c(), "cannotDelete" in e && (a.cannotDeleteAny = !0), "cannotSort" in e && (a.cannotSort = !0), "showHeader" in e && (a.showHeader = !0), a.envFromEntries && !a.envFromEntries.length && s(a.envFromEntries);
9294-
}, a.$onChanges = function(e) {
9295-
(e.entries || e.envFromSelectorOptions) && c();
9292+
r.$onInit = function() {
9293+
l(), "cannotDelete" in e && (r.cannotDeleteAny = !0), "cannotSort" in e && (r.cannotSort = !0), "showHeader" in e && (r.showHeader = !0), r.envFromEntries && !r.envFromEntries.length && c(r.envFromEntries);
9294+
}, r.$onChanges = function(e) {
9295+
(e.entries || e.envFromSelectorOptions) && l();
92969296
};
92979297
} ],
92989298
bindings: {

dist/scripts/templates.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -6770,23 +6770,33 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
67706770
"</div>\n" +
67716771
"<overlay-panel class=\"add-config-to-application\" show-panel=\"$ctrl.overlayPanelVisible\" show-close=\"true\" handle-close=\"$ctrl.closeOverlayPanel\">\n" +
67726772
"<div class=\"dialog-title\">\n" +
6773-
"<h3>Value Details</h3>\n" +
6773+
"<h3>{{$ctrl.overlayPaneEntryDetails.kind | humanizeKind : true}} Details</h3>\n" +
67746774
"</div>\n" +
67756775
"<div class=\"modal-body\">\n" +
67766776
"<h4>{{$ctrl.overlayPaneEntryDetails.metadata.name}}\n" +
6777-
"<small class=\"muted\">&ndash; {{$ctrl.overlayPaneEntryDetails.kind | humanizeKind : true}}</small></h4>\n" +
6777+
"<small ng-if=\"$ctrl.overlayPaneEntryDetails.kind === 'Secret'\" class=\"mar-left-sm\">\n" +
6778+
"<a href=\"\" role=\"button\" ng-click=\"$ctrl.showSecret = !$ctrl.showSecret\">{{$ctrl.showSecret ? \"Hide\" : \"Reveal\"}} Secret</a>\n" +
6779+
"</small>\n" +
6780+
"</h4>\n" +
67786781
"<div ng-if=\"!($ctrl.overlayPaneEntryDetails.data | size)\" class=\"empty-state-message text-center\">\n" +
67796782
"The {{$ctrl.overlayPaneEntryDetails.kind | humanizeKind}} has no properties.\n" +
67806783
"</div>\n" +
67816784
"<div ng-if=\"$ctrl.overlayPaneEntryDetails.data | size\" class=\"table-responsive scroll-shadows-horizontal\">\n" +
67826785
"<table class=\"table table-bordered table-bordered-columns config-map-table key-value-table\">\n" +
67836786
"<tbody>\n" +
6784-
"<tr ng-repeat=\"(prop, value) in $ctrl.overlayPaneEntryDetails.data\">\n" +
6787+
"<tr ng-repeat=\"(prop, value) in $ctrl.decodedData\">\n" +
67856788
"<td class=\"key\">{{prop}}</td>\n" +
67866789
"<td class=\"value\">\n" +
67876790
"<truncate-long-text ng-if=\"$ctrl.overlayPaneEntryDetails.kind === 'ConfigMap'\" content=\"value\" limit=\"50\" newline-limit=\"2\" expandable=\"true\">\n" +
67886791
"</truncate-long-text>\n" +
6789-
"<span ng-if=\"$ctrl.overlayPaneEntryDetails.kind === 'Secret'\">&#42;&#42;&#42;&#42;&#42;</span>\n" +
6792+
"<span ng-if=\"!$ctrl.showSecret && $ctrl.overlayPaneEntryDetails.kind === 'Secret'\">&#42;&#42;&#42;&#42;&#42;</span>\n" +
6793+
"<div ng-if=\"$ctrl.showSecret && $ctrl.overlayPaneEntryDetails.kind === 'Secret'\">\n" +
6794+
"<truncate-long-text content=\"value\" limit=\"50\" newline-limit=\"2\" expandable=\"true\">\n" +
6795+
"</truncate-long-text>\n" +
6796+
"<div ng-if=\"decodedData.$$nonprintable[prop]\" class=\"help-block\">\n" +
6797+
"This secret value contains non-printable characters and is displayed as a Base64-encoded string.\n" +
6798+
"</div>\n" +
6799+
"</div>\n" +
67906800
"</td>\n" +
67916801
"</tr>\n" +
67926802
"</tbody>\n" +

0 commit comments

Comments
 (0)