katello 3.10.2 → 3.11.0.rc1

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 (242) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +16 -22
  3. data/app/controllers/katello/api/v2/content_uploads_controller.rb +4 -7
  4. data/app/controllers/katello/api/v2/content_view_puppet_modules_controller.rb +4 -5
  5. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +4 -4
  6. data/app/controllers/katello/api/v2/content_views_controller.rb +3 -3
  7. data/app/controllers/katello/api/v2/docker_manifests_controller.rb +1 -1
  8. data/app/controllers/katello/api/v2/errata_controller.rb +2 -2
  9. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +1 -3
  10. data/app/controllers/katello/api/v2/package_groups_controller.rb +3 -3
  11. data/app/controllers/katello/api/v2/repositories_controller.rb +5 -24
  12. data/app/controllers/katello/api/v2/repository_sets_controller.rb +1 -1
  13. data/app/controllers/katello/application_controller.rb +4 -4
  14. data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +1 -1
  15. data/app/controllers/katello/sync_management_controller.rb +1 -1
  16. data/app/helpers/katello/errata_mailer_helper.rb +1 -1
  17. data/app/helpers/katello/sync_management_helper.rb +1 -1
  18. data/app/lib/actions/candlepin/environment/add_content_to_environment.rb +18 -0
  19. data/app/lib/actions/katello/content_view_puppet_environment/clone.rb +1 -4
  20. data/app/lib/actions/katello/content_view_puppet_environment/clone_content_for_version.rb +20 -0
  21. data/app/lib/actions/katello/content_view_puppet_environment/create_for_version.rb +3 -2
  22. data/app/lib/actions/katello/content_view_version/incremental_update.rb +15 -16
  23. data/app/lib/actions/katello/host/hypervisors_update.rb +17 -6
  24. data/app/lib/actions/katello/organization/manifest_delete.rb +1 -3
  25. data/app/lib/actions/katello/organization/manifest_import.rb +1 -3
  26. data/app/lib/actions/katello/organization/manifest_refresh.rb +1 -3
  27. data/app/lib/actions/katello/provider/update.rb +1 -1
  28. data/app/lib/actions/katello/repository/check_matching_content.rb +8 -2
  29. data/app/lib/actions/katello/repository/clone_contents.rb +52 -0
  30. data/app/lib/actions/katello/repository/clone_to_environment.rb +1 -11
  31. data/app/lib/actions/katello/repository/clone_to_version.rb +19 -29
  32. data/app/lib/actions/katello/repository/create.rb +3 -4
  33. data/app/lib/actions/katello/repository/export.rb +1 -2
  34. data/app/lib/actions/katello/repository/import_upload.rb +7 -5
  35. data/app/lib/actions/katello/repository/purge_empty_content.rb +16 -0
  36. data/app/lib/actions/katello/repository/remove_content.rb +2 -2
  37. data/app/lib/actions/katello/repository/sync.rb +1 -1
  38. data/app/lib/actions/pulp/content_view_puppet_environment/copy_contents.rb +36 -0
  39. data/app/lib/actions/pulp/repository/copy_all_units.rb +27 -0
  40. data/app/lib/actions/pulp/repository/copy_units.rb +29 -0
  41. data/app/lib/actions/pulp/repository/refresh.rb +3 -7
  42. data/app/lib/actions/pulp/repository/regenerate_applicability.rb +5 -2
  43. data/app/lib/katello/concerns/renderer_extensions.rb +1 -1
  44. data/app/lib/katello/http_resource.rb +5 -1
  45. data/app/lib/katello/resources/candlepin/consumer.rb +9 -0
  46. data/app/lib/katello/resources/candlepin/content.rb +2 -3
  47. data/app/lib/katello/util/cdn_var_substitutor.rb +1 -2
  48. data/app/lib/katello/util/path_with_substitutions.rb +18 -1
  49. data/app/lib/katello/validators/content_view_puppet_module_validator.rb +2 -2
  50. data/app/lib/katello/validators/environment_docker_repositories_validator.rb +7 -5
  51. data/app/models/katello/concerns/hostgroup_extensions.rb +2 -7
  52. data/app/models/katello/concerns/organization_extensions.rb +11 -1
  53. data/app/models/katello/concerns/pulp_database_unit.rb +40 -24
  54. data/app/models/katello/concerns/redhat_extensions.rb +7 -3
  55. data/app/models/katello/content_view.rb +5 -7
  56. data/app/models/katello/content_view_docker_filter.rb +3 -3
  57. data/app/models/katello/content_view_puppet_environment.rb +1 -1
  58. data/app/models/katello/content_view_puppet_module.rb +2 -3
  59. data/app/models/katello/docker_meta_tag.rb +1 -1
  60. data/app/models/katello/docker_tag.rb +4 -6
  61. data/app/models/katello/erratum.rb +1 -1
  62. data/app/models/katello/glue/pulp/repo.rb +3 -0
  63. data/app/models/katello/glue/pulp/repos.rb +4 -0
  64. data/app/models/katello/host/info_provider.rb +2 -2
  65. data/app/models/katello/host/subscription_facet.rb +0 -1
  66. data/app/models/katello/module_stream.rb +10 -4
  67. data/app/models/katello/ostree_branch.rb +4 -2
  68. data/app/models/katello/package_group.rb +2 -2
  69. data/app/models/katello/ping.rb +1 -1
  70. data/app/models/katello/puppet_module.rb +3 -3
  71. data/app/models/katello/repository.rb +15 -2
  72. data/app/models/katello/root_repository.rb +10 -0
  73. data/app/models/katello/yum_metadata_file.rb +46 -0
  74. data/app/services/katello/abstract/pulp/content.rb +19 -0
  75. data/app/services/katello/applicable_content_helper.rb +5 -5
  76. data/app/services/katello/pulp/content.rb +17 -0
  77. data/app/services/katello/pulp/repository.rb +45 -15
  78. data/app/services/katello/pulp/repository/deb.rb +8 -0
  79. data/app/services/katello/pulp/repository/docker.rb +19 -0
  80. data/app/services/katello/pulp/repository/file.rb +10 -0
  81. data/app/services/katello/pulp/repository/ostree.rb +4 -0
  82. data/app/services/katello/pulp/repository/puppet.rb +10 -0
  83. data/app/services/katello/pulp/repository/yum.rb +73 -0
  84. data/app/services/katello/pulp/yum_metadata_file.rb +7 -0
  85. data/app/services/katello/repository_type.rb +5 -0
  86. data/app/views/dashboard/_errata_widget.html.erb +1 -1
  87. data/app/views/katello/api/v2/debs/base.json.rabl +2 -1
  88. data/app/views/katello/api/v2/docker_tags/_base.json.rabl +3 -3
  89. data/app/views/katello/api/v2/errata/show.json.rabl +2 -1
  90. data/app/views/katello/api/v2/file_units/base.json.rabl +2 -1
  91. data/app/views/katello/api/v2/module_streams/base.json.rabl +2 -1
  92. data/app/views/katello/api/v2/ostree_branches/show.json.rabl +3 -2
  93. data/app/views/katello/api/v2/package_groups/base.json.rabl +2 -1
  94. data/app/views/katello/api/v2/package_groups/show.json.rabl +1 -1
  95. data/app/views/katello/api/v2/packages/base.json.rabl +2 -1
  96. data/app/views/katello/api/v2/packages/show.json.rabl +1 -1
  97. data/app/views/katello/api/v2/puppet_modules/base.json.rabl +2 -1
  98. data/app/views/katello/api/v2/puppet_modules/show.json.rabl +1 -1
  99. data/app/views/katello/api/v2/repositories/base.json.rabl +1 -0
  100. data/app/views/katello/layouts/react.html.erb +3 -3
  101. data/db/migrate/20181219205642_create_yum_metadata_file.rb +20 -0
  102. data/db/migrate/20190107160723_units_uuid_to_backend_ident.rb +8 -0
  103. data/db/seeds.d/101-locations.rb +11 -13
  104. data/db/seeds.d/102-organizations.rb +5 -3
  105. data/db/seeds.d/111-upgrade_tasks.rb +1 -1
  106. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +2 -0
  107. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/common/views/subscription-add-or-remove.html +1 -1
  108. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-subscriptions-modal.html +2 -2
  109. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.module.js +2 -1
  110. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-errata.html +2 -2
  111. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-events.html +1 -1
  112. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +2 -2
  113. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-provisioning-info.html +1 -1
  114. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +2 -2
  115. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.module.js +2 -1
  116. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/errata-filter-details.html +2 -2
  117. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/filter-repositories.html +2 -2
  118. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/filters.html +1 -1
  119. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/histories/views/content-view-history.html +20 -20
  120. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-deb-repositories.html +1 -1
  121. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-docker-repositories.html +1 -1
  122. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-file-repositories.html +1 -1
  123. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-ostree-repositories.html +1 -1
  124. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-repositories.html +1 -1
  125. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-versions.html +1 -1
  126. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/content-view-version-content.controller.js +1 -1
  127. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/views/content-view-version-errata.html +1 -1
  128. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/views/content-view-version-ostree-branches.html +2 -0
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/views/content-views.html +1 -1
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/dates/dates.module.js +50 -0
  131. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-content-views.html +1 -1
  132. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-details.html +0 -1
  133. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-errata.html +2 -1
  134. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-ostree.html +2 -0
  135. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/environments.module.js +2 -1
  136. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/views/erratum-info.html +2 -2
  137. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/errata.module.js +2 -1
  138. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/errata.html +1 -1
  139. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/ostree-branches/details/views/ostree-branch-info.html +3 -0
  140. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/views/products-bulk-sync-plan-modal.html +3 -3
  141. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +6 -5
  142. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-manage-ostree-branches.html +4 -0
  143. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-info.html +5 -4
  144. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +7 -8
  145. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/views/partials/product-table-sync-status.html +5 -4
  146. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-info.html +3 -3
  147. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/views/manifest-details.html +2 -2
  148. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/views/manifest-import-history.html +1 -1
  149. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/subscription-start-date.html +1 -1
  150. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/subscriptions.html +1 -1
  151. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/views/sync-plan-info.html +1 -1
  152. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/views/sync-plans.html +2 -2
  153. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/views/task-details.html +2 -2
  154. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/views/tasks-table.html +1 -1
  155. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/views/user-tasks-table.html +1 -1
  156. data/engines/bastion_katello/lib/bastion_katello/engine.rb +6 -1
  157. data/lib/katello/engine.rb +3 -3
  158. data/lib/katello/plugin.rb +3 -3
  159. data/lib/katello/repository_types/deb.rb +1 -0
  160. data/lib/katello/repository_types/yum.rb +1 -0
  161. data/lib/katello/tasks/reimport.rake +1 -0
  162. data/lib/katello/tasks/repository.rake +1 -1
  163. data/lib/katello/tasks/upgrades/3.11/import_yum_metadata_file.rake +12 -0
  164. data/lib/katello/version.rb +1 -1
  165. data/package.json +3 -1
  166. data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +2 -0
  167. data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +8 -0
  168. data/webpack/common_index.js +6 -0
  169. data/webpack/containers/Application/config.js +3 -3
  170. data/webpack/move_to_foreman/components/common/table/components/Table.js +3 -3
  171. data/webpack/move_to_foreman/components/common/table/components/Table.test.js +2 -0
  172. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/Table.test.js.snap +1 -17
  173. data/webpack/redux/actions/RedHatRepositories/helpers.js +19 -10
  174. data/webpack/scenes/ModuleStreams/Details/Profiles/__tests__/ModuleStreamDetailProfiles.test.js +2 -0
  175. data/webpack/scenes/ModuleStreams/Details/Repositories/__tests__/ModuleStreamDetailRepositories.test.js +2 -0
  176. data/webpack/scenes/ModuleStreams/Details/__tests__/ModuleStreamDetails.test.js +2 -0
  177. data/webpack/scenes/ModuleStreams/__tests__/ModuleStreamPage.test.js +1 -0
  178. data/webpack/scenes/ModuleStreams/__tests__/ModuleStreamsTable.test.js +1 -0
  179. data/webpack/scenes/RedHatRepositories/helpers.js +3 -3
  180. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetailProductContent.test.js.snap +1 -0
  181. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +1 -1
  182. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManageManifestModal.test.js +1 -0
  183. data/webpack/scenes/Subscriptions/Manifest/__tests__/__snapshots__/ManageManifestModal.test.js.snap +1 -1
  184. data/webpack/scenes/Subscriptions/SubscriptionActions.js +10 -0
  185. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +6 -0
  186. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +16 -0
  187. data/webpack/scenes/Subscriptions/SubscriptionValidations.js +3 -3
  188. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +28 -25
  189. data/webpack/scenes/Subscriptions/SubscriptionsSelectors.js +6 -0
  190. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +0 -1
  191. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsPage.test.js +1 -0
  192. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +0 -1
  193. data/webpack/scenes/Subscriptions/__tests__/SubscriptionValidations.test.js +9 -4
  194. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js +14 -0
  195. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +2 -0
  196. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsReducer.test.js +24 -0
  197. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsSelectors.test.js +6 -0
  198. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsActions.test.js.snap +24 -0
  199. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +1 -1
  200. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsReducer.test.js.snap +138 -0
  201. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsSelectors.test.js.snap +6 -0
  202. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/EntitlementsInlineEditFormatter.js +8 -6
  203. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js +23 -11
  204. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/EntitlementsInlineEditFormatter.test.js +14 -10
  205. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.fixtures.js +105 -0
  206. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.test.js +2 -0
  207. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTableHelpers.test.js +44 -0
  208. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/EntitlementsInlineEditFormatter.test.js.snap +3 -3
  209. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +2 -222
  210. data/webpack/scenes/Subscriptions/index.js +4 -0
  211. metadata +41 -44
  212. data/app/lib/actions/katello/content_view_puppet_environment/clone_content.rb +0 -32
  213. data/app/lib/actions/katello/repository/clone_deb_content.rb +0 -70
  214. data/app/lib/actions/katello/repository/clone_docker_content.rb +0 -26
  215. data/app/lib/actions/katello/repository/clone_file_content.rb +0 -17
  216. data/app/lib/actions/katello/repository/clone_ostree_content.rb +0 -17
  217. data/app/lib/actions/katello/repository/clone_yum_content.rb +0 -105
  218. data/app/lib/actions/katello/repository/clone_yum_metadata.rb +0 -36
  219. data/app/lib/actions/pulp/repository/copy_deb.rb +0 -15
  220. data/app/lib/actions/pulp/repository/copy_deb_component.rb +0 -11
  221. data/app/lib/actions/pulp/repository/copy_deb_release.rb +0 -11
  222. data/app/lib/actions/pulp/repository/copy_distribution.rb +0 -11
  223. data/app/lib/actions/pulp/repository/copy_docker_manifest.rb +0 -11
  224. data/app/lib/actions/pulp/repository/copy_docker_tag.rb +0 -11
  225. data/app/lib/actions/pulp/repository/copy_errata.rb +0 -15
  226. data/app/lib/actions/pulp/repository/copy_files.rb +0 -11
  227. data/app/lib/actions/pulp/repository/copy_module_default.rb +0 -11
  228. data/app/lib/actions/pulp/repository/copy_module_stream.rb +0 -11
  229. data/app/lib/actions/pulp/repository/copy_ostree_branch.rb +0 -11
  230. data/app/lib/actions/pulp/repository/copy_package_group.rb +0 -11
  231. data/app/lib/actions/pulp/repository/copy_puppet_module.rb +0 -15
  232. data/app/lib/actions/pulp/repository/copy_rpm.rb +0 -15
  233. data/app/lib/actions/pulp/repository/copy_srpm.rb +0 -16
  234. data/app/lib/actions/pulp/repository/copy_yum_metadata_file.rb +0 -11
  235. data/app/lib/actions/pulp/repository/purge_empty_errata.rb +0 -19
  236. data/app/lib/actions/pulp/repository/purge_empty_package_groups.rb +0 -24
  237. data/db/migrate/20190326145039_remove_version_date_from_ostree_branch.rb +0 -5
  238. data/lib/katello/tasks/upgrades/3.10/update_gpg_key_urls.rake +0 -32
  239. data/webpack/components/PaginationRow/PaginationRow.test.js +0 -25
  240. data/webpack/components/PaginationRow/__snapshots__/PaginationRow.test.js.snap +0 -35
  241. data/webpack/components/PaginationRow/index.js +0 -94
  242. data/webpack/move_to_foreman/components/common/EmptyState/index.js +0 -68
