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.

@@ -302,7 +302,8 @@

Certificates

drop-zone-id="certificate-file" show-text-area="true" help-text="The PEM format certificate. Upload file by dragging & dropping, selecting it, or pasting from the clipbard." - ng-disabled="disableCertificateInputs()"> + ng-readonly="areCertificateInputsReadOnly()" + ng-disabled="areCertificateInputsDisabled()">
@@ -312,7 +313,8 @@

Certificates

drop-zone-id="private-key-file" show-text-area="true" help-text="The PEM format key. Upload file by dragging & dropping, selecting it, or pasting from the clipboard." - ng-disabled="disableCertificateInputs()"> + ng-readonly="areCertificateInputsReadOnly()" + ng-disabled="areCertificateInputsDisabled()">
@@ -322,7 +324,8 @@

Certificates

drop-zone-id="ca-certificate-file" show-text-area="true" help-text="The PEM format CA certificate. Upload file by dragging & dropping, selecting it, or pasting from the clipboard." - ng-disabled="disableCertificateInputs()"> + ng-readonly="areCertificateInputsReadOnly()" + ng-disabled="areCertificateInputsDisabled()">
@@ -332,7 +335,8 @@

Certificates

show-text-area="true" drop-zone-id="dest-ca-certificate-file" help-text="The PEM format CA certificate to validate the endpoint certificate for re-encrypt termination. Upload file by dragging & dropping, selecting it, or pasting from the clipboard." - ng-disabled="route.tls.termination !== 'reencrypt'"> + ng-readonly="areCertificateInputsReadOnly()" + ng-disabled="isDestinationCACertInputDisabled()"> diff --git a/app/views/edit/route.html b/app/views/edit/route.html index f8e6c97326..789ee800f1 100644 --- a/app/views/edit/route.html +++ b/app/views/edit/route.html @@ -22,7 +22,7 @@

Edit Route {{routeName}}

model="routing" services="services" show-name-input="false" - host-read-only="true"> + existing-route="true">
\n" + "
\n" + - "\n" + + "\n" + "\n" + - "\n" + + "\n" + "Browse…\n" + - "\n" + + "\n" + "\n" + "\n" + "
\n" + @@ -7837,9 +7837,9 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "There was an error reading the file. Please copy the file content into the text area.\n" + "
\n" + - "\n" + - "Clear Value\n" + + "Clear Value\n" + "
" ); @@ -8157,7 +8157,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "\n" + "\n" + - "\n" + + "\n" + "\n" + "
\n" + "\n" + @@ -8170,7 +8170,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "You can use *.example.com with routers that support wildcard subdomains.\n" + "\n" + "

\n" + - "

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" + "
\n" + "
\n" + @@ -8352,22 +8352,22 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "
\n" + "\n" + - "\n" + + "\n" + "\n" + "
\n" + "
\n" + "\n" + - "\n" + + "\n" + "\n" + "
\n" + "
\n" + "\n" + - "\n" + + "\n" + "\n" + "
\n" + "
\n" + "\n" + - "\n" + + "\n" + "\n" + "\n" + "
\n" + @@ -10119,7 +10119,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "
\n" + "
\n" + - "\n" + + "\n" + "\n" + "
\n" + "\n" +