-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #24429 - Module stream host bulk actions #7736
Merged
johnpmitsch
merged 9 commits into
Katello:master
from
johnpmitsch:24429_module_stream_hosts
Oct 11, 2018
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
92f99d0
Fixes #24429 - module stream bulk host actions
51d0554
Fixes #24429 - Updated for new templates
d72e446
Refs #24429 - added service
9423372
Fixes #24429 - moving to bulk hosts
802dcb1
Fixes #24429 - updated include
1248518
Fixes #24429 - UI uses bulk host actions
dbbe532
Fixes #24429 - fix bulk actions
f784c98
Fixes #24429 - re-use template
7e51248
Fixes #24429 - Removed cancel button, updated link, updated rex
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...on_katello/app/assets/javascripts/bastion_katello/common/module-stream-actions.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc service | ||
* @name Bastion.common.service:ModuleStreamActions | ||
* | ||
* @description | ||
* Provides common list of actions for module streams | ||
*/ | ||
|
||
function ModuleStreamActions(translate) { | ||
this.getActions = function() { | ||
return [ | ||
{ action: 'enable', description: translate("Enable")}, | ||
{ action: 'disable', description: translate("Disable")}, | ||
{ action: 'install', description: translate("Install")}, | ||
{ action: 'update', description: translate("Update")}, | ||
{ action: 'remove', description: translate("Remove")} | ||
]; | ||
}; | ||
} | ||
|
||
angular.module('Bastion.common').service('ModuleStreamActions', ModuleStreamActions); | ||
ModuleStreamActions.$inject = ['translate']; | ||
})(); |
60 changes: 60 additions & 0 deletions
60
.../bastion_katello/content-hosts/bulk/content-hosts-bulk-module-streams-modal.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @ngdoc object | ||
* @name Bastion.content-hosts.controller:ContentHostsBulkModuleStreamsModalController | ||
* | ||
* @requires $scope | ||
* @requires $window | ||
* @requires $timeout | ||
* @requires $uibModalInstance | ||
* @requires HostBulkAction | ||
* @requires Nutupane | ||
* @requires BastionConfig | ||
* @requires hostIds | ||
* @requires ModuleStreamActions | ||
* | ||
* @description | ||
* Provides the functionality for the content host module streams list and actions. | ||
*/ | ||
|
||
angular.module('Bastion.content-hosts').controller('ContentHostsBulkModuleStreamsModalController', | ||
['$scope', '$window', '$timeout', '$uibModalInstance', 'HostBulkAction', 'Nutupane', 'BastionConfig', | ||
'hostIds', 'ModuleStreamActions', | ||
function ($scope, $window, $timeout, $uibModalInstance, HostBulkAction, Nutupane, | ||
BastionConfig, hostIds, ModuleStreamActions) { | ||
$scope.cancel = function () { | ||
$uibModalInstance.dismiss('cancel'); | ||
}; | ||
|
||
$scope.moduleStreamActions = ModuleStreamActions.getActions(); | ||
|
||
$scope.working = false; | ||
|
||
$scope.moduleStreamsNutupane = new Nutupane(HostBulkAction, hostIds, 'moduleStreams'); | ||
$scope.controllerName = 'katello_module_streams'; | ||
$scope.moduleStreamsNutupane.masterOnly = true; | ||
$scope.table = $scope.moduleStreamsNutupane.table; | ||
$scope.remoteExecutionPresent = BastionConfig.remoteExecutionPresent; | ||
$scope.remoteExecutionByDefault = BastionConfig.remoteExecutionByDefault; | ||
|
||
$scope.moduleStreamActionFormValues = { | ||
authenticityToken: $window.AUTH_TOKEN.replace(/"/g, ''), | ||
remoteAction: 'module_stream_action', | ||
search: hostIds.included.search | ||
}; | ||
|
||
if (hostIds.included.ids) { | ||
$scope.moduleStreamActionFormValues.hostIds = hostIds.included.ids.join(','); | ||
} | ||
|
||
$scope.performViaRemoteExecution = function(moduleSpec, actionType) { | ||
$scope.working = true; | ||
$scope.moduleStreamActionFormValues.moduleSpec = moduleSpec; | ||
$scope.moduleStreamActionFormValues.moduleStreamAction = actionType; | ||
|
||
$timeout(function () { | ||
angular.element('#moduleStreamActionForm').submit(); | ||
}, 0); | ||
}; | ||
} | ||
] | ||
); |
70 changes: 70 additions & 0 deletions
70
...ipts/bastion_katello/content-hosts/bulk/views/content-host-bulk-module-streams-modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<div data-extend-template="components/views/bst-modal.html"> | ||
<h4 data-block="modal-header">Content Host Module Stream Management</h4> | ||
<div data-block="modal-body"> | ||
<div bst-feature-flag="remote_actions"> | ||
<h3 translate ng-hide="selectedModuleStreamOption === 'available'">Available Module Streams</h3> | ||
</div> | ||
|
||
<form id="moduleStreamActionForm" method="post" action="/katello/remote_execution"> | ||
<input type="hidden" name="remote_action" ng-value="moduleStreamActionFormValues.remoteAction"/> | ||
<input type="hidden" name="module_stream_action" ng-value="moduleStreamActionFormValues.moduleStreamAction"/> | ||
<input type="hidden" name="module_spec" ng-value="moduleStreamActionFormValues.moduleSpec"/> | ||
<input type="hidden" name="scoped_search" ng-value="errataActionFormValues.search"/> | ||
<input type="hidden" name="host_ids" ng-value="moduleStreamActionFormValues.hostIds"/> | ||
<input type="hidden" name="customize" ng-value="moduleStreamActionFormValues.customize"/> | ||
<input type="hidden" name="authenticity_token" ng-value="moduleStreamActionFormValues.authenticityToken"/> | ||
</form> | ||
|
||
<div data-extend-template="layouts/partials/table.html"> | ||
|
||
<span data-block="no-rows-message" translate> | ||
There are no Module Streams to display. | ||
</span> | ||
|
||
<span data-block="no-search-results-message" translate> | ||
Your search returned zero Module Streams. | ||
</span> | ||
<div data-block="table"> | ||
<table class="table table-striped table-bordered" ng-class="{'table-mask': table.working}"> | ||
<thead> | ||
<tr bst-table-head> | ||
<th bst-table-column translate>Name</th> | ||
<th bst-table-column translate>Stream</th> | ||
<th bst-table-column translate>Actions</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<tr bst-table-row ng-repeat="module in table.rows"> | ||
<td bst-table-cell> | ||
<a href="/module_streams?search=module_spec%3D{{ module.module_spec }}"> | ||
{{ module.name }}</a></td> | ||
<td bst-table-cell>{{ module.stream }}</td> | ||
<td bst-table-cell> | ||
<div class="dropdown" ng-hide="!remoteExecutionPresent || denied('edit_content_hosts', contentHost)"> | ||
<button class="btn btn-default dropdown-toggle" ng-disabled="$scope.working" type="button" id="dropdownMenu1" data-toggle="dropdown"> Actions | ||
<span class="caret"></span> | ||
</button> | ||
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> | ||
<li role="presentation"> | ||
<label class="drop-down-check-box"> | ||
<input id="customize" name="customize" ng-model="moduleStreamActionFormValues.customize" type="checkbox"/> | ||
<span translate>Customize</span> | ||
</label> | ||
</li> | ||
<li role="presentation" class="divider"></li> | ||
|
||
<li role="presentation" ng-repeat="action in moduleStreamActions"><a role="menuitem" tabindex="-1" ng-click="performViaRemoteExecution(module.module_spec, action.action)" href="#">{{ action.description}}</a></li> | ||
</ul> | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
<div data-block="modal-footer"> | ||
<button class="btn btn-default" ng-click="cancel()" translate>Cancel</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
.../javascripts/bastion_katello/content-hosts/content/views/content-host-module-streams.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...atello/test/content-hosts/bulk/content-hosts-bulk-module-streams-modal.controller.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
describe('Controller: ContentHostsBulkModuleStreamsModalController', function() { | ||
var $scope, $controller, $uibModalInstance, hostIds, translate, ModuleStream, | ||
HostBulkAction, CurrentOrganization, Nutupane, formValues; | ||
|
||
beforeEach(module('Bastion.content-hosts', 'Bastion.test-mocks')); | ||
|
||
beforeEach(function() { | ||
HostBulkAction = { | ||
installContent: function() {} | ||
}; | ||
translate = function() {}; | ||
CurrentOrganization = 'foo'; | ||
selectedModuleStreams = [1, 2, 3, 4]; | ||
Nutupane = function() { | ||
this.table = { | ||
showColumns: function () {}, | ||
getSelected: function () {return selectedModuleStreams } | ||
}; | ||
|
||
this.setParams = function () {} | ||
}; | ||
|
||
$uibModalInstance = { | ||
close: function () {}, | ||
dismiss: function () {} | ||
}; | ||
|
||
hostIds = {included: {ids: [1, 2, 3]}}; | ||
ModuleStream = {}; | ||
ModuleStreamAction = {}; | ||
}); | ||
|
||
beforeEach(inject(function(_$controller_, $rootScope, $q, $window) { | ||
$window.AUTH_TOKEN = 'secret_token'; | ||
$scope = $rootScope.$new(); | ||
$controller = _$controller_; | ||
|
||
$scope.table = { | ||
rows: [], | ||
numSelected: 5 | ||
}; | ||
|
||
$controller('ContentHostsBulkModuleStreamsModalController', { | ||
$scope: $scope, | ||
$uibModalInstance: $uibModalInstance, | ||
ModuleStream: ModuleStream, | ||
hostIds: hostIds, | ||
Nutupane: Nutupane, | ||
translate: translate, | ||
CurrentOrganization: CurrentOrganization, | ||
ModuleStreamAction: ModuleStreamAction | ||
}); | ||
})); | ||
|
||
it("provides a function for cancelling the modal", function () { | ||
spyOn($uibModalInstance, 'dismiss'); | ||
$scope.cancel(); | ||
expect($uibModalInstance.dismiss).toHaveBeenCalled(); | ||
}); | ||
|
||
it("can call module stream actions on multiple content hosts", function() { | ||
formValues = { | ||
authenticityToken: 'secret_token', | ||
remoteAction: 'module_stream_action', | ||
search: undefined, | ||
hostIds: '1,2,3', | ||
moduleSpec: 'django:1.9', | ||
moduleStreamAction: 'enable' | ||
}; | ||
$scope.performViaRemoteExecution("django:1.9", "enable");; | ||
expect($scope.moduleStreamActionFormValues).toEqual(formValues); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does @hosts get set here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh find_editable_hosts is set to :except =>
nevermind :)