katello 4.2.1 → 4.3.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 (498) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/katello/common/katello.common.js +0 -67
  3. data/app/assets/javascripts/katello/common/katello.js +0 -27
  4. data/app/assets/javascripts/katello/common/vendor.js +0 -1
  5. data/app/assets/stylesheets/katello/katello.scss +0 -1
  6. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +10 -2
  7. data/app/controllers/katello/api/v2/api_controller.rb +35 -9
  8. data/app/controllers/katello/api/v2/capsule_content_controller.rb +16 -2
  9. data/app/controllers/katello/api/v2/content_view_components_controller.rb +22 -1
  10. data/app/controllers/katello/api/v2/content_view_filters_controller.rb +65 -1
  11. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +5 -1
  12. data/app/controllers/katello/api/v2/content_views_controller.rb +13 -6
  13. data/app/controllers/katello/api/v2/debs_controller.rb +74 -1
  14. data/app/controllers/katello/api/v2/errata_controller.rb +13 -10
  15. data/app/controllers/katello/api/v2/file_units_controller.rb +1 -0
  16. data/app/controllers/katello/api/v2/generic_content_units_controller.rb +1 -1
  17. data/app/controllers/katello/api/v2/host_errata_controller.rb +46 -5
  18. data/app/controllers/katello/api/v2/host_tracer_controller.rb +2 -1
  19. data/app/controllers/katello/api/v2/module_streams_controller.rb +4 -0
  20. data/app/controllers/katello/api/v2/organizations_controller.rb +22 -7
  21. data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +1 -1
  22. data/app/controllers/katello/api/v2/repositories_controller.rb +36 -19
  23. data/app/controllers/katello/api/v2/subscriptions_controller.rb +0 -8
  24. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +5 -1
  25. data/app/controllers/katello/concerns/api/v2/bulk_extensions.rb +40 -0
  26. data/app/controllers/katello/concerns/api/v2/host_errata_extensions.rb +4 -31
  27. data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +1 -1
  28. data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +1 -1
  29. data/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb +2 -6
  30. data/app/helpers/katello/katello_url_helper.rb +1 -1
  31. data/app/lib/actions/candlepin/abstract_async_task.rb +6 -3
  32. data/app/lib/actions/candlepin/async_hypervisors.rb +12 -8
  33. data/app/lib/actions/katello/applicability/hosts/bulk_generate.rb +10 -1
  34. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +3 -3
  35. data/app/lib/actions/katello/cdn_configuration/update.rb +38 -0
  36. data/app/lib/actions/katello/content_view/remove.rb +18 -7
  37. data/app/lib/actions/katello/content_view_version/destroy.rb +2 -2
  38. data/app/lib/actions/katello/content_view_version/republish_repositories.rb +1 -1
  39. data/app/lib/actions/katello/repository/clone_contents.rb +1 -2
  40. data/app/lib/actions/katello/repository/destroy.rb +21 -5
  41. data/app/lib/actions/katello/repository/fetch_pxe_files.rb +1 -1
  42. data/app/lib/actions/katello/repository/finish_upload.rb +1 -1
  43. data/app/lib/actions/katello/repository/import_upload.rb +1 -1
  44. data/app/lib/actions/katello/repository/index_content.rb +19 -6
  45. data/app/lib/actions/katello/repository/metadata_generate.rb +2 -0
  46. data/app/lib/actions/katello/repository/multi_clone_contents.rb +1 -1
  47. data/app/lib/actions/katello/repository/remove_content.rb +1 -1
  48. data/app/lib/actions/katello/repository/sync.rb +3 -7
  49. data/app/lib/actions/katello/repository_set/scan_cdn.rb +0 -4
  50. data/app/lib/actions/middleware/record_smart_proxy_sync_history.rb +1 -1
  51. data/app/lib/actions/pulp/orphan_cleanup/remove_unneeded_repos.rb +1 -1
  52. data/app/lib/actions/pulp/repository/clear.rb +1 -1
  53. data/app/lib/actions/pulp3/abstract_async_task.rb +10 -1
  54. data/app/lib/actions/pulp3/capsule_content/generate_metadata.rb +13 -18
  55. data/app/lib/actions/pulp3/capsule_content/refresh_distribution.rb +1 -11
  56. data/app/lib/actions/pulp3/content_view_version/create_export_history.rb +1 -1
  57. data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +3 -1
  58. data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +25 -42
  59. data/app/lib/actions/pulp3/orchestration/repository/sync.rb +8 -1
  60. data/app/lib/actions/pulp3/orchestration/repository/upload_content.rb +3 -3
  61. data/app/lib/actions/pulp3/repository/commit_upload.rb +1 -1
  62. data/app/lib/actions/pulp3/repository/import_upload.rb +8 -4
  63. data/app/lib/actions/pulp3/repository/multi_copy_content.rb +1 -1
  64. data/app/lib/actions/pulp3/repository/multi_copy_units.rb +1 -1
  65. data/app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb +18 -0
  66. data/app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb +7 -2
  67. data/app/lib/actions/pulp3/repository/presenters/repair_presenter.rb +6 -1
  68. data/app/lib/actions/pulp3/repository/save_artifact.rb +14 -4
  69. data/app/lib/katello/errors.rb +2 -0
  70. data/app/lib/katello/resources/candlepin/consumer.rb +0 -20
  71. data/app/lib/katello/resources/candlepin/proxy.rb +8 -2
  72. data/app/lib/katello/resources/candlepin/upstream_consumer.rb +2 -0
  73. data/app/lib/katello/resources/cdn/katello_cdn.rb +68 -0
  74. data/app/lib/katello/resources/cdn.rb +61 -29
  75. data/app/lib/katello/util/cdn_var_substitutor.rb +15 -9
  76. data/app/lib/katello/util/package.rb +22 -0
  77. data/app/lib/katello/util/path_with_substitutions.rb +12 -14
  78. data/app/models/katello/activation_key.rb +10 -0
  79. data/app/models/katello/ansible_collection.rb +1 -1
  80. data/app/models/katello/authorization/repository.rb +4 -4
  81. data/app/models/katello/candlepin/repository_mapper.rb +5 -1
  82. data/app/models/katello/cdn_configuration.rb +32 -0
  83. data/app/models/katello/concerns/content_facet_host_extensions.rb +40 -0
  84. data/app/models/katello/concerns/host_managed_extensions.rb +28 -2
  85. data/app/models/katello/concerns/hostgroup_extensions.rb +1 -1
  86. data/app/models/katello/concerns/organization_extensions.rb +3 -1
  87. data/app/models/katello/concerns/pulp_database_unit.rb +15 -5
  88. data/app/models/katello/concerns/remote_execution_provider_extensions.rb +9 -0
  89. data/app/models/katello/concerns/setting_extensions.rb +1 -1
  90. data/app/models/katello/concerns/smart_proxy_extensions.rb +4 -3
  91. data/app/models/katello/content_credential.rb +4 -0
  92. data/app/models/katello/content_facet_applicable_deb.rb +7 -0
  93. data/app/models/katello/content_view.rb +24 -1
  94. data/app/models/katello/content_view_component.rb +4 -0
  95. data/app/models/katello/content_view_erratum_filter.rb +2 -0
  96. data/app/models/katello/content_view_filter.rb +1 -1
  97. data/app/models/katello/content_view_package_filter_rule.rb +2 -1
  98. data/app/models/katello/content_view_version.rb +30 -1
  99. data/app/models/katello/deb.rb +71 -0
  100. data/app/models/katello/erratum.rb +13 -1
  101. data/app/models/katello/generic_content_unit.rb +3 -1
  102. data/app/models/katello/glue/pulp/repos.rb +2 -2
  103. data/app/models/katello/host/content_facet.rb +23 -2
  104. data/app/models/katello/host/subscription_facet.rb +1 -1
  105. data/app/models/katello/host_tracer.rb +21 -2
  106. data/app/models/katello/installed_deb.rb +1 -1
  107. data/app/models/katello/module_stream.rb +4 -0
  108. data/app/models/katello/ping.rb +20 -4
  109. data/app/models/katello/product.rb +7 -5
  110. data/app/models/katello/provider.rb +1 -24
  111. data/app/models/katello/repository.rb +37 -10
  112. data/app/models/katello/root_repository.rb +28 -14
  113. data/app/models/setting/content.rb +8 -13
  114. data/app/services/katello/applicability/applicable_content_helper.rb +20 -0
  115. data/app/services/katello/organization_creator.rb +8 -0
  116. data/app/services/katello/pulp3/api/ansible_collection.rb +0 -40
  117. data/app/services/katello/pulp3/api/apt.rb +0 -47
  118. data/app/services/katello/pulp3/api/content_guard.rb +1 -1
  119. data/app/services/katello/pulp3/api/core.rb +28 -23
  120. data/app/services/katello/pulp3/api/docker.rb +0 -50
  121. data/app/services/katello/pulp3/api/file.rb +0 -48
  122. data/app/services/katello/pulp3/api/generic.rb +1 -44
  123. data/app/services/katello/pulp3/api/yum.rb +4 -44
  124. data/app/services/katello/pulp3/generic_content_unit.rb +8 -4
  125. data/app/services/katello/pulp3/repository/ansible_collection.rb +4 -0
  126. data/app/services/katello/pulp3/repository/apt.rb +3 -3
  127. data/app/services/katello/pulp3/repository/generic.rb +10 -65
  128. data/app/services/katello/pulp3/repository/yum.rb +10 -0
  129. data/app/services/katello/pulp3/repository.rb +47 -21
  130. data/app/services/katello/pulp3/repository_mirror.rb +30 -11
  131. data/app/services/katello/pulp3/rpm.rb +2 -32
  132. data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +7 -8
  133. data/app/services/katello/pulp3/smart_proxy_repository.rb +1 -1
  134. data/app/services/katello/registration_manager.rb +2 -0
  135. data/app/services/katello/repository_type.rb +103 -15
  136. data/app/services/katello/repository_type_manager.rb +14 -8
  137. data/app/services/katello/ui_notifications/subscriptions/manifest_expired_warning.rb +1 -1
  138. data/app/services/katello/upstream_connection_checker.rb +1 -0
  139. data/app/views/foreman/job_templates/resolve_traces.erb +25 -0
  140. data/app/views/foreman/job_templates/resolve_traces_-_katello_ansible_default.erb +28 -0
  141. data/app/views/katello/api/v2/capsule_content/sync_status.json.rabl +1 -1
  142. data/app/views/katello/api/v2/common/_metadata.json.rabl +1 -0
  143. data/app/views/katello/api/v2/content_facet/base.json.rabl +3 -1
  144. data/app/views/katello/api/v2/content_facet/show.json.rabl +2 -1
  145. data/app/views/katello/api/v2/content_view_components/show.json.rabl +4 -0
  146. data/app/views/katello/api/v2/content_view_versions/base.json.rabl +7 -0
  147. data/app/views/katello/api/v2/content_views/base.json.rabl +12 -8
  148. data/app/views/katello/api/v2/content_views/index.json.rabl +1 -0
  149. data/app/views/katello/api/v2/content_views/permissions.rabl +8 -0
  150. data/app/views/katello/api/v2/debs/base.json.rabl +5 -0
  151. data/app/views/katello/api/v2/errata/index.json.rabl +4 -0
  152. data/app/views/katello/api/v2/generic_content_units/base.json.rabl +2 -0
  153. data/app/views/katello/api/v2/generic_content_units/show.json.rabl +7 -0
  154. data/app/views/katello/api/v2/host_tracer/base.json.rabl +1 -0
  155. data/app/views/katello/api/v2/module_streams/index.json.rabl +4 -0
  156. data/app/views/katello/api/v2/organizations/cdn_configuration.rabl +1 -0
  157. data/app/views/katello/api/v2/organizations/show.json.rabl +7 -0
  158. data/app/views/katello/api/v2/repositories/base.json.rabl +10 -17
  159. data/app/views/overrides/activation_keys/_host_synced_content_select.html.erb +2 -6
  160. data/config/routes/api/v2.rb +13 -0
  161. data/config/routes/overrides.rb +2 -0
  162. data/config/routes.rb +14 -2
  163. data/db/migrate/20140110000001_update_environments_add_katello_id.rb +1 -3
  164. data/db/migrate/20140610154745_content_view_puppet_environment_id.rb +0 -35
  165. data/db/migrate/20190802112101_add_applicable_debs.rb +16 -0
  166. data/db/migrate/20210201163238_migrate_background_download_policy_to_migrate.rb +2 -2
  167. data/db/migrate/20210909140337_add_last_indexed_to_repos.rb +5 -0
  168. data/db/migrate/20210910190324_move_background_settings_to_immediate.rb +25 -0
  169. data/db/migrate/20211006161617_add_filename_to_katello_generic_content_units.rb +5 -0
  170. data/db/migrate/20211019192121_create_cdn_configuration.katello.rb +30 -0
  171. data/db/migrate/20211025181315_add_additional_metadata_to_katello_generic_content_units.rb +5 -0
  172. data/engines/bastion/README.md +15 -0
  173. data/engines/bastion/app/assets/javascripts/bastion/components/nutupane.factory.js +2 -2
  174. data/engines/bastion/config/routes.rb +2 -0
  175. data/engines/bastion/vendor/assets/javascripts/bastion/angular/angular.js +3 -3
  176. data/engines/bastion/vendor/assets/javascripts/bastion/angular-sanitize/angular-sanitize.js +1 -1
  177. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +3 -0
  178. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/common/views/registration.html +1 -1
  179. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-debs-applicable.controller.js +44 -0
  180. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-debs.controller.js +1 -1
  181. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-debs-applicable.html +70 -0
  182. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-debs.html +1 -1
  183. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.routes.js +10 -0
  184. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-details.html +5 -0
  185. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +25 -9
  186. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.routes.js +2 -2
  187. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-versions.html +0 -9
  188. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/debs.controller.js +22 -2
  189. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/debs.routes.js +1 -1
  190. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/details/deb.controller.js +22 -2
  191. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/details/views/deb-content-views.html +1 -1
  192. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/details/views/deb-info.html +36 -4
  193. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/details/views/deb-repositories.html +1 -1
  194. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/details/views/deb.html +4 -4
  195. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/debs/views/debs.html +31 -4
  196. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/generic-content/generic-content.factory.js +21 -0
  197. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/generic-content/generic-content.module.js +17 -0
  198. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/packages/details/package.controller.js +4 -0
  199. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/packages/details/views/package-info.html +3 -3
  200. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-repositories.controller.js +6 -2
  201. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +30 -2
  202. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.filter.js +1 -13
  203. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-manage-content.controller.js +32 -9
  204. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details.controller.js +15 -4
  205. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-details.html +32 -19
  206. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +28 -28
  207. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-manage-generic-content.html +57 -0
  208. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +46 -4
  209. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +57 -27
  210. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repositories.module.js +1 -0
  211. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repositories.routes.js +16 -7
  212. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repository-types.service.js +30 -4
  213. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repository.factory.js +2 -1
  214. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/views/product-repositories.html +8 -0
  215. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/sync-plan-details-info.controller.js +6 -2
  216. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/views/sync-plan-info.html +1 -1
  217. data/engines/bastion_katello/lib/bastion_katello/engine.rb +1 -1
  218. data/lib/katello/engine.rb +0 -1
  219. data/lib/katello/permission_creator.rb +4 -3
  220. data/lib/katello/permissions/host_permissions.rb +1 -0
  221. data/lib/katello/permissions/organization_permissions.rb +2 -1
  222. data/lib/katello/plugin.rb +15 -11
  223. data/lib/katello/repository_types/ansible_collection.rb +13 -1
  224. data/lib/katello/repository_types/deb.rb +13 -0
  225. data/lib/katello/repository_types/docker.rb +13 -1
  226. data/lib/katello/repository_types/file.rb +13 -0
  227. data/lib/katello/repository_types/ostree.rb +48 -4
  228. data/lib/katello/repository_types/python.rb +26 -12
  229. data/lib/katello/repository_types/yum.rb +16 -1
  230. data/lib/katello/tasks/repository.rake +3 -12
  231. data/lib/katello/tasks/reset.rake +4 -5
  232. data/lib/katello/version.rb +1 -1
  233. data/package.json +3 -2
  234. data/webpack/__mocks__/react-intl/index.js +4 -0
  235. data/webpack/components/ActionableDetail.js +23 -3
  236. data/webpack/components/AddedStatusLabel.js +1 -1
  237. data/webpack/components/Bookmark/AddBookmarkModal.js +96 -0
  238. data/webpack/components/Bookmark/Bookmark.scss +28 -0
  239. data/webpack/components/Bookmark/BookmarkActions.js +24 -0
  240. data/webpack/components/Bookmark/BookmarkConstants.js +3 -0
  241. data/webpack/components/Bookmark/BookmarkSelectors.js +15 -0
  242. data/webpack/components/Bookmark/index.js +94 -0
  243. data/webpack/components/EditableSwitch.js +6 -1
  244. data/webpack/components/EditableTextInput/EditableTextInput.js +41 -13
  245. data/webpack/components/Errata/index.js +69 -0
  246. data/webpack/components/ErratumTypeLabel.js +31 -0
  247. data/webpack/components/Loading.js +5 -2
  248. data/webpack/components/RoutedTabs/__tests__/RoutedTabs.test.js +5 -11
  249. data/webpack/components/RoutedTabs/index.js +77 -2
  250. data/webpack/components/Search/Search.js +67 -80
  251. data/webpack/components/Search/__tests__/search.test.js +8 -26
  252. data/webpack/components/SelectAllCheckbox/SelectAllCheckbox.scss +3 -0
  253. data/webpack/components/SelectAllCheckbox/index.js +126 -0
  254. data/webpack/components/SelectableDropdown/SelectableDropdown.js +7 -2
  255. data/webpack/components/Table/EmptyStateMessage.js +38 -17
  256. data/webpack/components/Table/MainTable.js +49 -10
  257. data/webpack/components/Table/MainTable.scss +11 -0
  258. data/webpack/components/Table/PageControls.js +45 -0
  259. data/webpack/components/Table/TableHooks.js +230 -0
  260. data/webpack/components/Table/TableWrapper.js +221 -50
  261. data/webpack/components/Table/helpers.js +17 -0
  262. data/webpack/components/TypeAhead/TypeAhead.js +74 -58
  263. data/webpack/components/TypeAhead/pf4Search/TypeAheadInput.js +25 -10
  264. data/webpack/components/TypeAhead/pf4Search/TypeAheadInput.scss +9 -8
  265. data/webpack/components/TypeAhead/pf4Search/TypeAheadItems.js +2 -2
  266. data/webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js +32 -22
  267. data/webpack/components/extensions/HostDetails/Cards/ContentViewDetailsCard.js +101 -0
  268. data/webpack/components/extensions/HostDetails/Cards/__tests__/contentViewDetailsCard.test.js +53 -0
  269. data/webpack/components/extensions/HostDetails/HostErrata/HostErrataActions.js +47 -0
  270. data/webpack/components/extensions/HostDetails/HostErrata/HostErrataConstants.js +32 -0
  271. data/webpack/components/extensions/HostDetails/HostErrata/HostErrataSelectors.js +16 -0
  272. data/webpack/components/extensions/HostDetails/Tabs/ContentTab/EmptyPage.js +19 -0
  273. data/webpack/components/extensions/HostDetails/Tabs/ContentTab/SecondaryTabsRoutes.js +17 -0
  274. data/webpack/components/extensions/HostDetails/Tabs/ContentTab/constants.js +7 -0
  275. data/webpack/components/extensions/HostDetails/Tabs/ContentTab/helpers.js +3 -0
  276. data/webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js +40 -0
  277. data/webpack/components/extensions/HostDetails/Tabs/EnableTracerEmptyState.js +42 -0
  278. data/webpack/components/extensions/HostDetails/Tabs/EnableTracerModal.js +118 -0
  279. data/webpack/components/extensions/HostDetails/Tabs/ErrataTab.js +347 -0
  280. data/webpack/components/extensions/HostDetails/Tabs/ErrataTab.scss +16 -0
  281. data/webpack/components/extensions/HostDetails/Tabs/ErratumExpansionContents.js +60 -0
  282. data/webpack/components/extensions/HostDetails/Tabs/ErratumExpansionDetail.js +69 -0
  283. data/webpack/components/extensions/HostDetails/Tabs/HostTracesActions.js +19 -0
  284. data/webpack/components/extensions/HostDetails/Tabs/HostTracesConstants.js +2 -0
  285. data/webpack/components/extensions/HostDetails/Tabs/HostTracesSelectors.js +19 -0
  286. data/webpack/components/extensions/HostDetails/Tabs/RemoteExecutionActions.js +56 -0
  287. data/webpack/components/extensions/HostDetails/Tabs/RemoteExecutionConstants.js +5 -0
  288. data/webpack/components/extensions/HostDetails/Tabs/TracesTab.js +188 -0
  289. data/webpack/components/extensions/HostDetails/Tabs/TracesTab.scss +12 -0
  290. data/webpack/components/extensions/HostDetails/Tabs/__tests__/errata.fixtures.json +67 -0
  291. data/webpack/components/extensions/HostDetails/Tabs/__tests__/errataTab.test.js +785 -0
  292. data/webpack/components/extensions/HostDetails/Tabs/__tests__/resolveTraces.fixtures.json +35 -0
  293. data/webpack/components/extensions/HostDetails/Tabs/__tests__/tracerEmptyTraceResults.fixtures.json +7 -0
  294. data/webpack/components/extensions/HostDetails/Tabs/__tests__/tracerEnableJobInvocation.fixtures.json +35 -0
  295. data/webpack/components/extensions/HostDetails/Tabs/__tests__/traces.fixtures.json +44 -0
  296. data/webpack/components/extensions/HostDetails/Tabs/__tests__/tracesTab.test.js +386 -0
  297. data/webpack/components/extensions/HostDetails/Tabs/customizedRexUrlHelpers.js +20 -0
  298. data/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js +1 -1
  299. data/webpack/components/extensions/RegistrationCommands/index.js +1 -1
  300. data/webpack/components/pf3Table/components/Table.js +1 -1
  301. data/webpack/components/pf3Table/components/__snapshots__/Table.test.js.snap +3 -3
  302. data/webpack/containers/Application/Routes.js +3 -3
  303. data/webpack/containers/Application/config.js +21 -6
  304. data/webpack/containers/Application/overrides.scss +34 -3
  305. data/webpack/{fills_index.js → global_index.js} +11 -2
  306. data/webpack/global_test_setup.js +6 -1
  307. data/webpack/redux/actions/RedHatRepositories/helpers.js +4 -4
  308. data/webpack/scenes/AnsibleCollections/AnsibleCollectionsTableSchema.js +1 -1
  309. data/webpack/scenes/Content/ContentActions.js +31 -0
  310. data/webpack/scenes/Content/ContentConfig.js +138 -0
  311. data/webpack/scenes/Content/ContentConstants.js +7 -0
  312. data/webpack/scenes/Content/ContentPage.js +89 -0
  313. data/webpack/scenes/Content/ContentSelectors.js +43 -0
  314. data/webpack/scenes/Content/Details/ContentCounts.js +42 -0
  315. data/webpack/scenes/Content/Details/ContentDetails.js +66 -0
  316. data/webpack/scenes/Content/Details/ContentInfo.js +60 -0
  317. data/webpack/scenes/Content/Details/ContentRepositories.js +78 -0
  318. data/webpack/scenes/Content/Details/__tests__/ansibleCollectionDetails.fixtures.json +20 -0
  319. data/webpack/scenes/Content/Details/__tests__/ansibleCollectionRepositoryDetails.fixtures.json +71 -0
  320. data/webpack/scenes/Content/Details/__tests__/contentDetail.test.js +152 -0
  321. data/webpack/scenes/Content/Details/__tests__/pythonPackageDetails.fixtures.json +20 -0
  322. data/webpack/scenes/Content/Details/__tests__/pythonPackageRepositoryDetails.fixtures.json +71 -0
  323. data/webpack/scenes/Content/Details/index.js +4 -0
  324. data/webpack/scenes/Content/Table/ContentTable.js +90 -0
  325. data/webpack/scenes/Content/Table/index.js +3 -0
  326. data/webpack/scenes/Content/__tests__/ansibleCollections.fixtures.json +50 -0
  327. data/webpack/scenes/Content/__tests__/contentTable.test.js +89 -0
  328. data/webpack/scenes/Content/__tests__/contentTypes.fixtures.json +66 -0
  329. data/webpack/scenes/Content/__tests__/pythonPackages.fixtures.json +30 -0
  330. data/webpack/scenes/Content/index.js +4 -0
  331. data/webpack/scenes/ContentViews/ContentViewSelectors.js +5 -6
  332. data/webpack/scenes/ContentViews/ContentViewsActions.js +13 -8
  333. data/webpack/scenes/ContentViews/ContentViewsConstants.js +31 -4
  334. data/webpack/scenes/ContentViews/ContentViewsPage.js +4 -0
  335. data/webpack/scenes/ContentViews/Copy/CopyContentViewForm.js +19 -7
  336. data/webpack/scenes/ContentViews/Copy/CopyContentViewModal.js +7 -5
  337. data/webpack/scenes/ContentViews/Copy/__tests__/copyContentView.test.js +1 -1
  338. data/webpack/scenes/ContentViews/Create/CreateContentViewForm.js +7 -3
  339. data/webpack/scenes/ContentViews/Create/__tests__/createContentView.test.js +1 -2
  340. data/webpack/scenes/ContentViews/Delete/CVDeleteContext.js +4 -0
  341. data/webpack/scenes/ContentViews/Delete/ContentViewDeleteWizard.js +170 -0
  342. data/webpack/scenes/ContentViews/Delete/Steps/CVDeleteEnvironmentsSelection.js +108 -0
  343. data/webpack/scenes/ContentViews/Delete/Steps/CVDeletionFinish.js +69 -0
  344. data/webpack/scenes/ContentViews/Delete/Steps/CVDeletionReassignActivationKeysForm.js +121 -0
  345. data/webpack/scenes/ContentViews/Delete/Steps/CVDeletionReassignHostsForm.js +120 -0
  346. data/webpack/scenes/ContentViews/Delete/Steps/CVDeletionReview.js +62 -0
  347. data/webpack/scenes/ContentViews/Delete/Steps/CVEnvironmentSelectionForm.scss +4 -0
  348. data/webpack/scenes/ContentViews/Delete/__tests__/CvData.fixtures.json +259 -0
  349. data/webpack/scenes/ContentViews/Delete/__tests__/affectedHosts.fixtures.json +155 -0
  350. data/webpack/scenes/ContentViews/Delete/__tests__/contentViewDelete.test.js +241 -0
  351. data/webpack/scenes/ContentViews/Delete/__tests__/cvDetails.fixtures.json +248 -0
  352. data/webpack/scenes/ContentViews/Delete/__tests__/cvVersionsData.fixtures.json +865 -0
  353. data/webpack/scenes/ContentViews/Delete/__tests__/envPathData.fixtures.json +424 -0
  354. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentContentViewAddModal.js +15 -7
  355. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentContentViewBulkAddModal.js +123 -0
  356. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentEnvironments.js +1 -1
  357. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentVersion.js +8 -5
  358. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js +109 -51
  359. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.fixtures.json +21 -6
  360. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.test.js +80 -16
  361. data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +248 -3
  362. data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +141 -0
  363. data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +36 -54
  364. data/webpack/scenes/ContentViews/Details/ContentViewInfo.js +20 -4
  365. data/webpack/scenes/ContentViews/Details/Filters/Add/CVFilterAddModal.js +63 -38
  366. data/webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js +3 -4
  367. data/webpack/scenes/ContentViews/Details/Filters/AffectedRepositories/AffectedRepositorySelection.js +65 -0
  368. data/webpack/scenes/ContentViews/Details/Filters/AffectedRepositories/AffectedRepositoryTable.js +260 -0
  369. data/webpack/scenes/ContentViews/Details/Filters/ArtifactsWithNoErrata.js +54 -0
  370. data/webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js +202 -0
  371. data/webpack/scenes/ContentViews/Details/Filters/CVErrataDateFilterContent.js +291 -0
  372. data/webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js +441 -0
  373. data/webpack/scenes/ContentViews/Details/Filters/CVFilterDetailType.js +62 -3
  374. data/webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js +302 -0
  375. data/webpack/scenes/ContentViews/Details/Filters/CVPackageGroupFilterContent.js +186 -23
  376. data/webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js +144 -19
  377. data/webpack/scenes/ContentViews/Details/Filters/ContentType.js +2 -0
  378. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilterDetails.js +44 -13
  379. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilterDetailsHeader.js +81 -17
  380. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js +43 -43
  381. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/CVRpmMatchContentModal.js +96 -0
  382. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/__tests__/CVRpmMatchContent.fixtures.json +166 -0
  383. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/__tests__/CVRpmMatchContentModal.test.js +90 -0
  384. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/__tests__/CVRpmMatchContentSearch.fixtures.json +33 -0
  385. data/webpack/scenes/ContentViews/Details/Filters/Rules/ContainerTag/AddEditContainerTagRuleModal.js +91 -0
  386. data/webpack/scenes/ContentViews/Details/Filters/Rules/Package/AddEditPackageRuleModal.js +237 -0
  387. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVContainerImageFilterContent.fixtures.json +42 -0
  388. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVContainerImageFilterContent.test.js +265 -0
  389. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVRpmFilterContent.test.js +218 -11
  390. data/webpack/scenes/ContentViews/Details/Filters/__tests__/ContentViewPackageGroupFilter.test.js +517 -0
  391. data/webpack/scenes/ContentViews/Details/Filters/__tests__/allFilterErrata.fixtures.json +122 -0
  392. data/webpack/scenes/ContentViews/Details/Filters/__tests__/allFilterModulesStreams.fixtures.json +60 -0
  393. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewErrataByDateDetails.fixtures.json +359 -0
  394. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilterDetail.fixtures.json +88 -102
  395. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilterDetails.test.js +34 -9
  396. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.fixtures.json +148 -132
  397. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.test.js +25 -7
  398. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvAllRepos.fixtures.json +150 -0
  399. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvErrataDateFilterContent.test.js +74 -0
  400. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvErrataIDFilter.test.js +404 -0
  401. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvErratumFilterDetails.fixtures.json +89 -0
  402. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvFilterDetailModuleAffectedRepos.fixtures.json +383 -0
  403. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvFilterDetailWithAffectedRepos.fixtures.json +375 -0
  404. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvFilterFixutre.fixture.json +282 -0
  405. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvModuleStreamFilter.test.js +392 -0
  406. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvModuleStreamFilterDetails.fixtures.json +97 -0
  407. data/webpack/scenes/ContentViews/Details/Filters/index.js +26 -0
  408. data/webpack/scenes/ContentViews/Details/Histories/ContentViewHistories.js +68 -79
  409. data/webpack/scenes/ContentViews/Details/Histories/__tests__/contentViewHistory.test.js +1 -2
  410. data/webpack/scenes/ContentViews/Details/Promote/ContentViewVersionPromote.js +163 -0
  411. data/webpack/scenes/ContentViews/Details/Promote/ContentViewVersionPromoteSelectors.js +16 -0
  412. data/webpack/scenes/ContentViews/Details/Repositories/ContentCounts.js +9 -1
  413. data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +88 -74
  414. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewAddRemove.test.js +8 -9
  415. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.fixtures.json +3 -3
  416. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionContent.js +30 -9
  417. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionEnvironments.js +1 -1
  418. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionErrata.js +9 -5
  419. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionErrata.scss +2 -2
  420. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersions.js +132 -14
  421. data/webpack/scenes/ContentViews/Details/Versions/Delete/DeleteContext.js +4 -0
  422. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveCVVersionWizard.js +176 -0
  423. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVEnvironmentSelectionForm.js +127 -0
  424. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVReassignActivationKeysForm.js +131 -0
  425. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVReassignHostsForm.js +128 -0
  426. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVVersionDeleteFinish.js +94 -0
  427. data/webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVVersionRemoveReview.js +67 -0
  428. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvAffectedActivationKeys.fixture.json +53 -0
  429. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvAffectedHosts.fixture.json +153 -0
  430. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvDropDownOptionsResponse.fixture.json +192 -0
  431. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvVersionRemove.test.js +313 -0
  432. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvVersionRemoveResponse.fixture.json +74 -0
  433. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/versionRemoveEnvPaths.fixtures.json +352 -0
  434. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/versionsResponseData.fixtures.json +583 -0
  435. data/webpack/scenes/ContentViews/Details/Versions/Delete/affectedActivationKeys.js +96 -0
  436. data/webpack/scenes/ContentViews/Details/Versions/Delete/affectedHosts.js +97 -0
  437. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js +332 -0
  438. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetails.js +128 -0
  439. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetails.scss +44 -0
  440. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailsHeader.js +66 -0
  441. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailsTable.js +125 -0
  442. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionRepositoryCell.js +115 -0
  443. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionAnsibleCollections.fixtures.json +449 -0
  444. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionComponent.fixtures.json +753 -0
  445. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDebPackages.fixtures.json +58 -0
  446. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetails.fixtures.json +158 -0
  447. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetails.test.js +289 -0
  448. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetailsCounts.fixtures.json +73 -0
  449. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetailsEmpty.test.js +44 -0
  450. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDockerTags.fixtures.json +3024 -0
  451. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionErrata.fixtures.json +201 -0
  452. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionFiles.fixtures.json +22 -0
  453. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionModuleStreams.fixtures.json +196 -0
  454. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionRepositories.fixtures.json +1000 -0
  455. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionRpmPackageGroups.fixtures.json +44 -0
  456. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionRpmPackages.fixtures.json +394 -0
  457. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersions.fixtures.json +4 -4
  458. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersions.test.js +95 -26
  459. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersionsWithTask.fixtures.json +2 -2
  460. data/webpack/scenes/ContentViews/Details/Versions/index.js +25 -0
  461. data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetail.test.js +20 -16
  462. data/webpack/scenes/ContentViews/Publish/__tests__/publishContentView.test.js +3 -5
  463. data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +106 -64
  464. data/webpack/scenes/ContentViews/Table/tableDataGenerator.js +25 -4
  465. data/webpack/scenes/ContentViews/__tests__/basicContentViews.fixtures.js +1 -1
  466. data/webpack/scenes/ContentViews/__tests__/contentViewList.fixtures.json +4 -1
  467. data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +29 -36
  468. data/webpack/scenes/ContentViews/__tests__/mockDetails.fixtures.json +10 -0
  469. data/webpack/scenes/ContentViews/components/CVBreadCrumb.js +117 -0
  470. data/webpack/scenes/ContentViews/components/ContentViewsCounter.js +59 -0
  471. data/webpack/scenes/ContentViews/components/EnvironmentLabels.js +4 -3
  472. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.js +30 -11
  473. data/webpack/scenes/ContentViews/components/TaskPresenter/TaskPresenter.js +1 -1
  474. data/webpack/scenes/ContentViews/expansions/DetailsExpansion.js +38 -1
  475. data/webpack/scenes/ContentViews/expansions/RelatedCompositeContentViewsModal.js +79 -0
  476. data/webpack/scenes/ContentViews/expansions/RelatedContentViewComponentsModal.js +107 -0
  477. data/webpack/scenes/ContentViews/expansions/__tests__/contentViewComponentsModal.test.js +59 -0
  478. data/webpack/scenes/ContentViews/expansions/__tests__/contentViewComponentsResponse.fixtures.json +116 -0
  479. data/webpack/scenes/ContentViews/expansions/__tests__/relatedCompositeCvs.fixtures.json +4 -0
  480. data/webpack/scenes/ContentViews/helpers.js +1 -0
  481. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js +1 -1
  482. data/webpack/scenes/RedHatRepositories/components/SearchBar.js +4 -3
  483. data/webpack/scenes/SmartProxy/SmartProxyContentTable.js +1 -1
  484. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +17 -9
  485. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +3 -3
  486. data/webpack/test-utils/nockWrapper.js +20 -3
  487. data/webpack/utils/helpers.js +16 -2
  488. data/webpack/utils/useDebounce.js +20 -0
  489. metadata +232 -54
  490. data/app/assets/javascripts/katello/widgets/tabs.js +0 -13
  491. data/app/assets/stylesheets/katello/widgets/tabs.scss +0 -69
  492. data/app/lib/actions/katello/provider/update.rb +0 -38
  493. data/webpack/components/RoutedTabs/RoutedTabs.js +0 -90
  494. data/webpack/components/Search/Search.test.js +0 -23
  495. data/webpack/components/Search/__snapshots__/Search.test.js.snap +0 -21
  496. data/webpack/components/extensions/HostDetails/Tabs/ContentTab.js +0 -42
  497. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.test.js +0 -145
  498. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionPackages.js +0 -0
