Skip to content

Commit d7d4e84

Browse files
committed
Allow EnvFrom Prefix
Opened envFrom to allow prefix input.
1 parent 68b29c4 commit d7d4e84

File tree

5 files changed

+115
-31
lines changed

5 files changed

+115
-31
lines changed

app/scripts/directives/editEnvironmentFrom.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
}
8888
};
8989

90+
ctrl.removePrefix = function (entry) {
91+
delete entry.prefix;
92+
ctrl.editEnvironmentFromForm.$setDirty();
93+
};
94+
9095
ctrl.envFromObjectSelected = function(index, entry, selected) {
9196
var newEnvFrom = {};
9297

@@ -105,6 +110,10 @@
105110
break;
106111
}
107112

113+
if (entry.prefix) {
114+
newEnvFrom.prefix = entry.prefix;
115+
}
116+
108117
_.assign(ctrl.envFromEntries[index], newEnvFrom);
109118
ctrl.updateEntries(ctrl.envFromEntries);
110119
};
@@ -121,7 +130,7 @@
121130

122131
ctrl.envFromEntries = ctrl.entries || [];
123132

124-
if(!ctrl.envFromEntries.length) {
133+
if (!ctrl.envFromEntries.length) {
125134
addEntry(ctrl.envFromEntries);
126135
}
127136

app/styles/_kve.less

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@
170170
}
171171

