katello 3.7.0.rc1 → 3.7.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/v2/content_views_controller.rb +5 -2
  3. data/app/controllers/katello/api/v2/environments_controller.rb +8 -3
  4. data/app/controllers/katello/api/v2/host_tracer_controller.rb +1 -1
  5. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +4 -4
  6. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +5 -22
  7. data/app/lib/actions/katello/host/update_content_overrides.rb +1 -0
  8. data/app/lib/actions/katello/product/content_create.rb +1 -0
  9. data/app/lib/actions/katello/product/repositories_certs_reset.rb +25 -0
  10. data/app/lib/actions/katello/product/update.rb +6 -0
  11. data/app/lib/katello/resources/candlepin/activation_key.rb +8 -4
  12. data/app/lib/katello/resources/candlepin/product.rb +2 -1
  13. data/app/lib/katello/util/cdn_var_substitutor.rb +5 -3
  14. data/app/lib/katello/util/package.rb +21 -13
  15. data/app/lib/katello/util/package_filter.rb +33 -31
  16. data/app/lib/katello/validators/prior_validator.rb +6 -10
  17. data/app/models/katello/concerns/host_managed_extensions.rb +2 -0
  18. data/app/models/katello/concerns/organization_extensions.rb +1 -0
  19. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +10 -6
  20. data/app/models/katello/content.rb +23 -2
  21. data/app/models/katello/content_view_docker_filter.rb +1 -1
  22. data/app/models/katello/content_view_puppet_module.rb +3 -3
  23. data/app/models/katello/content_view_version.rb +4 -0
  24. data/app/models/katello/environment_prior.rb +7 -0
  25. data/app/models/katello/glue/candlepin/candlepin_object.rb +2 -2
  26. data/app/models/katello/glue/candlepin/pool.rb +10 -13
  27. data/app/models/katello/glue/candlepin/product.rb +19 -9
  28. data/app/models/katello/glue/candlepin/repository.rb +16 -0
  29. data/app/models/katello/glue/candlepin/subscription.rb +1 -1
  30. data/app/models/katello/glue/provider.rb +15 -81
  31. data/app/models/katello/host/subscription_facet.rb +1 -1
  32. data/app/models/katello/kt_environment.rb +39 -8
  33. data/app/models/katello/pool.rb +2 -1
  34. data/app/models/katello/rpm.rb +144 -2
  35. data/app/models/katello/upstream_pool.rb +7 -10
  36. data/app/services/katello/candlepin/pool_service.rb +18 -3
  37. data/app/services/katello/ui_notifications/pulp/proxy_disk_space.rb +13 -16
  38. data/app/views/dashboard/_content_views_widget.html.erb +3 -3
  39. data/app/views/dashboard/_errata_widget.html.erb +2 -2
  40. data/app/views/dashboard/_host_collection_widget.html.erb +3 -3
  41. data/app/views/dashboard/_subscription_status_widget.html.erb +2 -2
  42. data/app/views/dashboard/_subscription_widget.html.erb +1 -1
  43. data/app/views/dashboard/_sync_widget.html.erb +3 -3
  44. data/app/views/katello/api/v2/subscriptions/base.json.rabl +1 -1
  45. data/app/views/katello/api/v2/upstream_subscriptions/base.json.rabl +2 -6
  46. data/app/views/katello/layouts/react.html.erb +3 -3
  47. data/config/katello.yaml +89 -0
  48. data/config/routes.rb +3 -0
  49. data/db/migrate/20160302091113_change_environment_prior.rb +9 -0
  50. data/db/migrate/20180410140909_add_organization_id_to_pool.rb +2 -1
  51. data/db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb +10 -0
  52. data/db/migrate/20180612164926_add_content_org_id.rb +39 -0
  53. data/db/migrate/20180612165011_remove_content_fields_from_host.rb +7 -0
  54. data/db/migrate/20180626160422_add_upstream_pool_id_to_katello_pool.rb +9 -0
  55. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-packages-modal.html +1 -1
  56. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register.html +1 -1
  57. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/environment-content.controller.js +2 -3
  58. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment.html +4 -2
  59. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/environments.controller.js +19 -14
  60. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/new-environment.controller.js +18 -5
  61. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/paths.service.js +51 -0
  62. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/views/new-environment.html +16 -3
  63. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-advanced-sync-modal.controller.js +1 -1
  64. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +2 -2
  65. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/subscriptions.routes.js +3 -3
  66. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/tasks.module.js +1 -6
  67. data/engines/bastion_katello/app/assets/stylesheets/bastion_katello/bastion_katello.scss +4 -0
  68. data/engines/bastion_katello/lib/bastion_katello/engine.rb +1 -1
  69. data/lib/katello/plugin.rb +2 -11
  70. data/lib/katello/scheduled_jobs.rb +2 -14
  71. data/lib/katello/tasks/clean_backend_objects.rake +2 -0
  72. data/lib/katello/tasks/repository.rake +11 -2
  73. data/lib/katello/tasks/upgrades/3.7/import_pools.rake +12 -0
  74. data/lib/katello/version.rb +1 -1
  75. data/package.json +4 -3
  76. data/webpack/components/PaginationRow/index.js +6 -2
  77. data/webpack/containers/Application/config.js +7 -2
  78. data/webpack/index.js +3 -5
  79. data/webpack/move_to_foreman/common/helpers.js +5 -24
  80. data/webpack/move_to_foreman/components/common/emptyState/index.js +12 -7
  81. data/webpack/move_to_foreman/components/common/table/components/CollapseSubscriptionGroupButton.js +31 -0
  82. data/webpack/move_to_foreman/components/common/table/components/CollapseSubscriptionGroupButton.test.js +16 -0
  83. data/webpack/move_to_foreman/components/common/table/components/Table.js +76 -0
  84. data/webpack/move_to_foreman/components/common/table/components/Table.test.js +31 -0
  85. data/webpack/move_to_foreman/components/common/table/components/TableBody.js +27 -0
  86. data/webpack/move_to_foreman/components/common/table/components/TableBody.test.js +18 -0
  87. data/webpack/move_to_foreman/components/common/table/components/TableBodyMessage.js +18 -0
  88. data/webpack/move_to_foreman/components/common/table/components/TableBodyMessage.test.js +12 -0
  89. data/webpack/move_to_foreman/components/common/table/components/TableFixtures.js +14 -0
  90. data/webpack/move_to_foreman/components/common/table/components/TableSelectionCell.js +39 -0
  91. data/webpack/move_to_foreman/components/common/table/components/TableSelectionCell.test.js +16 -0
  92. data/webpack/move_to_foreman/components/common/table/components/TableSelectionHeaderCell.js +34 -0
  93. data/webpack/move_to_foreman/components/common/table/components/TableSelectionHeaderCell.test.js +14 -0
  94. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/CollapseSubscriptionGroupButton.test.js.snap +19 -0
  95. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/Table.test.js.snap +167 -0
  96. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/TableBody.test.js.snap +28 -0
  97. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/TableBodyMessage.test.js.snap +13 -0
  98. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/TableSelectionCell.test.js.snap +16 -0
  99. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/TableSelectionHeaderCell.test.js.snap +15 -0
  100. data/webpack/move_to_foreman/components/common/table/components/index.js +6 -0
  101. data/webpack/move_to_foreman/components/common/table/formatters/cellFormatter.js +4 -0
  102. data/webpack/move_to_foreman/components/common/table/formatters/collapseableAndSelectionCellFormatter.js +18 -0
  103. data/webpack/move_to_foreman/components/common/table/formatters/ellipsisCellFormatter.js +5 -0
  104. data/webpack/move_to_foreman/components/common/table/formatters/headerFormatter.js +4 -0
  105. data/webpack/move_to_foreman/components/common/table/formatters/index.js +6 -0
  106. data/webpack/move_to_foreman/components/common/table/formatters/selectionCellFormatter.js +17 -0
  107. data/webpack/move_to_foreman/components/common/table/formatters/selectionHeaderCellFormatter.js +10 -0
  108. data/webpack/move_to_foreman/components/common/table/index.js +2 -88
  109. data/webpack/move_to_pf/LoadingState/LoadingState.js +35 -0
  110. data/webpack/move_to_pf/LoadingState/LoadingState.scss +12 -0
  111. data/webpack/move_to_pf/LoadingState/LoadingState.test.js +28 -0
  112. data/webpack/move_to_pf/LoadingState/__snapshots__/LoadingState.test.js.snap +20 -0
  113. data/webpack/move_to_pf/LoadingState/index.js +3 -0
  114. data/webpack/move_to_pf/test-utils/testHelpers.js +71 -0
  115. data/webpack/redux/actions/RedHatRepositories/enabled.js +1 -1
  116. data/webpack/redux/actions/RedHatRepositories/helpers.js +34 -9
  117. data/webpack/redux/actions/RedHatRepositories/sets.js +28 -6
  118. data/webpack/redux/consts.js +1 -0
  119. data/webpack/redux/reducers/RedHatRepositories/sets.fixtures.js +12 -2
  120. data/webpack/redux/reducers/RedHatRepositories/sets.js +34 -27
  121. data/webpack/redux/reducers/RedHatRepositories/sets.test.js +10 -2
  122. data/webpack/redux/reducers/index.js +2 -0
  123. data/webpack/scenes/Organizations/OrganizationActions.js +3 -3
  124. data/webpack/scenes/RedHatRepositories/components/RecommendedRepositorySetsToggler.js +44 -0
  125. data/webpack/scenes/RedHatRepositories/components/RecommendedRepositorySetsToggler.scss +16 -0
  126. data/webpack/scenes/RedHatRepositories/components/RepositorySet.js +8 -2
  127. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepositories.js +5 -3
  128. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository.js +4 -2
  129. data/webpack/scenes/RedHatRepositories/components/Search.js +1 -1
  130. data/webpack/scenes/RedHatRepositories/components/SearchBar.js +1 -1
  131. data/webpack/scenes/RedHatRepositories/components/__tests__/RecommendedRepositorySetsToggler.test.js +17 -0
  132. data/webpack/scenes/RedHatRepositories/components/__tests__/__snapshots__/RecommendedRepositorySetsToggler.test.js.snap +37 -0
  133. data/webpack/scenes/RedHatRepositories/helpers.js +1 -1
  134. data/webpack/scenes/RedHatRepositories/index.js +17 -7
  135. data/webpack/scenes/RedHatRepositories/index.scss +16 -4
  136. data/webpack/scenes/Subscriptions/Details/SubscriptionAttributes.js +17 -0
  137. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailActions.js +28 -0
  138. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailAssociations.js +47 -0
  139. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailConstants.js +3 -0
  140. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailInfo.js +65 -0
  141. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailProducts.js +20 -0
  142. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailReducer.js +37 -0
  143. data/webpack/scenes/Subscriptions/Details/SubscriptionDetails.js +58 -0
  144. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailActions.test.js +47 -0
  145. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailAssociations.test.js +16 -0
  146. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailInfo.test.js +15 -0
  147. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailProducts.test.js +16 -0
  148. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailReducer.test.js +39 -0
  149. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetails.test.js +28 -0
  150. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetailAssociations.test.js.snap +53 -0
  151. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetailInfo.test.js.snap +185 -0
  152. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetailProducts.test.js.snap +77 -0
  153. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetails.test.js.snap +432 -0
  154. data/webpack/scenes/Subscriptions/Details/__tests__/subscriptionDetails.fixtures.js +167 -0
  155. data/webpack/scenes/Subscriptions/Details/index.js +19 -0
  156. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +58 -12
  157. data/webpack/scenes/Subscriptions/Manifest/Manifest.scss +6 -1
  158. data/webpack/scenes/Subscriptions/Manifest/ManifestActions.js +4 -4
  159. data/webpack/scenes/Subscriptions/Manifest/ManifestHistoryTableSchema.js +7 -7
  160. data/webpack/scenes/Subscriptions/Manifest/__tests__/__snapshots__/ManageManifestModal.test.js.snap +6 -9
  161. data/webpack/scenes/Subscriptions/Manifest/index.js +2 -2
  162. data/webpack/scenes/Subscriptions/SubscriptionActions.js +5 -6
  163. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +2 -3
  164. data/webpack/scenes/Subscriptions/SubscriptionValidations.js +1 -1
  165. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +46 -30
  166. data/webpack/scenes/Subscriptions/SubscriptionsPage.scss +38 -0
  167. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js +3 -3
  168. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +7 -6
  169. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsTableSchema.js +17 -14
  170. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +12 -15
  171. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/upstreamSubscriptions.fixtures.js +4 -4
  172. data/webpack/scenes/Subscriptions/__tests__/SubscriptionValidations.test.js +5 -0
  173. data/webpack/scenes/Subscriptions/__tests__/subscriptions.fixtures.js +2 -2
  174. data/webpack/scenes/Subscriptions/{EntitlementsInlineEditFormatter.js → components/SubscriptionsTable/EntitlementsInlineEditFormatter.js} +7 -7
  175. data/webpack/scenes/Subscriptions/{SubscriptionsTable.js → components/SubscriptionsTable/SubscriptionsTable.js} +75 -47
  176. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js +60 -0
  177. data/webpack/scenes/Subscriptions/{SubscriptionsTableSchema.js → components/SubscriptionsTable/SubscriptionsTableSchema.js} +37 -26
  178. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.test.js +56 -0
  179. data/webpack/scenes/Subscriptions/{__tests__ → components/SubscriptionsTable/__tests__}/__snapshots__/SubscriptionsTable.test.js.snap +16 -5
  180. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/index.js +2 -0
  181. data/webpack/scenes/Subscriptions/index.js +2 -2
  182. data/webpack/scenes/Tasks/TaskActions.js +18 -11
  183. data/webpack/scenes/Tasks/__tests__/TaskActions.test.js +92 -9
  184. data/webpack/scenes/Tasks/__tests__/task.fixtures.js +19 -9
  185. data/webpack/services/api/index.js +2 -2
  186. data/webpack/test_setup.js +1 -0
  187. metadata +79 -10
  188. data/webpack/scenes/Subscriptions/Subscriptions.scss +0 -14
  189. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsTable.test.js +0 -47