@@ -1,10 +1,11 @@
1
- import React, { useState, useCallback } from 'react';
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
2
  import useDeepCompareEffect from 'use-deep-compare-effect';
3
3
  import { useDispatch, useSelector } from 'react-redux';
4
4
  import { TableVariant, TableText } from '@patternfly/react-table';
5
5
  import { translate as __ } from 'foremanReact/common/I18n';
6
6
  import { urlBuilder } from 'foremanReact/common/urlHelpers';
7
7
  import { STATUS } from 'foremanReact/constants';
8
+ import { Link } from 'react-router-dom';
8
9
  import PropTypes from 'prop-types';
9
10
 
10
11
  import TableWrapper from '../../../../components/Table/TableWrapper';
@@ -18,20 +19,33 @@ import {
18
19
  selectCVVersionsStatus,
19
20
  selectCVVersionsError,
20
21
  } from '../ContentViewDetailSelectors';
22
+ import getEnvironmentPaths from '../../components/EnvironmentPaths/EnvironmentPathActions';
23
+ import ContentViewVersionPromote from '../Promote/ContentViewVersionPromote';
21
24
  import TaskPresenter from '../../components/TaskPresenter/TaskPresenter';
22
25
  import { startPollingTask } from '../../../Tasks/TaskActions';
26
+ import RemoveCVVersionWizard from './Delete/RemoveCVVersionWizard';
27
+ import { hasPermission } from '../../helpers';
23
28
 
