Skip to content

Commit

Permalink
Fixes #37040 - Fix outdated registration wording for AKs (Katello#10840)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz authored Jan 15, 2024
1 parent 5992bdd commit 9e3e5ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/views/overrides/activation_keys/_host_tab_pane.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
</div>

<p><%= _('Activation keys and subscriptions can be managed') %>
<b><a href="/activation_keys" target="_blank"> <%= _('here') %></a></b>
<b><a href="/activation_keys" target="_blank"> <%= _('here.') %></a></b>
</p>
<p><%= subscription_manager_configuration_url %></p>
<p translate>
Activation keys may be used during <a href="/hosts/register">system registration.</a>
</p>
<p><a href="" id="ak_refresh_subscriptions"><%= _('Reload data') %></a></p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

<div bst-alert="info">
<span translate>
This activation key may be used during system registration. For example:
This activation key may be used during <a href="/hosts/register?initialAKSelection={{ activationKey.name }}">system registration.</a>
</span>
<p translate>
subscription-manager register --org="{{ activationKey.organization.label }}" --activationkey="{{ activationKey.name }}"
</p>
</div>

<div data-extend-template="layouts/two-column-details.html">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions webpack/components/extensions/RegistrationCommands/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 (
<ActivationKeys
activationKeys={pluginData?.activationKeys}
Expand Down

0 comments on commit 9e3e5ca

Please sign in to comment.