mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
Merge pull request #4517 from jaredevantabor/aw-feature-fix
Adding the featureConfig promise to the feature directive
This commit is contained in:
@@ -23,15 +23,17 @@
|
|||||||
*/
|
*/
|
||||||
import featureController from './features.controller';
|
import featureController from './features.controller';
|
||||||
|
|
||||||
export default [ function() {
|
export default [ '$rootScope', function($rootScope) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
controller: featureController,
|
controller: featureController,
|
||||||
link: function (scope, element, attrs, controller){
|
link: function (scope, element, attrs, controller){
|
||||||
if(attrs.awFeature.length > 0){
|
if(attrs.awFeature.length > 0){
|
||||||
if(!controller.isFeatureEnabled(attrs.awFeature)){
|
$rootScope.featuresConfigured.promise.then(function() {
|
||||||
element.remove();
|
if(!controller.isFeatureEnabled(attrs.awFeature)){
|
||||||
}
|
element.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
describe('Directive: Features enabled/disabled', () => {
|
describe('Directive: Features enabled/disabled', () => {
|
||||||
let $compile,
|
let $compile,
|
||||||
$scope;
|
$scope,
|
||||||
|
q;
|
||||||
|
|
||||||
beforeEach(angular.mock.module('features'));
|
beforeEach(angular.mock.module('features'));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$compile_, _$rootScope_) => {
|
beforeEach(angular.mock.inject((_$compile_, _$rootScope_, $q) => {
|
||||||
$compile = _$compile_;
|
$compile = _$compile_;
|
||||||
$scope = _$rootScope_;
|
$scope = _$rootScope_;
|
||||||
|
q = $q;
|
||||||
|
|
||||||
|
$scope.featuresConfigured = q.defer();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('Removes the element if feature is disabled', () => {
|
it('Removes the element if feature is disabled', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user