diff --git a/awx/ui/client/src/license/license.block.less b/awx/ui/client/src/license/license.block.less index f274b903a9..b0091d71ee 100644 --- a/awx/ui/client/src/license/license.block.less +++ b/awx/ui/client/src/license/license.block.less @@ -183,3 +183,9 @@ white-space: nowrap; overflow: hidden; } + +.License-label { + color: @field-label; + font-weight: 400; + margin-top: 10px; +} diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index 7809a664f2..799e1c6b32 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -7,11 +7,10 @@ import {N_} from "../i18n"; export default - ['Wait', '$state', '$scope', '$rootScope', - 'ProcessErrors', 'CheckLicense', 'moment','$window', - 'ConfigService', 'pendoService', 'insightsEnablementService', 'i18n', 'config', - function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, - $window, ConfigService, pendoService, insightsEnablementService, i18n, config) { + ['Wait', '$state', '$scope', '$rootScope', 'ProcessErrors', 'CheckLicense', 'moment', 'Rest', + '$window', 'ConfigService', 'pendoService', 'insightsEnablementService', 'i18n', 'config', 'GetBasePath', + function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, Rest, + $window, ConfigService, pendoService, insightsEnablementService, i18n, config, GetBasePath) { const calcDaysRemaining = function(seconds) { // calculate the number of days remaining on the license @@ -34,11 +33,10 @@ export default const reset = function() { document.getElementById('License-form').reset(); - $scope.rhPassword = null; - $scope.rhUsername = null; + $scope.rhCreds = {}; }; - const init = function(config) { + const initVars = (config) => { // license/license.partial.html compares fileName $scope.fileName = N_("No file selected."); @@ -59,8 +57,29 @@ export default pendo: true, insights: true }; + + $scope.rhCreds = {}; }; + const init = (config) => { + Rest.setUrl(`${GetBasePath('settings')}system/`); + Rest.get() + .then(({data}) => { + initVars(config); + + if (data.REDHAT_USERNAME && data.REDHAT_USERNAME !== "") { + $scope.rhCreds.username = data.REDHAT_USERNAME; + } + + if (data.REDHAT_PASSWORD && data.REDHAT_PASSWORD !== "") { + $scope.rhCreds.password = data.REDHAT_PASSWORD; + $scope.hasPasswordFromSettings = true; + } + }).catch(() => { + initVars(config); + }); + }; + init(config); $scope.getKey = function(event) { @@ -89,7 +108,7 @@ export default // HTML5 spec doesn't provide a way to customize file input css // So we hide the default input, show our own, and simulate clicks to the hidden input $scope.fakeClick = function() { - if($scope.user_is_superuser && (!$scope.rhUsername || $scope.rhUsername === '') && (!$scope.rhPassword || $scope.rhPassword === '')) { + if($scope.user_is_superuser && (!$scope.rhCreds.username || $scope.rhCreds.username === '') && (!$scope.rhCreds.password || $scope.rhCreds.password === '')) { $('#License-file').click(); } }; @@ -104,10 +123,10 @@ export default let payload = {}; if ($scope.newLicense.file) { payload = $scope.newLicense.file; - } else if ($scope.rhUsername && $scope.rhPassword) { + } else if ($scope.rhCreds.username && $scope.rhCreds.password) { payload = { - rh_password: $scope.rhPassword, - rh_username: $scope.rhUsername + rh_password: $scope.rhCreds.password, + rh_username: $scope.rhCreds.username }; } CheckLicense.post(payload, $scope.newLicense.eula) diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index 7c3e5e6e4d..f7cabdee32 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -8,7 +8,7 @@
License
Valid License - Invalid License + Invalid License
@@ -94,7 +94,7 @@ 2 - Choose your license file or provide your Red Hat subscription credentials, agree to the End User License Agreement, and click submit. + Choose your license file or provide your Red Hat customer credentials, agree to the End User License Agreement, and click submit.
@@ -108,7 +108,7 @@
Upload a license file
- Browse + Browse {{fileName|translate}}
@@ -121,15 +121,26 @@
-
Provide your Red Hat subscription credentials
+
Provide your Red Hat customer credentials
- - + +
- - + +
+ + + +
+
+ + + + +
+
@@ -167,7 +178,7 @@
- + Save successful! Invalid License - Save unsuccessful
diff --git a/awx/ui/client/src/license/license.route.js b/awx/ui/client/src/license/license.route.js index 98ba25d79c..430da0174e 100644 --- a/awx/ui/client/src/license/license.route.js +++ b/awx/ui/client/src/license/license.route.js @@ -17,30 +17,31 @@ export default { ncyBreadcrumb: { label: N_('LICENSE') }, - onEnter: ['$state', 'ConfigService', (state, configService) => { - return configService.getConfig() - .then(config => { - if (_.get(config, 'license_info.license_type') === 'open') { - return state.go('setup'); - } - }); - }], + onEnter: ['$state', 'ConfigService', (state, configService) => { + return configService.getConfig() + .then(config => { + if (_.get(config, 'license_info.license_type') === 'open') { + return state.go('setup'); + } + }); + }], resolve: { features: ['CheckLicense', '$rootScope', function(CheckLicense, $rootScope) { if($rootScope.licenseMissing === undefined){ return CheckLicense.notify(); } - - }], + } + ], config: ['ConfigService', 'CheckLicense', '$rootScope', function(ConfigService, CheckLicense, $rootScope) { ConfigService.delete(); - return ConfigService.getConfig() - .then(function(config){ - $rootScope.licenseMissing = (CheckLicense.valid(config.license_info) === false) ? true : false; - return config; - }); - }] + return ConfigService.getConfig() + .then(function(config){ + $rootScope.licenseMissing = (CheckLicense.valid(config.license_info) === false) ? true : false; + return config; + }); + } + ] }, };