Skip to content

Commit

Permalink
Refs #7883: Adds repository filter to tabs on content view version de…
Browse files Browse the repository at this point in the history
…tails.

This adds the ability to filter the package, errata and package group list
for a content view version by repository.
  • Loading branch information
ehelms committed Nov 14, 2014
1 parent 7c558f8 commit b23235f
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 47 deletions.
Expand Up @@ -22,7 +22,7 @@
* Handles fetching content view version content and populating Nutupane based on the current
* ui-router state.
*/
function ContentViewVersionContentController($scope, Nutupane, Package, Erratum, PackageGroup, PuppetModule, Repository) {
function ContentViewVersionContentController($scope, translate, Nutupane, Package, Erratum, PackageGroup, PuppetModule, Repository) {
var nutupane, contentTypes, currentState, params;

currentState = $scope.$state.current.name.split('.').pop();
Expand Down Expand Up @@ -55,13 +55,35 @@

$scope.nutupane = nutupane;
$scope.detailsTable = nutupane.table;

$scope.repository = {name: translate('All Repositories'), id: 'all'};
$scope.repositories = [];

$scope.version.$promise.then(function (version) {
$scope.repositories = version.repositories;
$scope.repositories.unshift($scope.repository);
});

$scope.$watch('repository', function (repository) {
var params = nutupane.getParams();

if (repository.id === 'all') {
params['repository_id'] = null;
nutupane.setParams(params);
} else {
params['repository_id'] = repository.id;
nutupane.setParams(params);
}

nutupane.refresh();
});
}

angular
.module('Bastion.content-views.versions')
.controller('ContentViewVersionContentController', ContentViewVersionContentController);

ContentViewVersionContentController.$inject = ['$scope', 'Nutupane', 'Package', 'Erratum',
ContentViewVersionContentController.$inject = ['$scope', 'translate', 'Nutupane', 'Package', 'Erratum',
'PackageGroup', 'PuppetModule', 'Repository'];

})();
Expand Up @@ -3,48 +3,53 @@
<div data-block="header"></div>
<div data-block="selection-summary"></div>

<span class="input-group-addon" data-block="search-filter">
<select ng-model="repository" ng-options="repository.name for (id, repository) in repositories">
</select>
</span>

<table data-block="table" class="table table-striped table-bordered">
<thead>
<tr alch-table-head>
<th alch-table-column="errataId" sortable>{{ "Errata ID" | translate }}</th>
<th alch-table-column="title">{{ "Title" | translate }}</th>
<th alch-table-column="type">{{ "Type" | translate }}</th>
<th alch-table-column="numberOfContentHosts">{{ "Affected Content Hosts" | translate }}</th>
<th alch-table-column="updated">{{ "Updated" | translate }}</th>
</tr>
</thead>

<tbody>
<tr alch-table-row ng-repeat="errata in detailsTable.rows">
<td alch-table-cell>
{{ errata.errata_id }}
<i class="icon-chevron-right selected-icon" ng-show="errata.selected"></i>
</td>
<td alch-table-cell>
<a>
{{ errata.title }}
</a>
</td>
<td alch-table-cell>
<span ng-show="errata.type == 'security'">
<i class="icon-warning-sign inline-icon" title="{{ 'Security' | translate }}"></i>
</span>

<span ng-show="errata.type == 'bugfix'">
<i class="icon-bug inline-icon" title="{{ 'Bug Fix' | translate }}"></i>
</span>

<span ng-show="errata.type == 'enhancement'">
<i class="icon-plus-sign-alt inline-icon" title="{{ 'Enhancement' | translate }}"></i>
</span>

{{ errata.type }}
<span ng-show="errata.severity">- {{ errata.severity }}</span>
</td>
<td alch-table-cell>{{ errata.systems_available_count || 0 }}</td>
<td alch-table-cell>{{ errata.updated | date:'shortDate'}}</td>
</tr>
</tbody>
</table>
<thead>
<tr alch-table-head>
<th alch-table-column="errataId" sortable>{{ "Errata ID" | translate }}</th>
<th alch-table-column="title">{{ "Title" | translate }}</th>
<th alch-table-column="type">{{ "Type" | translate }}</th>
<th alch-table-column="numberOfContentHosts">{{ "Affected Content Hosts" | translate }}</th>
<th alch-table-column="updated">{{ "Updated" | translate }}</th>
</tr>
</thead>

