diff --git a/app/scripts/directives/oscFileInput.js b/app/scripts/directives/oscFileInput.js index 292c7f7e9a..29db962625 100644 --- a/app/scripts/directives/oscFileInput.js +++ b/app/scripts/directives/oscFileInput.js @@ -8,6 +8,7 @@ angular.module('openshiftConsole') model: "=", required: "=", disabled: "=ngDisabled", + readonly: "=ngReadonly", showTextArea: '=', // Hide the clear value link. hideClear: '=?', diff --git a/app/scripts/directives/oscRouting.js b/app/scripts/directives/oscRouting.js index 17db10afe6..d14f7fa66f 100644 --- a/app/scripts/directives/oscRouting.js +++ b/app/scripts/directives/oscRouting.js @@ -30,7 +30,8 @@ angular.module("openshiftConsole") * An expression that will disable the form (default: false) */ .directive("oscRouting", - function(Constants, + function($filter, + Constants, DNS1123_SUBDOMAIN_VALIDATION) { return { require: '^form', @@ -40,7 +41,7 @@ angular.module("openshiftConsole") services: "=", showNameInput: "=", routingDisabled: "=", - hostReadOnly: "=" + existingRoute: "=" }, templateUrl: 'views/directives/osc-routing.html', link: function(scope, element, attrs, formCtl) { @@ -51,12 +52,42 @@ angular.module("openshiftConsole") alternateServices: false }; + var customHostResource = { + group: 'route.openshift.io', + resource: 'routes/custom-host' + }; + scope.canICreateCustomHosts = $filter('canI')(customHostResource, 'create'); + scope.canIUpdateCustomHosts = $filter('canI')(customHostResource, 'update'); + + var canISetCustomHost = function() { + if (scope.existingRoute) { + return scope.canIUpdateCustomHosts; + } + + return scope.canICreateCustomHosts; + }; + + scope.isHostnameReadOnly = function() { + return !canISetCustomHost(); + }; + scope.disableWildcards = Constants.DISABLE_WILDCARD_ROUTES; - scope.disableCertificateInputs = function() { + + // Certificate updates also require custom host. + scope.areCertificateInputsReadOnly = function() { + return !canISetCustomHost(); + }; + + scope.areCertificateInputsDisabled = function() { var termination = _.get(scope, 'route.tls.termination'); return !termination || termination === 'passthrough'; }; + scope.isDestinationCACertInputDisabled = function() { + // This input only applies to reencrypt routes. + return _.get(scope, 'route.tls.termination') !== 'reencrypt'; + }; + scope.insecureTrafficOptions = [ {value: '', label: 'None'}, {value: 'Allow', label: 'Allow'}, diff --git a/app/views/directives/osc-file-input.html b/app/views/directives/osc-file-input.html index 877c158a2f..3fe44b121d 100644 --- a/app/views/directives/osc-file-input.html +++ b/app/views/directives/osc-file-input.html @@ -10,11 +10,12 @@ readonly ng-show="supportsFileUpload" ng-disabled="disabled" + ng-readonly="readonly" ng-attr-aria-describedby="{{helpText ? helpID : undefined}}"> - + Browse… - + @@ -30,11 +31,12 @@ ng-model="model" ng-required="required" ng-disabled="disabled" + ng-readonly="readonly" autocorrect="off" autocapitalize="none" spellcheck="false" ng-attr-aria-describedby="{{helpText ? helpID : undefined}}"> - Clear Value + Clear Value diff --git a/app/views/directives/osc-routing.html b/app/views/directives/osc-routing.html index 4cfd9e3bfa..feaeb2df8f 100644 --- a/app/views/directives/osc-routing.html +++ b/app/views/directives/osc-routing.html @@ -48,7 +48,7 @@ ng-model="route.host" ng-pattern="hostnamePattern" ng-maxlength="hostnameMaxLength" - ng-readonly="hostReadOnly" + ng-readonly="isHostnameReadOnly()" placeholder="www.example.com" autocorrect="off" autocapitalize="none" @@ -66,7 +66,7 @@ You can use *.example.com with routers that support wildcard subdomains.
-The hostname can't be changed after the route is created.
+The hostname can't be changed after the route is created.
The hostname can't be changed after the route is created.
\n" + + "The hostname can't be changed after the route is created.
\n" + "\n" + "