diff --git a/web/client/actions/catalog.js b/web/client/actions/catalog.js index fd41eeab71..41147acc91 100644 --- a/web/client/actions/catalog.js +++ b/web/client/actions/catalog.js @@ -45,6 +45,7 @@ export const SAVING_SERVICE = 'CATALOG:SAVING_SERVICE'; export const CATALOG_INITED = 'CATALOG:INIT'; export const GET_METADATA_RECORD_BY_ID = 'CATALOG:GET_METADATA_RECORD_BY_ID'; export const SET_LOADING = 'CATALOG:SET_LOADING'; +export const SHOW_FORMAT_ERROR = 'CATALOG:SHOW_FORMAT_ERROR'; export const TOGGLE_TEMPLATE = 'CATALOG:TOGGLE_TEMPLATE'; export const TOGGLE_THUMBNAIL = 'CATALOG:TOGGLE_THUMBNAIL'; export const TOGGLE_ADVANCED_SETTINGS = 'CATALOG:TOGGLE_ADVANCED_SETTINGS'; @@ -285,6 +286,7 @@ export const toggleThumbnail = () => ({type: TOGGLE_THUMBNAIL}); export const formatOptionsFetch = (url, force) => ({type: FORMAT_OPTIONS_FETCH, url, force}); export const formatsLoading = (loading) => ({type: FORMAT_OPTIONS_LOADING, loading}); export const setSupportedFormats = (formats, url) => ({type: SET_FORMAT_OPTIONS, formats, url}); +export const showFormatError = (status) => ({type: SHOW_FORMAT_ERROR, status}); import {error} from './notifications'; diff --git a/web/client/components/catalog/CatalogServiceEditor.jsx b/web/client/components/catalog/CatalogServiceEditor.jsx index 5eb06219a5..351000fd6d 100644 --- a/web/client/components/catalog/CatalogServiceEditor.jsx +++ b/web/client/components/catalog/CatalogServiceEditor.jsx @@ -46,6 +46,7 @@ const CatalogServiceEditor = ({ formatOptions, buttonStyle, saving, + showFormatError, onChangeServiceFormat = () => {}, onChangeMetadataTemplate = () => {}, onToggleAdvancedSettings = () => { }, @@ -100,6 +101,7 @@ const CatalogServiceEditor = ({ currentWMSCatalogLayerSize={layerOptions.tileSize ? layerOptions.tileSize : 256} selectedService={selectedService} onFormatOptionsFetch={onFormatOptionsFetch} + showFormatError={showFormatError} formatsLoading={formatsLoading} infoFormatOptions={infoFormatOptions} autoSetVisibilityLimits={autoSetVisibilityLimits} diff --git a/web/client/components/catalog/__tests__/CatalogServiceEditor-test.jsx b/web/client/components/catalog/__tests__/CatalogServiceEditor-test.jsx index f2f16f1bee..90865ca442 100644 --- a/web/client/components/catalog/__tests__/CatalogServiceEditor-test.jsx +++ b/web/client/components/catalog/__tests__/CatalogServiceEditor-test.jsx @@ -58,12 +58,9 @@ describe('Test CatalogServiceEditor', () => { layerOptions={{tileSize: 256}} />, document.getElementById("container")); - const formatFormGroups = [...document.querySelectorAll('.form-group')].filter(fg => { - const labels = [...fg.querySelectorAll('label')]; - return labels.length === 1 && labels[0].textContent === 'layerProperties.format.title'; - }); - expect(formatFormGroups.length).toBe(1); - const formatSelect = formatFormGroups[0].querySelector('.Select-value-label'); + const formatFormGroups = [...document.querySelectorAll('.form-group-flex')]; + expect(formatFormGroups.length).toBe(5); + const formatSelect = formatFormGroups[2].querySelector('.Select-value-label'); expect(formatSelect).toExist(); expect(formatSelect.textContent).toBe('image/png8'); // expect(formatSelect.props.options).toEqual(formatOptions); TODO: test properties are passed to select diff --git a/web/client/components/catalog/editor/AdvancedSettings/CSWFilters.jsx b/web/client/components/catalog/editor/AdvancedSettings/CSWFilters.jsx index 96bf34715b..29e440f891 100644 --- a/web/client/components/catalog/editor/AdvancedSettings/CSWFilters.jsx +++ b/web/client/components/catalog/editor/AdvancedSettings/CSWFilters.jsx @@ -1,6 +1,5 @@ import React, { useState, useEffect } from "react"; import { - Col, ControlLabel, FormGroup, Glyphicon, @@ -59,14 +58,14 @@ const FilterCode = ({ type, code, setCode, error }) => { const filterProp = `${type}Filter`; return ( - +
{error[type] && renderError} - - +
+
{ }} /> {type === 'dynamic' && renderHelpText} - +
); }; diff --git a/web/client/components/catalog/editor/AdvancedSettings/CommonAdvancedSettings.jsx b/web/client/components/catalog/editor/AdvancedSettings/CommonAdvancedSettings.jsx index 45900f3d36..5368fe49b9 100644 --- a/web/client/components/catalog/editor/AdvancedSettings/CommonAdvancedSettings.jsx +++ b/web/client/components/catalog/editor/AdvancedSettings/CommonAdvancedSettings.jsx @@ -7,7 +7,7 @@ */ import React from 'react'; import { isNil } from 'lodash'; -import { FormGroup, Checkbox, Col } from "react-bootstrap"; +import { FormGroup, Checkbox } from "react-bootstrap"; import Message from "../../../I18N/Message"; import InfoPopover from '../../../widgets/widget/InfoPopover'; @@ -25,44 +25,36 @@ export default ({ onChangeServiceProperty = () => { }, onToggleThumbnail = () => { } }) => ( -
+ <> - - {service.autoload !== undefined && onChangeServiceProperty("autoload", e.target.checked)} - checked={!isNil(service.autoload) ? service.autoload : false}> - - } - + {service.autoload !== undefined && onChangeServiceProperty("autoload", e.target.checked)} + checked={!isNil(service.autoload) ? service.autoload : false}> + + } - - onToggleThumbnail()} - checked={!isNil(service.hideThumbnail) ? !service.hideThumbnail : true}> - - - + onToggleThumbnail()} + checked={!isNil(service.hideThumbnail) ? !service.hideThumbnail : true}> + + {!isNil(service.type) && service.type === "wfs" && - - onChangeServiceProperty("allowUnsecureLayers", e.target.checked)} - checked={!isNil(service.allowUnsecureLayers) ? service.allowUnsecureLayers : false}> -  } /> - - + onChangeServiceProperty("allowUnsecureLayers", e.target.checked)} + checked={!isNil(service.allowUnsecureLayers) ? service.allowUnsecureLayers : false}> +  } /> + } {!isNil(service.type) && service.type === "cog" && - - onChangeServiceProperty("fetchMetadata", e.target.checked)} - checked={!isNil(service.fetchMetadata) ? service.fetchMetadata : true}> -  } /> - - + onChangeServiceProperty("fetchMetadata", e.target.checked)} + checked={!isNil(service.fetchMetadata) ? service.fetchMetadata : true}> +  } /> + } {children} -
+ ); diff --git a/web/client/components/catalog/editor/AdvancedSettings/RasterAdvancedSettings.js b/web/client/components/catalog/editor/AdvancedSettings/RasterAdvancedSettings.js index b5abdf7f04..42a7909dac 100644 --- a/web/client/components/catalog/editor/AdvancedSettings/RasterAdvancedSettings.js +++ b/web/client/components/catalog/editor/AdvancedSettings/RasterAdvancedSettings.js @@ -6,22 +6,22 @@ * LICENSE file in the root directory of this source tree. */ import React, {useEffect} from 'react'; -import {FormGroup, Col, ControlLabel, Checkbox, Button as ButtonRB, Glyphicon } from "react-bootstrap"; +import {FormGroup, ControlLabel, Checkbox, Button as ButtonRB, Glyphicon, InputGroup } from "react-bootstrap"; import RS from 'react-select'; -import localizedProps from '../../../misc/enhancers/localizedProps'; -const Select = localizedProps('noResultsText')(RS); +import {isNil, camelCase} from "lodash"; +import localizedProps from '../../../misc/enhancers/localizedProps'; import CommonAdvancedSettings from './CommonAdvancedSettings'; -import {isNil, camelCase} from "lodash"; import ReactQuill from '../../../../libs/quill/react-quill-suspense'; import { ServerTypes } from '../../../../utils/LayersUtils'; - import InfoPopover from '../../../widgets/widget/InfoPopover'; import CSWFilters from "./CSWFilters"; import Message from "../../../I18N/Message"; import WMSDomainAliases from "./WMSDomainAliases"; import tooltip from '../../../misc/enhancers/buttonTooltip'; + const Button = tooltip(ButtonRB); +const Select = localizedProps('noResultsText')(RS); /** * Generates an array of options in the form e.g. [{value: "256", label: "256x256"}] @@ -58,6 +58,7 @@ const getServerTypeOptions = () => { * */ export default ({ + showFormatError, service, formatOptions = [], infoFormatOptions = [], @@ -82,52 +83,42 @@ export default ({ const serverTypeOptions = getServerTypeOptions(); return ( {(isLocalizedLayerStylesEnabled && !isNil(service.type) ? service.type === "wms" : false) && ( - - onChangeServiceProperty("localizedLayerStyles", e.target.checked)} - checked={!isNil(service.localizedLayerStyles) ? service.localizedLayerStyles : false}> -  } /> - - + onChangeServiceProperty("localizedLayerStyles", e.target.checked)} + checked={!isNil(service.localizedLayerStyles) ? service.localizedLayerStyles : false}> +  } /> + )} - - onChangeServiceProperty("autoSetVisibilityLimits", e.target.checked)} - checked={!isNil(service.autoSetVisibilityLimits) ? service.autoSetVisibilityLimits : false}> -  } /> - - + onChangeServiceProperty("autoSetVisibilityLimits", e.target.checked)} + checked={!isNil(service.autoSetVisibilityLimits) ? service.autoSetVisibilityLimits : false}> +  } /> + {!isNil(service.type) && service.type === "wms" && - - onChangeServiceProperty("layerOptions", { ...service.layerOptions, singleTile: e.target.checked })} - checked={!isNil(service?.layerOptions?.singleTile) ? service.layerOptions.singleTile : false}> -  } /> - - + onChangeServiceProperty("layerOptions", { ...service.layerOptions, singleTile: e.target.checked })} + checked={!isNil(service?.layerOptions?.singleTile) ? service.layerOptions.singleTile : false}> +  } /> + } {!isNil(service.type) && service.type === "wms" && - - onChangeServiceProperty("allowUnsecureLayers", e.target.checked)} - checked={!isNil(service.allowUnsecureLayers) ? service.allowUnsecureLayers : false}> -  } /> - - + onChangeServiceProperty("allowUnsecureLayers", e.target.checked)} + checked={!isNil(service.allowUnsecureLayers) ? service.allowUnsecureLayers : false}> +  } /> + } {(!isNil(service.type) ? (service.type === "csw" && !service.excludeShowTemplate) : false) && ( - - onToggleTemplate()} - checked={service && service.showTemplate}> - - -
- + onToggleTemplate()} + checked={service && service.showTemplate}> + + +
{service && service.showTemplate && - ( + (

@@ -138,8 +129,8 @@ export default ({ {" ${ description }"} - )} - +

)} +
{service && service.showTemplate && } - +
)} - - - - - -
- onChangeServiceProperty("layerOptions", { ...service.layerOptions, serverType: event?.value })} /> + - - - - - -
- onFormatOptionsFetch(service.url)} + value={service && service.format} + clearable + noResultsText={props.formatsLoading + ? "catalog.format.loading" : "catalog.format.noOption"} + options={props.formatsLoading ? [] : formatOptions.map((format) => format?.value ? format : ({ value: format, label: format }))} + onChange={event => onChangeServiceFormat(event && event.value)} /> + - - - - - + + + + onChangeServiceProperty("layerOptions", { ...service.layerOptions, tileSize: event && event.value })} /> - - - - - - - -