Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default catalog changes after the catalog is opened from the background tool #10486 #10586

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions web/client/actions/backgroundselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const CLEAR_MODAL_PARAMETERS = 'BACKGROUND_SELECTOR:CLEAR_MODAL_PARAMETER
export const CONFIRM_DELETE_BACKGROUND_MODAL = 'BACKGROUND_SELECTOR:CONFIRM_DELETE_BACKGROUND_MODAL';
export const ALLOW_BACKGROUNDS_DELETION = 'BACKGROUND_SELECTOR:ALLOW_BACKGROUNDS_DELETION';
export const SYNC_CURRENT_BACKGROUND_LAYER = 'BACKGROUND_SELECTOR:SYNC_CURRENT_BACKGROUND_LAYER';
export const STASH_SELECTED_SERVICE = 'BACKGROUND_SELECTOR:STASH_SELECTED_SERVICE';

export function createBackgroundsList(backgrounds) {
return {
Expand Down Expand Up @@ -125,3 +126,20 @@ export function confirmDeleteBackgroundModal(show, layerTitle = null, layerId =
layerId
};
}

/**
* Stashes the currently selected catalog service for later restoration.
* This is useful when closing the catalog and reopening it for background selection,
* allowing the user to easily return to their previous selection.
*
* @param {Object} service - The service object representing the currently selected catalog.
* @returns {Object} An action object with the type `STASH_SELECTED_SERVICE`
* and the selected service.
*/

export function stashSelectedCatalogService(service) {
return {
type: STASH_SELECTED_SERVICE,
service
};
}
8 changes: 6 additions & 2 deletions web/client/epics/backgroundselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
setBackgroundModalParams,
setCurrentBackgroundLayer,
allowBackgroundsDeletion,
backgroundAdded
backgroundAdded,
stashSelectedCatalogService
} from '../actions/backgroundselector';

import { setControlProperty } from '../actions/controls';
Expand All @@ -35,15 +36,18 @@ import { getLayerCapabilities } from '../observables/wms';
import { getCustomTileGridProperties, getLayerOptions } from '../utils/WMSUtils';
import { getLayerTileMatrixSetsInfo } from '../api/WMTS';
import { generateGeoServerWMTSUrl } from '../utils/WMTSUtils';
import { selectedServiceSelector } from '../selectors/catalog';

const accessMetadataExplorer = (action$) =>
const accessMetadataExplorer = (action$, store) =>
action$.ofType(ADD_BACKGROUND)
.switchMap(() => Rx.Observable.of(
setControlProperty('metadataexplorer', 'enabled', true),
allowBackgroundsDeletion(false),
stashSelectedCatalogService(selectedServiceSelector(store.getState())),
changeSelectedService('default_map_backgrounds')
));


const addBackgroundPropertiesEpic = (action$) =>
action$.ofType(ADD_BACKGROUND_PROPERTIES)
.switchMap(({modalParams}) => {
Expand Down
6 changes: 3 additions & 3 deletions web/client/epics/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
catalogSearchInfoSelector,
isActiveSelector, servicesSelectorWithBackgrounds
} from '../selectors/catalog';
import { metadataSourceSelector } from '../selectors/backgroundselector';
import { metadataSourceSelector, stashedServiceSelector } from '../selectors/backgroundselector';
import { currentMessagesSelector } from "../selectors/locale";
import { getSelectedLayer, selectedNodesSelector } from '../selectors/layers';

Expand Down Expand Up @@ -592,13 +592,13 @@ export default (API) => ({
.switchMap(() => {
const state = store.getState();
const metadataSource = metadataSourceSelector(state);
const services = servicesSelector(state);
const stashedService = stashedServiceSelector(state);
return Rx.Observable.of(...([
setControlProperties('metadataexplorer', "enabled", false, "group", null),
changeCatalogMode("view"),
resetCatalog()
].concat(metadataSource === 'backgroundSelector' ?
[changeSelectedService(head(keys(services))), allowBackgroundsDeletion(true)] : [])));
[changeSelectedService(stashedService), allowBackgroundsDeletion(true)] : [])));
}),

/**
Expand Down
10 changes: 9 additions & 1 deletion web/client/reducers/backgroundselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
REMOVE_BACKGROUND,
CREATE_BACKGROUNDS_LIST,
CLEAR_MODAL_PARAMETERS,
CONFIRM_DELETE_BACKGROUND_MODAL
CONFIRM_DELETE_BACKGROUND_MODAL,
STASH_SELECTED_SERVICE
} from '../actions/backgroundselector';

import { RESET_CATALOG } from '../actions/catalog';
Expand Down Expand Up @@ -102,6 +103,13 @@ function backgroundselector(state = null, action) {
case ALLOW_BACKGROUNDS_DELETION: {
return assign({}, state, {allowDeletion: action.allow || false});
}
case STASH_SELECTED_SERVICE : {
return assign({}, state, {
stashedService: action.service
});
}


default:
return state;
}
Expand Down
1 change: 1 addition & 0 deletions web/client/selectors/backgroundselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export const backgroundLayersSelector = createSelector(layersSelector, mapTypeSe
const backgroundLayers = layers.filter((l) => l && l.group === "background");
return loaded && loaded[maptype] ? backgroundLayers.map((l) => invalidateUnsupportedLayer(l, maptype)) || [] : backgroundLayers;
});
export const stashedServiceSelector = state => state.backgroundSelector && state?.backgroundSelector.stashedService;
Loading