24
- const ContentViewVersions = ({ cvId }) => {
29
+ const ContentViewVersions = ({ cvId, details }) => {
25
30
  const response = useSelector(state => selectCVVersions(state, cvId));
31
+ const { results, ...metadata } = response;
26
32
  const status = useSelector(state => selectCVVersionsStatus(state, cvId));
27
33
  const error = useSelector(state => selectCVVersionsError(state, cvId));
28
34
  const [pollingFinished, setPollingFinished] = useState(false);
29
35
  const loading = status === STATUS.PENDING;
30
36
  const dispatch = useDispatch();
31
-
32
37
  const [rows, setRows] = useState([]);
33
- const [metadata, setMetadata] = useState({});
34
38
  const [searchQuery, updateSearchQuery] = useState('');
39
+ const [versionIdToPromote, setVersionIdToPromote] = useState('');
40
+ const [versionNameToPromote, setVersionNameToPromote] = useState('');
41
+ const [versionIdToRemove, setVersionIdToRemove] = useState('');
42
+ const [versionNameToRemove, setVersionNameToRemove] = useState('');
43
+ const [versionEnvironments, setVersionEnvironments] = useState([]);
44
+ const [promoting, setPromoting] = useState(false);
45
+ const [removingFromEnv, setRemovingFromEnv] = useState(false);
46
+ const [deleteVersion, setDeleteVersion] = useState(false);
47
+ const [currentStep, setCurrentStep] = useState(1);
48
+ const { permissions } = details;
35
49
 
36
50
  const columnHeaders = [
37
51
  __('Version'),
@@ -42,6 +56,13 @@ const ContentViewVersions = ({ cvId }) => {
42
56
  __('Description'),
43
57
  ];
44
58
 
59
+ useEffect(
60
+ () => {
61
+ dispatch(getEnvironmentPaths());
62
+ },
63
+ [dispatch],
64
+ );
65
+
45
66
  const buildCells = useCallback((cvVersion) => {
46
67
  const {
47
68
  version,
@@ -52,9 +73,9 @@ const ContentViewVersions = ({ cvId }) => {
52
73
  errata_counts: errataCounts,
53
74
  } = cvVersion;
54
75
  return [
55
- { title: <a href={urlBuilder(`content_views/${cvId}/versions/${versionId}`, '')}>{__('Version ')}{version}</a> },
76
+ { title: <Link to={`/versions/${versionId}`}>{__('Version ')}{version}</Link> },
56
77
  { title: <ContentViewVersionEnvironments {...{ environments }} /> },
57
- { title: <a href={urlBuilder(`content_views/${cvId}/versions/${versionId}/packages`, '')}>{`${packageCount}`}</a> },
78
+ { title: <a href={urlBuilder(`content_views/${cvId}#/versions/${versionId}/packages`, '')}>{packageCount}</a> },
58
79
  { title: <ContentViewVersionErrata {...{ cvId, versionId, errataCounts }} /> },
59
80
  { title: <ContentViewVersionContent {...{ cvId, versionId, cvVersion }} /> },
60
81
  { title: description ? <TableText wrapModifier="truncate">{description}</TableText> : <InactiveText text={__('No description')} /> },
@@ -75,7 +96,7 @@ const ContentViewVersions = ({ cvId }) => {
75
96
  }
76
97
 
77
98
  return [
78
- { title: <a href={urlBuilder(`content_views/${cvId}/versions/${versionId}`, '')}>{__('Version ')}{version}</a> },
99
+ { title: <Link disabled to={`/versions/${versionId}`}>{__('Version ')}{version}</Link> },
79
100
  {
80
101
  title: <TaskPresenter
81
102
  activeHistory={activeHistory[0]}
@@ -87,31 +108,95 @@ const ContentViewVersions = ({ cvId }) => {
87
108
  { title: '' },
88
109
  { title: description ? <TableText wrapModifier="truncate">{description}</TableText> : <InactiveText text={__('No description')} /> },
89
110
  ];
90
- }, [cvId, dispatch]);
111
+ }, [dispatch]);
91
112
 
92
113
  useDeepCompareEffect(() => {
93
- const buildRows = (results) => {
114
+ const buildRows = () => {
94
115
  const newRows = [];
95
116
  results.forEach((cvVersion) => {
96
117
  const {
118
+ version,
119
+ id: versionId,
120
+ environments,
97
121
  active_history: activeHistory,
98
122
  } = cvVersion;
99
123
 
100
124
  const cells = activeHistory.length ?
101
125
  buildActiveTaskCells(cvVersion) :
102
126
  buildCells(cvVersion);
103
- newRows.push({ cells });
127
+ newRows.push({
128
+ cvVersionId: versionId,
129
+ cvVersionName: version,
130
+ cvVersionEnvironments: environments,
131
+ activeHistory,
132
+ cells,
133
+ });
104
134
  });
105
135
  return newRows;
106
136
  };
107
137
 
108
- const { results, ...meta } = response;
109
- setMetadata(meta);
110
138
  if (!loading && results) {
111
- const newRows = buildRows(results);
139
+ const newRows = buildRows();
112
140
  setRows(newRows);
113
141
  }
114
- }, [response, setMetadata, buildActiveTaskCells, buildCells, dispatch, loading, setRows]);
142
+ }, [response, results, buildActiveTaskCells, buildCells, dispatch, loading, setRows]);
143
+
144
+ const onPromote = ({ cvVersionId, cvVersionName, cvVersionEnvironments }) => {
145
+ setVersionIdToPromote(cvVersionId);
146
+ setVersionNameToPromote(cvVersionName);
147
+ setVersionEnvironments(cvVersionEnvironments);
148
+ setPromoting(true);
149
+ setPollingFinished(false);
150
+ };
151
+
152
+ const onRemoveFromEnv = ({
153
+ cvVersionId, cvVersionName, cvVersionEnvironments, deleting,
154
+ }) => {
155
+ setVersionIdToRemove(cvVersionId);
156
+ setVersionNameToRemove(cvVersionName);
157
+ setVersionEnvironments(cvVersionEnvironments);
158
+ setRemovingFromEnv(true);
159
+ setDeleteVersion(deleting);
160
+ setPollingFinished(false);
161
+ };
162
+
163
+ const actionResolver = (rowData, { _rowIndex }) => [
164
+ {
165
+ title: __('Promote'),
166
+ isDisabled: rowData.activeHistory.length,
167
+ onClick: (_event, rowId, rowInfo) => {
168
+ onPromote({
169
+ cvVersionId: rowInfo.cvVersionId,
170
+ cvVersionName: rowInfo.cvVersionName,
171
+ cvVersionEnvironments: rowInfo.cvVersionEnvironments,
172
+ });
173
+ },
174
+ },
175
+ {
176
+ title: __('Remove'),
177
+ isDisabled: rowData.activeHistory.length,
178
+ onClick: (_event, rowId, rowInfo) => {
179
+ onRemoveFromEnv({
180
+ cvVersionId: rowInfo.cvVersionId,
181
+ cvVersionName: rowInfo.cvVersionName,
182
+ cvVersionEnvironments: rowInfo.cvVersionEnvironments,
183
+ deleting: false,
184
+ });
185
+ },
186
+ },
187
+ {
188
+ title: __('Delete'),
189
+ isDisabled: rowData.activeHistory.length,
190
+ onClick: (_event, rowId, rowInfo) => {
191
+ onRemoveFromEnv({
192
+ cvVersionId: rowInfo.cvVersionId,
193
+ cvVersionName: rowInfo.cvVersionName,
194
+ cvVersionEnvironments: rowInfo.cvVersionEnvironments,
195
+ deleting: true,
196
+ });
197
+ },
198
+ },
199
+ ];
115
200
 
116
201
  const emptyContentTitle = __("You currently don't have any versions for this content view.");
117
202
  const emptyContentBody = __('Versions will appear here when the content view is published.'); // needs link
@@ -132,15 +217,48 @@ const ContentViewVersions = ({ cvId }) => {
132
217
  error,
133
218
  status,
134
219
  }}
220
+ actionResolver={hasPermission(permissions, 'promote_or_remove_content_views') ? actionResolver : null}
135
221
  cells={columnHeaders}
136
222
  variant={TableVariant.compact}
137
223
  autocompleteEndpoint={`/content_view_versions/auto_complete_search?content_view_id=${cvId}`}
138
224
  fetchItems={useCallback(params => getContentViewVersions(cvId, params), [cvId])}
139
225
  additionalListeners={[pollingFinished]}
226
+ actionButtons={
227
+ <>
228
+ {promoting &&
229
+ <ContentViewVersionPromote
230
+ cvId={cvId}
231
+ versionIdToPromote={versionIdToPromote}
232
+ versionNameToPromote={versionNameToPromote}
233
+ versionEnvironments={versionEnvironments}
234
+ setIsOpen={setPromoting}
235
+ aria-label="promote_content_view_modal"
236
+ />
237
+ }
238
+ {removingFromEnv &&
239
+ <RemoveCVVersionWizard
240
+ cvId={cvId}
241
+ versionIdToRemove={versionIdToRemove}
242
+ versionNameToRemove={versionNameToRemove}
243
+ versionEnvironments={versionEnvironments}
244
+ show={removingFromEnv}
245
+ setIsOpen={setRemovingFromEnv}
246
+ currentStep={currentStep}
247
+ setCurrentStep={setCurrentStep}
248
+ deleteWizard={deleteVersion}
249
+ aria-label="remove_content_view_version_modal"
250
+ />
251
+ }
252
+ </>
253
+ }
140
254
  />);
141
255
  };
142
256
 
143
257
  ContentViewVersions.propTypes = {
144
258
  cvId: PropTypes.number.isRequired,
259
+ details: PropTypes.shape({
260
+ permissions: PropTypes.shape({}),
261
+ }).isRequired,
145
262
  };
263
+
146
264
  export default ContentViewVersions;
@@ -0,0 +1,4 @@
1
+ import { createContext } from 'react';
2
+
3
+ const DeleteContext = createContext({});
4
+ export default DeleteContext;
@@ -0,0 +1,176 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { useDispatch } from 'react-redux';
3
+ import PropTypes from 'prop-types';
4
+ import { Wizard } from '@patternfly/react-core';
5
+ import { translate as __ } from 'foremanReact/common/I18n';
6
+ import getEnvironmentPaths from '../../../components/EnvironmentPaths/EnvironmentPathActions';
7
+ import CVEnvironmentSelectionForm from './RemoveSteps/CVEnvironmentSelectionForm';
8
+ import CVReassignActivationKeysForm from './RemoveSteps/CVReassignActivationKeysForm';
9
+ import CVReassignHostsForm from './RemoveSteps/CVReassignHostsForm';
10
+ import CVVersionRemoveReview from './RemoveSteps/CVVersionRemoveReview';
11
+ import CVVersionDeleteFinish from './RemoveSteps/CVVersionDeleteFinish';
12
+ import getContentViewDetails from '../../ContentViewDetailActions';
13
+ import getContentViews from '../../../ContentViewsActions';
14
+ import DeleteContext from './DeleteContext';
15
+ import { useSet } from '../../../../../components/Table/TableHooks';
16
+
17
+ const RemoveCVVersionWizard = ({
18
+ cvId, versionIdToRemove, versionNameToRemove,
19
+ versionEnvironments, show, setIsOpen,
20
+ currentStep, setCurrentStep, deleteWizard,
21
+ }) => {
22
+ const [selectedEnvForAK, setSelectedEnvForAK] = useState([]);
23
+ const [selectedEnvForHost, setSelectedEnvForHost] = useState([]);
24
+ const dispatch = useDispatch();
25
+ const selectedEnvSet = useSet([]);
26
+ const [selectedCVForAK, setSelectedCVForAK] = useState(null);
27
+ const [selectedCVNameForAK, setSelectedCVNameForAK] = useState(null);
28
+ const [selectedCVForHosts, setSelectedCVForHosts] = useState(null);
29
+ const [selectedCVNameForHosts, setSelectedCVNameForHosts] = useState(null);
30
+ const [affectedActivationKeys, setAffectedActivationKeys] = useState(false);
31
+ const [affectedHosts, setAffectedHosts] = useState(false);
32
+ const [deleteFlow, setDeleteFlow] = useState(deleteWizard || false);
33
+ const [removeDeletionFlow, setRemoveDeletionFlow] = useState(false);
34
+ const [canReview, setCanReview] = useState(false);
35
+
36
+ useEffect(
37
+ () => {
38
+ dispatch(getEnvironmentPaths());
39
+ if (deleteFlow) {
40
+ versionEnvironments.forEach(env => selectedEnvSet.add(env.id));
41
+ }
42
+ if (versionEnvironments.length === 0) setDeleteFlow(true);
43
+ },
44
+ [dispatch, deleteFlow, setDeleteFlow, versionEnvironments, selectedEnvSet],
45
+ );
46
+
47
+ useEffect(() => {
48
+ const hostsStepComplete = affectedHosts ?
49
+ selectedEnvForHost && selectedCVForHosts :
50
+ true;
51
+ const activationStepComplete = affectedActivationKeys ?
52
+ selectedEnvForAK && selectedCVForAK :
53
+ true;
54
+ setCanReview(hostsStepComplete &&
55
+ activationStepComplete &&
56
+ (selectedEnvSet.size || versionEnvironments.length === 0));
57
+ }, [affectedHosts, selectedEnvForHost, selectedCVForHosts, versionEnvironments,
58
+ affectedActivationKeys, selectedEnvForAK, selectedCVForAK, selectedEnvSet.size]);
59
+
60
+ const environmentSelectionStep = {
61
+ id: 1,
62
+ name: __('Remove from environments'),
63
+ component: <CVEnvironmentSelectionForm />,
64
+ enableNext: (selectedEnvSet.size || versionEnvironments.length === 0),
65
+ };
66
+
67
+ const hostStep = {
68
+ id: 2,
69
+ name: 'Reassign affected hosts',
70
+ component: <CVReassignHostsForm />,
71
+ enableNext: (affectedHosts ? selectedEnvForHost && selectedCVForHosts : true),
72
+ canJumpTo: affectedHosts,
73
+ };
74
+
75
+ const activationStep = {
76
+ id: 3,
77
+ name: 'Reassign affected activation keys',
78
+ component: <CVReassignActivationKeysForm />,
79
+ enableNext: canReview,
80
+ canJumpTo: affectedActivationKeys &&
81
+ (affectedHosts ? selectedEnvForHost && selectedCVForHosts : true),
82
+ };
83
+
84
+ const reviewStep = {
85
+ id: 4,
86
+ name: 'Review',
87
+ component: <CVVersionRemoveReview />,
88
+ canJumpTo: canReview,
89
+ nextButtonText: deleteFlow ? __('Delete') : __('Remove'),
90
+ };
91
+
92
+ const finishStep = {
93
+ id: 5,
94
+ name: 'Finish',
95
+ component: <CVVersionDeleteFinish />,
96
+ isFinishedStep: true,
97
+ };
98
+
99
+ const steps = [
100
+ environmentSelectionStep,
101
+ ...(affectedHosts ? [hostStep] : []),
102
+ ...(affectedActivationKeys ? [activationStep] : []),
103
+ reviewStep,
104
+ finishStep,
105
+ ];
106
+
107
+ return (
108
+ <DeleteContext.Provider value={{
109
+ cvId,
110
+ versionIdToRemove,
111
+ versionNameToRemove,
112
+ versionEnvironments,
113
+ setIsOpen,
114
+ affectedActivationKeys,
115
+ affectedHosts,
116
+ setAffectedActivationKeys,
117
+ setAffectedHosts,
118
+ deleteFlow,
119
+ setDeleteFlow,
120
+ removeDeletionFlow,
121
+ setRemoveDeletionFlow,
122
+ currentStep,
123
+ selectedCVForHosts,
124
+ setSelectedCVNameForHosts,
125
+ setSelectedCVForHosts,
126
+ selectedCVForAK,
127
+ setSelectedCVNameForAK,
128
+ selectedCVNameForAK,
129
+ selectedCVNameForHosts,
130
+ setSelectedCVForAK,
131
+ selectedEnvForAK,
132
+ setSelectedEnvForAK,
133
+ selectedEnvForHost,
134
+ setSelectedEnvForHost,
135
+ selectedEnvSet,
136
+ }}
137
+ >
138
+ <Wizard
139
+ title={deleteFlow ? __('Delete Version') : __('Remove Version')}
140
+ description={__(`${deleteFlow ? 'Deleting' : 'Removing'} version ${versionNameToRemove}`)}
141
+ steps={steps}
142
+ startAtStep={currentStep}
143
+ onClose={() => {
144
+ selectedEnvSet.clear();
145
+ if (currentStep === 3) {
146
+ setCurrentStep(1);
147
+ dispatch(getContentViewDetails(cvId));
148
+ dispatch(getContentViews);
149
+ }
150
+ setIsOpen(false);
151
+ }}
152
+ isOpen={show}
153
+ />
154
+ </DeleteContext.Provider>
155
+ );
156
+ };
157
+
158
+ RemoveCVVersionWizard.propTypes = {
159
+ cvId: PropTypes.number.isRequired,
160
+ versionIdToRemove: PropTypes.number.isRequired,
161
+ versionNameToRemove: PropTypes.string.isRequired,
162
+ versionEnvironments: PropTypes.arrayOf(PropTypes.shape({})),
163
+ show: PropTypes.bool,
164
+ setIsOpen: PropTypes.func,
165
+ currentStep: PropTypes.number.isRequired,
166
+ setCurrentStep: PropTypes.func.isRequired,
167
+ deleteWizard: PropTypes.bool.isRequired,
168
+ };
169
+
170
+ RemoveCVVersionWizard.defaultProps = {
171
+ versionEnvironments: [],
172
+ show: false,
173
+ setIsOpen: null,
174
+ };
175
+
176
+ export default RemoveCVVersionWizard;
@@ -0,0 +1,127 @@
1
+ import React, { useContext } from 'react';
2
+ import useDeepCompareEffect from 'use-deep-compare-effect';
3
+ import { Alert, Checkbox, EmptyState, EmptyStateVariant, Title, EmptyStateBody } from '@patternfly/react-core';
4
+ import { TableVariant, TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';
5
+ import { translate as __ } from 'foremanReact/common/I18n';
6
+ import DeleteContext from '../DeleteContext';
7
+
8
+ const CVEnvironmentSelectionForm = () => {
9
+ const {
10
+ versionNameToRemove, versionEnvironments, selectedEnvSet,
11
+ setAffectedActivationKeys, setAffectedHosts, deleteFlow,
12
+ removeDeletionFlow, setRemoveDeletionFlow,
13
+ } = useContext(DeleteContext);
14
+
15
+ const areAllSelected = () => versionEnvironments.every(env => selectedEnvSet.has(env.id));
16
+
17
+ const onSelect = (_event, isSelected, rowId) => {
18
+ if (isSelected) {
19
+ selectedEnvSet.add(rowId);
20
+ } else {
21
+ selectedEnvSet.delete(rowId);
22
+ }
23
+ };
24
+
25
+ // Based on env selected for removal, decide if we need to reassign hosts and activation keys.
26
+ useDeepCompareEffect(() => {
27
+ const selectedEnv = versionEnvironments.filter(env => selectedEnvSet.has(env.id));
28
+ setAffectedActivationKeys(!!(selectedEnv.filter(env => env.activation_key_count > 0).length));
29
+ setAffectedHosts(!!(selectedEnv.filter(env => env.host_count > 0).length));
30
+ }, [setAffectedActivationKeys, setAffectedHosts,
31
+ versionEnvironments, selectedEnvSet, selectedEnvSet.size]);
32
+
33
+ const onSelectAll = (event, isSelected) => {
34
+ if (!isSelected) {
35
+ setRemoveDeletionFlow(false);
36
+ selectedEnvSet.clear();
37
+ } else {
38
+ versionEnvironments.forEach(env => selectedEnvSet.add(env.id));
39
+ }
40
+ };
41
+
42
+ const columnHeaders = [
43
+ __('Environment'),
44
+ __('Hosts'),
45
+ __('Activation keys'),
46
+ ];
47
+
48
+ const versionDeleteInfo = __(`Version ${versionNameToRemove} will be deleted from the listed environments. It will no longer be available for promotion.`);
49
+ const versionRemovalInfo = __('Removing this version from all environments will not delete the version. Version will still be available for later promotion.');
50
+ const versionEnvironmentsEmptyInfo = __(`Version ${versionNameToRemove} has not been promoted to any environments. ` +
51
+ 'You can delete this version completely and it will no longer be available for promotion.');
52
+ return (
53
+ <>
54
+ {deleteFlow &&
55
+ <Alert variant="warning" isInline title={__('Warning')}>
56
+ <p style={{ marginBottom: '0.5em' }}>{versionDeleteInfo}</p>
57
+ </Alert>
58
+ }
59
+ {(!deleteFlow &&
60
+ (removeDeletionFlow || areAllSelected() || versionEnvironments.length === 0))
61
+ && (
62
+ <Alert variant="warning" isInline title={__('Warning')}>
63
+ <p style={{ marginBottom: '0.5em' }}>{removeDeletionFlow ? versionDeleteInfo : versionRemovalInfo}</p>
64
+ <Checkbox
65
+ id="delete_version"
66
+ label={__('Delete version')}
67
+ isChecked={removeDeletionFlow}
68
+ onChange={checked => setRemoveDeletionFlow(checked)}
69
+ style={{ margin: 0 }}
70
+ />
71
+ </Alert>)}
72
+ {(versionEnvironments.length !== 0) &&
73
+ <TableComposable variant={TableVariant.compact}>
74
+ <Thead>
75
+ <Tr>
76
+ <Td
77
+ select={{
78
+ rowIndex: 0,
79
+ onSelect: onSelectAll,
80
+ isSelected: areAllSelected() || deleteFlow || removeDeletionFlow,
81
+ disable: deleteFlow || removeDeletionFlow,
82
+ }}
83
+ />
84
+ {columnHeaders.map(col =>
85
+ <Th key={col}>{col}</Th>)}
86
+ </Tr>
87
+ </Thead>
88
+ <Tbody>
89
+ {versionEnvironments?.map(({
90
+ id, name, activation_key_count: akCount,
91
+ host_count: hostCount,
92
+ }, rowIndex) =>
93
+ (
94
+ <Tr key={`${name}_${id}`}>
95
+ <Td
96
+ key={`${name}__${id}_select`}
97
+ select={{
98
+ rowIndex,
99
+ onSelect: (event, isSelected) => onSelect(event, isSelected, id),
100
+ isSelected: selectedEnvSet.has(id) || deleteFlow || removeDeletionFlow,
101
+ disable: deleteFlow || removeDeletionFlow,
102
+ }}
103
+ />
104
+ <Td>
105
+ {name}
106
+ </Td>
107
+ <Td>{hostCount}</Td>
108
+ <Td>{akCount}</Td>
109
+ </Tr>
110
+ ))
111
+ }
112
+ </Tbody>
113
+ </TableComposable>}
114
+ {(versionEnvironments.length === 0) &&
115
+ <EmptyState variant={EmptyStateVariant.xs}>
116
+ <Title headingLevel="h4" size="md">
117
+ {__('This version has not been promoted to any environments.')}
118
+ </Title>
119
+ <EmptyStateBody>
120
+ {versionEnvironmentsEmptyInfo}
121
+ </EmptyStateBody>
122
+ </EmptyState>}
123
+ </>
124
+ );
125
+ };
126
+
127
+ export default CVEnvironmentSelectionForm;
@@ -0,0 +1,131 @@
1
+ import React, { useState, useContext } from 'react';
2
+ import { useDispatch, useSelector } from 'react-redux';
3
+ import useDeepCompareEffect from 'use-deep-compare-effect';
4
+ import { ExpandableSection, Select, SelectOption } from '@patternfly/react-core';
5
+ import { STATUS } from 'foremanReact/constants';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+ import EnvironmentPaths from '../../../../components/EnvironmentPaths/EnvironmentPaths';
8
+ import getContentViews from '../../../../ContentViewsActions';
9
+ import { selectContentViewError, selectContentViews, selectContentViewStatus } from '../../../../ContentViewSelectors';
10
+ import AffectedActivationKeys from '../affectedActivationKeys';
11
+ import DeleteContext from '../DeleteContext';
12
+
13
+ const CVReassignActivationKeysForm = () => {
14
+ const dispatch = useDispatch();
15
+ const contentViewsInEnvResponse = useSelector(selectContentViews);
16
+ const contentViewsInEnvStatus = useSelector(selectContentViewStatus);
17
+ const contentViewsInEnvError = useSelector(selectContentViewError);
18
+ const cvInEnvLoading = contentViewsInEnvStatus === STATUS.PENDING;
19
+ const [cvSelectOpen, setCVSelectOpen] = useState(false);
20
+ const [cvSelectOptions, setCvSelectionOptions] = useState([]);
21
+ const [showActivationKeys, setShowActivationKeys] = useState(false);
22
+ const {
23
+ currentStep, selectedEnvForAK, versionEnvironments, cvId, selectedEnvSet,
24
+ setSelectedEnvForAK, selectedCVForAK, setSelectedCVNameForAK, setSelectedCVForAK,
25
+ } = useContext(DeleteContext);
26
+
27
+ // Fetch content views for selected environment to reassign activation keys to.
28
+ useDeepCompareEffect(
29
+ () => {
30
+ if (selectedEnvForAK.length) {
31
+ dispatch(getContentViews({
32
+ environment_id: selectedEnvForAK[0].id,
33
+ include_default: true,
34
+ full_result: true,
35
+ }));
36
+ }
37
+ setCVSelectOpen(false);
38
+ },
39
+ [selectedEnvForAK, dispatch, setCVSelectOpen],
40
+ );
41
+
42
+ // Upon receiving CVs in selected env, form select options for the content view drop down
43
+ useDeepCompareEffect(() => {
44
+ const { results } = contentViewsInEnvResponse;
45
+ // Filter out the cv in the environments that are currently being removed
46
+ const contentViewEligible = (cv) => {
47
+ if (cv.id === cvId) {
48
+ const selectedEnv = versionEnvironments.filter(env => selectedEnvSet.has(env.id));
49
+ return (selectedEnv.filter(env => env.id === selectedEnvForAK[0]?.id).length === 0);
50
+ }
51
+ return true;
52
+ };
53
+ if (!cvInEnvLoading && results && selectedEnvForAK.length) {
54
+ setCvSelectionOptions(results.map(cv => ((contentViewEligible(cv)) ?
55
+ (
56
+ <SelectOption
57
+ key={cv.id}
58
+ value={cv.id}
59
+ >
60
+ {cv.name}
61
+ </SelectOption>
62
+ ) : null)).filter(n => n));
63
+ }
64
+ if (!cvInEnvLoading && results && selectedCVForAK &&
65
+ results.filter(cv => cv.id === selectedCVForAK && contentViewEligible(cv)).length === 0) {
66
+ setSelectedCVForAK(null);
67
+ setSelectedCVNameForAK(null);
68
+ }
69
+ }, [contentViewsInEnvResponse, contentViewsInEnvStatus, currentStep,
70
+ contentViewsInEnvError, selectedEnvForAK, setSelectedCVForAK, setSelectedCVNameForAK,
71
+ cvInEnvLoading, selectedCVForAK, cvId, versionEnvironments, selectedEnvSet]);
72
+
73
+ const fetchSelectedCVName = (id) => {
74
+ const { results } = contentViewsInEnvResponse ?? { };
75
+ return results.filter(cv => cv.id === id)[0]?.name;
76
+ };
77
+
78
+ const onSelect = (event, selection) => {
79
+ setSelectedCVForAK(selection);
80
+ setSelectedCVNameForAK(fetchSelectedCVName(selection));
81
+ setCVSelectOpen(false);
82
+ };
83
+
84
+ return (
85
+ <>
86
+ <EnvironmentPaths
87
+ userCheckedItems={selectedEnvForAK}
88
+ setUserCheckedItems={setSelectedEnvForAK}
89
+ publishing={false}
90
+ headerText={__('Select lifecycle environment')}
91
+ multiSelect={false}
92
+ />
93
+ {!cvInEnvLoading && selectedEnvForAK.length > 0 &&
94
+ <div style={{ marginTop: '1em' }}>
95
+ <h3>{__('Select content view')}</h3>
96
+ <Select
97
+ selections={selectedCVForAK}
98
+ onSelect={onSelect}
99
+ isOpen={cvSelectOpen}
100
+ isDisabled={cvSelectOptions.length === 0}
101
+ onToggle={isExpanded => setCVSelectOpen(isExpanded)}
102
+ id="selectCV"
103
+ name="selectCV"
104
+ aria-label="selectCV"
105
+ placeholderText={(cvSelectOptions.length === 0) ? __('No content views available') : __('Select a content view')}
106
+ >
107
+ {cvSelectOptions}
108
+ </Select>
109
+ </div>
110
+ }
111
+ <ExpandableSection
112
+ toggleText={showActivationKeys ?
113
+ 'Hide activation keys' :
114
+ 'Show activation keys'}
115
+ onToggle={expanded => setShowActivationKeys(expanded)}
116
+ isExpanded={showActivationKeys}
117
+ >
118
+ <AffectedActivationKeys
119
+ {...{
120
+ cvId,
121
+ versionEnvironments,
122
+ selectedEnvSet,
123
+ }}
124
+ deleteCV={false}
125
+ />
126
+ </ExpandableSection>
127
+ </>
128
+ );
129
+ };
130
+
131
+ export default CVReassignActivationKeysForm;