Skip to content

Commit a3c0ced

Browse files
committed
Allow EnvFrom Prefix
Opened envFrom to allow prefix input.
1 parent bae09d0 commit a3c0ced

File tree

4 files changed

+56
-10
lines changed

4 files changed

+56
-10
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/views/directives/edit-environment-from.html

+25-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
</div>
2424
<div ng-if="entry.configMapRef.name || entry.secretRef.name" class="faux-form-control readonly">
2525
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>
26+
<span ng-if="entry.prefix">prefixed</span>
27+
<span ng-if="entry.configMapRef.name">config map
28+
<span ng-if="entry.prefix">"{{entry.prefix}}"</span>
29+
{{entry.configMapRef.name}}</span>
30+
<span ng-if="entry.secretRef.name">secret
31+
<span ng-if="entry.prefix">"{{entry.prefix}}"</span>
32+
{{entry.secretRef.name}}</span>
2833
</div>
2934
</div>
3035

@@ -48,6 +53,16 @@
4853
</ui-select>
4954
</div>
5055
</div>
56+
57+
<div ng-if="!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions() && (entry.prefix || entry.addPrefix)">
58+
<label for="envfrom-prefix-{{$index}}" class="sr-only">Prefix</label>
59+
<input type="text"
60+
class="form-control"
61+
placeholder="Add prefix"
62+
id="envfrom-prefix-{{$index}}"
63+
name="envfrom-prefix-{{$index}}"
64+
ng-model="entry.prefix"/>
65+
</div>
5166
</div>
5267

5368
<div ng-if="!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasEntries()" class="environment-from-editor-button">
@@ -66,11 +81,17 @@
6681
aria-label="Delete row"
6782
ng-click="$ctrl.deleteEntry($index, 1)"></a>
6883
</div>
69-
<div class="environment-from-view-details">
84+
<div class="environment-from-view-details" ng-if="entry.selectedEnvFrom">
7085
<a
7186
href=""
72-
ng-if="entry.selectedEnvFrom"
7387
ng-click="$ctrl.viewOverlayPanel(entry.selectedEnvFrom)">View Details</a>
88+
<span ng-if="!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions()">
89+
<span class="action-divider" aria-hidden="true">&nbsp;|&nbsp;</span>
90+
<a
91+
href=""
92+
ng-click="entry.addPrefix = !entry.addPrefix; $ctrl.removePrefix(entry)">
93+
{{entry.prefix || entry.addPrefix ? "Remove" : "Add"}} Prefix</a>
94+
</span>
7495
</div>
7596
</div>
7697

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

+18-4
Original file line numberDiff line numberDiff line change
@@ -6711,8 +6711,13 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
67116711
"</div>\n" +
67126712
"<div ng-if=\"entry.configMapRef.name || entry.secretRef.name\" class=\"faux-form-control readonly\">\n" +
67136713
"Use all keys and values from\n" +
6714-
"<span ng-if=\"entry.configMapRef.name\">config map {{entry.configMapRef.name}}</span>\n" +
6715-
"<span ng-if=\"entry.secretRef.name\">secret {{entry.secretRef.name}}</span>\n" +
6714+
"<span ng-if=\"entry.prefix\">prefixed</span>\n" +
6715+
"<span ng-if=\"entry.configMapRef.name\">config map\n" +
6716+
"<span ng-if=\"entry.prefix\">\"{{entry.prefix}}\"</span>\n" +
6717+
"{{entry.configMapRef.name}}</span>\n" +
6718+
"<span ng-if=\"entry.secretRef.name\">secret\n" +
6719+
"<span ng-if=\"entry.prefix\">\"{{entry.prefix}}\"</span>\n" +
6720+
"{{entry.secretRef.name}}</span>\n" +
67166721
"</div>\n" +
67176722
"</div>\n" +
67186723
"<div ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions()\">\n" +
@@ -6730,13 +6735,22 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
67306735
"</ui-select>\n" +
67316736
"</div>\n" +
67326737
"</div>\n" +
6738+
"<div ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions() && (entry.prefix || entry.addPrefix)\">\n" +
6739+
"<label for=\"envfrom-prefix-{{$index}}\" class=\"sr-only\">Prefix</label>\n" +
6740+
"<input type=\"text\" class=\"form-control\" placeholder=\"Add prefix\" id=\"envfrom-prefix-{{$index}}\" name=\"envfrom-prefix-{{$index}}\" ng-model=\"entry.prefix\"/>\n" +
6741+
"</div>\n" +
67336742
"</div>\n" +
67346743
"<div ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasEntries()\" class=\"environment-from-editor-button\">\n" +
67356744
"<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" +
67366745
"<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" +
67376746
"</div>\n" +
6738-
"<div class=\"environment-from-view-details\">\n" +
6739-
"<a href=\"\" ng-if=\"entry.selectedEnvFrom\" ng-click=\"$ctrl.viewOverlayPanel(entry.selectedEnvFrom)\">View Details</a>\n" +
6747+
"<div class=\"environment-from-view-details\" ng-if=\"entry.selectedEnvFrom\">\n" +
6748+
"<a href=\"\" ng-click=\"$ctrl.viewOverlayPanel(entry.selectedEnvFrom)\">View Details</a>\n" +
6749+
"<span ng-if=\"!$ctrl.isEnvFromReadonly(entry) && $ctrl.hasOptions()\">\n" +
6750+
"<span class=\"action-divider\" aria-hidden=\"true\">&nbsp;|&nbsp;</span>\n" +
6751+
"<a href=\"\" ng-click=\"entry.addPrefix = !entry.addPrefix; $ctrl.removePrefix(entry)\">\n" +
6752+
"{{entry.prefix || entry.addPrefix ? \"Remove\" : \"Add\"}} Prefix</a>\n" +
6753+
"</span>\n" +
67406754
"</div>\n" +
67416755
"</div>\n" +
67426756
"<div class=\"environment-from-entry form-group\" ng-if=\"!$ctrl.isEnvFromReadonly() && $ctrl.hasOptions()\">\n" +

0 commit comments

Comments
 (0)