@@ -1,5 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`Subscriptions selectors should select delete-button-disabled 1`] = `true`;
4
+
3
5
  exports[`Subscriptions selectors should select delete-modal-opened 1`] = `false`;
4
6
 
5
7
  exports[`Subscriptions selectors should select manifest-modal-opened 1`] = `false`;
@@ -13,11 +15,15 @@ Array [
13
15
  ]
14
16
  `;
15
17
 
18
+ exports[`Subscriptions selectors should select task-modal-opened 1`] = `false`;
19
+
16
20
  exports[`Subscriptions selectors should select the subscriptions state 1`] = `
17
21
  Object {
22
+ "deleteButtonDisabled": true,
18
23
  "deleteModalOpened": false,
19
24
  "manifestModalOpened": false,
20
25
  "searchQuery": "some-query",
26
+ "taskModalOpened": false,
21
27
  "tasks": Array [
22
28
  "task1",
23
29
  "task2",
@@ -34,20 +34,22 @@ export const entitlementsInlineEditFormatter =
34
34
  );
35
35
  },
36
36
  renderEdit: (value, additionalData) => {
37
- const { availableQuantity, availableQuantityLoaded } = additionalData.rowData;
37
+ const {
38
+ upstreamAvailable, upstreamAvailableLoaded, maxQuantity,
39
+ } = additionalData.rowData;
38
40
 
39
41
  const className = inlineEditController.hasChanged(additionalData)
40
42
  ? 'editable editing changed'
41
43
  : 'editable editing';
42
44
 
43
45
  let maxMessage;
44
- if (availableQuantityLoaded && (availableQuantity !== undefined)) {
45
- maxMessage = (availableQuantity < 1)
46
+ if (maxQuantity && upstreamAvailableLoaded && (upstreamAvailable !== undefined)) {
47
+ maxMessage = (upstreamAvailable < 0)
46
48
  ? __('Unlimited')
47
- : sprintf(__('Max %(availableQuantity)s'), { availableQuantity });
49
+ : sprintf(__('Max %(maxQuantity)s'), { maxQuantity });
48
50
  }
49
51
 
50
- const validation = validateQuantity(value, availableQuantity);
52
+ const validation = validateQuantity(value, maxQuantity);
51
53
 
52
54
  const formGroup = (
53
55
  // We have to block editing until available quantities are loaded.
@@ -58,7 +60,7 @@ export const entitlementsInlineEditFormatter =
58
60
  // The same issue prevents from correct switching inputs on TAB.
59
61
  // See the reactabular code for details:
60
62
  // https://github.com/reactabular/reactabular/blob/master/packages/reactabular-table/src/body-row.js#L58
61
- <Spinner loading={!availableQuantityLoaded} size="xs">
63
+ <Spinner loading={!upstreamAvailableLoaded} size="xs">
62
64
  <FormGroup
63
65
  validationState={validation.state}
64
66
  >
@@ -1,23 +1,36 @@
1
+ const getMaxQuantity = (subscription, upstreamAvailable) => {
2
+ if (upstreamAvailable === -1) {
3
+ return upstreamAvailable;
4
+ }
5
+ return upstreamAvailable + subscription.quantity;
6
+ };
7
+
1
8
  const buildTableRow = (subscription, availableQuantities, updatedQuantity) => {
2
- const availableQuantityLoaded = !!availableQuantities;
3
- const availableQuantity = availableQuantityLoaded
9
+ const upstreamAvailableLoaded = !!availableQuantities;
10
+ const upstreamAvailable = upstreamAvailableLoaded
4
11
  ? availableQuantities[subscription.id]
5
12
  : null;
6
13
 
14
+ let maxQuantity;
15
+ if (upstreamAvailableLoaded) {
16
+ maxQuantity = getMaxQuantity(subscription, upstreamAvailable);
17
+ }
18
+
19
+ const baseSubscription = {
20
+ ...subscription,
21
+ upstreamAvailable,
22
+ upstreamAvailableLoaded,
23
+ maxQuantity,
24
+ };
25
+
7
26
  if (updatedQuantity[subscription.id]) {
8
27
  return {
9
- ...subscription,
28
+ ...baseSubscription,
10
29
  entitlementsChanged: true,
11
30
  quantity: updatedQuantity[subscription.id],
12
- availableQuantity,
13
- availableQuantityLoaded,
14
31
  };
15
32
  }
16
- return {
17
- ...subscription,
18
- availableQuantity,
19
- availableQuantityLoaded,
20
- };
33
+ return baseSubscription;
21
34
  };
22
35
 
23
36
  const buildTableRowsFromGroup = (subscriptionGroup, availableQuantities, updatedQuantity) => {
@@ -36,7 +49,6 @@ const buildTableRowsFromGroup = (subscriptionGroup, availableQuantities, updated
36
49
 
37
50
  export const buildTableRows = (groupedSubscriptions, availableQuantities, updatedQuantity) => {
38
51
  const rows = [];
39
-
40
52
  Object.values(groupedSubscriptions).forEach(subscriptionGroup =>
41
53
  rows.push(...buildTableRowsFromGroup(subscriptionGroup, availableQuantities, updatedQuantity)));
42
54
 
@@ -22,7 +22,7 @@ describe('EntitlementsInlineEditFormatter', () => {
22
22
  const controller = mockController();
23
23
  const value = 100;
24
24
  const formatter = editFormatter(controller)(value, data({
25
- availableQuantityLoaded: false,
25
+ upstreamAvailableLoaded: false,
26
26
  }));
27
27
 
28
28
  expect(toJson(shallow(formatter))).toMatchSnapshot();
@@ -34,8 +34,9 @@ describe('EntitlementsInlineEditFormatter', () => {
34
34
  const controller = mockController();
35
35
  const value = 100;
36
36
  const formatter = editFormatter(controller)(value, data({
37
- availableQuantityLoaded: true,
38
- availableQuantity: 500,
37
+ upstreamAvailableLoaded: true,
38
+ upstreamAvailable: 500,
39
+ maxQuantity: 600,
39
40
  }));
40
41
 
41
42
  expect(toJson(shallow(formatter))).toMatchSnapshot();
@@ -45,8 +46,9 @@ describe('EntitlementsInlineEditFormatter', () => {
45
46
  const controller = mockController();
46
47
  const value = 100;
47
48
  const formatter = editFormatter(controller)(value, data({
48
- availableQuantityLoaded: true,
49
- availableQuantity: -1,
49
+ upstreamAvailableLoaded: true,
50
+ upstreamAvailable: -1,
51
+ maxQuantity: -1,
50
52
  }));
51
53
 
52
54
  expect(toJson(shallow(formatter))).toMatchSnapshot();
@@ -56,8 +58,9 @@ describe('EntitlementsInlineEditFormatter', () => {
56
58
  const controller = mockController();
57
59
  const value = 200;
58
60
  const formatter = editFormatter(controller)(value, data({
59
- availableQuantityLoaded: true,
60
- availableQuantity: 100,
61
+ upstreamAvailableLoaded: true,
62
+ upstreamAvailable: 100,
63
+ maxQuantity: 150,
61
64
  }));
62
65
 
63
66
  expect(toJson(shallow(formatter))).toMatchSnapshot();
@@ -67,8 +70,9 @@ describe('EntitlementsInlineEditFormatter', () => {
67
70
  const controller = mockController({ changed: true });
68
71
  const value = 100;
69
72
  const formatter = editFormatter(controller)(value, data({
70
- availableQuantityLoaded: true,
71
- availableQuantity: 200,
73
+ upstreamAvailableLoaded: true,
74
+ upstreamAvailable: 200,
75
+ maxQuantity: 300,
72
76
  }));
73
77
 
74
78
  expect(toJson(shallow(formatter))).toMatchSnapshot();
@@ -80,7 +84,7 @@ describe('EntitlementsInlineEditFormatter', () => {
80
84
  const controller = mockController();
81
85
  const value = 200;
82
86
  const formatter = editFormatter(controller)(value, data({
83
- availableQuantityLoaded: true,
87
+ upstreamAvailableLoaded: true,
84
88
  }));
85
89
 
86
90
  expect(toJson(shallow(formatter))).toMatchSnapshot();
@@ -0,0 +1,105 @@
1
+ import Immutable from 'seamless-immutable';
2
+
3
+ const groupedSubscriptions = Immutable({
4
+ RH00001: {
5
+ open: false,
6
+ subscriptions: [
7
+ {
8
+ id: 1,
9
+ name: 'Alpha',
10
+ quantity: 10,
11
+ consumed: 0,
12
+ product_id: 'RH00001',
13
+ },
14
+ {
15
+ id: 2,
16
+ name: 'Alpha',
17
+ quantity: 15,
18
+ consumed: 5,
19
+ product_id: 'RH00001',
20
+ },
21
+ ],
22
+ },
23
+ RH00002: {
24
+ open: false,
25
+ subscriptions: [
26
+ {
27
+ id: 3,
28
+ name: 'Charlie',
29
+ quantity: 10,
30
+ consumed: 0,
31
+ product_id: 'RH00002',
32
+ },
33
+ ],
34
+ },
35
+ RH00003: {
36
+ open: false,
37
+ subscriptions: [
38
+ {
39
+ id: 4,
40
+ name: 'Bravo',
41
+ quantity: 100,
42
+ consumed: 0,
43
+ product_id: 'RH00003',
44
+ },
45
+ ],
46
+ },
47
+ RH00004: {
48
+ open: false,
49
+ subscriptions: [
50
+ {
51
+ id: 5,
52
+ name: 'Delta',
53
+ quantity: 15,
54
+ consumed: 5,
55
+ product_id: 'RH00004',
56
+ },
57
+ ],
58
+ },
59
+ });
60
+
61
+ export const subOne = Immutable({
62
+ consumed: 0,
63
+ id: 1,
64
+ maxQuantity: 60,
65
+ name: 'Alpha',
66
+ product_id: 'RH00001',
67
+ quantity: 10,
68
+ upstreamAvailable: 50,
69
+ upstreamAvailableLoaded: true,
70
+ });
71
+
72
+ export const subTwo = Immutable({
73
+ consumed: 0,
74
+ id: 3,
75
+ maxQuantity: -1,
76
+ name: 'Charlie',
77
+ product_id: 'RH00002',
78
+ quantity: 10,
79
+ upstreamAvailable: -1,
80
+ upstreamAvailableLoaded: true,
81
+ });
82
+
83
+ export const subThree = Immutable({
84
+ consumed: 0,
85
+ id: 4,
86
+ maxQuantity: 200,
87
+ name: 'Bravo',
88
+ product_id: 'RH00003',
89
+ quantity: 100,
90
+ upstreamAvailable: 100,
91
+ upstreamAvailableLoaded: true,
92
+ });
93
+
94
+ export const subFour = Immutable({
95
+ consumed: 5,
96
+ id: 5,
97
+ maxQuantity: 65,
98
+ name: 'Delta',
99
+ product_id: 'RH00004',
100
+ quantity: 15,
101
+ upstreamAvailable: 50,
102
+ upstreamAvailableLoaded: true,
103
+ });
104
+
105
+ export default groupedSubscriptions;
@@ -7,7 +7,9 @@ import { successState, loadingState, emptyState } from '../../../__tests__/subsc
7
7
  import { loadSubscriptions, updateQuantity } from '../../../SubscriptionActions';
8
8
 
9
9
  jest.mock('../../../../../move_to_foreman/foreman_toast_notifications');
10
+ jest.mock('foremanReact/components/Pagination/PaginationWrapper');
10
11
  jest.useFakeTimers();
12
+
11
13
  const tableColumns = [
12
14
  'id',
13
15
  'product_id',
@@ -0,0 +1,44 @@
1
+ import groupedSubscriptions, { subOne, subTwo, subThree, subFour } from './SubscriptionsTable.fixtures';
2
+ import { buildTableRows } from '../SubscriptionsTableHelpers';
3
+
4
+ describe('Build Table Rows', () => {
5
+ it('should display correct maxQuantity', () => {
6
+ const availableQuantities = {
7
+ 1: 50,
8
+ 2: 50,
9
+ 3: -1,
10
+ 4: 100,
11
+ 5: 50,
12
+ };
13
+
14
+ const rows = [subOne, subTwo, subThree, subFour];
15
+
16
+ expect(buildTableRows(groupedSubscriptions, availableQuantities, {}))
17
+ .toEqual(rows);
18
+ });
19
+
20
+ it('should update quantities', () => {
21
+ const availableQuantities = {
22
+ 1: 50,
23
+ 2: 50,
24
+ 3: -1,
25
+ 4: 100,
26
+ 5: 50,
27
+ };
28
+
29
+ const updatedQuantities = {
30
+ 1: 20,
31
+ 4: 150,
32
+ };
33
+
34
+ const rows = [
35
+ { ...subOne, entitlementsChanged: true, quantity: 20 },
36
+ subTwo,
37
+ { ...subThree, entitlementsChanged: true, quantity: 150 },
38
+ subFour,
39
+ ];
40
+
41
+ expect(buildTableRows(groupedSubscriptions, availableQuantities, updatedQuantities))
42
+ .toEqual(rows);
43
+ });
44
+ });
@@ -57,7 +57,7 @@ exports[`EntitlementsInlineEditFormatter edit mode when available quantities are
57
57
  <HelpBlock
58
58
  bsClass="help-block"
59
59
  >
60
- Max 200
60
+ Max 300
61
61
  <div
62
62
  className="validationMessages"
63
63
  />
@@ -91,7 +91,7 @@ exports[`EntitlementsInlineEditFormatter edit mode when available quantities are
91
91
  <HelpBlock
92
92
  bsClass="help-block"
93
93
  >
94
- Max 500
94
+ Max 600
95
95
  <div
96
96
  className="validationMessages"
97
97
  />
@@ -160,7 +160,7 @@ exports[`EntitlementsInlineEditFormatter edit mode when available quantities are
160
160
  <HelpBlock
161
161
  bsClass="help-block"
162
162
  >
163
- Max 100
163
+ Max 150
164
164
  <div
165
165
  className="validationMessages"
166
166
  >
@@ -209,231 +209,11 @@ exports[`subscriptions table should render a table 1`] = `
209
209
  </tr>
210
210
  </tbody>
211
211
  </table>
212
- <form
213
- class="content-view-pf-pagination table-view-pf-pagination clearfix"
214
- >
215
- <div
216
- class="form-group"
217
- >
218
- <div
219
- class="dropup pagination-pf-pagesize btn-group"
220
- >
221
- <button
222
- aria-expanded="false"
223
- aria-haspopup="true"
224
- class="dropdown-toggle btn btn-default"
225
- id="pagination-row-dropdown"
226
- role="button"
227
- type="button"
228
- >
229
- 2
230
- <span
231
- class="caret"
232
- />
233
- </button>
234
- <ul
235
- aria-labelledby="pagination-row-dropdown"
236
- class="dropdown-menu"
237
- role="menu"
238
- >
239
- <li
240
- class=""
241
- role="presentation"
242
- >
243
- <a
244
- href="#"
245
- role="menuitem"
246
- tabindex="-1"
247
- >
248
- 5
249
- </a>
250
- </li>
251
- <li
252
- class=""
253
- role="presentation"
254
- >
255
- <a
256
- href="#"
257
- role="menuitem"
258
- tabindex="-1"
259
- >
260
- 10
261
- </a>
262
- </li>
263
- <li
264
- class=""
265
- role="presentation"
266
- >
267
- <a
268
- href="#"
269
- role="menuitem"
270
- tabindex="-1"
271
- >
272
- 15
273
- </a>
274
- </li>
275
- <li
276
- class=""
277
- role="presentation"
278
- >
279
- <a
280
- href="#"
281
- role="menuitem"
282
- tabindex="-1"
283
- >
284
- 20
285
- </a>
286
- </li>
287
- <li
288
- class=""
289
- role="presentation"
290
- >
291
- <a
292
- href="#"
293
- role="menuitem"
294
- tabindex="-1"
295
- >
296
- 25
297
- </a>
298
- </li>
299
- <li
300
- class=""
301
- role="presentation"
302
- >
303
- <a
304
- href="#"
305
- role="menuitem"
306
- tabindex="-1"
307
- >
308
- 50
309
- </a>
310
- </li>
311
- </ul>
312
- </div>
313
- <span>
314
- per page
315
- </span>
316
- </div>
317
- <div
318
- class="form-group"
319
- >
320
- <span>
321
- <span
322
- class="pagination-pf-items-current"
323
- >
324
- 1-2
325
- </span>
326
-  of 
327
- <span
328
- class="pagination-pf-items-total"
329
- >
330
- 81
331
- </span>
332
- </span>
333
- <ul
334
- class="pagination pagination-pf-back"
335
- >
336
- <li
337
- class="disabled"
338
- >
339
- <a
340
- href="#"
341
- title="First Page"
342
- >
343
- <span
344
- aria-hidden="true"
345
- class="fa fa-angle-double-left i"
346
- />
347
- </a>
348
- </li>
349
- <li
350
- class="disabled"
351
- >
352
- <a
353
- href="#"
354
- title="Previous Page"
355
- >
356
- <span
357
- aria-hidden="true"
358
- class="fa fa-angle-left i"
359
- />
360
- </a>
361
- </li>
362
- </ul>
363
- <label
364
- class="sr-only control-label"
365
- >
366
- Current Page
367
- </label>
368
- <input
369
- class="pagination-pf-page form-control"
370
- type="text"
371
- value="1"
372
- />
373
- <span>
374
-  of 
375
- <span
376
- class="pagination-pf-pages"
377
- >
378
- 41
379
- </span>
380
- </span>
381
- <ul
382
- class="pagination pagination-pf-forward"
383
- >
384
- <li
385
- class=""
386
- >
387
- <a
388
- href="#"
389
- title="Next Page"
390
- >
391
- <span
392
- aria-hidden="true"
393
- class="fa fa-angle-right i"
394
- />
395
- </a>
396
- </li>
397
- <li
398
- class=""
399
- >
400
- <a
401
- href="#"
402
- title="Last Page"
403
- >
404
- <span
405
- aria-hidden="true"
406
- class="fa fa-angle-double-right i"
407
- />
408
- </a>
409
- </li>
410
- </ul>
411
- </div>
412
- </form>
413
212
  </div>
414
213
  `;
415
214
 
416
215
  exports[`subscriptions table should render an empty state 1`] = `
417
- <div
418
- class="blank-slate-pf"
419
- >
420
- <div
421
- class="blank-slate-pf-icon"
422
- >
423
- <span
424
- aria-hidden="true"
425
- class="pficon pficon-add-circle-o"
426
- />
427
- </div>
428
- <h4
429
- class="h1 blank-slate-pf-title"
430
- >
431
- Yay empty state
432
- </h4>
433
- <p
434
- class="blank-slate-pf-info"
435
- >
436
- There is nothing to see here
437
- </p>
216
+ <div>
217
+ EmptyState: {"header":"Yay empty state","description":"There is nothing to see here"}
438
218
  </div>
439
219
  `;