From 74733ee423eaf5fa5f2e4a3cbea286516bd32d03 Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Tue, 3 Jan 2023 18:18:25 -0800 Subject: [PATCH] Update to use Form Signed-off-by: Junqiu Lei --- .../custom_map_config/custom_map_source.tsx | 244 +++++++++--------- 1 file changed, 117 insertions(+), 127 deletions(-) diff --git a/maps_dashboards/public/components/layer_config/custom_map_config/custom_map_source.tsx b/maps_dashboards/public/components/layer_config/custom_map_config/custom_map_source.tsx index 2a66b298..25204488 100644 --- a/maps_dashboards/public/components/layer_config/custom_map_config/custom_map_source.tsx +++ b/maps_dashboards/public/components/layer_config/custom_map_config/custom_map_source.tsx @@ -5,17 +5,13 @@ import React, { useEffect, useState } from 'react'; import { - EuiFlexItem, - EuiFormLabel, - EuiFlexGrid, EuiSpacer, EuiPanel, EuiForm, EuiFieldText, - EuiFormErrorText, EuiSelect, + EuiFormRow, } from '@elastic/eui'; -import { FormattedMessage } from '@osd/i18n/react'; import { CustomLayerSpecification } from '../../../model/mapLayerType'; interface Props { @@ -42,7 +38,7 @@ export const CustomMapSource = ({ const [WMSFormat, setWMSFormat] = useState(''); const [WMSStyles, setWMSStyles] = useState(''); // CRS: Coordinate reference systems in WMS - const [WMSCRS, setWMSCRS] = useState(''); + const [WMSCoordinateSystem, setWMSCoordinateSystem] = useState(''); const [WMSBbox, setWMSBbox] = useState(''); const onChangeCustomMapURL = (e: any) => { @@ -122,8 +118,8 @@ export const CustomMapSource = ({ }); }; - const onChangeWMSCRS = (e: any) => { - setWMSCRS(e.target.value); + const onChangeWMSCoordinateSystem = (e: any) => { + setWMSCoordinateSystem(e.target.value); setSelectedLayerConfig({ ...selectedLayerConfig, source: { @@ -163,7 +159,7 @@ export const CustomMapSource = ({ setWMSVersion(selectedLayerConfig.source.version); setWMSFormat(selectedLayerConfig.source.format); setWMSStyles(selectedLayerConfig.source.styles); - setWMSCRS(selectedLayerConfig.source.crs); + setWMSCoordinateSystem(selectedLayerConfig.source.crs); setWMSBbox(selectedLayerConfig.source.bbox); } }, [selectedLayerConfig]); @@ -178,130 +174,124 @@ export const CustomMapSource = ({ } else { setIsUpdateDisabled(isInvalidURL(customMapURL)); } - }, [ - WMSBbox, - WMSCRS, - WMSFormat, - WMSLayers, - WMSStyles, - WMSVersion, - customMapURL, - customType, - setIsUpdateDisabled, - ]); + }, [WMSLayers, WMSVersion, customMapURL, customType, setIsUpdateDisabled]); return (
- - - Custom type - - - - {selectedLayerConfig.source.customType === 'tms' && ( - <> - - TMS URL - - - {isInvalidURL(customMapURL) && ( - - - - )} - - - TMS attribution - - - - - )} - {selectedLayerConfig.source.customType === 'wms' && ( - <> - - WMS URL - - - {isInvalidURL(customMapURL) && ( - - - - )} - - - WMS layers - - - - - WMS version - - - - - WMS format - - - - - WMS CRS - - - - - WMS bbox - - - - - WMS attribution - - - - - WMS styles - - - - - )} - + + + - + + {selectedLayerConfig.source.customType === 'tms' && ( + + + + + + + + + + )} + {selectedLayerConfig.source.customType === 'wms' && ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )} +
);