Use existing config service for license_type checks

This commit is contained in:
gconsidine
2017-08-01 13:36:05 -04:00
parent bdb2bbbd41
commit 214b72bb8d
5 changed files with 18 additions and 2 deletions

View File

@@ -11,12 +11,17 @@ function getTruncatedVersion () {
return version;
}
function isOpen () {
return this.get('license_info.license_type') === 'open';
}
function ConfigModel (method, resource, graft) {
BaseModel.call(this, 'config', { cache: true });
this.Constructor = ConfigModel;
this.getTruncatedVersion = getTruncatedVersion;
this.isOpen = isOpen;
return this.create(method, resource, graft);
}

View File

@@ -6,6 +6,7 @@
import {templateUrl} from '../shared/template-url/template-url.factory';
import { N_ } from '../i18n';
import _ from 'lodash';
export default {
name: 'license',
@@ -17,6 +18,12 @@ export default {
parent: 'setup',
label: N_('LICENSE')
},
onEnter: ['$state', 'ConfigService', (state, configService) => {
return configService.getConfig()
.then(config => {
return _.get(config, 'license_info.license_type') === 'open' && state.go('setup');
});
}],
resolve: {
features: ['CheckLicense', '$rootScope',
function(CheckLicense, $rootScope) {

View File

@@ -68,7 +68,7 @@
View information about this version of Ansible {{BRAND_NAME}}.
</p>
</a>
<a ui-sref="license" class="SetupItem">
<a ui-sref="license" class="SetupItem" ng-if="!isOpen">
<h4 class="SetupItem-title" translate>View Your License</h4>
<p class="SetupItem-description" translate>
View and edit your license information.

View File

@@ -1,5 +1,6 @@
import {templateUrl} from '../shared/template-url/template-url.factory';
import { N_ } from '../i18n';
import _ from 'lodash';
export default {
name: 'setup',
@@ -8,10 +9,12 @@ export default {
label: N_("SETTINGS")
},
templateUrl: templateUrl('setup-menu/setup-menu'),
controller: function(orgAdmin, $scope){
controller: function(config, orgAdmin, $scope){
$scope.isOpen = _.get(config, 'license_info.license_type') === 'open';
$scope.orgAdmin = orgAdmin;
},
resolve: {
config: ['ConfigService', config => config.getConfig()],
orgAdmin:
['$rootScope', 'ProcessErrors', 'Rest', 'GetBasePath',
function($rootScope, ProcessErrors, Rest, GetBasePath){

View File

@@ -58,6 +58,7 @@ export default function($stateProvider) {
controllerAs: state.controllerAs,
views: state.views,
parent: state.parent,
redirectTo: state.redirectTo,
// new in uiRouter 1.0
lazyLoad: state.lazyLoad,
};