mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 13:11:19 -03:30
Merge pull request #6696 from mabashian/5554-license
Fixed license delete navigation bug
This commit is contained in:
commit
112011b813
@ -9,10 +9,10 @@ import {N_} from "../i18n";
|
||||
export default
|
||||
['Wait', '$state', '$scope', '$rootScope',
|
||||
'ProcessErrors', 'CheckLicense', 'moment','$window',
|
||||
'ConfigService', 'FeaturesService', 'pendoService', 'i18n',
|
||||
'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config',
|
||||
function( Wait, $state, $scope, $rootScope,
|
||||
ProcessErrors, CheckLicense, moment, $window, ConfigService,
|
||||
FeaturesService, pendoService, i18n){
|
||||
FeaturesService, pendoService, i18n, config){
|
||||
|
||||
var calcDaysRemaining = function(seconds){
|
||||
// calculate the number of days remaining on the license
|
||||
@ -38,18 +38,13 @@ export default
|
||||
// license/license.partial.html compares fileName
|
||||
$scope.fileName = N_("No file selected.");
|
||||
$scope.title = $rootScope.licenseMissing ? ("Tower " + i18n._("License")) : i18n._("License Management");
|
||||
Wait('start');
|
||||
ConfigService.delete();
|
||||
ConfigService.getConfig().then(function(config){
|
||||
$scope.license = config;
|
||||
$scope.license.version = config.version.split('-')[0];
|
||||
$scope.time = {};
|
||||
$scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining);
|
||||
$scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date);
|
||||
$scope.valid = CheckLicense.valid($scope.license.license_info);
|
||||
$scope.compliant = $scope.license.license_info.compliant;
|
||||
Wait('stop');
|
||||
});
|
||||
$scope.license = config;
|
||||
$scope.license.version = config.version.split('-')[0];
|
||||
$scope.time = {};
|
||||
$scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining);
|
||||
$scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date);
|
||||
$scope.valid = CheckLicense.valid($scope.license.license_info);
|
||||
$scope.compliant = $scope.license.license_info.compliant;
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<form id="License-form" name="license">
|
||||
<form id="License-form" name="uploadlicense">
|
||||
<div class="License-subTitleText prepend-asterisk"> <translate>License File</translate></div>
|
||||
<div class="input-group License-file--container">
|
||||
<span class="btn btn-primary" ng-click="fakeClick()" translate>Browse</span>
|
||||
|
||||
@ -24,6 +24,15 @@ export default {
|
||||
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;
|
||||
});
|
||||
}]
|
||||
},
|
||||
};
|
||||
|
||||
@ -5,7 +5,8 @@ describe('Controller: LicenseController', () => {
|
||||
let scope,
|
||||
LicenseController,
|
||||
ConfigService,
|
||||
ProcessErrors;
|
||||
ProcessErrors,
|
||||
config;
|
||||
|
||||
beforeEach(angular.mock.module('Tower'));
|
||||
beforeEach(angular.mock.module('license', ($provide) => {
|
||||
@ -14,40 +15,33 @@ describe('Controller: LicenseController', () => {
|
||||
'delete'
|
||||
]);
|
||||
|
||||
ConfigService.getConfig.and.returnValue({
|
||||
then: function(callback){
|
||||
return callback({
|
||||
license_info: {
|
||||
time_remaining: 1234567 // seconds
|
||||
},
|
||||
version: '3.1.0-devel'
|
||||
});
|
||||
}
|
||||
});
|
||||
config = {
|
||||
license_info: {
|
||||
time_remaining: 1234567 // seconds
|
||||
},
|
||||
version: '3.1.0-devel'
|
||||
};
|
||||
|
||||
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
||||
|
||||
$provide.value('ConfigService', ConfigService);
|
||||
$provide.value('ProcessErrors', ProcessErrors);
|
||||
$provide.value('config', config);
|
||||
}));
|
||||
|
||||
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_) => {
|
||||
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_, _config_) => {
|
||||
scope = $rootScope.$new();
|
||||
ConfigService = _ConfigService_;
|
||||
ProcessErrors = _ProcessErrors_;
|
||||
config = _config_;
|
||||
LicenseController = $controller('licenseController', {
|
||||
$scope: scope,
|
||||
ConfigService: ConfigService,
|
||||
ProcessErrors: ProcessErrors
|
||||
ProcessErrors: ProcessErrors,
|
||||
config: config
|
||||
});
|
||||
}));
|
||||
|
||||
// Suites
|
||||
it('should GET a config object on initialization', ()=>{
|
||||
expect(ConfigService.delete).toHaveBeenCalled();
|
||||
expect(ConfigService.getConfig).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
xit('should show correct expiration date', ()=>{
|
||||
let date = new Date(),
|
||||
options = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user