From 6ed2918b6c76077af87ed0941d1cb457992a35e8 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Thu, 19 Mar 2020 15:06:33 +0200 Subject: [PATCH] [SIEM][CASE] Configuration page action bar (#60608) * Add bottom bar * Add listeners --- .../case/components/configure_cases/index.tsx | 97 ++++++++++++------- 1 file changed, 62 insertions(+), 35 deletions(-) diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/configure_cases/index.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/configure_cases/index.tsx index b3c424bef6a7a..cbc3be6d144a2 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/configure_cases/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/configure_cases/index.tsx @@ -7,8 +7,15 @@ import React, { useReducer, useCallback, useEffect, useState } from 'react'; import styled, { css } from 'styled-components'; -import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiSpacer, EuiCallOut } from '@elastic/eui'; -import { noop, isEmpty } from 'lodash/fp'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiButton, + EuiCallOut, + EuiBottomBar, + EuiButtonEmpty, +} from '@elastic/eui'; +import { isEmpty } from 'lodash/fp'; import { useKibana } from '../../../../lib/kibana'; import { useConnectors } from '../../../../containers/case/configure/use_connectors'; import { useCaseConfigure } from '../../../../containers/case/configure/use_configure'; @@ -32,6 +39,9 @@ import { Mapping } from '../configure_cases/mapping'; import { SectionWrapper } from '../wrappers'; import { configureCasesReducer, State } from './reducer'; import * as i18n from './translations'; +import { getCaseUrl } from '../../../../components/link_to'; + +const CASE_URL = getCaseUrl(); const FormWrapper = styled.div` ${({ theme }) => css` @@ -68,6 +78,8 @@ const ConfigureCasesComponent: React.FC = () => { null ); + const [actionBarVisible, setActionBarVisible] = useState(false); + const handleShowAddFlyout = useCallback(() => setAddFlyoutVisibility(true), []); const [{ connectorId, closureType, mapping }, dispatch] = useReducer( @@ -111,11 +123,22 @@ const ConfigureCasesComponent: React.FC = () => { const handleSubmit = useCallback( // TO DO give a warning/error to user when field are not mapped so they have chance to do it () => { + setActionBarVisible(false); persistCaseConfigure({ connectorId, closureType }); }, [connectorId, closureType, mapping] ); + const onChangeConnector = useCallback((newConnectorId: string) => { + setActionBarVisible(true); + setConnectorId(newConnectorId); + }, []); + + const onChangeClosureType = useCallback((newClosureType: ClosureType) => { + setActionBarVisible(true); + setClosureType(newClosureType); + }, []); + useEffect(() => { if ( !isEmpty(connectors) && @@ -171,7 +194,7 @@ const ConfigureCasesComponent: React.FC = () => { connectors={connectors ?? []} disabled={persistLoading || isLoadingConnectors} isLoading={isLoadingConnectors} - onChangeConnector={setConnectorId} + onChangeConnector={onChangeConnector} handleShowAddFlyout={handleShowAddFlyout} selectedConnector={connectorId} /> @@ -180,7 +203,7 @@ const ConfigureCasesComponent: React.FC = () => { @@ -192,37 +215,41 @@ const ConfigureCasesComponent: React.FC = () => { setEditFlyoutVisibility={setEditFlyoutVisibility} /> - - - - - - {i18n.CANCEL} - - - - - {i18n.SAVE_CHANGES} - - - - + {actionBarVisible && ( + + + + + + + {i18n.CANCEL} + + + + + {i18n.SAVE_CHANGES} + + + + + + + )}