<tbody>
<tr alch-table-row ng-repeat="errata in detailsTable.rows">
<td alch-table-cell>
{{ errata.errata_id }}
<i class="icon-chevron-right selected-icon" ng-show="errata.selected"></i>
</td>
<td alch-table-cell>
<a>
{{ errata.title }}
</a>
</td>
<td alch-table-cell>
<span ng-show="errata.type == 'security'">
<i class="icon-warning-sign inline-icon" title="{{ 'Security' | translate }}"></i>
</span>

<span ng-show="errata.type == 'bugfix'">
<i class="icon-bug inline-icon" title="{{ 'Bug Fix' | translate }}"></i>
</span>

<span ng-show="errata.type == 'enhancement'">
<i class="icon-plus-sign-alt inline-icon" title="{{ 'Enhancement' | translate }}"></i>
</span>

{{ errata.type }}
<span ng-show="errata.severity">- {{ errata.severity }}</span>
</td>
<td alch-table-cell>{{ errata.systems_available_count || 0 }}</td>
<td alch-table-cell>{{ errata.updated | date:'shortDate'}}</td>
</tr>
</tbody>
</table>

</div>
Expand Up @@ -3,6 +3,11 @@
<div data-block="header"></div>
<div data-block="selection-summary"></div>

<span class="input-group-addon" data-block="search-filter">
<select ng-model="repository" ng-options="repository.name for (id, repository) in repositories">
</select>
</span>

<table data-block="table" class="table table-striped table-bordered">
<thead>
<tr alch-table-head>
Expand Down
Expand Up @@ -3,6 +3,11 @@
<div data-block="header"></div>
<div data-block="selection-summary"></div>

<span class="input-group-addon" data-block="search-filter">
<select ng-model="repository" ng-options="repository.name for (id, repository) in repositories">
</select>
</span>

<table data-block="table" class="table table-striped table-bordered">
<thead>
<tr alch-table-head>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<div data-block="header"></div>
<div data-block="selection-summary"></div>

<table data-block="table" class="table table-striped">
<table data-block="table" class="table table-striped table-bordered">
<thead>
<tr alch-table-head>
<th alch-table-column translate>Name</th>
Expand Down
Expand Up @@ -15,7 +15,8 @@ describe('Controller: ContentViewsVersionContentController', function() {
var $scope,
Package,
PackageGroup,
Nutupane;
Nutupane,
ContentViewVersion;

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

Expand All @@ -27,7 +28,10 @@ describe('Controller: ContentViewsVersionContentController', function() {
};
this.removeRow = function() {};
this.get = function() {};
this.enableSelectAllResults = function() {}
this.enableSelectAllResults = function() {};
this.refresh = function () {};
this.getParams = function () { return {'repository_id': 1} };
this.setParams = function () {};
};
});

Expand All @@ -40,10 +44,13 @@ describe('Controller: ContentViewsVersionContentController', function() {
PackageGroup = $injector.get('MockResource').$new();
Erratum = $injector.get('MockResource').$new();
PuppetModule = $injector.get('MockResource').$new();
ContentViewVersion = $injector.get('MockResource').$new();

$scope = $injector.get('$rootScope').$new();
$scope.$stateParams = {versionId: '1'};
$scope.$state = {current: {name: state}};
$scope.version = ContentViewVersion.get({id: 1});
$scope.version.repositories = [{id: 1}];

$controller('ContentViewVersionContentController', {
$scope: $scope,
Expand Down Expand Up @@ -81,5 +88,24 @@ describe('Controller: ContentViewsVersionContentController', function() {
expect($scope.nutupane.resource).toBe(PuppetModule);
});

it("setups up Package resource when is state is 'puppet modules'", function() {
SetupController('content-views.details.version.puppet-modules');
expect($scope.nutupane.resource).toBe(PuppetModule);
});

it("builds a list of repositories from the version", function() {
SetupController('content-views.details.version.packages');
expect($scope.repositories.length).toBe(2);
});

it("builds a list of repositories from the version", function() {
SetupController('content-views.details.version.packages');
spyOn($scope.nutupane, 'refresh');

$scope.repositories = {id: 2};
$scope.$digest();
expect($scope.nutupane.refresh).toHaveBeenCalled();
});

});

0 comments on commit b23235f

Please sign in to comment.