172172
.key-value-editor .key-value-editor-input,
173-
.key-value-editor-header {
173+
.key-value-editor-header,
174+
.environment-from-editor-header {
174175
float: left;
175176
margin-bottom: 0;
176177
padding-right: 5px;

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

+67-24
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,35 @@
44
class="environment-from-entry environment-from-editor-entry-header">
55
<div class="form-group environment-from-editor-header value-header">
66
<div class="input-group">
7-
<span class="help-block">{{$ctrl.selectorPlaceholder}}</span>
7+
{{$ctrl.selectorPlaceholder}}
8+
</div>
9+
</div>
10+
<div class="form-group environment-from-editor-header value-header">
11+
<div class="input-group">
12+
Prefix
13+
<small class="pficon pficon-help"
14+
aria-hidden="true"
15+
data-toggle="tooltip"
16+
data-original-title="Optional prefix added to each environment variable name for this resource."></small>
817
</div>
918
</div>
1019
</div>
20+
21+
<div
22+
ng-if="showHeader"
23+
class="key-value-editor-entry key-value-editor-entry-header">
24+
<div class="form-group key-value-editor-header key-header">
25+
<div class="input-group">
26+
<span class="help-block">{{keyPlaceholder}}</span>
27+
</div>
28+
</div>
29+
<div class="form-group key-value-editor-header value-header">
30+
<div class="input-group">
31+
<span class="help-block">{{valuePlaceholder}}</span>
32+
</div>
33+
</div>
34+
</div>
35+
1136
<div ng-model="$ctrl.entries" class="environment-from-editor" as-sortable="$ctrl.dragControlListeners">
1237
<div
1338
class="environment-from-entry"
@@ -23,8 +48,13 @@
2348
</div>
2449
<div ng-if="entry.configMapRef.name || entry.secretRef.name" class="faux-form-control readonly">
2550
Use all keys and values from
26-
<span ng-if="entry.configMapRef.name">config map {{entry.configMapRef.name}}</span>
27-
<span ng-if="entry.secretRef.name">secret {{entry.secretRef.name}}</span>
51+
<span ng-if="entry.prefix">prefixed</span>
52+
<span ng-if="entry.configMapRef.name">config map
53+
<span ng-if="entry.prefix">"{{entry.prefix}}"</span>
54+
{{entry.configMapRef.name}}</span>
55+
<span ng-if="entry.secretRef.name">secret
56+
<span ng-if="entry.prefix">"{{entry.prefix}}"</span>
57+
{{entry.secretRef.name}}</span>
2858
</div>
2959
</div>
3060

@@ -50,27 +80,40 @@
5080
</div>
5181
</div>
5282

53-
<div ng-if="!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasEntries()" class="environment-from-editor-button">
54-
<span
55-
ng-if="!$ctrl.cannotSort && $ctrl.entries.length > 1"
56-
class="fa fa-bars sort-row"
57-
role="button"
58-
aria-label="Move row"
59-
aria-grabbed="false"
60-
as-sortable-item-handle></span>
61-
<a
62-
ng-if="!$ctrl.cannotDeleteAny"
63-
href=""
64-
class="pficon pficon-close delete-row as-sortable-item-delete"
65-
role="button"
66-
aria-label="Delete row"
67-
ng-click="$ctrl.deleteEntry($index, 1)"></a>
68-
</div>
69-
<div class="environment-from-view-details">
70-
<a
71-
href=""
72-
ng-if="entry.selectedEnvFrom"
73-
ng-click="$ctrl.viewOverlayPanel(entry.selectedEnvFrom)">View Details</a>
83+
<div class="form-group environment-from-input">
84+
<div class="environment-from-input" ng-if="!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions()">
85+
<label for="envfrom-prefix-{{$index}}" class="sr-only">Prefix</label>
86+
<input type="text"
87+
class="form-control"
88+
placeholder="Add prefix"
89+
id="envfrom-prefix-{{$index}}"
90+
name="envfrom-prefix-{{$index}}"
91+
ng-model="entry.prefix"/>
92+
</div>
93+
94+
<div ng-if="!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasEntries()" class="environment-from-editor-button">
95+
<span
96+
ng-if="!$ctrl.cannotSort && $ctrl.entries.length > 1"
97+
class="fa fa-bars sort-row"
98+
role="button"
99+
aria-label="Move row"
100+
aria-grabbed="false"
101+
as-sortable-item-handle></span>
102+
<a
103+
ng-if="!$ctrl.cannotDeleteAny"
104+
href=""
105+
class="pficon pficon-close delete-row as-sortable-item-delete"
106+
role="button"
107+
aria-label="Delete row"
108+
ng-click="$ctrl.deleteEntry($index, 1)"></a>
109+
</div>
110+
111+
<div class="environment-from-view-details">
112+
<a
113+
ng-if="entry.selectedEnvFrom"
114+
href=""
115+
ng-click="$ctrl.viewOverlayPanel(entry.selectedEnvFrom)">View Details</a>
116+
</div>
74117
</div>
75118
</div>
76119

dist/scripts/scripts.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9243,6 +9243,8 @@ return e.itemScope.sortableScope.$id === t.$id;
92439243
orderChanged: function() {
92449244
a.editEnvironmentFromForm.$setDirty();
92459245
}
9246+
}, a.removePrefix = function(e) {
9247+
delete e.prefix, a.editEnvironmentFromForm.$setDirty();
92469248
}, a.envFromObjectSelected = function(e, t, n) {
92479249
var r = {};
92489250
switch (n.kind) {
@@ -9257,7 +9259,7 @@ r.configMapRef = {
92579259
name: n.metadata.name
92589260
}, delete a.envFromEntries[e].secretRef;
92599261
}
9260-
_.assign(a.envFromEntries[e], r), a.updateEntries(a.envFromEntries);
9262+
t.prefix && (r.prefix = t.prefix), _.assign(a.envFromEntries[e], r), a.updateEntries(a.envFromEntries);
92619263
}, a.updateEntries = function(e) {
92629264
a.entries = _.filter(e, function(e) {
92639265
return e.secretRef || e.configMapRef;

dist/scripts/templates.js

+33-4
Original file line numberDiff line numberDiff line change
@@ -6700,7 +6700,25 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
67006700
"<div ng-if=\"$ctrl.showHeader\" class=\"environment-from-entry environment-from-editor-entry-header\">\n" +
67016701
"<div class=\"form-group environment-from-editor-header value-header\">\n" +
67026702
"<div class=\"input-group\">\n" +
6703-
"<span class=\"help-block\">{{$ctrl.selectorPlaceholder}}</span>\n" +
6703+
"{{$ctrl.selectorPlaceholder}}\n" +
6704+
"</div>\n" +
6705+
"</div>\n" +
6706+
"<div class=\"form-group environment-from-editor-header value-header\">\n" +
6707+
"<div class=\"input-group\">\n" +
6708+
"Prefix\n" +
6709+
"<small class=\"pficon pficon-help\" aria-hidden=\"true\" data-toggle=\"tooltip\" data-original-title=\"Optional prefix added to each environment variable name for this resource.\"></small>\n" +
6710+
"</div>\n" +
6711+
"</div>\n" +
6712+
"</div>\n" +
6713+
"<div ng-if=\"showHeader\" class=\"key-value-editor-entry key-value-editor-entry-header\">\n" +
6714+
"<div class=\"form-group key-value-editor-header key-header\">\n" +
6715+
"<div class=\"input-group\">\n" +
6716+
"<span class=\"help-block\">{{keyPlaceholder}}</span>\n" +
6717+
"</div>\n" +
6718+
"</div>\n" +
6719+
"<div class=\"form-group key-value-editor-header value-header\">\n" +
6720+
"<div class=\"input-group\">\n" +
6721+
"<span class=\"help-block\">{{valuePlaceholder}}</span>\n" +
67046722
"</div>\n" +
67056723
"</div>\n" +
67066724
"</div>\n" +
@@ -6713,8 +6731,13 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
67136731
"</div>\n" +
67146732
"<div ng-if=\"entry.configMapRef.name || entry.secretRef.name\" class=\"faux-form-control readonly\">\n" +
67156733
"Use all keys and values from\n" +
6716-
"<span ng-if=\"entry.configMapRef.name\">config map {{entry.configMapRef.name}}</span>\n" +
6717-
"<span ng-if=\"entry.secretRef.name\">secret {{entry.secretRef.name}}</span>\n" +
6734+
"<span ng-if=\"entry.prefix\">prefixed</span>\n" +
6735+
"<span ng-if=\"entry.configMapRef.name\">config map\n" +
6736+
"<span ng-if=\"entry.prefix\">\"{{entry.prefix}}\"</span>\n" +
6737+
"{{entry.configMapRef.name}}</span>\n" +
6738+
"<span ng-if=\"entry.secretRef.name\">secret\n" +
6739+
"<span ng-if=\"entry.prefix\">\"{{entry.prefix}}\"</span>\n" +
6740+
"{{entry.secretRef.name}}</span>\n" +
67186741
"</div>\n" +
67196742
"</div>\n" +
67206743
"<div ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions()\">\n" +
@@ -6733,12 +6756,18 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
67336756
"</div>\n" +
67346757
"</div>\n" +
67356758
"</div>\n" +
6759+
"<div class=\"form-group environment-from-input\">\n" +
6760+
"<div class=\"environment-from-input\" ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions()\">\n" +
6761+
"<label for=\"envfrom-prefix-{{$index}}\" class=\"sr-only\">Prefix</label>\n" +
6762+
"<input type=\"text\" class=\"form-control\" placeholder=\"Add prefix\" id=\"envfrom-prefix-{{$index}}\" name=\"envfrom-prefix-{{$index}}\" ng-model=\"entry.prefix\"/>\n" +
6763+
"</div>\n" +
67366764
"<div ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasEntries()\" class=\"environment-from-editor-button\">\n" +
67376765
"<span ng-if=\"!$ctrl.cannotSort && $ctrl.entries.length > 1\" class=\"fa fa-bars sort-row\" role=\"button\" aria-label=\"Move row\" aria-grabbed=\"false\" as-sortable-item-handle></span>\n" +
67386766
"<a ng-if=\"!$ctrl.cannotDeleteAny\" href=\"\" class=\"pficon pficon-close delete-row as-sortable-item-delete\" role=\"button\" aria-label=\"Delete row\" ng-click=\"$ctrl.deleteEntry($index, 1)\"></a>\n" +
67396767
"</div>\n" +
67406768
"<div class=\"environment-from-view-details\">\n" +
6741-
"<a href=\"\" ng-if=\"entry.selectedEnvFrom\" ng-click=\"$ctrl.viewOverlayPanel(entry.selectedEnvFrom)\">View Details</a>\n" +
6769+
"<a ng-if=\"entry.selectedEnvFrom\" href=\"\" ng-click=\"$ctrl.viewOverlayPanel(entry.selectedEnvFrom)\">View Details</a>\n" +
6770+
"</div>\n" +
67426771
"</div>\n" +
67436772
"</div>\n" +
67446773
"<div class=\"environment-from-entry form-group\" ng-if=\"!$ctrl.isEnvFromReadonly() && $ctrl.hasOptions()\">\n" +

0 commit comments

Comments
 (0)