Skip to content

Commit

Permalink
Similarly move use of context to settings form container
Browse files Browse the repository at this point in the history
We are only interested in the es docs path string in the settings
form component so no need to render for other updates.
  • Loading branch information
jloleysens committed Jul 7, 2020
1 parent 366e76e commit 4ade0ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useForm, OnFormUpdateArg, FormData } from '../../../../../shared_import
import { ProcessorInternal } from '../../types';

import { ProcessorSettingsForm as ViewComponent } from './processor_settings_form';
import { usePipelineProcessorsContext } from '../../context';

export type ProcessorSettingsFromOnSubmitArg = Omit<ProcessorInternal, 'id'>;

Expand All @@ -32,6 +33,10 @@ export const ProcessorSettingsForm: FunctionComponent<Props> = ({
onSubmit,
...rest
}) => {
const {
links: { esDocsBasePath },
} = usePipelineProcessorsContext();

const handleSubmit = useCallback(
async (data: FormData, isValid: boolean) => {
if (isValid) {
Expand Down Expand Up @@ -60,5 +65,7 @@ export const ProcessorSettingsForm: FunctionComponent<Props> = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [onFormUpdate]);

return <ViewComponent processor={processor} form={form} {...rest} />;
return (
<ViewComponent {...rest} processor={processor} form={form} esDocsBasePath={esDocsBasePath} />
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from '@elastic/eui';

import { Form, FormDataProvider, FormHook } from '../../../../../shared_imports';
import { usePipelineProcessorsContext } from '../../context';
import { ProcessorInternal } from '../../types';

import { DocumentationButton } from './documentation_button';
Expand All @@ -35,6 +34,7 @@ export interface Props {
form: FormHook;
onClose: () => void;
onOpen: () => void;
esDocsBasePath: string;
}

const updateButtonLabel = i18n.translate(
Expand All @@ -52,11 +52,7 @@ const cancelButtonLabel = i18n.translate(
);

export const ProcessorSettingsForm: FunctionComponent<Props> = memo(
({ processor, form, isOnFailure, onClose, onOpen }) => {
const {
links: { esDocsBasePath },
} = usePipelineProcessorsContext();

({ processor, form, isOnFailure, onClose, onOpen, esDocsBasePath }) => {
const flyoutTitleContent = isOnFailure ? (
<FormattedMessage
id="xpack.ingestPipelines.settingsFormOnFailureFlyout.title"
Expand Down

0 comments on commit 4ade0ad

Please sign in to comment.