diff --git a/x-pack/plugins/cases/public/components/create/form_context.test.tsx b/x-pack/plugins/cases/public/components/create/form_context.test.tsx
index b988f13ee34c..b55542499fbe 100644
--- a/x-pack/plugins/cases/public/components/create/form_context.test.tsx
+++ b/x-pack/plugins/cases/public/components/create/form_context.test.tsx
@@ -239,6 +239,29 @@ describe('Create case', () => {
);
});
+ it('should set sync alerts to false when the sync setting is passed in as false and alerts are disabled', async () => {
+ useConnectorsMock.mockReturnValue({
+ ...sampleConnectorData,
+ connectors: connectorsMock,
+ });
+
+ const wrapper = mount(
+
+
+
+
+
+
+ );
+
+ fillForm(wrapper);
+ wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
+
+ await waitFor(() =>
+ expect(postCase).toBeCalledWith({ ...sampleData, settings: { syncAlerts: false } })
+ );
+ });
+
it('it should select the default connector set in the configuration', async () => {
useCaseConfigureMock.mockImplementation(() => ({
...useCaseConfigureResponse,
diff --git a/x-pack/plugins/cases/public/components/create/form_context.tsx b/x-pack/plugins/cases/public/components/create/form_context.tsx
index f59e1822c70b..03d8ec56fb0a 100644
--- a/x-pack/plugins/cases/public/components/create/form_context.tsx
+++ b/x-pack/plugins/cases/public/components/create/form_context.tsx
@@ -34,6 +34,7 @@ interface Props {
children?: JSX.Element | JSX.Element[];
hideConnectorServiceNowSir?: boolean;
onSuccess?: (theCase: Case) => Promise;
+ syncAlertsDefaultValue?: boolean;
}
export const FormContext: React.FC = ({
@@ -42,6 +43,7 @@ export const FormContext: React.FC = ({
children,
hideConnectorServiceNowSir,
onSuccess,
+ syncAlertsDefaultValue = true,
}) => {
const { connectors, loading: isLoadingConnectors } = useConnectors();
const owner = useOwnerContext();
@@ -51,7 +53,12 @@ export const FormContext: React.FC = ({
const submitCase = useCallback(
async (
- { connectorId: dataConnectorId, fields, syncAlerts = true, ...dataWithoutConnectorId },
+ {
+ connectorId: dataConnectorId,
+ fields,
+ syncAlerts = syncAlertsDefaultValue,
+ ...dataWithoutConnectorId
+ },
isValid
) => {
if (isValid) {
@@ -94,6 +101,7 @@ export const FormContext: React.FC = ({
onSuccess,
postComment,
pushCaseToExternalService,
+ syncAlertsDefaultValue,
]
);
diff --git a/x-pack/plugins/cases/public/components/create/index.tsx b/x-pack/plugins/cases/public/components/create/index.tsx
index 7f8b8f664529..d3eaba1ea0bc 100644
--- a/x-pack/plugins/cases/public/components/create/index.tsx
+++ b/x-pack/plugins/cases/public/components/create/index.tsx
@@ -58,6 +58,8 @@ const CreateCaseComponent = ({
caseType={caseType}
hideConnectorServiceNowSir={hideConnectorServiceNowSir}
onSuccess={onSuccess}
+ // if we are disabling alerts, then we should not sync alerts
+ syncAlertsDefaultValue={!disableAlerts}
>