From 9e3e5cac342628b48dc1192c45fd469c4bc595ad Mon Sep 17 00:00:00 2001 From: Jeremy Lenz Date: Mon, 15 Jan 2024 17:45:22 -0500 Subject: [PATCH] Fixes #37040 - Fix outdated registration wording for AKs (#10840) --- .../overrides/activation_keys/_host_tab_pane.html.erb | 6 ++++-- .../details/views/activation-key-info.html | 5 +---- .../RegistrationCommands/fields/ActivationKeys.js | 4 +++- .../components/extensions/RegistrationCommands/index.js | 9 +++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/views/overrides/activation_keys/_host_tab_pane.html.erb b/app/views/overrides/activation_keys/_host_tab_pane.html.erb index 3f3760db736..5910c6a4a8c 100644 --- a/app/views/overrides/activation_keys/_host_tab_pane.html.erb +++ b/app/views/overrides/activation_keys/_host_tab_pane.html.erb @@ -21,9 +21,11 @@

<%= _('Activation keys and subscriptions can be managed') %> - <%= _('here') %> + <%= _('here.') %>

-

<%= subscription_manager_configuration_url %>

+

+ Activation keys may be used during system registration. +

<%= _('Reload data') %>

diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-info.html index 95f787f389b..72c0b564bb5 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-info.html @@ -2,11 +2,8 @@
- This activation key may be used during system registration. For example: + This activation key may be used during system registration. -

- subscription-manager register --org="{{ activationKey.organization.label }}" --activationkey="{{ activationKey.name }}" -

diff --git a/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js b/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js index b15600bcca0..9628e1c7b66 100644 --- a/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js +++ b/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js @@ -147,7 +147,9 @@ ActivationKeys.propTypes = { PropTypes.array, ]), hostGroupId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - pluginValues: PropTypes.objectOf(PropTypes.shape({})), + pluginValues: PropTypes.shape({ + activationKeys: PropTypes.array, + }), onChange: PropTypes.func.isRequired, handleInvalidField: PropTypes.func.isRequired, isLoading: PropTypes.bool, diff --git a/webpack/components/extensions/RegistrationCommands/index.js b/webpack/components/extensions/RegistrationCommands/index.js index 0c05f18f84e..ea39324a492 100644 --- a/webpack/components/extensions/RegistrationCommands/index.js +++ b/webpack/components/extensions/RegistrationCommands/index.js @@ -1,6 +1,7 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import { noop } from 'foremanReact/common/helpers'; +import { useUrlParams } from 'foremanReact/components/PF4/TableIndexPage/Table/TableHooks'; import ActivationKeys from './fields/ActivationKeys'; import IgnoreSubmanErrors from './fields/IgnoreSubmanErrors'; @@ -48,10 +49,18 @@ export const RegistrationActivationKeys = ({ handleInvalidField, isLoading, }) => { + const { initialAKSelection } = useUrlParams(); useEffect(() => { onChange({ activationKeys: [] }); }, [onChange, organizationId, hostGroupId]); + useEffect(() => { + if (initialAKSelection && + (pluginData?.activationKeys ?? []).some(ak => ak.name === initialAKSelection)) { + onChange({ activationKeys: initialAKSelection.split(',') }); + } + }, [initialAKSelection, onChange, pluginData?.activationKeys]); + return (