Skip to content

Commit

Permalink
Fixes #32282 - Repos restricted to an OS showed in a label on Reposit…
Browse files Browse the repository at this point in the history
…ory Sets screen
  • Loading branch information
lfu committed Jun 2, 2022
1 parent ba76712 commit ba22d6a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/views/katello/api/v2/repository_sets/show.json.rabl
Expand Up @@ -37,6 +37,10 @@ child @resource.repositories => :repositories do
attributes :minor => :releasever
end

node :osRestricted do |pc|
pc.repositories&.first&.os_versions&.first
end

node :override do |pc|
pc.override if pc.respond_to? :override
end
Expand Down
Expand Up @@ -113,6 +113,29 @@ EnabledIcon.propTypes = {
isOverridden: PropTypes.bool.isRequired,
};

const OsRestrictedIcon = ({ osRestricted }) => (
<Tooltip
position="right"
content={<FormattedMessage
id="os-restricted-tooltip"
defaultMessage={__('OS restricted to {osRestricted}. If host OS does not match, the repository will not be available on this host.')}
values={{ osRestricted }}
/>}
>
<Label color="blue" className="os-restricted-label" style={{ marginLeft: '8px' }}>
{__(osRestricted)}
</Label>
</Tooltip>
);

OsRestrictedIcon.propTypes = {
osRestricted: PropTypes.string,
};

OsRestrictedIcon.defaultProps = {
osRestricted: null,
};

const RepositorySetsTab = () => {
const hostDetails = useSelector(state => selectAPIResponse(state, 'HOST_DETAILS'));
const {
Expand Down Expand Up @@ -451,6 +474,7 @@ const RepositorySetsTab = () => {
enabled_content_override: enabledContentOverride,
contentUrl: repoPath,
product: { name: productName, id: productId },
osRestricted,
} = repoSet;
const { isEnabled, isOverridden } =
getEnabledValue({ enabled, enabledContentOverride });
Expand All @@ -477,6 +501,9 @@ const RepositorySetsTab = () => {
</Td>
<Td>
<span><EnabledIcon key={`enabled-icon-${id}`} {...{ isEnabled, isOverridden }} /></span>
{osRestricted &&
<span><OsRestrictedIcon key={`os-restricted-icon-${id}`} {...{ osRestricted }} /></span>
}
</Td>
{canDoContentOverrides ? (
<Td
Expand Down
Expand Up @@ -41,6 +41,7 @@
"type": "yum",
"gpgUrl": null,
"contentUrl": "/custom/ParthaProduct/empty_repo",
"osRestricted": null,
"override": "default",
"overrides": [],
"enabled_content_override": null
Expand Down Expand Up @@ -75,6 +76,7 @@
"type": "yum",
"gpgUrl": null,
"contentUrl": "/custom/ParthaProduct/partha_multi-errata",
"osRestricted": "rhel-7",
"override": "0",
"overrides": [
{
Expand Down Expand Up @@ -107,6 +109,7 @@
"type": "yum",
"gpgUrl": null,
"contentUrl": "/custom/Pull_Provider/yggdrasil",
"osRestricted": null,
"override": "1",
"overrides": [
{
Expand All @@ -117,4 +120,4 @@
"enabled_content_override": true
}
]
}
}
Expand Up @@ -388,3 +388,19 @@ test('Can filter by status', async (done) => {
assertNockRequest(autoSearchScope);
assertNockRequest(scope2, done); // Pass jest callback to confirm test is done
});

test('Can display osRestricted as a label', async (done) => {
const autocompleteScope = mockAutocomplete(nockInstance, autocompleteUrl);
const scope = nockInstance
.get(hostRepositorySets)
.query(defaultQuery)
.reply(200, mockRepoSetData);

const { getByText } = renderWithRedux(<RepositorySetsTab />, renderOptions());

await patientlyWaitFor(() => expect(getByText(secondRepoSet.contentUrl)).toBeInTheDocument());
expect(secondRepoSet.osRestricted).not.toBeNull();
expect(getByText(secondRepoSet.osRestricted)).toBeInTheDocument();
assertNockRequest(autocompleteScope);
assertNockRequest(scope, done); // Pass jest callback to confirm test is done
});

0 comments on commit ba22d6a

Please sign in to comment.