bastion 5.0.10 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fc7ab4359921312f4a5551442e7f340260be8ed
4
- data.tar.gz: c7a7eb0c7bb49afc4d284025472dc792e05270d4
3
+ metadata.gz: d05f64b71186c3e4b4a56b394b66da1c349a94b6
4
+ data.tar.gz: 8ed3faeff7d99fae5b3c35462964491d6dc57dd3
5
5
  SHA512:
6
- metadata.gz: e363b5dcb92710f6c8497a105b00247f1987240a63f997c04dcd2415014b71e83d785e4a5f7356d9e98e49afd68644793674a4f958783f1e16ab5cd03926bd34
7
- data.tar.gz: 502a381aa188cffa90686562ecba7303486ccac310bf233ab71d718d7f118edb8272c57de5e8bb28190970f6da8783f8e45dc82f7d06c55bc760455cf00695dc
6
+ metadata.gz: af67d9e2961b6fed6d58a5ee03a5f6a820c2dc7fb5bb885633fe364ee54e730ad8a7414488de31d96116b45ede6b7ee8a5b5cccfa1140281256b503e850aa4d9
7
+ data.tar.gz: ddf07a93597190b2e793a8aae92e412e4793cbb71ab83bde4664c158a8ff129341d46d86c39ff192df15b4f3181cfd0f5ef81ad7587e9935febef8e975d75600
@@ -0,0 +1,47 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ /**
5
+ * @ngdoc directive
6
+ * @name Bastion.components.directive:bstResourceSwitcher
7
+ *
8
+ * @description
9
+ * Allows switching between resources on the same level.
10
+ */
11
+ function bstResourceSwitcher($breadcrumb, $location, $state, TableCache) {
12
+ function getTableName(url) {
13
+ var tableName = url.split('/');
14
+
15
+ if (isFinite(parseInt(tableName[tableName.length - 1], 10))) {
16
+ tableName.pop();
17
+ }
18
+
19
+ return tableName.join('-').slice(1);
20
+ }
21
+
22
+ return {
23
+ templateUrl: 'components/views/bst-resource-switcher.html',
24
+ link: function (scope) {
25
+ var breadcrumbs = $breadcrumb.getStatesChain(), listUrl;
26
+ scope.table = {rows: []};
27
+
28
+ if (breadcrumbs.length > 0) {
29
+ listUrl = breadcrumbs[breadcrumbs.length - 2].ncyBreadcrumbLink;
30
+ scope.table = TableCache.getTable(getTableName(listUrl));
31
+ }
32
+
33
+ scope.changeResource = function (id) {
34
+ var currentUrl, nextUrl;
35
+ currentUrl = $location.path();
36
+ nextUrl = currentUrl.replace(/\d+([^\d+]*)$/, id + '$1');
37
+ $location.path(nextUrl);
38
+ };
39
+ }
40
+ };
41
+ }
42
+
43
+ angular.module('Bastion.components').directive('bstResourceSwitcher', bstResourceSwitcher);
44
+
45
+ bstResourceSwitcher.$inject = ['$breadcrumb', '$location', '$state', 'TableCache'];
46
+
47
+ })();
@@ -39,6 +39,11 @@ angular.module('Bastion.components').factory('Nutupane',
39
39
  }
40
40
 
