Skip to content

Commit

Permalink
geosolutions-it#10385: Misleading persistence of CSW advanced setting…
Browse files Browse the repository at this point in the history
…s edits in dashboards (geosolutions-it#10412)

Description:
- fix the issue of misleading persistence of CSW advanced settings edits in dahsboards instead of showing the default csw with its default advanced settings
  • Loading branch information
mahmoudadel54 authored Jun 17, 2024
1 parent 03ea83e commit 0967a50
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions web/client/plugins/widgetbuilder/CatalogServiceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ const emptyService = {
export default ({service: defaultService, catalogServices,
error = () => {}, onAddService = () => {}, isNew, dashboardServices, defaultServices, defaultSelectedService,
dashboardSelectedService, ...props}) => {
const [service, setService] = useState(isNew ? emptyService :
isEmpty(dashboardSelectedService) ? {...defaultServices[defaultSelectedService],
old: defaultServices[defaultSelectedService], key: defaultSelectedService, excludeShowTemplate: true} :
{...dashboardServices[dashboardSelectedService], old: dashboardServices[dashboardSelectedService],
key: dashboardSelectedService, excludeShowTemplate: true} );
const [service, setService] = useState(() => {
// [dashboardHasEmptyServices] if true => show the default sevices, else show the dashobaord services with its stored configurations
// adding (!dashboardServices) in the condition shows the expceted behaviour
const dashboardHasEmptyServices = isEmpty(dashboardSelectedService) && !dashboardServices;
return isNew ? emptyService :
dashboardHasEmptyServices ?
{...defaultServices[defaultSelectedService], old: defaultServices[defaultSelectedService], key: defaultSelectedService, excludeShowTemplate: true} :
{...dashboardServices[dashboardSelectedService || defaultSelectedService], old: dashboardServices[dashboardSelectedService || defaultSelectedService],
key: dashboardSelectedService || defaultSelectedService, excludeShowTemplate: true};
});

const existingServices = isEmpty(dashboardServices) ? defaultServices : dashboardServices;

Expand Down

0 comments on commit 0967a50

Please sign in to comment.