katello 4.4.2.2 → 4.5.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 (444) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +5 -1
  3. data/app/controllers/katello/api/v2/alternate_content_sources_controller.rb +98 -0
  4. data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +39 -3
  5. data/app/controllers/katello/api/v2/content_exports_controller.rb +19 -0
  6. data/app/controllers/katello/api/v2/content_imports_controller.rb +13 -16
  7. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +0 -12
  8. data/app/controllers/katello/api/v2/content_views_controller.rb +13 -0
  9. data/app/controllers/katello/api/v2/environments_controller.rb +1 -1
  10. data/app/controllers/katello/api/v2/host_module_streams_controller.rb +8 -2
  11. data/app/controllers/katello/api/v2/host_subscriptions_controller.rb +25 -3
  12. data/app/controllers/katello/api/v2/organizations_controller.rb +4 -2
  13. data/app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb +1 -1
  14. data/app/controllers/katello/api/v2/repositories_controller.rb +9 -3
  15. data/app/controllers/katello/api/v2/repository_sets_controller.rb +40 -7
  16. data/app/controllers/katello/api/v2/subscriptions_controller.rb +2 -2
  17. data/app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb +1 -1
  18. data/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb +4 -0
  19. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +21 -3
  20. data/app/lib/actions/katello/alternate_content_source/create.rb +24 -0
  21. data/app/lib/actions/katello/alternate_content_source/destroy.rb +27 -0
  22. data/app/lib/actions/katello/alternate_content_source/update.rb +41 -0
  23. data/app/lib/actions/katello/cdn_configuration/update.rb +2 -2
  24. data/app/lib/actions/katello/content_view/destroy.rb +2 -1
  25. data/app/lib/actions/katello/content_view/incremental_updates.rb +7 -3
  26. data/app/lib/actions/katello/content_view/publish.rb +7 -9
  27. data/app/lib/actions/katello/content_view_version/auto_create_products.rb +4 -4
  28. data/app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb +6 -4
  29. data/app/lib/actions/katello/content_view_version/auto_create_repositories.rb +6 -4
  30. data/app/lib/actions/katello/content_view_version/import.rb +25 -22
  31. data/app/lib/actions/katello/content_view_version/import_library.rb +0 -1
  32. data/app/lib/actions/katello/content_view_version/import_repository.rb +21 -0
  33. data/app/lib/actions/katello/content_view_version/incremental_update.rb +85 -93
  34. data/app/lib/actions/katello/content_view_version/reset_content_view_repositories_from_metadata.rb +2 -2
  35. data/app/lib/actions/katello/product/content_create.rb +10 -8
  36. data/app/lib/actions/katello/repository/destroy.rb +36 -12
  37. data/app/lib/actions/katello/repository_set/disable_repository.rb +8 -3
  38. data/app/lib/actions/pulp3/alternate_content_source/create.rb +20 -0
  39. data/app/lib/actions/pulp3/alternate_content_source/create_remote.rb +20 -0
  40. data/app/lib/actions/pulp3/alternate_content_source/delete.rb +16 -0
  41. data/app/lib/actions/pulp3/alternate_content_source/delete_remote.rb +16 -0
  42. data/app/lib/actions/pulp3/alternate_content_source/update.rb +16 -0
  43. data/app/lib/actions/pulp3/alternate_content_source/update_remote.rb +17 -0
  44. data/app/lib/actions/pulp3/content_view_version/{import.rb → create_import.rb} +5 -5
  45. data/app/lib/actions/pulp3/content_view_version/create_importer.rb +4 -3
  46. data/app/lib/actions/pulp3/content_view_version/destroy_importer.rb +12 -1
  47. data/app/lib/actions/pulp3/orchestration/alternate_content_source/create.rb +18 -0
  48. data/app/lib/actions/pulp3/orchestration/alternate_content_source/delete.rb +23 -0
  49. data/app/lib/actions/pulp3/orchestration/alternate_content_source/update.rb +18 -0
  50. data/app/lib/actions/pulp3/orchestration/content_view_version/copy_version_units_to_library.rb +1 -1
  51. data/app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb +51 -0
  52. data/app/lib/actions/pulp3/orchestration/content_view_version/import.rb +5 -2
  53. data/app/lib/actions/pulp3/repository/refresh_distribution.rb +4 -1
  54. data/app/lib/actions/pulp3/repository/save_distribution_references.rb +2 -0
  55. data/app/lib/katello/api/v2/error_handling.rb +1 -0
  56. data/app/lib/katello/resources/cdn/katello_cdn.rb +3 -1
  57. data/app/lib/katello/util/errata.rb +2 -3
  58. data/app/lib/katello/validators/alternate_content_source_path_validator.rb +29 -0
  59. data/app/lib/katello/validators/content_default_http_proxy_setting_validator.rb +12 -0
  60. data/app/lib/katello/validators/content_view_environment_validator.rb +10 -5
  61. data/app/models/katello/alternate_content_source.rb +66 -0
  62. data/app/models/katello/authorization/alternate_content_source.rb +33 -0
  63. data/app/models/katello/authorization/repository.rb +3 -3
  64. data/app/models/katello/candlepin/repository_mapper.rb +13 -6
  65. data/app/models/katello/cdn_configuration.rb +15 -15
  66. data/app/models/katello/concerns/content_facet_host_extensions.rb +25 -0
  67. data/app/models/katello/concerns/host_managed_extensions.rb +7 -5
  68. data/app/models/katello/concerns/http_proxy_extensions.rb +14 -0
  69. data/app/models/katello/concerns/organization_extensions.rb +4 -2
  70. data/app/models/katello/concerns/setting_extensions.rb +14 -0
  71. data/app/models/katello/concerns/smart_proxy_extensions.rb +2 -1
  72. data/app/models/katello/content.rb +1 -0
  73. data/app/models/katello/content_credential.rb +6 -0
  74. data/app/models/katello/content_override.rb +7 -3
  75. data/app/models/katello/content_view.rb +33 -2
  76. data/app/models/katello/content_view_erratum_filter.rb +26 -12
  77. data/app/models/katello/content_view_filter.rb +4 -0
  78. data/app/models/katello/content_view_version.rb +12 -0
  79. data/app/models/katello/content_view_version_export_history.rb +3 -1
  80. data/app/models/katello/erratum.rb +9 -5
  81. data/app/models/katello/events/delete_latest_content_view_version.rb +40 -0
  82. data/app/models/katello/host/content_facet.rb +14 -0
  83. data/app/models/katello/host_available_module_stream.rb +12 -0
  84. data/app/models/katello/product_content.rb +1 -0
  85. data/app/models/katello/purpose_sla_status.rb +1 -1
  86. data/app/models/katello/purpose_status.rb +2 -2
  87. data/app/models/katello/repository.rb +7 -4
  88. data/app/models/katello/root_repository.rb +1 -1
  89. data/app/models/katello/smart_proxy_alternate_content_source.rb +8 -0
  90. data/app/models/katello/sync_plan.rb +1 -1
  91. data/app/presenters/katello/product_content_presenter.rb +15 -0
  92. data/app/services/katello/applicable_host_queue.rb +1 -1
  93. data/app/services/katello/content_unit_indexer.rb +2 -1
  94. data/app/services/katello/product_content_finder.rb +12 -2
  95. data/app/services/katello/pulp3/alternate_content_source.rb +117 -0
  96. data/app/services/katello/pulp3/api/file.rb +8 -0
  97. data/app/services/katello/pulp3/api/yum.rb +8 -0
  98. data/app/services/katello/pulp3/content_view_version/export.rb +27 -5
  99. data/app/services/katello/pulp3/content_view_version/import.rb +97 -71
  100. data/app/services/katello/pulp3/content_view_version/import_export_common.rb +4 -4
  101. data/app/services/katello/pulp3/content_view_version/import_gpg_keys.rb +13 -11
  102. data/app/services/katello/pulp3/content_view_version/import_validator.rb +67 -72
  103. data/app/services/katello/pulp3/content_view_version/importable_products.rb +40 -24
  104. data/app/services/katello/pulp3/content_view_version/importable_repositories.rb +88 -39
  105. data/app/services/katello/pulp3/content_view_version/metadata_generator.rb +2 -2
  106. data/app/services/katello/pulp3/content_view_version/metadata_map.rb +117 -0
  107. data/app/services/katello/pulp3/pulp_content_unit.rb +6 -1
  108. data/app/services/katello/pulp3/repository/yum.rb +70 -12
  109. data/app/services/katello/pulp3/repository.rb +7 -91
  110. data/app/services/katello/pulp3/service_common.rb +66 -0
  111. data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +4 -1
  112. data/app/services/katello/ui_notifications/content_view/delete_latest_version_failure.rb +22 -0
  113. data/app/views/foreman/job_templates/change_content_source.erb +1 -1
  114. data/app/views/foreman/job_templates/install_errata.erb +5 -5
  115. data/app/views/foreman/job_templates/install_errata_by_search_query.erb +7 -6
  116. data/app/views/foreman/job_templates/install_group.erb +4 -4
  117. data/app/views/foreman/job_templates/install_package.erb +4 -4
  118. data/app/views/foreman/job_templates/install_packages_by_search_query.erb +3 -3
  119. data/app/views/foreman/job_templates/remove_group.erb +4 -4
  120. data/app/views/foreman/job_templates/remove_package.erb +4 -4
  121. data/app/views/foreman/job_templates/remove_packages_by_search_query.erb +3 -3
  122. data/app/views/foreman/job_templates/resolve_traces.erb +2 -2
  123. data/app/views/foreman/job_templates/restart_services.erb +3 -3
  124. data/app/views/foreman/job_templates/update_group.erb +4 -4
  125. data/app/views/foreman/job_templates/update_package.erb +4 -4
  126. data/app/views/foreman/job_templates/update_packages_by_search_query.erb +3 -3
  127. data/app/views/katello/api/v2/alternate_content_sources/base.json.rabl +15 -0
  128. data/app/views/katello/api/v2/alternate_content_sources/index.json.rabl +7 -0
  129. data/app/views/katello/api/v2/alternate_content_sources/show.json.rabl +3 -0
  130. data/app/views/katello/api/v2/capsule_content/sync_status.json.rabl +1 -1
  131. data/app/views/katello/api/v2/content_view_version_export_histories/show.json.rabl +2 -3
  132. data/app/views/katello/api/v2/content_view_versions/base.json.rabl +1 -1
  133. data/app/views/katello/api/v2/content_views/base.json.rabl +1 -0
  134. data/app/views/katello/api/v2/environments/show.json.rabl +2 -0
  135. data/app/views/katello/api/v2/errata/_counts.json.rabl +2 -2
  136. data/app/views/katello/api/v2/host_module_streams/base.json.rabl +2 -2
  137. data/app/views/katello/api/v2/hosts/host_collections.json.rabl +1 -1
  138. data/app/views/katello/api/v2/organizations/show.json.rabl +7 -1
  139. data/app/views/katello/api/v2/repositories/show.json.rabl +2 -1
  140. data/app/views/katello/sync_management/_repo.html.erb +8 -29
  141. data/config/routes/api/v2.rb +7 -0
  142. data/db/migrate/20150930183738_migrate_content_hosts.rb +0 -399
  143. data/db/migrate/20171025163149_remove_use_pulp_oauth_setting.rb +1 -1
  144. data/db/migrate/20171114150937_cleanup_installed_packages.rb +1 -1
  145. data/db/migrate/20180402160223_clean_up_force_post_sync_action_setting.rb +1 -1
  146. data/db/migrate/20211129200124_remove_dependency_solving_algorithm_setting.rb +1 -1
  147. data/db/migrate/20211220185935_clean_duplicate_content_units.rb +10 -12
  148. data/db/migrate/20220110223754_update_disconnected_settings.rb +5 -5
  149. data/db/migrate/20220117151612_add_alternate_content_sources.rb +48 -0
  150. data/db/migrate/20220124191056_add_type_to_cdn_configuration.rb +9 -4
  151. data/db/migrate/20220209203251_add_generated_for_to_content_views.rb +13 -0
  152. data/db/migrate/20220209205137_expand_sync_timeout_settings.rb +7 -7
  153. data/db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb +12 -0
  154. data/db/migrate/20220404190836_delete_old_setting_data.rb +9 -0
  155. data/db/migrate/20220405220616_update_cdn_configuration_type.rb +11 -0
  156. data/db/migrate/20220419193414_content_settings_to_dsl_category.rb +5 -0
  157. data/db/seeds.d/110-content-view-autopublish.rb +13 -0
  158. data/db/seeds.d/150-module_job_templates.rb +1 -1
  159. data/engines/bastion/README.md +1 -0
  160. data/engines/bastion/app/assets/javascripts/bastion/components/bst-modal.directive.js +1 -0
  161. data/engines/bastion/app/views/bastion/layouts/assets.html.erb +1 -0
  162. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/activation-key-details.controller.js +4 -2
  163. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +10 -5
  164. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-module-streams.controller.js +1 -0
  165. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-packages-installed.controller.js +1 -0
  166. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-traces.controller.js +1 -0
  167. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-packages-actions.html +1 -1
  168. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-packages-applicable.html +1 -1
  169. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +8 -0
  170. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js +4 -2
  171. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +2 -2
  172. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/content.service.js +10 -0
  173. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-deb-repositories.html +26 -0
  174. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-debs.html +27 -0
  175. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/environments.controller.js +1 -0
  176. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/environments.routes.js +22 -0
  177. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/views/environments.html +13 -7
  178. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +63 -17
  179. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +7 -8
  180. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details.controller.js +10 -1
  181. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-details.html +21 -3
  182. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +8 -9
  183. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +7 -5
  184. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +2 -1
  185. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/discovery/discovery-create.controller.js +1 -1
  186. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/discovery/views/discovery-create.html +1 -1
  187. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.routes.js +1 -0
  188. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/content-access-mode-banner.html +6 -1
  189. data/lib/katello/engine.rb +1 -5
  190. data/lib/katello/permission_creator.rb +32 -4
  191. data/lib/katello/plugin.rb +378 -4
  192. data/lib/katello/tasks/reset.rake.bak +67 -0
  193. data/lib/katello/tasks/update_content_default_http_proxy.rake +2 -3
  194. data/lib/katello/version.rb +1 -1
  195. data/locale/action_names.rb +47 -41
  196. data/locale/bn/LC_MESSAGES/katello.mo +0 -0
  197. data/locale/bn/katello.po +820 -106
  198. data/locale/bn/katello.po.time_stamp +0 -0
  199. data/locale/cs/LC_MESSAGES/katello.mo +0 -0
  200. data/locale/cs/katello.po +818 -104
  201. data/locale/cs/katello.po.time_stamp +0 -0
  202. data/locale/de/LC_MESSAGES/katello.mo +0 -0
  203. data/locale/de/katello.po +893 -179
  204. data/locale/de/katello.po.time_stamp +0 -0
  205. data/locale/en/LC_MESSAGES/katello.mo +0 -0
  206. data/locale/en/katello.po +817 -103
  207. data/locale/en/katello.po.time_stamp +0 -0
  208. data/locale/es/LC_MESSAGES/katello.mo +0 -0
  209. data/locale/es/katello.po +882 -168
  210. data/locale/es/katello.po.time_stamp +0 -0
  211. data/locale/fr/LC_MESSAGES/katello.mo +0 -0
  212. data/locale/fr/katello.po +1219 -505
  213. data/locale/fr/katello.po.time_stamp +0 -0
  214. data/locale/gu/LC_MESSAGES/katello.mo +0 -0
  215. data/locale/gu/katello.po +826 -112
  216. data/locale/gu/katello.po.time_stamp +0 -0
  217. data/locale/hi/LC_MESSAGES/katello.mo +0 -0
  218. data/locale/hi/katello.po +826 -112
  219. data/locale/hi/katello.po.time_stamp +0 -0
  220. data/locale/it/LC_MESSAGES/katello.mo +0 -0
  221. data/locale/it/katello.po +863 -148
  222. data/locale/it/katello.po.time_stamp +0 -0
  223. data/locale/ja/LC_MESSAGES/katello.mo +0 -0
  224. data/locale/ja/katello.po +1216 -499
  225. data/locale/ja/katello.po.time_stamp +0 -0
  226. data/locale/katello.pot +3847 -2507
  227. data/locale/kn/LC_MESSAGES/katello.mo +0 -0
  228. data/locale/kn/katello.po +826 -112
  229. data/locale/kn/katello.po.time_stamp +0 -0
  230. data/locale/ko/LC_MESSAGES/katello.mo +0 -0
  231. data/locale/ko/katello.po +912 -198
  232. data/locale/ko/katello.po.time_stamp +0 -0
  233. data/locale/mr/LC_MESSAGES/katello.mo +0 -0
  234. data/locale/mr/katello.po +826 -112
  235. data/locale/mr/katello.po.time_stamp +0 -0
  236. data/locale/or/LC_MESSAGES/katello.mo +0 -0
  237. data/locale/or/katello.po +826 -112
  238. data/locale/or/katello.po.time_stamp +0 -0
  239. data/locale/pa/LC_MESSAGES/katello.mo +0 -0
  240. data/locale/pa/katello.po +826 -112
  241. data/locale/pa/katello.po.time_stamp +0 -0
  242. data/locale/pt/LC_MESSAGES/katello.mo +0 -0
  243. data/locale/pt/katello.po +817 -103
  244. data/locale/pt/katello.po.time_stamp +0 -0
  245. data/locale/pt_BR/LC_MESSAGES/katello.mo +0 -0
  246. data/locale/pt_BR/katello.po +879 -165
  247. data/locale/pt_BR/katello.po.time_stamp +0 -0
  248. data/locale/ru/LC_MESSAGES/katello.mo +0 -0
  249. data/locale/ru/katello.po +927 -213
  250. data/locale/ru/katello.po.time_stamp +0 -0
  251. data/locale/ta/LC_MESSAGES/katello.mo +0 -0
  252. data/locale/ta/katello.po +820 -106
  253. data/locale/ta/katello.po.time_stamp +0 -0
  254. data/locale/te/LC_MESSAGES/katello.mo +0 -0
  255. data/locale/te/katello.po +826 -112
  256. data/locale/te/katello.po.time_stamp +0 -0
  257. data/locale/zh_CN/LC_MESSAGES/katello.mo +0 -0
  258. data/locale/zh_CN/katello.po +1202 -486
  259. data/locale/zh_CN/katello.po.time_stamp +0 -0
  260. data/locale/zh_TW/LC_MESSAGES/katello.mo +0 -0
  261. data/locale/zh_TW/katello.po +856 -142
  262. data/locale/zh_TW/katello.po.time_stamp +0 -0
  263. data/webpack/components/EditableTextInput/EditableTextInput.js +20 -5
  264. data/webpack/components/Errata/index.js +38 -8
  265. data/webpack/components/Packages/index.js +1 -4
  266. data/webpack/components/Search/Search.js +18 -3
  267. data/webpack/components/SelectAllCheckbox/index.js +1 -0
  268. data/webpack/components/SelectableDropdown/SelectableDropdown.js +4 -2
  269. data/webpack/components/Table/EmptyStateMessage.js +21 -7
  270. data/webpack/components/Table/MainTable.js +29 -4
  271. data/webpack/components/Table/TableHooks.js +63 -19
  272. data/webpack/components/Table/TableWrapper.js +4 -2
  273. data/webpack/components/Table/components/SortableColumnHeaders.js +19 -0
  274. data/webpack/components/Table/components/TranslatedPlural.js +57 -0
  275. data/webpack/components/TypeAhead/TypeAhead.js +8 -0
  276. data/webpack/components/TypeAhead/pf4Search/TypeAheadInput.js +13 -11
  277. data/webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js +5 -2
  278. data/webpack/components/extensions/HostDetails/ActionsBar/index.js +27 -0
  279. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/ChangeHostCVModal.js +256 -0
  280. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/ContentViewDetailsCard.js +202 -0
  281. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/HostContentViewActions.js +19 -0
  282. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/HostContentViewConstants.js +2 -0
  283. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/__tests__/changeHostCVModal.test.js +131 -0
  284. data/webpack/components/extensions/HostDetails/Cards/{__tests__ → ContentViewDetailsCard/__tests__}/contentViewDetailsCard.test.js +22 -0
  285. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/__tests__/contentViews.fixtures.json +443 -0
  286. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard/__tests__/envPaths.fixtures.json +320 -0
  287. data/webpack/components/extensions/HostDetails/Cards/ErrataOverviewCard.js +57 -33
  288. data/webpack/components/extensions/HostDetails/Cards/ErrataOverviewCard.scss +3 -0
  289. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsActions.js +30 -0
  290. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsCard.js +187 -0
  291. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsConstants.js +7 -0
  292. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsModal.js +227 -0
  293. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsSelectors.js +18 -0
  294. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/__tests__/availableHostCollections.fixtures.json +106 -0
  295. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/__tests__/hostCollectionsCard.test.js +110 -0
  296. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/__tests__/hostCollectionsModal.test.js +235 -0
  297. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/__tests__/removableHostCollections.fixtures.json +45 -0
  298. data/webpack/components/extensions/HostDetails/Cards/__tests__/errataOverviewCard.test.js +33 -8
  299. data/webpack/components/extensions/HostDetails/DetailsTabCards/InstalledProductsCard.js +44 -0
  300. data/webpack/components/extensions/HostDetails/DetailsTabCards/RegistrationCard.js +107 -0
  301. data/webpack/components/extensions/HostDetails/DetailsTabCards/SystemPropertiesCardExtensions.js +38 -0
  302. data/webpack/components/extensions/HostDetails/Tabs/ErrataTab/ErrataTab.js +62 -39
  303. data/webpack/components/extensions/HostDetails/Tabs/ErrataTab/HostErrataActions.js +1 -7
  304. data/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsActions.js +1 -3
  305. data/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsConstants.js +28 -0
  306. data/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js +486 -116
  307. data/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/__tests__/moduleStreamsTab.test.js +147 -1
  308. data/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/__tests__/modules.fixtures.json +6 -3
  309. data/webpack/components/extensions/HostDetails/Tabs/PackagesTab/HostPackagesActions.js +1 -7
  310. data/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackageInstallModal.js +2 -1
  311. data/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js +48 -19
  312. data/webpack/components/extensions/HostDetails/Tabs/RemoteExecutionActions.js +35 -47
  313. data/webpack/components/extensions/HostDetails/Tabs/RemoteExecutionConstants.js +1 -0
  314. data/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsActions.js +33 -54
  315. data/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsConstants.js +20 -0
  316. data/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js +269 -132
  317. data/webpack/components/extensions/HostDetails/Tabs/TracesTab/TracesTab.js +47 -11
  318. data/webpack/components/extensions/HostDetails/Tabs/__tests__/errataTab.test.js +30 -42
  319. data/webpack/components/extensions/HostDetails/Tabs/__tests__/packagesTab.test.js +36 -1
  320. data/webpack/components/extensions/HostDetails/Tabs/__tests__/repositorySetsTab.test.js +94 -46
  321. data/webpack/components/extensions/HostDetails/Tabs/__tests__/tracesTab.test.js +18 -2
  322. data/webpack/components/extensions/HostDetails/Tabs/customizedRexUrlHelpers.js +6 -0
  323. data/webpack/containers/Application/config.js +5 -0
  324. data/webpack/global_index.js +30 -7
  325. data/webpack/global_test_setup.js +13 -0
  326. data/webpack/redux/actions/RedHatRepositories/enabled.js +2 -1
  327. data/webpack/redux/actions/RedHatRepositories/helpers.js +9 -8
  328. data/webpack/scenes/AlternateContentSources/ACSActions.js +53 -0
  329. data/webpack/scenes/AlternateContentSources/ACSConstants.js +4 -0
  330. data/webpack/scenes/AlternateContentSources/ACSIndexPage.js +23 -0
  331. data/webpack/scenes/AlternateContentSources/ACSSelectors.js +15 -0
  332. data/webpack/scenes/AlternateContentSources/MainTable/ACSTable.js +152 -0
  333. data/webpack/scenes/AlternateContentSources/MainTable/__tests__/acsIndex.fixtures.json +91 -0
  334. data/webpack/scenes/AlternateContentSources/MainTable/__tests__/acsTable.test.js +67 -0
  335. data/webpack/scenes/AlternateContentSources/index.js +4 -0
  336. data/webpack/scenes/Content/Details/ContentRepositories.js +1 -0
  337. data/webpack/scenes/Content/Table/ContentTable.js +1 -0
  338. data/webpack/scenes/ContentViews/ContentViewsActions.js +6 -2
  339. data/webpack/scenes/ContentViews/ContentViewsConstants.js +11 -3
  340. data/webpack/scenes/ContentViews/Copy/CopyContentViewForm.js +2 -1
  341. data/webpack/scenes/ContentViews/Create/ContentViewFormComponents.js +10 -1
  342. data/webpack/scenes/ContentViews/Create/CreateContentViewForm.js +4 -3
  343. data/webpack/scenes/ContentViews/Create/__tests__/createContentView.test.js +1 -1
  344. data/webpack/scenes/ContentViews/Delete/ContentViewDeleteWizard.js +7 -5
  345. data/webpack/scenes/ContentViews/Delete/Steps/CVDeletionFinish.js +29 -21
  346. data/webpack/scenes/ContentViews/Delete/__tests__/contentViewDelete.test.js +15 -8
  347. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentContentViewAddModal.js +3 -3
  348. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentContentViewBulkAddModal.js +4 -4
  349. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js +3 -1
  350. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.test.js +4 -4
  351. data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +34 -8
  352. data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +33 -29
  353. data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +130 -79
  354. data/webpack/scenes/ContentViews/Details/ContentViewInfo.js +17 -3
  355. data/webpack/scenes/ContentViews/Details/Filters/Add/CVFilterAddModal.js +2 -1
  356. data/webpack/scenes/ContentViews/Details/Filters/AffectedRepositories/AffectedRepositoryTable.js +2 -1
  357. data/webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js +6 -1
  358. data/webpack/scenes/ContentViews/Details/Filters/CVErrataDateFilterContent.js +41 -21
  359. data/webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js +38 -20
  360. data/webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js +2 -0
  361. data/webpack/scenes/ContentViews/Details/Filters/CVPackageGroupFilterContent.js +8 -1
  362. data/webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js +9 -1
  363. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js +2 -1
  364. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/CVRpmMatchContentModal.js +1 -0
  365. data/webpack/scenes/ContentViews/Details/Filters/Rules/ContainerTag/AddEditContainerTagRuleModal.js +27 -12
  366. data/webpack/scenes/ContentViews/Details/Filters/Rules/Package/AddEditPackageRuleModal.js +39 -17
  367. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVContainerImageFilterContent.test.js +27 -10
  368. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVRpmFilterContent.test.js +46 -23
  369. data/webpack/scenes/ContentViews/Details/Histories/ContentViewHistories.js +3 -2
  370. data/webpack/scenes/ContentViews/Details/Promote/ContentViewVersionPromote.js +5 -2
  371. data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +161 -108
  372. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewAddRemove.test.js +7 -7
  373. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewRepoAdd.fixture.json +1 -0
  374. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/ActionSummary.js +58 -0
  375. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/BulkDeleteContextWrapper.js +45 -0
  376. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/BulkDeleteHelpers.js +30 -0
  377. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/BulkDeleteModal.js +56 -0
  378. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/ConfirmBulkDelete.js +126 -0
  379. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/FinishBulkDelete.js +61 -0
  380. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/ReassignActivationKeys.js +196 -0
  381. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/ReassignHosts.js +220 -0
  382. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/ReviewEnvironments.js +104 -0
  383. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/__tests__/BulkDeleteModal.test.js +122 -0
  384. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/__tests__/BulkDeleteVersions.fixtures.json +600 -0
  385. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/__tests__/contentView.fixtures.json +1504 -0
  386. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/__tests__/contentViewVersion.fixtures.json +936 -0
  387. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/__tests__/environmentPaths.fixtures.json +261 -0
  388. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/__tests__/hosts.fixtures.json +163 -0
  389. data/webpack/scenes/ContentViews/Details/Versions/BulkDelete/bulkDeleteSteps.js +79 -0
  390. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersions.js +192 -167
  391. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveCVVersionWizard.js +2 -5
  392. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVVersionDeleteFinish.js +38 -53
  393. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVVersionRemoveReview.js +1 -1
  394. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvVersionRemove.test.js +6 -12
  395. data/webpack/scenes/ContentViews/Details/Versions/Delete/affectedActivationKeys.js +1 -0
  396. data/webpack/scenes/ContentViews/Details/Versions/Delete/affectedHosts.js +1 -0
  397. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js +1 -0
  398. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetails.js +8 -20
  399. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailsHeader.js +23 -13
  400. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailsTable.js +3 -0
  401. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetails.fixtures.json +4 -4
  402. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetails.test.js +0 -3
  403. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetailsEmpty.test.js +4 -4
  404. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersions.test.js +12 -14
  405. data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetails.fixtures.json +1 -0
  406. data/webpack/scenes/ContentViews/Publish/CVPublishFinish.js +96 -117
  407. data/webpack/scenes/ContentViews/Publish/PublishContentViewWizard.js +13 -19
  408. data/webpack/scenes/ContentViews/Publish/__tests__/publishContentView.test.js +9 -20
  409. data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +165 -148
  410. data/webpack/scenes/ContentViews/Table/tableDataGenerator.js +2 -0
  411. data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +4 -4
  412. data/webpack/scenes/ContentViews/components/ContentViewIcon.js +14 -3
  413. data/webpack/scenes/ContentViews/components/ContentViewsCounter.js +1 -1
  414. data/webpack/scenes/ContentViews/components/EnvironmentLabels.js +4 -3
  415. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.js +9 -5
  416. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.scss +6 -1
  417. data/webpack/scenes/ContentViews/components/TaskPresenter/TaskPresenter.js +40 -35
  418. data/webpack/scenes/ContentViews/expansions/DetailsExpansion.js +2 -2
  419. data/webpack/scenes/ContentViews/expansions/RelatedCompositeContentViewsModal.js +1 -1
  420. data/webpack/scenes/ContentViews/expansions/RelatedContentViewComponentsModal.js +4 -4
  421. data/webpack/scenes/ContentViews/expansions/__tests__/contentViewComponentsModal.test.js +1 -1
  422. data/webpack/scenes/ContentViews/helpers.js +3 -0
  423. data/webpack/scenes/Hosts/ChangeContentSource/helpers.js +5 -0
  424. data/webpack/scenes/RedHatRepositories/RedHatRepositoriesPage.js +3 -3
  425. data/webpack/scenes/RedHatRepositories/components/EnabledRepository/EnabledRepository.js +2 -1
  426. data/webpack/scenes/RedHatRepositories/components/EnabledRepository/__tests__/EnabledRepository.test.js +2 -0
  427. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/CdnConfigurationConstants.js +3 -3
  428. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/CdnTypeForm.js +2 -0
  429. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/{AirGappedTypeForm.js → ExportSyncForm.js} +7 -6
  430. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/{UpstreamServerTypeForm.js → NetworkSyncForm.js} +15 -7
  431. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/__tests__/{AirGappedTypeForm.test.js → ExportSyncForm.test.js} +4 -4
  432. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/__tests__/{UpstreamServerTypeForm.test.js → NetworkSyncForm.test.js} +8 -8
  433. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/index.js +11 -11
  434. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +1 -0
  435. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +8 -7
  436. data/webpack/scenes/Tasks/TaskActions.js +6 -0
  437. data/webpack/scenes/Tasks/TaskSelectors.js +11 -0
  438. data/webpack/scenes/Tasks/helpers.js +33 -5
  439. data/webpack/utils/helpers.js +2 -0
  440. metadata +158 -40
  441. data/app/models/setting/content.rb +0 -201
  442. data/webpack/components/Table/__test__/useBulkSelect.test.js +0 -99
  443. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard.js +0 -96
  444. data/webpack/scenes/ContentViews/Details/DetailsContainer.js +0 -36
