Skip to content

Commit

Permalink
Fixes #36790 - Show recalculate action in happy empty state (#10756)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz authored Oct 3, 2023
1 parent f238c23 commit 9d03ca6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 7 additions & 4 deletions webpack/components/Table/EmptyStateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ const EmptyStateMessage = ({
const clearSearch = useSelector(selectSearchBarClearSearch);
const showSecondaryActionAnchor = showSecondaryAction && secondaryActionLink;
const handleClick = () => {
const shouldReload = (searchIsActive || filtersAreActive);
if (searchIsActive) {
clearSearch();
}
if (filtersAreActive || showSecondaryActionButton) {
resetFilters();
}
dispatch({
type: `${requestKey}_REQUEST`,
key: requestKey,
});
if (shouldReload) {
dispatch({
type: `${requestKey}_REQUEST`,
key: requestKey,
});
}
};

const actionButton = primaryActionButton ?? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export const ErrataTab = () => {
setToggleGroupState(APPLICABLE);
};

const recalculateErrata = () => {
setIsBulkActionOpen(false);
dispatch(regenerateApplicability(hostId));
};

let resetFilters = resetFiltersOnly;
let secondaryActionTextOverride;
let emptyContentTitle;
Expand All @@ -114,6 +119,8 @@ export const ErrataTab = () => {
case 'All up to date':
emptyContentTitle = __('All up to date');
emptyContentBody = __('No action is needed because there are no applicable errata for this host.');
resetFilters = recalculateErrata;
secondaryActionTextOverride = __('Recalculate');
break;
case 'Needed':
emptyContentTitle = __('No matching errata found');
Expand Down Expand Up @@ -266,11 +273,6 @@ export const ErrataTab = () => {
hostname, search: (selectedCount > 0) ? fetchBulkParams() : '',
});

const recalculateErrata = () => {
setIsBulkActionOpen(false);
dispatch(regenerateApplicability(hostId));
};

const showActions = can(invokeRexJobs, userPermissions);

const readOnlyBookmarks =
Expand Down Expand Up @@ -447,7 +449,7 @@ export const ErrataTab = () => {
secondaryActionTextOverride,
}
}
showSecondaryActionButton={neededErrata}
showSecondaryActionButton={neededErrata || showRecalculate}
happyEmptyContent={allUpToDate}
ouiaId="host-errata-table"
additionalListeners={[
Expand Down

0 comments on commit 9d03ca6

Please sign in to comment.