/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import React, { useState } from 'react'; import { EuiTitle, EuiComboBox, EuiFormRow, EuiFieldText, EuiSwitch, EuiToolTip, } from '@elastic/eui'; import { useEffect } from 'react'; import { isEmpty } from 'lodash'; import { useDispatch, useSelector } from 'react-redux'; import SavedObjects from '../../../../services/saved_objects/event_analytics/saved_objects'; import { fetchPanels, selectPanelList, } from '../../../../../public/components/custom_panels/redux/panel_slice'; interface ISavedPanelProps { selectedOptions: any; handleNameChange: any; handleOptionChange: any; savedObjects: SavedObjects; savePanelName: string; showOptionList: boolean; curVisId: string; setSubType: any; isSaveAsMetricEnabled: boolean; } interface CustomPanelOptions { id: string; name: string; dateCreated: string; dateModified: string; } export const SavePanel = ({ selectedOptions, handleNameChange, handleOptionChange, savedObjects, savePanelName, showOptionList, setSubType, isSaveAsMetricEnabled, }: ISavedPanelProps) => { const [checked, setChecked] = useState(false); const [svpnlError, setSvpnlError] = useState(null); const customPanels = useSelector(selectPanelList); const dispatch = useDispatch(); useEffect(() => { dispatch(fetchPanels()); }, []); const onToggleChange = (e: { target: { checked: React.SetStateAction } }) => { setChecked(e.target.checked); if (e.target.checked) { setSubType('metric'); } else { setSubType('visualization'); } }; return ( <> {showOptionList && ( <>

{'Custom operational dashboards/application'}

{ handleOptionChange(daOptions); }} selectedOptions={selectedOptions} options={customPanels.map((option: any) => { return { panel: option, label: option.title, }; })} isClearable={true} singleSelection={{ asPlainText: true }} data-test-subj="eventExplorer__querySaveComboBox" /> )}

Name

{ handleNameChange(e.target.value); }} data-test-subj="eventExplorer__querySaveName" /> {showOptionList && ( <> )} ); };