@@ -0,0 +1,227 @@
1
+ import React, { useState } from 'react';
2
+ import { Modal, Button } from '@patternfly/react-core';
3
+ import { useSelector, useDispatch } from 'react-redux';
4
+ import { FormattedMessage } from 'react-intl';
5
+ import { Thead, Th, Tbody, Tr, Td, TableVariant } from '@patternfly/react-table';
6
+ import { HOST_DETAILS_KEY } from 'foremanReact/components/HostDetails/consts';
7
+ import { translate as __ } from 'foremanReact/common/I18n';
8
+ import { urlBuilder } from 'foremanReact/common/urlHelpers';
9
+ import { propsToCamelCase } from 'foremanReact/common/helpers';
10
+ import PropTypes from 'prop-types';
11
+ import TableWrapper from '../../../../Table/TableWrapper';
12
+ import { useSelectionSet } from '../../../../Table/TableHooks';
13
+ import { selectAvailableHostCollections, selectAvailableHostCollectionsStatus, selectRemovableHostCollections, selectRemovableHostCollectionsStatus } from './HostCollectionsSelectors';
14
+ import hostIdNotReady from '../../HostDetailsActions';
15
+ import { alterHostCollections, getHostAvailableHostCollections, getHostRemovableHostCollections } from './HostCollectionsActions';
16
+ import { MODAL_TYPES } from './HostCollectionsConstants';
17
+ import { truncate } from '../../../../../utils/helpers';
18
+
19
+ export const HostCollectionsAddModal =
20
+ props => <HostCollectionsModal modalType={MODAL_TYPES.ADD} {...props} />;
21
+ export const HostCollectionsRemoveModal =
22
+ props => <HostCollectionsModal modalType={MODAL_TYPES.REMOVE} {...props} />;
23
+
24
+ export const HostCollectionsModal = ({
25
+ isOpen, closeModal, hostId, hostName, modalType = MODAL_TYPES.ADD, existingHostCollectionIds,
26
+ }) => {
27
+ const emptyContentTitle = __('No host collections');
28
+ const emptyContentBody = __('There are no host collections available to add.');
29
+ const emptySearchTitle = __('No matching host collections found');
30
+ const emptySearchBody = __('Try changing your search settings.');
31
+ const errorSearchTitle = __('Problem searching host collections');
32
+
33
+ const columnHeaders = ['', __('Host collection'), __('Capacity'), __('Description')];
34
+ const adding = (modalType === MODAL_TYPES.ADD);
35
+
36
+ const response = useSelector(state =>
37
+ (adding ? selectAvailableHostCollections(state) : selectRemovableHostCollections(state))) || {};
38
+ const status = useSelector(state => (adding ?
39
+ selectAvailableHostCollectionsStatus(state) :
40
+ selectRemovableHostCollectionsStatus(state))) || '';
41
+ const dispatch = useDispatch();
42
+ const { results, error: errorSearchBody, ...metadata } = response;
43
+ const [suppressFirstFetch, setSuppressFirstFetch] = useState(false);
44
+ const [searchQuery, updateSearchQuery] = useState('');
45
+
46
+ const hostLimitNotExceeded = (hc) => {
47
+ const { totalHosts, maxHosts, unlimitedHosts } = propsToCamelCase(hc);
48
+ if (unlimitedHosts) return true;
49
+ return totalHosts < maxHosts;
50
+ };
51
+
52
+ const hostLimitExceeded = hc => !hostLimitNotExceeded(hc);
53
+
54
+ const {
55
+ isSelected,
56
+ selectOne,
57
+ selectNone,
58
+ fetchBulkParams,
59
+ isSelectable,
60
+ selectedCount,
61
+ selectedResults,
62
+ selectionSet,
63
+ ...selectAll
64
+ } = useSelectionSet({
65
+ results,
66
+ metadata,
67
+ isSelectable: adding ? hc => hostLimitNotExceeded(hc) : () => true,
68
+ });
69
+
70
+ const fetchItems = (params) => {
71
+ if (!hostId) return hostIdNotReady;
72
+
73
+ if (results?.length > 0 && suppressFirstFetch) {
74
+ // If the modal has already been opened, no need to re-fetch the data that's already present
75
+ setSuppressFirstFetch(false);
76
+ return { type: 'HOST_COLLECTIONS_NOOP' };
77
+ }
78
+ switch (modalType) {
79
+ case MODAL_TYPES.ADD:
80
+ return getHostAvailableHostCollections({ ...params, host_id: hostId });
81
+ case MODAL_TYPES.REMOVE:
82
+ return getHostRemovableHostCollections({ ...params, host_id: hostId });
83
+ default:
84
+ return { type: 'HOST_COLLECTIONS_NOOP' };
85
+ }
86
+ };
87
+
88
+ const handleModalCancel = () => {
89
+ setSuppressFirstFetch(true);
90
+ closeModal();
91
+ };
92
+
93
+ const newHostCollectionIds = (hcIds) => {
94
+ const uniq = ids => [...new Set(ids)];
95
+ switch (modalType) {
96
+ case MODAL_TYPES.ADD:
97
+ return uniq([...hcIds, ...selectionSet]);
98
+ case MODAL_TYPES.REMOVE:
99
+ return uniq(hcIds.filter(id => !selectionSet.has(id)));
100
+ default:
101
+ return uniq(hcIds);
102
+ }
103
+ };
104
+
105
+ const refreshHostDetails = () => dispatch({
106
+ type: 'API_GET',
107
+ payload: {
108
+ key: HOST_DETAILS_KEY,
109
+ url: `/api/hosts/${hostName}`,
110
+ },
111
+ });
112
+
113
+ const handleModalAction = () => {
114
+ const newIds = newHostCollectionIds(existingHostCollectionIds);
115
+ dispatch(alterHostCollections(hostId, { host_collection_ids: newIds }, refreshHostDetails));
116
+ selectNone();
117
+ closeModal();
118
+ };
119
+
120
+ const modalActions = ([
121
+ <Button key="add" variant="primary" onClick={handleModalAction} isDisabled={!selectedCount}>
122
+ {adding ? __('Add') : __('Remove')}
123
+ </Button>,
124
+ <Button key="cancel" variant="link" onClick={handleModalCancel}>
125
+ Cancel
126
+ </Button>,
127
+ ]);
128
+
129
+ return (
130
+ <Modal
131
+ isOpen={isOpen}
132
+ onClose={closeModal}
133
+ title={adding ? __('Add host to host collections') : __('Remove host from host collections')}
134
+ width="50%"
135
+ position="top"
136
+ actions={modalActions}
137
+ id={adding ? 'add-host-to-host-collections-modal' : 'remove-host-from-host-collections-modal'}
138
+ >
139
+ <FormattedMessage
140
+ className="host-collections-modal-blurb"
141
+ id={adding ? 'add-host-to-host-collections-modal-blurb' : 'remove-host-from-host-collections-modal-blurb'}
142
+ defaultMessage={adding ? __('Select host collection(s) to associate with host {hostName}.') : __('Select host collection(s) to remove from host {hostName}.')}
143
+ values={{
144
+ hostName: <strong>{hostName}</strong>,
145
+ }}
146
+ />
147
+ <TableWrapper
148
+ {...{
149
+ metadata,
150
+ emptyContentTitle,
151
+ emptyContentBody,
152
+ emptySearchTitle,
153
+ emptySearchBody,
154
+ errorSearchTitle,
155
+ errorSearchBody,
156
+ status,
157
+ searchQuery,
158
+ updateSearchQuery,
159
+ selectedCount,
160
+ selectNone,
161
+ }
162
+ }
163
+ ouiaId="host-collections-table"
164
+ additionalListeners={[hostId, modalType, existingHostCollectionIds.join(',')]}
165
+ fetchItems={fetchItems}
166
+ searchPlaceholderText={__('Search host collections')}
167
+ autocompleteEndpoint="/host_collections/auto_complete_search"
168
+ variant={TableVariant.compact}
169
+ {...selectAll}
170
+ displaySelectAllCheckbox={results?.length > 0}
171
+ >
172
+ <Thead>
173
+ <Tr>
174
+ {columnHeaders.map(col =>
175
+ <Th key={col}>{col}</Th>)}
176
+ <Th />
177
+ </Tr>
178
+ </Thead>
179
+ <Tbody>
180
+ {results?.map((hostCollection, rowIndex) => {
181
+ const {
182
+ id, name, description, maxHosts, unlimitedHosts, totalHosts,
183
+ } = propsToCamelCase(hostCollection);
184
+ const isDisabled = (adding && hostLimitExceeded(hostCollection));
185
+ return (
186
+ <Tr key={id}>
187
+ <Td
188
+ select={{
189
+ disable: isDisabled,
190
+ isSelected: isSelected(id),
191
+ onSelect: (_event, selected) => selectOne(selected, id, hostCollection),
192
+ rowIndex,
193
+ variant: 'checkbox',
194
+ }}
195
+ />
196
+ <Td>
197
+ <a href={urlBuilder(`host_collections/${id}`, '')}>{name}</a>
198
+ </Td>
199
+ <Td>
200
+ {totalHosts}/{unlimitedHosts ? __('unlimited') : maxHosts}
201
+ </Td>
202
+ <Td>{description && truncate(description)}</Td>
203
+ </Tr>
204
+ );
205
+ })
206
+ }
207
+ </Tbody>
208
+ </TableWrapper>
209
+ </Modal>
210
+ );
211
+ };
212
+
213
+ HostCollectionsModal.propTypes = {
214
+ isOpen: PropTypes.bool.isRequired,
215
+ closeModal: PropTypes.func.isRequired,
216
+ hostId: PropTypes.number.isRequired,
217
+ hostName: PropTypes.string.isRequired,
218
+ showKatelloAgent: PropTypes.bool,
219
+ modalType: PropTypes.string.isRequired,
220
+ existingHostCollectionIds: PropTypes.arrayOf(PropTypes.number).isRequired,
221
+ };
222
+
223
+ HostCollectionsModal.defaultProps = {
224
+ showKatelloAgent: false,
225
+ };
226
+
227
+ export default HostCollectionsModal;
@@ -0,0 +1,18 @@
1
+ import {
2
+ selectAPIStatus,
3
+ selectAPIResponse,
4
+ } from 'foremanReact/redux/API/APISelectors';
5
+ import { STATUS } from 'foremanReact/constants';
6
+ import { AVAILABLE_HOST_COLLECTIONS_KEY, REMOVABLE_HOST_COLLECTIONS_KEY } from './HostCollectionsConstants';
7
+
8
+ export const selectAvailableHostCollections = state =>
9
+ selectAPIResponse(state, AVAILABLE_HOST_COLLECTIONS_KEY) ?? {};
10
+
11
+ export const selectRemovableHostCollections = state =>
12
+ selectAPIResponse(state, REMOVABLE_HOST_COLLECTIONS_KEY) ?? {};
13
+
14
+ export const selectAvailableHostCollectionsStatus = state =>
15
+ selectAPIStatus(state, AVAILABLE_HOST_COLLECTIONS_KEY) || STATUS.PENDING;
16
+
17
+ export const selectRemovableHostCollectionsStatus = state =>
18
+ selectAPIStatus(state, REMOVABLE_HOST_COLLECTIONS_KEY);
@@ -0,0 +1,106 @@
1
+ {
2
+ "total": 6,
3
+ "subtotal": 6,
4
+ "selectable": 6,
5
+ "page": "1",
6
+ "per_page": "20",
7
+ "error": null,
8
+ "search": null,
9
+ "sort": {
10
+ "by": "name",
11
+ "order": "asc"
12
+ },
13
+ "results": [
14
+ {
15
+ "name": "hc1",
16
+ "organization_id": 1,
17
+ "max_hosts": null,
18
+ "description": null,
19
+ "total_hosts": 1,
20
+ "unlimited_hosts": true,
21
+ "created_at": "2022-03-04 09:28:47 -0500",
22
+ "updated_at": "2022-03-04 09:28:47 -0500",
23
+ "id": 5,
24
+ "permissions": {
25
+ "deletable": true,
26
+ "editable": true
27
+ }
28
+ },
29
+ {
30
+ "name": "hc2",
31
+ "organization_id": 1,
32
+ "max_hosts": 2,
33
+ "description": null,
34
+ "total_hosts": 1,
35
+ "unlimited_hosts": false,
36
+ "created_at": "2022-03-04 09:29:03 -0500",
37
+ "updated_at": "2022-03-04 09:29:03 -0500",
38
+ "id": 6,
39
+ "permissions": {
40
+ "deletable": true,
41
+ "editable": true
42
+ }
43
+ },
44
+ {
45
+ "name": "hc3",
46
+ "organization_id": 1,
47
+ "max_hosts": null,
48
+ "description": null,
49
+ "total_hosts": 1,
50
+ "unlimited_hosts": true,
51
+ "created_at": "2022-03-04 09:29:18 -0500",
52
+ "updated_at": "2022-03-04 09:29:18 -0500",
53
+ "id": 7,
54
+ "permissions": {
55
+ "deletable": true,
56
+ "editable": true
57
+ }
58
+ },
59
+ {
60
+ "name": "hc4",
61
+ "organization_id": 1,
62
+ "max_hosts": 1,
63
+ "description": null,
64
+ "total_hosts": 1,
65
+ "unlimited_hosts": false,
66
+ "created_at": "2022-03-04 09:29:30 -0500",
67
+ "updated_at": "2022-03-04 09:29:30 -0500",
68
+ "id": 8,
69
+ "permissions": {
70
+ "deletable": true,
71
+ "editable": true
72
+ }
73
+ },
74
+ {
75
+ "name": "hc5",
76
+ "organization_id": 1,
77
+ "max_hosts": 5,
78
+ "description": null,
79
+ "total_hosts": 1,
80
+ "unlimited_hosts": false,
81
+ "created_at": "2022-03-04 09:29:42 -0500",
82
+ "updated_at": "2022-03-04 09:29:42 -0500",
83
+ "id": 9,
84
+ "permissions": {
85
+ "deletable": true,
86
+ "editable": true
87
+ }
88
+ },
89
+ {
90
+ "name": "Partha hosts",
91
+ "organization_id": 1,
92
+ "max_hosts": 1,
93
+ "description": null,
94
+ "total_hosts": 1,
95
+ "unlimited_hosts": false,
96
+ "created_at": "2022-02-28 16:19:45 -0500",
97
+ "updated_at": "2022-02-28 16:19:45 -0500",
98
+ "id": 3,
99
+ "permissions": {
100
+ "deletable": true,
101
+ "editable": true
102
+ }
103
+ }
104
+ ]
105
+ }
106
+
@@ -0,0 +1,110 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from 'react-testing-lib-wrapper';
3
+ import HostCollectionsCard from '../HostCollectionsCard';
4
+
5
+ const hostDetails = {
6
+ host_collections: [
7
+ {
8
+ id: 1,
9
+ name: 'Jer Hosts',
10
+ description: null,
11
+ max_hosts: null,
12
+ unlimited_hosts: true,
13
+ total_hosts: 2,
14
+ },
15
+ {
16
+ id: 3,
17
+ name: 'Partha hosts',
18
+ description: null,
19
+ max_hosts: 1,
20
+ unlimited_hosts: false,
21
+ total_hosts: 1,
22
+ },
23
+ {
24
+ id: 2,
25
+ name: 'Jturel hosts',
26
+ description: 'This is my awesome description',
27
+ max_hosts: 43,
28
+ unlimited_hosts: false,
29
+ total_hosts: 1,
30
+ },
31
+ ],
32
+ subscription_facet_attributes: {
33
+ uuid: '123',
34
+ },
35
+ };
36
+
37
+ const emptyHostDetails = {
38
+ host_collections: [],
39
+ subscription_facet_attributes: {
40
+ uuid: '123',
41
+ },
42
+ };
43
+
44
+ test('shows host collections and host limits when present', () => {
45
+ const { getByText } = render(<HostCollectionsCard hostDetails={hostDetails} />);
46
+ expect(getByText('Host collections')).toBeInTheDocument();
47
+ expect(getByText('Jturel hosts')).toBeInTheDocument();
48
+ expect(getByText('1/43')).toBeInTheDocument();
49
+ expect(getByText('1/1')).toBeInTheDocument();
50
+ expect(getByText('2/unlimited')).toBeInTheDocument();
51
+ });
52
+
53
+ test('shows empty card when no host collections present', () => {
54
+ const { queryByText } = render(<HostCollectionsCard hostDetails={emptyHostDetails} />);
55
+ expect(queryByText('Host collections')).toBeInTheDocument();
56
+ expect(queryByText('Jturel hosts')).not.toBeInTheDocument();
57
+ });
58
+
59
+ test('expands to show description', () => {
60
+ const { getByText, queryByText } = render(<HostCollectionsCard hostDetails={hostDetails} />);
61
+ expect(getByText('Jturel hosts')).toBeInTheDocument();
62
+ expect(queryByText('This is my awesome description')).not.toBeVisible();
63
+ fireEvent.click(getByText('Jturel hosts'));
64
+ expect(getByText('This is my awesome description')).toBeVisible();
65
+ });
66
+
67
+ test('expands to show when no description provided', () => {
68
+ const { getAllByText, queryAllByText } = render(<HostCollectionsCard
69
+ hostDetails={hostDetails}
70
+ />);
71
+ const indescribableHostCollection = getAllByText('Jer Hosts')[0];
72
+ expect(indescribableHostCollection).toBeInTheDocument();
73
+ queryAllByText('No description provided').forEach(element => expect(element).not.toBeVisible());
74
+ fireEvent.click(indescribableHostCollection);
75
+ expect(getAllByText('No description provided')[0]).toBeVisible();
76
+ });
77
+
78
+ test('shows add and remove options in kebab', () => {
79
+ const { queryByLabelText } = render(<HostCollectionsCard hostDetails={hostDetails} />);
80
+ const kebab = queryByLabelText('host_collections_bulk_actions');
81
+ expect(kebab).toBeInTheDocument();
82
+ fireEvent.click(kebab);
83
+
84
+ const add = queryByLabelText('add_host_to_collections');
85
+ const remove = queryByLabelText('remove_host_from_collections');
86
+
87
+ expect(add).toBeInTheDocument();
88
+ expect(remove).toBeInTheDocument();
89
+ expect(add).toHaveAttribute('aria-disabled', 'false');
90
+ expect(remove).toHaveAttribute('aria-disabled', 'false');
91
+ });
92
+
93
+ test('remove is disabled when no host collections present', () => {
94
+ const { queryByLabelText } = render(<HostCollectionsCard hostDetails={emptyHostDetails} />);
95
+ const kebab = queryByLabelText('host_collections_bulk_actions');
96
+ expect(kebab).toBeInTheDocument();
97
+ fireEvent.click(kebab);
98
+
99
+ const remove = queryByLabelText('remove_host_from_collections');
100
+ expect(remove).toBeInTheDocument();
101
+ expect(remove).toHaveAttribute('aria-disabled', 'true');
102
+ });
103
+
104
+ test('does not show card when host not registered', () => {
105
+ const { queryByText } = render(<HostCollectionsCard
106
+ hostDetails={{ ...emptyHostDetails, subscription_facet_attributes: undefined }}
107
+ />);
108
+ const cardTitle = queryByText('Host collections');
109
+ expect(cardTitle).not.toBeInTheDocument();
110
+ });
@@ -0,0 +1,235 @@
1
+ import React from 'react';
2
+ import { renderWithRedux, patientlyWaitFor, fireEvent } from 'react-testing-lib-wrapper';
3
+ import mockAvailableHostCollections from './availableHostCollections.fixtures.json';
4
+ import mockRemovableHostCollections from './removableHostCollections.fixtures.json';
5
+ import { REMOVABLE_HOST_COLLECTIONS_KEY } from '../HostCollectionsConstants';
6
+ import { assertNockRequest, mockAutocomplete, mockSetting, nockInstance } from '../../../../../../test-utils/nockWrapper';
7
+ import katelloApi, { foremanApi } from '../../../../../../services/api';
8
+ import { HostCollectionsAddModal, HostCollectionsRemoveModal } from '../HostCollectionsModal';
9
+
10
+ const renderOptions = () => ({
11
+ apiNamespace: REMOVABLE_HOST_COLLECTIONS_KEY,
12
+ initialState: {
13
+ API: {
14
+ HOST_DETAILS: {
15
+ response: {
16
+ id: 1,
17
+ name: 'test-host',
18
+ },
19
+ status: 'RESOLVED',
20
+ },
21
+ },
22
+ },
23
+ });
24
+
25
+ const availableHostCollections = katelloApi.getApiUrl('/host_collections');
26
+ const alterHostCollections = foremanApi.getApiUrl('/hosts/1/host_collections');
27
+ const autocompleteUrl = '/host_collections/auto_complete_search';
28
+ const hostDetailsUrl = '/api/hosts/test-host';
29
+
30
+ const defaultQuery = {
31
+ host_id: 1,
32
+ per_page: 20,
33
+ page: 1,
34
+ };
35
+ const defaultQueryWithAvailable = {
36
+ ...defaultQuery,
37
+ available_for: 'host',
38
+ };
39
+
40
+ let firstHostCollection;
41
+ let searchDelayScope;
42
+ let autoSearchScope;
43
+
44
+ describe('HostCollectionsAddModal', () => {
45
+ beforeEach(() => {
46
+ const { results } = mockAvailableHostCollections;
47
+ [firstHostCollection] = results;
48
+ searchDelayScope = mockSetting(nockInstance, 'autosearch_delay', 500);
49
+ autoSearchScope = mockSetting(nockInstance, 'autosearch_while_typing', true);
50
+ });
51
+
52
+ afterEach(() => {
53
+ assertNockRequest(searchDelayScope);
54
+ assertNockRequest(autoSearchScope);
55
+ });
56
+
57
+ test('Calls API with available_for=host on page load', async (done) => {
58
+ const autocompleteScope = mockAutocomplete(nockInstance, autocompleteUrl);
59
+
60
+ const scope = nockInstance
61
+ .get(availableHostCollections)
62
+ .query(defaultQueryWithAvailable)
63
+ .reply(200, mockAvailableHostCollections);
64
+
65
+ const { getAllByText }
66
+ = renderWithRedux(<HostCollectionsAddModal
67
+ isOpen
68
+ closeModal={jest.fn()}
69
+ hostId={1}
70
+ hostName="test-host"
71
+ existingHostCollectionIds={[]}
72
+ />, renderOptions());
73
+
74
+ await patientlyWaitFor(() =>
75
+ expect(getAllByText(firstHostCollection.name)[0]).toBeInTheDocument());
76
+ assertNockRequest(autocompleteScope);
77
+ assertNockRequest(scope, done); // Pass jest callback to confirm test is done
78
+ });
79
+
80
+ test('Calls alterHostCollections with combined list of existing and new host collections', async (done) => {
81
+ const autocompleteScope = mockAutocomplete(nockInstance, autocompleteUrl);
82
+
83
+ const scope = nockInstance
84
+ .get(availableHostCollections)
85
+ .query(defaultQueryWithAvailable)
86
+ .reply(200, mockAvailableHostCollections);
87
+
88
+ const alterScope = nockInstance
89
+ .put(alterHostCollections, {
90
+ host_collection_ids:
91
+ [...mockRemovableHostCollections.results.map(r => r.id), firstHostCollection.id],
92
+ })
93
+ .reply(200, {});
94
+
95
+ const hostDetailsScope = nockInstance
96
+ .get(hostDetailsUrl)
97
+ .reply(200, {});
98
+
99
+ const { getByRole, getAllByText }
100
+ = renderWithRedux(<HostCollectionsAddModal
101
+ isOpen
102
+ closeModal={jest.fn()}
103
+ hostId={1}
104
+ hostName="test-host"
105
+ existingHostCollectionIds={mockRemovableHostCollections.results.map(r => r.id)}
106
+ />, renderOptions());
107
+
108
+ await patientlyWaitFor(() =>
109
+ expect(getAllByText(firstHostCollection.name)[0]).toBeInTheDocument());
110
+ const checkbox = getByRole('checkbox', { name: 'Select row 0' });
111
+ fireEvent.click(checkbox);
112
+ const addButton = getByRole('button', { name: 'Add' });
113
+ expect(addButton).toHaveAttribute('aria-disabled', 'false');
114
+ fireEvent.click(addButton);
115
+
116
+ assertNockRequest(autocompleteScope);
117
+ assertNockRequest(scope);
118
+ assertNockRequest(alterScope);
119
+ assertNockRequest(hostDetailsScope, done);
120
+ });
121
+ test('Host collections whose host limit is exceeded are disabled', async (done) => {
122
+ const autocompleteScope = mockAutocomplete(nockInstance, autocompleteUrl);
123
+
124
+ const scope = nockInstance
125
+ .get(availableHostCollections)
126
+ .query(defaultQueryWithAvailable)
127
+ .reply(200, mockAvailableHostCollections);
128
+
129
+ const { getAllByRole, getAllByText }
130
+ = renderWithRedux(<HostCollectionsAddModal
131
+ isOpen
132
+ closeModal={jest.fn()}
133
+ hostId={1}
134
+ hostName="test-host"
135
+ existingHostCollectionIds={[]}
136
+ />, renderOptions());
137
+
138
+ await patientlyWaitFor(() =>
139
+ expect(getAllByText(firstHostCollection.name)[0]).toBeInTheDocument());
140
+
141
+ const disabledCheckboxes = getAllByRole('checkbox').filter(c => c.disabled);
142
+ const maxedOutHostCollections = mockAvailableHostCollections.results.filter(r =>
143
+ r.max_hosts === r.total_hosts);
144
+ expect(disabledCheckboxes.length).toBeGreaterThan(0);
145
+ expect(disabledCheckboxes).toHaveLength(maxedOutHostCollections.length);
146
+
147
+ assertNockRequest(autocompleteScope);
148
+ assertNockRequest(scope, done); // Pass jest callback to confirm test is done
149
+ });
150
+ });
151
+
152
+ describe('HostCollectionsRemoveModal', () => {
153
+ beforeEach(() => {
154
+ const { results } = mockAvailableHostCollections;
155
+ [firstHostCollection] = results;
156
+ searchDelayScope = mockSetting(nockInstance, 'autosearch_delay', 500);
157
+ autoSearchScope = mockSetting(nockInstance, 'autosearch_while_typing', true);
158
+ });
159
+
160
+ afterEach(() => {
161
+ assertNockRequest(searchDelayScope);
162
+ assertNockRequest(autoSearchScope);
163
+ });
164
+
165
+ test('Calls API without available_for=host on page load', async (done) => {
166
+ const autocompleteScope = mockAutocomplete(nockInstance, autocompleteUrl);
167
+
168
+ const scope = nockInstance
169
+ .get(availableHostCollections)
170
+ .query(defaultQuery)
171
+ .reply(200, mockAvailableHostCollections);
172
+
173
+ const { getAllByText }
174
+ = renderWithRedux(<HostCollectionsRemoveModal
175
+ isOpen
176
+ closeModal={jest.fn()}
177
+ hostId={1}
178
+ hostName="test-host"
179
+ existingHostCollectionIds={mockRemovableHostCollections.results.map(r => r.id)}
180
+ />, renderOptions());
181
+
182
+ // Assert that the packages are now showing on the screen, but wait for them to appear.
183
+ await patientlyWaitFor(() =>
184
+ expect(getAllByText(firstHostCollection.name)[0]).toBeInTheDocument());
185
+ // Assert request was made and completed, see helper function
186
+ assertNockRequest(autocompleteScope);
187
+ assertNockRequest(scope, done); // Pass jest callback to confirm test is done
188
+ });
189
+
190
+ test('Calls alterHostCollections with host collections being removed filtered out from the list', async (done) => {
191
+ const autocompleteScope = mockAutocomplete(nockInstance, autocompleteUrl);
192
+
193
+ const scope = nockInstance
194
+ .get(availableHostCollections)
195
+ .query(defaultQuery)
196
+ .reply(200, mockRemovableHostCollections);
197
+
198
+ const alterScope = nockInstance
199
+ .put(alterHostCollections, {
200
+ host_collection_ids:
201
+ mockRemovableHostCollections.results.map(r => r.id).filter(r =>
202
+ r !== mockRemovableHostCollections.results[0].id),
203
+ })
204
+ .reply(200, {});
205
+
206
+ const hostDetailsScope = nockInstance // calls host details after successful alter
207
+ .get(hostDetailsUrl)
208
+ .reply(200, {});
209
+
210
+ const { getByRole, getAllByText }
211
+ = renderWithRedux(<HostCollectionsRemoveModal
212
+ isOpen
213
+ closeModal={jest.fn()}
214
+ hostId={1}
215
+ hostName="test-host"
216
+ existingHostCollectionIds={mockRemovableHostCollections.results.map(r => r.id)}
217
+ />, renderOptions());
218
+
219
+ const [firstRemovableHostCollection] = mockRemovableHostCollections.results;
220
+ await patientlyWaitFor(() =>
221
+ expect(getAllByText(firstRemovableHostCollection.name)[0]).toBeInTheDocument());
222
+ const checkbox = getByRole('checkbox', { name: 'Select row 0' });
223
+ fireEvent.click(checkbox);
224
+ expect(getAllByText('1 selected')).toHaveLength(1);
225
+ const removeButton = getByRole('button', { name: 'Remove' });
226
+ expect(removeButton).toHaveAttribute('aria-disabled', 'false');
227
+ fireEvent.click(removeButton);
228
+
229
+ assertNockRequest(autocompleteScope);
230
+ assertNockRequest(scope);
231
+ assertNockRequest(alterScope);
232
+ assertNockRequest(hostDetailsScope, done);
233
+ });
234
+ });
235
+