Skip to content

Commit 9c67b86

Browse files
committed
Show checkbox for secure routes rather than advanced options
1 parent 644d949 commit 9c67b86

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

app/scripts/directives/oscRouting.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,29 @@ angular.module("openshiftConsole")
123123
// Show a warning if previously-set certificates won't be used because
124124
// the TLS termination is now incompatible.
125125
scope.$watch('route.tls.termination', function() {
126-
if (_.get(scope, 'route.tls.termination')) {
127-
// If editing a route with TLS termination already set, expand the secure route options.
128-
scope.showSecureRouteOptions = true;
129-
}
126+
scope.secureRoute = !!_.get(scope, 'route.tls.termination');
130127
scope.showCertificatesNotUsedWarning = showCertificateWarning();
131128
});
132129

130+
var previousTermination;
131+
scope.$watch('secureRoute', function(newValue, oldValue) {
132+
if (newValue === oldValue) {
133+
return;
134+
}
135+
136+
var termination = _.get(scope, 'route.tls.termination');
137+
if (!scope.securetRoute && termination) {
138+
// Remember previous value if user switches back to secure.
139+
previousTermination = termination;
140+
delete scope.route.tls.termination;
141+
}
142+
143+
if (scope.secureRoute && !termination) {
144+
// Restore previous termination value or default to edge if no previous value.
145+
_.set(scope, 'route.tls.termination', previousTermination || 'edge');
146+
}
147+
});
148+
133149
scope.addAlternateService = function() {
134150
scope.route.alternateServices = scope.route.alternateServices || [];
135151
var firstUnselected = _.find(scope.services, function(service) {

app/views/directives/osc-routing.html

+8-13
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,20 @@ <h3>Alternate Services</h3>
150150
</div>
151151
</div>
152152

153-
<div>
154-
<a href=""
155-
ng-click="showSecureRouteOptions = true"
156-
ng-show="!showSecureRouteOptions">Show options for secured routes</a>
157-
</div>
158-
159-
<div ng-show="showSecureRouteOptions">
160-
<h3>Route Type</h3>
161-
<div>
162-
<span class="help-block">
163-
Routes can be secured using several TLS termination types for serving certificates.
164-
</span>
153+
<div class="checkbox">
154+
<label>
155+
<input type="checkbox" ng-model="secureRoute" id="secure-route">Secure route
156+
</label>
157+
<div class="help-block">
158+
Routes can be secured using several TLS termination types for serving certificates.
165159
</div>
160+
</div>
166161

162+
<div ng-show="secureRoute">
167163
<!-- TLS Termination -->
168164
<div class="form-group">
169165
<label>TLS Termination</label>
170166
<select ng-model="route.tls.termination" class="form-control">
171-
<option value="">None</option>
172167
<option value="edge">Edge</option>
173168
<option value="passthrough">Passthrough</option>
174169
<option value="reencrypt">Re-encrypt</option>

dist/scripts/scripts.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -8946,7 +8946,14 @@ var f = function() {
89468946
return !!a.route.tls && ((!a.route.tls.termination || "passthrough" === a.route.tls.termination) && (a.route.tls.certificate || a.route.tls.key || a.route.tls.caCertificate || a.route.tls.destinationCACertificate));
89478947
};
89488948
a.$watch("route.tls.termination", function() {
8949-
_.get(a, "route.tls.termination") && (a.showSecureRouteOptions = !0), a.showCertificatesNotUsedWarning = f();
8949+
a.secureRoute = !!_.get(a, "route.tls.termination"), a.showCertificatesNotUsedWarning = f();
8950+
});
8951+
var g;
8952+
a.$watch("secureRoute", function(b, c) {
8953+
if (b !== c) {
8954+
var d = _.get(a, "route.tls.termination");
8955+
!a.securetRoute && d && (g = d, delete a.route.tls.termination), a.secureRoute && !d && _.set(a, "route.tls.termination", g || "edge");
8956+
}
89508957
}), a.addAlternateService = function() {
89518958
a.route.alternateServices = a.route.alternateServices || [];
89528959
var b = _.find(a.services, function(b) {

dist/scripts/templates.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -6908,21 +6908,19 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
69086908
"</span>\n" +
69096909
"</div>\n" +
69106910
"</div>\n" +
6911-
"<div>\n" +
6912-
"<a href=\"\" ng-click=\"showSecureRouteOptions = true\" ng-show=\"!showSecureRouteOptions\">Show options for secured routes</a>\n" +
6913-
"</div>\n" +
6914-
"<div ng-show=\"showSecureRouteOptions\">\n" +
6915-
"<h3>Route Type</h3>\n" +
6916-
"<div>\n" +
6917-
"<span class=\"help-block\">\n" +
6911+
"<div class=\"checkbox\">\n" +
6912+
"<label>\n" +
6913+
"<input type=\"checkbox\" ng-model=\"secureRoute\" id=\"secure-route\">Secure route\n" +
6914+
"</label>\n" +
6915+
"<div class=\"help-block\">\n" +
69186916
"Routes can be secured using several TLS termination types for serving certificates.\n" +
6919-
"</span>\n" +
69206917
"</div>\n" +
6918+
"</div>\n" +
6919+
"<div ng-show=\"secureRoute\">\n" +
69216920
"\n" +
69226921
"<div class=\"form-group\">\n" +
69236922
"<label>TLS Termination</label>\n" +
69246923
"<select ng-model=\"route.tls.termination\" class=\"form-control\">\n" +
6925-
"<option value=\"\">None</option>\n" +
69266924
"<option value=\"edge\">Edge</option>\n" +
69276925
"<option value=\"passthrough\">Passthrough</option>\n" +
69286926
"<option value=\"reencrypt\">Re-encrypt</option>\n" +

0 commit comments

Comments
 (0)