From c4c40c0c9f0b86eba146543e1c32fa6a1ed9dae1 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Mon, 17 Aug 2020 16:20:09 -0400 Subject: [PATCH] remove unused file --- .../test_pipeline/flyout_provider.tsx | 172 ------------------ 1 file changed, 172 deletions(-) delete mode 100644 x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/test_pipeline/flyout_provider.tsx diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/test_pipeline/flyout_provider.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/test_pipeline/flyout_provider.tsx deleted file mode 100644 index 53aeb9fdc08ba..0000000000000 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/test_pipeline/flyout_provider.tsx +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { useState, useEffect, useCallback } from 'react'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; - -import { - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiSpacer, - EuiTitle, - EuiCallOut, -} from '@elastic/eui'; - -import { useKibana } from '../../../../../shared_imports'; - -import { usePipelineProcessorsContext, useTestConfigContext } from '../../context'; -import { serialize } from '../../serialize'; - -import { Tabs, Tab, OutputTab, DocumentsTab } from './flyout_tabs'; - -export interface Props { - children: (openFlyout: () => void) => React.ReactNode; -} - -export const FlyoutProvider: React.FunctionComponent = ({ children }) => { - const { services } = useKibana(); - const { - state: { processors }, - } = usePipelineProcessorsContext(); - - const serializedProcessors = serialize(processors.state); - - const { testConfig } = useTestConfigContext(); - const { documents: cachedDocuments, verbose: cachedVerbose } = testConfig; - - const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); - - const initialSelectedTab = cachedDocuments ? 'output' : 'documents'; - const [selectedTab, setSelectedTab] = useState(initialSelectedTab); - - const [shouldExecuteImmediately, setShouldExecuteImmediately] = useState(false); - const [isExecuting, setIsExecuting] = useState(false); - const [executeError, setExecuteError] = useState(null); - const [executeOutput, setExecuteOutput] = useState(undefined); - - const handleExecute = useCallback( - async (documents: object[], verbose?: boolean) => { - setIsExecuting(true); - setExecuteError(null); - - const { error, data: output } = await services.api.simulatePipeline({ - documents, - verbose, - pipeline: { ...serializedProcessors }, - }); - - setIsExecuting(false); - - if (error) { - setExecuteError(error); - return; - } - - setExecuteOutput(output); - - services.notifications.toasts.addSuccess( - i18n.translate('xpack.ingestPipelines.testPipelineFlyout.successNotificationText', { - defaultMessage: 'Pipeline executed', - }), - { - toastLifeTimeMs: 1000, - } - ); - - setSelectedTab('output'); - }, - [services.api, services.notifications.toasts, serializedProcessors] - ); - - useEffect(() => { - if (isFlyoutVisible === false && cachedDocuments) { - setShouldExecuteImmediately(true); - } - }, [isFlyoutVisible, cachedDocuments]); - - useEffect(() => { - // If the user has already tested the pipeline once, - // use the cached test config and automatically execute the pipeline - if (isFlyoutVisible && shouldExecuteImmediately && cachedDocuments) { - setShouldExecuteImmediately(false); - handleExecute(cachedDocuments!, cachedVerbose); - } - }, [handleExecute, cachedDocuments, cachedVerbose, isFlyoutVisible, shouldExecuteImmediately]); - - let tabContent; - - if (selectedTab === 'output') { - tabContent = ( - - ); - } else { - // default to "Documents" tab - tabContent = ; - } - - return ( - <> - {children(() => setIsFlyoutVisible(true))} - - {isFlyoutVisible && ( - setIsFlyoutVisible(false)} - data-test-subj="testPipelineFlyout" - > - - -

- -

-
-
- - - !executeOutput && tabId === 'output'} - /> - - - - {/* Execute error */} - {executeError ? ( - <> - - } - color="danger" - iconType="alert" - > -

{executeError.message}

-
- - - ) : null} - - {/* Documents or output tab content */} - {tabContent} -
-
- )} - - ); -};