mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Security Solution] Fix Incorrect Enable Button Behavior in Entity Store Modal (#212078)
## Summary Ensure Enable Button Considers Disabled State of Risk Score & Entity Store. Previously only used the checked state of the toggle. ### Reproduce the Issue Steps, as [per bug ticket:](https://github.com/elastic/kibana/issues/209242#issue-2826951496) 1. Kibana version 8.16.0 or above should exist 2. Navigate to the Dashboards tab under Security 3. Select Entity Analytics dashboard 4. Click on the enable button and enable risk score 5. Disable the options for Entity store 6. Then again select the enable button for Entity store 7. Disable the enable button 8. Observe the Enable button is still enabled ### After Issue Solved Same steps as above, but should show the warning and disable the button. #### Videos Videos show when either riskScore or entityStore is enabled, and the other is unchecked, the warning should show and the button should be disabled. https://github.com/user-attachments/assets/236f9e69-f810-4116-9948-38fd27d4d945 https://github.com/user-attachments/assets/2971e845-5d46-4eac-997a-79b3b17922c0 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
a51e96eae2
commit
ba9210c259
2 changed files with 38 additions and 1 deletions
|
@ -146,6 +146,24 @@ describe('EntityStoreEnablementModal', () => {
|
|||
expect(enableButton).toBeDisabled();
|
||||
});
|
||||
|
||||
it('should show proceed warning when riskScore is enabled but entityStore is disabled and unchecked', () => {
|
||||
renderComponent({
|
||||
...defaultProps,
|
||||
riskScore: { disabled: false, checked: false }, // Enabled & Checked
|
||||
entityStore: { disabled: true, checked: false }, // Disabled & Unchecked
|
||||
});
|
||||
expect(screen.getByText('Please enable at least one option to proceed.')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should show proceed warning when entityStore is enabled but riskScore is disabled and unchecked', () => {
|
||||
renderComponent({
|
||||
...defaultProps,
|
||||
entityStore: { disabled: false, checked: false }, // Enabled & Checked
|
||||
riskScore: { disabled: true, checked: false }, // Disabled & Unchecked
|
||||
});
|
||||
expect(screen.getByText('Please enable at least one option to proceed.')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not show entity engine missing privileges warning when no missing privileges', () => {
|
||||
renderComponent();
|
||||
expect(
|
||||
|
|
|
@ -54,6 +54,20 @@ interface EntityStoreEnablementModalProps {
|
|||
};
|
||||
}
|
||||
|
||||
const shouldAllowEnablement = (
|
||||
riskScoreEnabled: boolean,
|
||||
entityStoreEnabled: boolean,
|
||||
enablements: Enablements
|
||||
) => {
|
||||
if (riskScoreEnabled) {
|
||||
return enablements.entityStore;
|
||||
}
|
||||
if (entityStoreEnabled) {
|
||||
return enablements.riskScore;
|
||||
}
|
||||
return enablements.riskScore || enablements.entityStore;
|
||||
};
|
||||
|
||||
export const EntityStoreEnablementModal: React.FC<EntityStoreEnablementModalProps> = ({
|
||||
visible,
|
||||
toggle,
|
||||
|
@ -69,7 +83,12 @@ export const EntityStoreEnablementModal: React.FC<EntityStoreEnablementModalProp
|
|||
const { data: entityEnginePrivileges, isLoading: isLoadingEntityEnginePrivileges } =
|
||||
useEntityEnginePrivileges();
|
||||
const riskEnginePrivileges = useMissingRiskEnginePrivileges();
|
||||
const enablementOptions = enablements.riskScore || enablements.entityStore;
|
||||
|
||||
const enablementOptions = shouldAllowEnablement(
|
||||
!!riskScore.disabled,
|
||||
!!entityStore.disabled,
|
||||
enablements
|
||||
);
|
||||
const { AdditionalChargesMessage } = useContractComponents();
|
||||
|
||||
if (!visible) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue