Skip to content

Commit

Permalink
Fixes #28781 - Disable Auto attach on Host (Katello#8529)
Browse files Browse the repository at this point in the history
* Fixes #28781 - Disable Auto attach on Host

This commit does a couple of things
1) It disables auto attach setup in Simple Content Access enabled orgs.
2) It sets it auto attach status to 'Not Applicable'
3) Changed contentAccessMode=== 'org_enviroment' to
   'simpleContentAccessEnabled' when Simple Content Access is enabled.
  • Loading branch information
parthaa committed Jan 28, 2020
1 parent 0a0dc76 commit 97589ec
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/models/katello/glue/candlepin/owner.rb
Expand Up @@ -35,7 +35,7 @@ def content_access_mode
self.owner_details['contentAccessMode']
end

def golden_ticket?
def simple_content_access?
content_access_mode == "org_environment"
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/_subscription_widget.html.erb
Expand Up @@ -4,7 +4,7 @@

<% if Organization.current.blank? %>
<p class="ca"><%= _("Please select an organization to view subscription status.") %></p>
<% elsif Organization.current.golden_ticket?%>
<% elsif Organization.current.simple_content_access?%>
<div class="bastion alert alert-info">
<span translate>This organization has Simple Content Access enabled. Hosts can consume from all repositories in their Content View regardless of subscription status.
</span>
Expand Down
2 changes: 1 addition & 1 deletion engines/bastion/app/views/bastion/layouts/assets.html.erb
Expand Up @@ -18,7 +18,7 @@
angular.module('Bastion.features').value('FeatureSettings', angular.fromJson(<%= SETTINGS[:features].nil? ? {} : SETTINGS[:features].to_json.html_safe %>));
angular.module('Bastion').value('currentLocale', '<%= I18n.locale %>');
angular.module('Bastion').value('CurrentOrganization', "<%= Organization.current.id if Organization.current %>");
angular.module('Bastion').value('contentAccessMode', "<%= Organization.current.try(:content_access_mode) if Organization.current %>");
angular.module('Bastion').value('simpleContentAccessEnabled', <%= Organization.current.simple_content_access? if Organization.current %>);
angular.module('Bastion').value('foreman', tfm);
angular.module('Bastion').value('repositoryTypes', angular.fromJson('<%= Katello::RepositoryTypeManager.repository_types.values.to_json.html_safe %>'));
angular.module('Bastion').value('deleteHostOnUnregister', angular.fromJson('<%= Setting[:unregister_delete_host] %>'));
Expand Down
Expand Up @@ -12,13 +12,14 @@
* @requires SubscriptionsHelper
* @requires Notification
* @requires hostIds
* @requires simpleContentAccessEnabled
*
* @description
* A controller for providing bulk action functionality to the content hosts page.
*/
angular.module('Bastion.content-hosts').controller('ContentHostsBulkSubscriptionsModalController',
['$scope', '$location', '$uibModalInstance', 'Nutupane', 'CurrentOrganization', 'HostBulkAction', 'Subscription', 'SubscriptionsHelper', 'Notification', 'hostIds', 'contentAccessMode',
function ($scope, $location, $uibModalInstance, Nutupane, CurrentOrganization, HostBulkAction, Subscription, SubscriptionsHelper, Notification, hostIds, contentAccessMode) {
['$scope', '$location', '$uibModalInstance', 'Nutupane', 'CurrentOrganization', 'HostBulkAction', 'Subscription', 'SubscriptionsHelper', 'Notification', 'hostIds', 'simpleContentAccessEnabled',
function ($scope, $location, $uibModalInstance, Nutupane, CurrentOrganization, HostBulkAction, Subscription, SubscriptionsHelper, Notification, hostIds, simpleContentAccessEnabled) {
var success, error, params = {
'organization_id': CurrentOrganization,
'sort_order': 'ASC',
Expand All @@ -44,7 +45,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkSubscription
});
};


$scope.contentNutupane = new Nutupane(Subscription, params,
'queryPaged', {disableAutoLoad: true});
$scope.controllerName = 'katello_subscriptions';
Expand All @@ -53,7 +53,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostsBulkSubscription
$scope.contentNutupane.masterOnly = true;
$scope.contentNutupane.load();
$scope.groupedSubscriptions = {};
$scope.contentAccessMode = contentAccessMode;
$scope.simpleContentAccessEnabled = simpleContentAccessEnabled;

$scope.$watch('table.rows', function (rows) {
$scope.groupedSubscriptions = SubscriptionsHelper.groupByProductName(rows);
Expand Down
Expand Up @@ -7,19 +7,19 @@ <h4 data-block="modal-header" translate>

<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-default" ng-click="autoAttach()" ng-disabled="table.numSelected > 0 || contentAccessMode === 'org_environment'">
<button type="button" class="btn btn-default" ng-click="autoAttach()" ng-disabled="table.numSelected > 0 || simpleContentAccessEnabled">
<span translate>Auto-Attach</span>
</button>

<p class="help-text" ng-show="table.numSelected === 0 && contentAccessMode != 'org_environment'">
<p class="help-text" ng-show="table.numSelected === 0 && !simpleContentAccessEnabled">
Auto-attach available subscriptions to all selected hosts.
</p>

<p>
<div content-access-mode-banner/>
</p>

<p class="help-text" ng-show="table.numSelected > 0 && contentAccessMode != 'org_environment'">
<p class="help-text" ng-show="table.numSelected > 0 && !simpleContentAccessEnabled">
Auto-attach uses all available subscriptions, not a selected subset.
</p>
</div>
Expand Down
Expand Up @@ -141,6 +141,10 @@ angular.module('Bastion.content-hosts').controller('ContentHostDetailsController
return false;
};

$scope.autoHealOptions = function () {
return [{value: true, name: translate("Yes")}, {value: true, name: translate("No")}];
};

$scope.serviceLevels = function () {
return $scope.organization.$promise.then(function(org) {
return _.union(org.service_levels, $scope.defaultServiceLevels);
Expand Down
Expand Up @@ -8,13 +8,14 @@
* @requires Subscription
* @requires SubscriptionsHelper
* @requires Notification
* @requires simpleContentAccessEnabled
*
* @description
* Provides the functionality for the content host details action pane.
*/
angular.module('Bastion.content-hosts').controller('ContentHostSubscriptionsController',
['$scope', '$location', 'translate', 'Nutupane', 'CurrentOrganization', 'Subscription', 'Host', 'HostSubscription', 'SubscriptionsHelper', 'Notification',
function ($scope, $location, translate, Nutupane, CurrentOrganization, Subscription, Host, HostSubscription, SubscriptionsHelper, Notification) {
['$scope', '$location', 'translate', 'Nutupane', 'CurrentOrganization', 'Subscription', 'Host', 'HostSubscription', 'SubscriptionsHelper', 'Notification', 'simpleContentAccessEnabled',
function ($scope, $location, translate, Nutupane, CurrentOrganization, Subscription, Host, HostSubscription, SubscriptionsHelper, Notification, simpleContentAccessEnabled) {

var params = {
'organization_id': CurrentOrganization,
Expand All @@ -30,6 +31,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostSubscriptionsCont
$scope.nutupane.masterOnly = true;
$scope.isRemoving = false;
$scope.contextAdd = false;
$scope.simpleContentAccessEnabled = simpleContentAccessEnabled;
$scope.groupedSubscriptions = {};
$scope.$watch('table.rows', function (rows) {
$scope.groupedSubscriptions = SubscriptionsHelper.groupByProductName(rows);
Expand Down
Expand Up @@ -82,12 +82,12 @@ <h4 translate>Subscriptions</h4>
</dd>

<dt translate>Auto-Attach</dt>
<dd bst-edit-checkbox="host.subscription_facet_attributes.autoheal"
<dd ng-if= "simpleContentAccessEnabled" translate> Not Applicable </dd>
<dd ng-if= "!simpleContentAccessEnabled" bst-edit-select="host.subscription_facet_attributes.autoheal"
readonly="denied('edit_hosts', host)"
formatter="booleanToYesNo"
on-save="saveSubscriptionFacet(host)">
</dd>

</dl>

<div class="divider"></div>
Expand Down
Expand Up @@ -25,22 +25,27 @@ <h4 translate>Subscription Details</h4>

<dt translate>Auto-Attach</dt>
<dd>
<span ng-if="simpleContentAccessEnabled" translate>
Not Applicable
</span>
<div ng-if="!simpleContentAccessEnabled">
<div bst-edit-checkbox="host.subscription_facet_attributes.autoheal"
formatter="booleanToYesNo"
readonly="denied('edit_hosts', host)"
on-save="saveSubscriptionFacet(host)">
</div>
<a ng-hide="denied('edit_hosts', host)"
ng-click="autoAttachSubscriptions()"
class="btn btn-default"
ng-disabled="subscription.workingMode">
<span translate>Run Auto-Attach</span>
</a>

<a ng-hide="denied('edit_hosts', host)"
ng-click="autoAttachSubscriptions()"
ng-disabled="subscription.workingMode">
<span translate>Run Auto-Attach</span>
</a>

<span ng-show="subscription.workingMode">
<i class="fa fa-spinner inline-icon fa-spin"></i>
<span translate>Working</span>
</span>
<span ng-show="subscription.workingMode">
<i class="fa fa-spinner inline-icon fa-spin"></i>
<span translate>Working</span>
</span>
</div>
</dd>

<dt translate>Service Level</dt>
Expand Down
Expand Up @@ -2,19 +2,19 @@
* @ngdoc directive
* @name Bastion.subscriptions:contentAccessModeBanner
*
* @requires contentAccessMode
* @requires simpleContentAccessEnabled
*
* @description
* Component for showing information about content access mode (whether content is
* allowed with or without a subscription)
*/
angular.module('Bastion.subscriptions').directive('contentAccessModeBanner',
['contentAccessMode',
function (contentAccessMode) {
['simpleContentAccessEnabled',
function (simpleContentAccessEnabled) {
return {
restrict: 'AE',
controller: ['$scope', function ($scope) {
$scope.contentAccessMode = contentAccessMode;
$scope.simpleContentAccessEnabled = simpleContentAccessEnabled;
}],
templateUrl: 'subscriptions/views/content-access-mode-banner.html'
};
Expand Down
@@ -1,4 +1,4 @@
<div bst-alert="info" ng-show="contentAccessMode === 'org_environment'">
<div bst-alert="info" ng-show="simpleContentAccessEnabled">
<span translate>
This organization has Simple Content Access enabled. Hosts can consume from all repositories in their Content View regardless of subscription status.
</span>
Expand Down
@@ -1,5 +1,5 @@
describe('Controller: ContentHostsBulkSubscriptionsModalController', function() {
var $scope, $uibModalInstance, Nutupane, hostIds, CurrentOrganization, HostBulkAction, HostCollection, SubscriptionsHelper, contentAccessMode;
var $scope, $uibModalInstance, Nutupane, hostIds, CurrentOrganization, HostBulkAction, HostCollection, SubscriptionsHelper, simpleContentAccessEnabled;

beforeEach(module('Bastion.content-hosts', 'Bastion.test-mocks'));

Expand Down Expand Up @@ -60,7 +60,7 @@ describe('Controller: ContentHostsBulkSubscriptionsModalController', function()
HostBulkAction: HostBulkAction,
HostCollection: HostCollection,
SubscriptionsHelper: SubscriptionsHelper,
contentAccessMode: contentAccessMode
simpleContentAccessEnabled: simpleContentAccessEnabled
});
}));

Expand Down
Expand Up @@ -74,7 +74,8 @@ describe('Controller: ContentHostSubscriptionsController', function() {
Subscription: Subscription,
Nutupane: Nutupane,
HostSubscription: HostSubscription,
SubscriptionsHelper: SubscriptionsHelper
SubscriptionsHelper: SubscriptionsHelper,
simpleContentAccessEnabled: false
});
}));

Expand Down
Expand Up @@ -7,7 +7,7 @@ describe('Directive: contentAccessModeBanner', function() {
));

beforeEach(module(function($provide) {
$provide.value('contentAccessMode', 'org_environment');
$provide.value('simpleContentAccessEnabled', true);
}));

beforeEach(inject(function($compile, $rootScope, $httpBackend) {
Expand All @@ -21,6 +21,6 @@ describe('Directive: contentAccessModeBanner', function() {
}));

it("set content access mode on the scope", function() {
expect($scope.contentAccessMode).toEqual("org_environment");
expect($scope.simpleContentAccessEnabled).toEqual(true);
});
});

0 comments on commit 97589ec

Please sign in to comment.