Skip to content

Commit

Permalink
[Security Solution] Hide Rule Updates tab when no updates are availab…
Browse files Browse the repository at this point in the history
…le (elastic#161196)

## Summary

Fixes: elastic#161195

- Hide Rule Updates tab when no rules are available for update.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 885e4bf)
  • Loading branch information
jpdjere committed Jul 6, 2023
1 parent 449fce9 commit 4eed956
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ describe('Detection rules, Prebuilt Rules Installation and Update workflow', ()
waitForRulesTableToBeLoaded();

/* Assert that there are no installation or update notifications */
/* Add Elastic Rules button and Rule Upgrade tabs should not contain a number badge */
/* Add Elastic Rules button should not contain a number badge */
/* and Rule Upgrade tab should not be displayed */
cy.get(ADD_ELASTIC_RULES_BTN).should('have.text', 'Add Elastic rules');
cy.get(RULES_UPDATES_TAB).should('have.text', 'Rule Updates');
cy.get(RULES_UPDATES_TAB).should('not.exist');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ export const RulesTableToolbar = React.memo(() => {
(ruleManagementFilters?.rules_summary.prebuilt_installed_count ?? 0);
const updateTotal = prebuiltRulesStatus?.num_prebuilt_rules_to_upgrade ?? 0;

const ruleUpdateTab = useMemo(
() => ({
[AllRulesTabs.updates]: {
id: AllRulesTabs.updates,
name: i18n.RULE_UPDATES_TAB,
disabled: false,
href: `/rules/${AllRulesTabs.updates}`,
isBeta: updateTotal > 0,
betaOptions: {
text: `${updateTotal}`,
},
},
}),
[updateTotal]
);

const ruleTabs = useMemo(
() => ({
[AllRulesTabs.management]: {
Expand All @@ -48,18 +64,9 @@ export const RulesTableToolbar = React.memo(() => {
text: `${installedTotal}`,
},
},
[AllRulesTabs.updates]: {
id: AllRulesTabs.updates,
name: i18n.RULE_UPDATES_TAB,
disabled: false,
href: `/rules/${AllRulesTabs.updates}`,
isBeta: updateTotal > 0,
betaOptions: {
text: `${updateTotal}`,
},
},
...(updateTotal > 0 ? ruleUpdateTab : {}),
}),
[installedTotal, updateTotal]
[installedTotal, ruleUpdateTab, updateTotal]
);

return <TabNavigation navTabs={ruleTabs} />;
Expand Down

0 comments on commit 4eed956

Please sign in to comment.