Skip to content

Commit

Permalink
fixes #4768 - various activation key page issues
Browse files Browse the repository at this point in the history
* Default content View was not selectable
* Using a paged API for content view dropdown (fixed across the app)
* Fixes environment selector on new activation key page, no disable option needed
* Updated text slightly on activation key page to make it more user friendly
  • Loading branch information
jlsherrill committed Mar 29, 2014
1 parent b7473a1 commit 71936e0
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ angular.module('Bastion.activation-keys').controller('ActivationKeyDetailsInfoCo
$scope.contentViews = function () {
var deferred = $q.defer();

ContentView.query({ 'environment_id': $scope.activationKey.environment.id }, function (response) {
ContentView.queryUnpaged({ 'environment_id': $scope.activationKey.environment.id }, function (response) {
deferred.resolve(response.results);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ angular.module('Bastion.activation-keys').controller('NewActivationKeyController

$scope.contentViews = [];
$scope.editContentView = false;
$scope.disableEnvironmentSelection = false;
$scope.environments = [];

$scope.environments = Organization.registerableEnvironments({organizationId: CurrentOrganization});
Expand All @@ -51,8 +50,7 @@ angular.module('Bastion.activation-keys').controller('NewActivationKeyController
$scope.$watch('activationKey.environment', function (environment) {
if (environment) {
$scope.editContentView = true;
$scope.disableEnvironmentSelection = true;
ContentView.query({ 'environment_id': environment.id }, function (response) {
ContentView.queryUnpaged({ 'environment_id': environment.id }, function (response) {
$scope.contentViews = response.results;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,26 @@ <h2 class="pull-left" translate>New Activation Key</h2>
<div class="col-sm-5 input">
<span path-selector="environments"
ng-model="activationKey.environment"
mode="singleSelect"
disable-trigger="disableEnvironmentSelection">
mode="singleSelect">
</span>
</div>
</div>

<div alch-form-group label="{{ 'Content View' | translate }}">
<select id="content_view_id"
<select ng-hide="contentViews.length === 0"
id="content_view_id"
name="content_view_id"
ng-model="activationKey.content_view_id"
ng-options="contentView.id as contentView.name for contentView in contentViews"
tabindex="4"
autofocus
required>
</select>
<span class="help-block" translate>
If the content view selector list is blank you will need to choose a different environment that contains at least one content view.
<span class="help-block" ng-show="activationKey.environment !== undefined && contentViews.length === 0" translate>
The selected environment contains no Content Views, please select a different environment.
</span>
<span class="help-block" ng-show="activationKey.environment === undefined" translate>
Please select an environment.
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ angular.module('Bastion.content-views').factory('ContentView',
return $resource('/api/v2/content_views/:id/:action',
{id: '@id', 'organization_id': CurrentOrganization},
{
query: {method: 'GET', isArray: false, params: {nondefault: true}},
queryPaged: {method: 'GET', isArray: false},
queryUnpaged: {method: 'GET', isArray: false, params: {'full_result': true}},
update: {method: 'PUT'},
publish: {method: 'POST', params: {action: 'publish'}},
history: {method: 'GET', params: {action: 'history'}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ angular.module('Bastion.content-views').controller('ContentViewsController',
function ($scope, Nutupane, ContentView, CurrentOrganization) {

var nutupane = new Nutupane(ContentView, {
'nondefault': true,
'organization_id': CurrentOrganization,
'sort_by': 'name',
'sort_order': 'ASC'
});
}, 'queryPaged');

$scope.table = nutupane.table;
$scope.removeRow = nutupane.removeRow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ angular.module('Bastion.content-views').controller('NewContentViewController',
$scope.createOption = 'new';
$scope.table = {};

ContentView.query({}, function (response) {
$scope.table.rows = response.results;
});

$scope.save = function (contentView) {
contentView.$save(success, error);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ angular.module('Bastion.systems').controller('SystemsBulkActionEnvironmentContro
$scope.fetchViews = function () {
$scope.fetchingContentViews = true;

ContentView.query({ 'environment_id': $scope.selected.environment.id }, function (response) {
ContentView.queryUnpaged({ 'environment_id': $scope.selected.environment.id }, function (response) {
$scope.contentViews = response.results;
$scope.fetchingContentViews = false;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ angular.module('Bastion.systems').controller('SystemDetailsInfoController',
$scope.contentViews = function () {
var deferred = $q.defer();

ContentView.query({ 'environment_id': $scope.system.environment.id }, function (response) {
ContentView.queryUnpaged({ 'environment_id': $scope.system.environment.id}, function (response) {
deferred.resolve(response.results);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Controller: NewActivationKeyController', function() {
};

ContentView = $injector.get('MockResource').$new();
ContentView.query = function (params, callback) {};
ContentView.unPaged = function (params, callback) {};

FormUtils = $injector.get('FormUtils');

Expand Down Expand Up @@ -151,11 +151,11 @@ describe('Controller: NewActivationKeyController', function() {

it("should fetch content views", function () {
$httpBackend.expectGET('/organizations/default_label?name=Test+Resource').respond('changed_name');
spyOn(ContentView, 'query');
spyOn(ContentView, 'queryUnpaged');
$scope.activationKey.environment = paths[0][0];
$scope.$apply();

expect(ContentView.query).toHaveBeenCalled();
expect(ContentView.queryUnpaged).toHaveBeenCalled();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ describe('Factory: ContentView', function() {
});

it('provides a way to get a collection of content views', function() {
$httpBackend.expectGET('/api/v2/content_views?nondefault=true&organization_id=ACME')
$httpBackend.expectGET('/api/v2/content_views?organization_id=ACME')
.respond(contentViews);

ContentView.query(function (response) {
ContentView.queryPaged(function (response) {
var views = response;

expect(views.results.length).toBe(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ describe('Controller: SystemsBulkActionEnvironmentController', function() {
};

CurrentOrganization = 'foo';
paths = [[{name: "Library", id: 1}, {name: "Dev", id: 2}]]
paths = [[{name: "Library", id: 1}, {name: "Dev", id: 2}]];
selectedSystems = {included: {ids: [1, 2, 3]}};
ContentView = $injector.get('MockResource').$new();
Organization = $injector.get('MockResource').$new();
ContentView.queryUnpaged = function(){return {}};

Organization.registerableEnvironments = function (params, callback) {
var response = paths;
Expand Down Expand Up @@ -64,11 +65,11 @@ describe('Controller: SystemsBulkActionEnvironmentController', function() {

it("should fetch content views", function () {
$scope.selected.environment = paths[0][0];
spyOn(ContentView, 'query').andCallThrough();
spyOn(ContentView, 'queryUnpaged').andCallThrough();

$scope.fetchViews();
expect(ContentView.query).toHaveBeenCalled();
expect($scope.contentViews).toBe(ContentView.query().results);
expect(ContentView.queryUnpaged).toHaveBeenCalled();
expect($scope.contentViews).toBe(ContentView.queryUnpaged().results);
});

it("should perform the correct action", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('Controller: SystemDetailsInfoController', function() {
System = $injector.get('MockResource').$new();
$scope = $injector.get('$rootScope').$new();

ContentView.queryUnpaged = function(){};
System.releaseVersions = function(params, callback) {
callback.apply(this, [['RHEL6']]);
};
Expand Down
2 changes: 2 additions & 0 deletions engines/bastion/test/test-mocks.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ angular.module('Bastion.test-mocks').factory('MockResource', function () {
}
return Resource.mockResources;
};
Resource.queryPaged = Resource.query;
Resource.queryUnpaged = Resource.query;

Resource.save = function(params, data, success, error) {
var item = new Resource(data);
Expand Down

0 comments on commit 71936e0

Please sign in to comment.