41
41
  function setQueryStrings() {
42
+ // Don't manipulate the query string for params of a modal view
43
+ if (document.body.className.indexOf("modal-open") >= 0) {
44
+ return;
45
+ }
46
+
42
47
  if (self.table.params.paged) {
43
48
  $location.search("page", self.table.params.page).replace();
44
49
  $location.search("per_page", self.table.params['per_page']).replace();
@@ -76,7 +81,7 @@ angular.module('Bastion.components').factory('Nutupane',
76
81
  };
77
82
 
78
83
  self.loadParamsFromExistingTable = function (existingTable) {
79
- params = existingTable.params;
84
+ _.extend(params, existingTable.params);
80
85
  self.table.params = existingTable.params;
81
86
  if (!self.table.searchTerm) {
82
87
  self.table.searchTerm = existingTable.searchTerm;
@@ -0,0 +1,66 @@
1
+ <span uib-dropdown ng-show="table.rows" on-toggle="toggled(open)">
2
+ <a href uib-dropdown-toggle>
3
+ <i class="fa fa-exchange"></i>
4
+ </a>
5
+ <ul class="dropdown-menu" uib-dropdown-menu>
6
+ <form role="form" class="search-pf has-button">
7
+ <div class="form-group has-clear">
8
+ <div class="search-pf-input-group">
9
+ <label for="search" class="sr-only" translate>
10
+ Search
11
+ </label>
12
+ <input id="search" type="search" class="form-control" placeholder="{{ 'Search' | translate }}" ng-model="resourceFilter" />
13
+ <button type="button" class="clear" aria-hidden="true" ng-click="resourceFilter = null" ng-hide="resourceFilter === null">
14
+ <span class="pficon pficon-close"></span>
15
+ </button>
16
+ </div>
17
+ </div>
18
+ <div class="form-group">
19
+ <button class="btn btn-default" type="button">
20
+ <span class="fa fa-search"></span>
21
+ </button>
22
+ </div>
23
+ </form>
24
+ <li ng-class="{'table-mask': table.refreshing || table.working}" ng-repeat="item in table.rows | filter:resourceFilter">
25
+ <a ng-click="changeResource(item.id)">{{ item.name }}</a>
26
+ </li>
27
+
28
+ <li role="separator" class="divider"></li>
29
+
30
+ <li>
31
+ <form class="content-view-pf-pagination">
32
+ <div class="form-group" ng-show="table.hasPagination()">
33
+
34
+ <ul class="pagination pagination-pf-back">
35
+ <li ng-class="{ disabled: table.onFirstPage() }">
36
+ <a ng-click="table.onFirstPage() || table.previousPage()" title="{{ 'Previous Page' | translate }}">
37
+ <span class="i fa fa-angle-left"></span>
38
+ </a>
39
+ </li>
40
+ </ul>
41
+
42
+ <label for="currentPage" class="sr-only" translate>
43
+ Current Page
44
+ </label>
45
+
46
+ <input id="currentPage" ng-show="table.resource.subtotal > 0" class="pagination-pf-page" type="text" ng-model="table.params.page"
47
+ ng-blur="table.changePage(table.params.page)" bst-on-enter="table.changePage(table.params.page)"/>
48
+
49
+ <input ng-show="table.resource.subtotal === 0" class="pagination-pf-page" type="text" readonly="true" ng-value="table.resource.subtotal"/>
50
+
51
+ <span translate>of
52
+ <span class="pagination-pf-pages">{{ (table.resource.subtotal / table.resource.per_page) | roundUp }}</span>
53
+ </span>
54
+
55
+ <ul class="pagination pagination-pf-forward">
56
+ <li ng-class="{ disabled: table.onLastPage() }">
57
+ <a ng-click="table.onLastPage() || table.nextPage()" title=" {{ 'Next Page' | translate }}">
58
+ <span class="i fa fa-angle-right"></span>
59
+ </a>
60
+ </li>
61
+ </ul>
62
+ </div>
63
+ </form>
64
+ </li>
65
+ </ul>
66
+ </span>
@@ -1,5 +1,6 @@
1
1
  <div class="row">
2
- <div class="col-sm-12 breadcrumbs">
2
+ <div class="col-sm-12 breadcrumbs breadcrumbs-inline">
3
3
  <div ncy-breadcrumb></div>
4
+ <span bst-resource-switcher></span>
4
5
  </div>
5
6
  </div>
@@ -102,7 +102,7 @@
102
102
  </label>
103
103
 
104
104
  <input id="currentPage" ng-show="table.resource.subtotal > 0" class="pagination-pf-page" type="text" ng-model="table.params.page"
105
- ng-blur="table.changePage(table.params.page)" bst-on-enter="table.changePage()"/>
105
+ ng-blur="table.changePage(table.params.page)" bst-on-enter="table.changePage(table.params.page)"/>
106
106
 
107
107
  <input ng-show="table.resource.subtotal === 0" class="pagination-pf-page" type="text" readonly="true" ng-value="table.resource.subtotal"/>
108
108
 
@@ -58,3 +58,7 @@
58
58
  text-align: center;
59
59
  }
60
60
  }
61
+
62
+ [bst-resource-switcher] {
63
+ margin-left: -10px;
64
+ }
@@ -27,16 +27,20 @@ table.table {
27
27
  padding: 0;
28
28
  }
29
29
 
30
- .breadcrumb > .active a {
31
- color: $breadcrumb-active-color;
32
- }
33
-
34
30
  .wizard li {
35
31
  &:not(:first-child) span {
36
32
  padding-left: 15px;
37
33
  }
38
34
  }
39
35
 
36
+ .breadcrumbs-inline .breadcrumb {
37
+ display: inline-block;
38
+ }
39
+
40
+ .breadcrumb > .active a {
41
+ color: $breadcrumb-active-color;
42
+ }
43
+
40
44
  .breadcrumbs .breadcrumb {
41
45
  margin-bottom: 0;
42
46
  }
@@ -78,4 +82,23 @@ html .toolbar-pf.table-view-pf-toolbar-external .toolbar-pf-filter {
78
82
  // Add some margin to the bottom of the table footer
79
83
  .content-view-pf-pagination {
80
84
  margin-bottom: 20px;
81
- }
85
+ }
86
+
87
+ .dropdown-menu form {
88
+ padding: 5px;
89
+ }
90
+
91
+ html .dropdown-menu .content-view-pf-pagination {
92
+ background-color: #FFFFFF;
93
+ border: none;
94
+ margin-bottom: 0;
95
+ white-space: nowrap;
96
+
97
+ .pagination-pf-back {
98
+ margin-left: 0;
99
+ }
100
+
101
+ .form-group:last-child {
102
+ justify-content: center;
103
+ }
104
+ }
@@ -1,3 +1,3 @@
1
1
  module Bastion
2
- VERSION = "5.0.10"
2
+ VERSION = "5.1.0"
3
3
  end
@@ -0,0 +1,85 @@
1
+ describe('Directive: bstResourceSwitcher', function() {
2
+ var $breadcrumb, $location, $state, scope, compile, element, elementScope, TableCache;
3
+
4
+ function createDirective () {
5
+ element = angular.element('<div bst-resource-switcher></div>');
6
+ compile(element)(scope);
7
+ scope.$digest();
8
+ elementScope = element.isolateScope();
9
+ }
10
+
11
+ beforeEach(module('Bastion.components', 'components/views/bst-resource-switcher.html'));
12
+
13
+ beforeEach(module(function ($provide) {
14
+ $breadcrumb = {
15
+ getStatesChain: function () {
16
+ return [];
17
+ }
18
+ };
19
+
20
+ $location = {
21
+ path: function () {}
22
+ };
23
+
24
+ $state = {
25
+ go: function () {},
26
+ get: function () {
27
+ return [];
28
+ },
29
+ href: function () {},
30
+ current: {}
31
+ };
32
+
33
+ TableCache = {
34
+ getTable: function () {}
35
+ };
36
+
37
+ $provide.value('translateFilter', function(a) { return a; });
38
+ $provide.value('$breadcrumb', $breadcrumb);
39
+ $provide.value('$location', $location);
40
+ $provide.value('$state', $state);
41
+ $provide.value('TableCache', TableCache);
42
+ }));
43
+
44
+ beforeEach(inject(function(_$compile_, _$rootScope_) {
45
+ compile = _$compile_;
46
+ scope = _$rootScope_;
47
+ }));
48
+
49
+ beforeEach(function() {
50
+ createDirective();
51
+ });
52
+
53
+ it("should display the resource switcher", function() {
54
+ expect(element.find('.fa-exchange').length).toBe(1);
55
+ expect(element.find('.dropdown-menu').length).toBe(1);
56
+ expect(element.find('.content-view-pf-pagination').length).toBe(1);
57
+ });
58
+
59
+ describe("should", function () {
60
+ var breadcrumbs = [{ncyBreadcrumbLink: '/fake'}, {ncyBreadcrumbLink: '/fake/1'}];
61
+
62
+ beforeEach(function () {
63
+ spyOn($breadcrumb, 'getStatesChain').and.returnValue(breadcrumbs);
64
+ spyOn(TableCache, 'getTable');
65
+ });
66
+
67
+ afterEach(function () {
68
+ expect($breadcrumb.getStatesChain).toHaveBeenCalled();
69
+ });
70
+
71
+ it("get the table from the table cache", function () {
72
+ createDirective();
73
+ expect(TableCache.getTable).toHaveBeenCalledWith('fake');
74
+ });
75
+
76
+ it("be able to change the resource", function () {
77
+ spyOn($location, 'path').and.returnValue('/fake/1');
78
+
79
+ createDirective();
80
+ scope.changeResource(2);
81
+
82
+ expect($location.path).toHaveBeenCalledWith('/fake/2');
83
+ });
84
+ });
85
+ });
@@ -205,14 +205,14 @@ describe('Factory: Nutupane', function() {
205
205
  });
206
206
 
207
207
  it("decrements num selected if removed row is selected.", function() {
208
- var row = nutupane.table.rows[0];
209
- row.selected = true;
210
- nutupane.table.numSelected = 1;
211
-
212
- nutupane.removeRow(row.id);
213
- expect(nutupane.table.rows.length).toBe(1);
214
- expect(nutupane.table.rows).not.toContain(row);
215
- expect(nutupane.table.numSelected).toBe(0);
208
+ var row = nutupane.table.rows[0];
209
+ row.selected = true;
210
+ nutupane.table.numSelected = 1;
211
+
212
+ nutupane.removeRow(row.id);
213
+ expect(nutupane.table.rows.length).toBe(1);
214
+ expect(nutupane.table.rows).not.toContain(row);
215
+ expect(nutupane.table.numSelected).toBe(0);
216
216
  });
217
217
 
218
218
  it("provides a way to check if the table supports pagination", function () {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bastion
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.10
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric D Helms
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-22 00:00:00.000000000 Z
12
+ date: 2017-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: angular-rails-templates
@@ -72,6 +72,7 @@ files:
72
72
  - app/assets/javascripts/bastion/components/bst-menu.directive.js
73
73
  - app/assets/javascripts/bastion/components/bst-modal.directive.js
74
74
  - app/assets/javascripts/bastion/components/bst-on-enter.directive.js
75
+ - app/assets/javascripts/bastion/components/bst-resource-switcher.directive.js
75
76
  - app/assets/javascripts/bastion/components/bst-save-control.directive.js
76
77
  - app/assets/javascripts/bastion/components/bst-table.directive.js
77
78
  - app/assets/javascripts/bastion/components/components.module.js
@@ -111,6 +112,7 @@ files:
111
112
  - app/assets/javascripts/bastion/components/views/bst-global-notification.html
112
113
  - app/assets/javascripts/bastion/components/views/bst-menu.html
113
114
  - app/assets/javascripts/bastion/components/views/bst-modal.html
115
+ - app/assets/javascripts/bastion/components/views/bst-resource-switcher.html
114
116
  - app/assets/javascripts/bastion/components/views/bst-save-control.html
115
117
  - app/assets/javascripts/bastion/components/views/current-tasks.html
116
118
  - app/assets/javascripts/bastion/components/views/path-selector.html
@@ -203,6 +205,7 @@ files:
203
205
  - test/components/bst-global-notification.directive.test.js
204
206
  - test/components/bst-menu.directive.test.js
205
207
  - test/components/bst-modal.directive.test.js
208
+ - test/components/bst-resource-switcher.test.js
206
209
  - test/components/bst-table.directive.test.js
207
210
  - test/components/formatters/array-to-string.filter.test.js
208
211
  - test/components/formatters/boolean-to-yes-no.filter.test.js
@@ -1760,47 +1763,48 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1760
1763
  version: '0'
1761
1764
  requirements: []
1762
1765
  rubyforge_project:
1763
- rubygems_version: 2.4.6
1766
+ rubygems_version: 2.6.11
1764
1767
  signing_key:
1765
1768
  specification_version: 4
1766
1769
  summary: UI library of AngularJS based components for Foreman
1767
1770
  test_files:
1768
- - test/features/bst-feature-flag.directive.test.js
1769
- - test/features/feature-flag.service.test.js
1770
1771
  - test/auth/authorization.service.test.js
1772
+ - test/bastion/test-constants.js
1773
+ - test/components/bst-alert.directive.test.js
1774
+ - test/components/bst-alerts.directive.test.js
1775
+ - test/components/bst-bookmark.directive.test.js
1776
+ - test/components/bst-bookmark.factory.test.js
1777
+ - test/components/bst-dropdown.directive.test.js
1778
+ - test/components/bst-edit.directive.test.js
1779
+ - test/components/bst-flyout.directive.test.js
1780
+ - test/components/bst-form-buttons.directive.test.js
1771
1781
  - test/components/bst-form-group.directive.test.js
1772
- - test/components/bst-table.directive.test.js
1773
- - test/components/page-title.directive.test.js
1782
+ - test/components/bst-global-notification.directive.test.js
1774
1783
  - test/components/bst-menu.directive.test.js
1775
- - test/components/bst-alerts.directive.test.js
1776
- - test/components/nutupane.factory.test.js
1777
- - test/components/path-selector.directive.test.js
1784
+ - test/components/bst-modal.directive.test.js
1785
+ - test/components/bst-resource-switcher.test.js
1786
+ - test/components/bst-table.directive.test.js
1778
1787
  - test/components/formatters/array-to-string.filter.test.js
1779
- - test/components/formatters/unlimited-filter.filter.test.js
1788
+ - test/components/formatters/boolean-to-yes-no.filter.test.js
1780
1789
  - test/components/formatters/capitalize.filter.test.js
1781
1790
  - test/components/formatters/key-value-to-string.filter.test.js
1782
- - test/components/formatters/boolean-to-yes-no.filter.test.js
1791
+ - test/components/formatters/unlimited-filter.filter.test.js
1792
+ - test/components/global-notification.service.test.js
1793
+ - test/components/nutupane.factory.test.js
1794
+ - test/components/page-title.directive.test.js
1783
1795
  - test/components/page-title.service.test.js
1784
- - test/components/bst-bookmark.factory.test.js
1785
- - test/components/bst-alert.directive.test.js
1786
- - test/components/bst-bookmark.directive.test.js
1787
- - test/components/bst-global-notification.directive.test.js
1788
- - test/components/bst-flyout.directive.test.js
1796
+ - test/components/path-selector.directive.test.js
1789
1797
  - test/components/table-cache.service.test.js
1790
- - test/components/bst-dropdown.directive.test.js
1791
1798
  - test/components/typeahead-empty.directive.test.js
1792
- - test/components/bst-form-buttons.directive.test.js
1793
- - test/components/global-notification.service.test.js
1794
- - test/components/bst-edit.directive.test.js
1795
- - test/components/bst-modal.directive.test.js
1799
+ - test/features/bst-feature-flag.directive.test.js
1800
+ - test/features/feature-flag.service.test.js
1801
+ - test/i18n/translate.service.test.js
1802
+ - test/menu/menu-expander.service.test.js
1796
1803
  - test/routing.module.test.js
1797
1804
  - test/test-mocks.module.js
1798
- - test/menu/menu-expander.service.test.js
1799
- - test/i18n/translate.service.test.js
1800
- - test/bastion/test-constants.js
1801
- - test/utils/form-utils.service.test.js
1805
+ - test/utils/bastion-resource.factory.test.js
1802
1806
  - test/utils/disable-link.directive.test.js
1807
+ - test/utils/form-utils.service.test.js
1808
+ - test/utils/round-up.filter.test.js
1803
1809
  - test/utils/stop-event.directive.test.js
1804
- - test/utils/bastion-resource.factory.test.js
1805
1810
  - test/utils/urlencode.filter.test.js
1806
- - test/utils/round-up.filter.test.js