Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.15] [Search] Fix: Enterprise Search gated form submission (#196983) #197088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { useCallback } from 'react';

import { useActions, useValues } from 'kea';

Expand Down Expand Up @@ -450,10 +450,14 @@ export const AppSearchGate: React.FC = () => {
const { feature, participateInUXLabs } = useValues(AppSearchGateLogic);
const { formSubmitRequest, setAdditionalFeedback, setParticipateInUXLabs, setFeature } =
useActions(AppSearchGateLogic);
const onSubmitForm = useCallback((e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
formSubmitRequest();
}, []);
const options = getOptionsFeaturesList();
return (
<EuiPanel hasShadow={false}>
<EuiForm component="form" fullWidth>
<EuiForm component="form" fullWidth onSubmit={onSubmitForm}>
<EuiFormLabel>
{i18n.translate('xpack.enterpriseSearch.appSearch.gateForm.features.Label', {
defaultMessage: 'What App Search feature are you looking to use?',
Expand Down Expand Up @@ -598,12 +602,7 @@ export const AppSearchGate: React.FC = () => {
<EuiSpacer />
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButton
isDisabled={!feature ?? false}
type="submit"
fill
onClick={() => formSubmitRequest()}
>
<EuiButton isDisabled={!feature ?? false} type="submit" fill>
{i18n.translate('xpack.enterpriseSearch.appSearch.gateForm.submit', {
defaultMessage: 'Submit',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const AppSearchGateLogic = kea<MakeLogicType<AppSearchGateValues, AppSear
setParticipateInUXLabs: (participateInUXLabs) => ({ participateInUXLabs }),
},
connect: {
actions: [UpdateAppSearchGatedFormDataApiLogic, ['makeRequest as submitGatedFormDataRequest']],
actions: [
UpdateAppSearchGatedFormDataApiLogic,
['makeRequest as submitGatedFormDataRequest', 'apiSuccess as submitGatedFormSuccess'],
],
},
listeners: ({ actions, values }) => ({
formSubmitRequest: () => {
Expand All @@ -52,6 +55,9 @@ export const AppSearchGateLogic = kea<MakeLogicType<AppSearchGateValues, AppSear
});
}
},
submitGatedFormSuccess: () => {
window.location.reload();
},
}),
path: ['enterprise_search', 'app_search', 'gate_form'],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { Fragment } from 'react';
import React, { Fragment, useCallback } from 'react';

import { useActions, useValues } from 'kea';

Expand Down Expand Up @@ -537,10 +537,14 @@ export const WorkplaceSearchGate: React.FC = () => {
useActions(WorkplaceSearchGateLogic);

const { feature, participateInUXLabs } = useValues(WorkplaceSearchGateLogic);
const onSubmitForm = useCallback((e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
formSubmitRequest();
}, []);

return (
<EuiPanel hasShadow={false}>
<EuiForm component="form" fullWidth>
<EuiForm component="form" fullWidth onSubmit={onSubmitForm}>
<EuiFormLabel>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.gateForm.features.Label', {
defaultMessage: 'What Workplace Search feature are you looking to use?',
Expand Down Expand Up @@ -685,12 +689,7 @@ export const WorkplaceSearchGate: React.FC = () => {
<EuiSpacer />
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButton
isDisabled={!feature ?? false}
type="submit"
fill
onClick={() => formSubmitRequest()}
>
<EuiButton isDisabled={!feature ?? false} type="submit" fill>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.gateForm.submit', {
defaultMessage: 'Submit',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export const WorkplaceSearchGateLogic = kea<
setParticipateInUXLabs: (participateInUXLabs) => ({ participateInUXLabs }),
},
connect: {
actions: [UpdateGatedFormDataApiLogic, ['makeRequest as submitGatedFormDataRequest']],
actions: [
UpdateGatedFormDataApiLogic,
['makeRequest as submitGatedFormDataRequest', 'apiSuccess as submitGatedFormSuccess'],
],
},
listeners: ({ actions, values }) => ({
formSubmitRequest: () => {
Expand All @@ -49,6 +52,9 @@ export const WorkplaceSearchGateLogic = kea<
});
}
},
submitGatedFormSuccess: () => {
window.location.reload();
},
}),
path: ['enterprise_search', 'workplace_search', 'gate_form'],

Expand Down