[Security Solution] Disables loadPrebuiltRulesAndTemplatesButton if loading is in progress (#103568)
This commit is contained in:
parent
bc097856e6
commit
1b5cc2a7bc
|
@ -127,4 +127,26 @@ describe('LoadPrebuiltRulesAndTemplatesButton', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('renders disabled button if loading is true', async () => {
|
||||
(getPrePackagedRulesStatus as jest.Mock).mockResolvedValue({
|
||||
rules_not_installed: 0,
|
||||
rules_installed: 0,
|
||||
rules_not_updated: 0,
|
||||
timelines_not_installed: 3,
|
||||
timelines_installed: 0,
|
||||
timelines_not_updated: 0,
|
||||
});
|
||||
|
||||
const wrapper: ReactWrapper = mount(
|
||||
<PrePackagedRulesPrompt {...{ ...props, loading: true }} />
|
||||
);
|
||||
await waitFor(() => {
|
||||
wrapper.update();
|
||||
|
||||
expect(
|
||||
wrapper.find('[data-test-subj="load-prebuilt-rules"] button').props().disabled
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -64,12 +64,12 @@ const PrePackagedRulesPromptComponent: React.FC<PrePackagedRulesPromptProps> = (
|
|||
const loadPrebuiltRulesAndTemplatesButton = useMemo(
|
||||
() =>
|
||||
getLoadPrebuiltRulesAndTemplatesButton({
|
||||
isDisabled: !userHasPermissions,
|
||||
isDisabled: !userHasPermissions || loading,
|
||||
onClick: handlePreBuiltCreation,
|
||||
fill: true,
|
||||
'data-test-subj': 'load-prebuilt-rules',
|
||||
}),
|
||||
[getLoadPrebuiltRulesAndTemplatesButton, handlePreBuiltCreation, userHasPermissions]
|
||||
[getLoadPrebuiltRulesAndTemplatesButton, handlePreBuiltCreation, userHasPermissions, loading]
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue