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..22ec2d71 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 @@ -4,18 +4,7 @@ */ import React, { useEffect, useState } from 'react'; -import { - EuiFlexItem, - EuiFormLabel, - EuiFlexGrid, - EuiSpacer, - EuiPanel, - EuiForm, - EuiFieldText, - EuiFormErrorText, - EuiSelect, -} from '@elastic/eui'; -import { FormattedMessage } from '@osd/i18n/react'; +import { EuiSpacer, EuiPanel, EuiForm, EuiFieldText, EuiSelect, EuiFormRow } from '@elastic/eui'; import { CustomLayerSpecification } from '../../../model/mapLayerType'; interface Props { @@ -42,7 +31,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 +111,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 +152,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]); @@ -174,134 +163,134 @@ export const CustomMapSource = ({ useEffect(() => { if (customType === 'wms') { - setIsUpdateDisabled(isInvalidURL(customMapURL) || WMSLayers === '' || WMSVersion === ''); + setIsUpdateDisabled( + customMapURL === '' || + WMSLayers === '' || + WMSVersion === '' || + WMSFormat === '' || + isInvalidURL(customMapURL) + ); } else { - setIsUpdateDisabled(isInvalidURL(customMapURL)); + setIsUpdateDisabled(customMapURL === '' || isInvalidURL(customMapURL)); } - }, [ - WMSBbox, - WMSCRS, - WMSFormat, - WMSLayers, - WMSStyles, - WMSVersion, - customMapURL, - customType, - setIsUpdateDisabled, - ]); + }, [WMSFormat, 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' && ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )} +
);