@@ -0,0 +1,28 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TableBody renders TableBody 1`] = `
4
+ <Body
5
+ onRow={[Function]}
6
+ rowKey={[Function]}
7
+ rows={
8
+ Array [
9
+ Object {
10
+ "data": "data-1",
11
+ "id": 1,
12
+ },
13
+ Object {
14
+ "data": "data-2",
15
+ "id": 2,
16
+ },
17
+ ]
18
+ }
19
+ />
20
+ `;
21
+
22
+ exports[`TableBody renders TableBody with message 1`] = `
23
+ <TableBodyMessage
24
+ colSpan={2}
25
+ >
26
+ some message
27
+ </TableBodyMessage>
28
+ `;
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TableBodyMessage renders TableBodyMessage 1`] = `
4
+ <tbody>
5
+ <tr>
6
+ <td
7
+ colSpan={2}
8
+ >
9
+ some children
10
+ </td>
11
+ </tr>
12
+ </tbody>
13
+ `;
@@ -0,0 +1,16 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TableSelectionCell renders TableSelectionCell 1`] = `
4
+ <TableSelectionCell
5
+ className=""
6
+ >
7
+ some before
8
+ <TableCheckbox
9
+ checked={true}
10
+ id="some id"
11
+ label="some label"
12
+ onChange={[Function]}
13
+ />
14
+ some after
15
+ </TableSelectionCell>
16
+ `;
@@ -0,0 +1,15 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TableSelectionHeaderCell renders TableSelectionHeaderCell 1`] = `
4
+ <TableSelectionHeading
5
+ aria-label="some label"
6
+ className=""
7
+ >
8
+ <TableCheckbox
9
+ checked={true}
10
+ id="some id"
11
+ label="some label"
12
+ onChange={[Function]}
13
+ />
14
+ </TableSelectionHeading>
15
+ `;
@@ -0,0 +1,6 @@
1
+ export { default as Table } from './Table';
2
+ export { default as TableBody } from './TableBody';
3
+ export { default as TableBodyMessage } from './TableBodyMessage';
4
+ export { default as TableSelectionHeaderCell } from './TableSelectionHeaderCell';
5
+ export { default as TableSelectionCell } from './TableSelectionCell';
6
+ export { default as CollapseSubscriptionGroupButton } from './CollapseSubscriptionGroupButton';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { Table as PfTable } from 'patternfly-react';
3
+
4
+ export default value => <PfTable.Cell>{value}</PfTable.Cell>;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import selectionCellFormatter from './selectionCellFormatter';
3
+ import CollapseSubscriptionGroupButton from '../components/CollapseSubscriptionGroupButton';
4
+
5
+ export default (collapseableController, selectionController, additionalData) => {
6
+ const shouldShowCollapseButton = collapseableController.isCollapseable(additionalData);
7
+
8
+ return selectionCellFormatter(
9
+ selectionController,
10
+ additionalData,
11
+ shouldShowCollapseButton && (
12
+ <CollapseSubscriptionGroupButton
13
+ collapsed={collapseableController.isCollapsed(additionalData)}
14
+ onClick={() => collapseableController.toggle(additionalData)}
15
+ />
16
+ ),
17
+ );
18
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import EllipsisWithTooltip from 'react-ellipsis-with-tooltip';
3
+ import cellFormatter from './cellFormatter';
4
+
5
+ export default value => cellFormatter(<EllipsisWithTooltip>{value}</EllipsisWithTooltip>);
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { Table as PfTable } from 'patternfly-react';
3
+
4
+ export default value => <PfTable.Heading>{value}</PfTable.Heading>;
@@ -0,0 +1,6 @@
1
+ export { default as headerFormatter } from './headerFormatter';
2
+ export { default as cellFormatter } from './cellFormatter';
3
+ export { default as ellipsisCellFormatter } from './ellipsisCellFormatter';
4
+ export { default as selectionHeaderCellFormatter } from './selectionHeaderCellFormatter';
5
+ export { default as selectionCellFormatter } from './selectionCellFormatter';
6
+ export { default as collapseableAndSelectionCellFormatter } from './collapseableAndSelectionCellFormatter';
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import TableSelectionCell from '../components/TableSelectionCell';
3
+
4
+ export default (
5
+ selectionController,
6
+ additionalData,
7
+ before,
8
+ after,
9
+ ) => (
10
+ <TableSelectionCell
11
+ id={`select${additionalData.rowIndex}`}
12
+ checked={selectionController.isSelected(additionalData)}
13
+ onChange={() => selectionController.selectRow(additionalData)}
14
+ before={before}
15
+ after={after}
16
+ />
17
+ );
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import TableSelectionHeaderCell from '../components/TableSelectionHeaderCell';
3
+
4
+ export default (selectionController, label) => (
5
+ <TableSelectionHeaderCell
6
+ label={label}
7
+ checked={selectionController.allRowsSelected()}
8
+ onChange={() => selectionController.selectAllRows()}
9
+ />
10
+ );
@@ -1,88 +1,2 @@
1
- /* eslint-disable */
2
- import { Table as PfTable } from 'patternfly-react';
3
- import React from 'react';
4
- import EllipsisWithTooltip from 'react-ellipsis-with-tooltip';
5
- import EmptyState from '../emptyState';
6
- import PaginationRow from '../../../../components/PaginationRow/index';
7
-
8
- export const headerFormat = value => <PfTable.Heading>{value}</PfTable.Heading>;
9
- export const cellFormat = value => <PfTable.Cell>{value}</PfTable.Cell>;
10
-
11
- export const ellipsisFormat = value => (
12
- <PfTable.Cell>
13
- <EllipsisWithTooltip>{value}</EllipsisWithTooltip>
14
- </PfTable.Cell>
15
- );
16
-
17
- export const TableBody = (props) => {
18
- const { columns, rows, message } = props;
19
-
20
- if (message !== undefined) {
21
- return (
22
- <tbody>
23
- <tr>
24
- <td colSpan={columns.length}>{message}</td>
25
- </tr>
26
- </tbody>
27
- );
28
- }
29
-
30
- return (
31
- <PfTable.Body
32
- rows={rows}
33
- rowKey={({ rowIndex }) => rowIndex}
34
- />
35
- );
36
- };
37
-
38
- export class Table extends React.Component {
39
- isEmpty() {
40
- return this.props.rows.length === 0 && this.props.bodyMessage === undefined;
41
- }
42
-
43
- render() {
44
- const { columns, rows, emptyState, bodyMessage, children, itemCount, pagination, onPaginationChange, ...otherProps } = this.props;
45
- let { sortingColumns } = this.props;
46
-
47
- let paginationComponent;
48
- if (itemCount && pagination) {
49
- paginationComponent = (
50
- <PaginationRow
51
- viewType="table"
52
- itemCount={itemCount}
53
- pagination={pagination}
54
- onChange={onPaginationChange}
55
- />
56
- );
57
- }
58
-
59
- if (this.isEmpty()) {
60
- return (<EmptyState {...emptyState} />);
61
- }
62
-
63
- const table = (children !== undefined)
64
- ? children
65
- : [
66
- <PfTable.Header key="header" />,
67
- <TableBody key="body" columns={columns} rows={rows} message={bodyMessage} rowKey="id" />,
68
- ];
69
-
70
- sortingColumns = sortingColumns || {};
71
-
72
- return (
73
- <div>
74
- <PfTable.PfProvider
75
- className="table-fixed"
76
- striped
77
- bordered
78
- hover
79
- columns={columns}
80
- {...otherProps}
81
- >
82
- {table}
83
- </PfTable.PfProvider>
84
- {paginationComponent}
85
- </div>
86
- );
87
- }
88
- }
1
+ export * from './formatters';
2
+ export * from './components';
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Spinner } from 'patternfly-react';
4
+ import './LoadingState.scss';
5
+
6
+ const LoadingState = ({
7
+ loading,
8
+ loadingText,
9
+ children,
10
+ }) => {
11
+ if (loading) {
12
+ return (
13
+ <div className="loading-state">
14
+ <Spinner loading={loading} size="lg" />
15
+ <p>{loadingText}</p>
16
+ </div>
17
+ );
18
+ }
19
+
20
+ return children;
21
+ };
22
+
23
+ LoadingState.propTypes = {
24
+ loading: PropTypes.bool,
25
+ loadingText: PropTypes.string,
26
+ children: PropTypes.node,
27
+ };
28
+
29
+ LoadingState.defaultProps = {
30
+ loading: false,
31
+ loadingText: __('Loading'),
32
+ children: null,
33
+ };
34
+
35
+ export default LoadingState;
@@ -0,0 +1,12 @@
1
+ .loading-state {
2
+ margin-top: 5%;
3
+
4
+ .spinner {
5
+ float: none;
6
+ }
7
+
8
+ p {
9
+ font-size: 15px;
10
+ text-align: center;
11
+ }
12
+ }
@@ -0,0 +1,28 @@
1
+ /* eslint-disable */
2
+ // Ignore eslint for this entire file because our rules
3
+ // don't match patternfly-react's rules
4
+ import React from 'react';
5
+ import { shallow } from 'enzyme';
6
+ import toJson from 'enzyme-to-json';
7
+
8
+ import { LoadingState } from './index';
9
+
10
+ test('Loading State renders properly while loading', () => {
11
+ const component = shallow(
12
+ <LoadingState loading loadingText="Loading">
13
+ <p>Loading Complete</p>
14
+ </LoadingState>
15
+ );
16
+
17
+ expect(toJson(component.render())).toMatchSnapshot();
18
+ });
19
+
20
+ test('Loading State renders properly while not loading', () => {
21
+ const component = shallow(
22
+ <LoadingState loading={false} loadingText="Loading">
23
+ <p>Loading Complete</p>
24
+ </LoadingState>
25
+ );
26
+
27
+ expect(toJson(component.render())).toMatchSnapshot();
28
+ });
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Loading State renders properly while loading 1`] = `
4
+ <div
5
+ class="loading-state"
6
+ >
7
+ <div
8
+ class="spinner spinner-lg"
9
+ />
10
+ <p>
11
+ Loading
12
+ </p>
13
+ </div>
14
+ `;
15
+
16
+ exports[`Loading State renders properly while not loading 1`] = `
17
+ <p>
18
+ Loading Complete
19
+ </p>
20
+ `;
@@ -0,0 +1,3 @@
1
+ // patternfly-react doesn't use this rule and this is how their components are structured
2
+ // eslint-disable-next-line import/prefer-default-export
3
+ export { default as LoadingState } from './LoadingState';
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import toJson from 'enzyme-to-json';
4
+
5
+
6
+ // a helper method for invoking a class method (for unit tests)
7
+ // obj = a class
8
+ // func = a tested function
9
+ // objThis = an object's this
10
+ // arg = function args
11
+ export const classFunctionUnitTest = (obj, func, objThis, args) =>
12
+ obj.prototype[func].apply(objThis, args);
13
+
14
+ /**
15
+ * Shallow render a component multipile times with fixtures
16
+ * @param {ReactComponent} Component Component to shallow-render
17
+ * @param {Object} fixtures key=fixture description, value=props to apply
18
+ * @return {Object} key=fixture description, value=shallow-rendered component
19
+ */
20
+ export const shallowRenderComponentWithFixtures = (Component, fixtures) =>
21
+ Object.entries(fixtures).map(([description, props]) => ({
22
+ description,
23
+ component: shallow(<Component {...props} />),
24
+ }));
25
+
26
+ /**
27
+ * Test a component with fixtures and snapshots
28
+ * @param {ReactComponent} Component Component to test
29
+ * @param {Object} fixtures key=fixture description, value=props to apply
30
+ */
31
+ export const testComponentSnapshotsWithFixtures = (Component, fixtures) =>
32
+ shallowRenderComponentWithFixtures(Component, fixtures).forEach(({ description, component }) =>
33
+ it(description, () => expect(toJson(component)).toMatchSnapshot()));
34
+
35
+ /**
36
+ * run an action (sync or async) and except the results to much snapshot
37
+ * @param {Function} runAction Action runner function
38
+ * @return {Promise}
39
+ */
40
+ export const testActionSnapshot = async (runAction) => {
41
+ const actionResults = runAction();
42
+
43
+ // if it's an async action
44
+ if (typeof actionResults === 'function') {
45
+ const dispatch = jest.fn();
46
+ await actionResults(dispatch);
47
+
48
+ expect(dispatch.mock.calls).toMatchSnapshot();
49
+ } else {
50
+ expect(actionResults).toMatchSnapshot();
51
+ }
52
+ };
53
+
54
+ /**
55
+ * Test actions with fixtures and snapshots
56
+ * @param {Object} fixtures key=fixture description, value=action runner function
57
+ */
58
+ export const testActionSnapshotWithFixtures = fixtures =>
59
+ Object.entries(fixtures).forEach(([description, runAction]) =>
60
+ it(description, () => testActionSnapshot(runAction)));
61
+
62
+ /**
63
+ * Test a reducer with fixtures and snapshots
64
+ * @param {Function} reducer reducer to test
65
+ * @param {Object} fixtures key=fixture description, value=props to apply
66
+ */
67
+ export const testReducerSnapshotWithFixtures = (reducer, fixtures) => {
68
+ const reduce = ({ state, action = {} } = {}) => reducer(state, action);
69
+ Object.entries(fixtures).forEach(([description, action]) =>
70
+ it(description, () => expect(reduce(action)).toMatchSnapshot()));
71
+ };
@@ -23,7 +23,7 @@ export const createEnabledRepoParams = (extendedParams = {}) => {
23
23
  ]);
24
24
 
25
25
  const repoParams = {
26
- ...{ organization_id: orgId, enabled: 'true' },
26
+ ...{ organization_id: orgId(), enabled: 'true' },
27
27
  ...propsToSnakeCase(extendedParams),
28
28
  search,
29
29
  };