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 1 commit
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
8 changes: 8 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 ADD_BACKUP_BACKGROUND = 'BACKGROUND_SELECTOR:ADD_BACKUP_BACKGROUND';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const ADD_BACKUP_BACKGROUND = 'BACKGROUND_SELECTOR:ADD_BACKUP_BACKGROUND';
export const ADD_BACKUP_BACKGROUND = 'BACKGROUND_SELECTOR:STASH_SELECTED_SERVICE';


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

export function addBackupBackground(background) {
return {
type: ADD_BACKUP_BACKGROUND,
background
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action stashes the selected catalog, not a backup of the background.
I'd also document to understand what is the parameter accepted (e.g. ID, object....).
So for this action I should use the following:

Suggested change
export function addBackupBackground(background) {
return {
type: ADD_BACKUP_BACKGROUND,
background
};
}
/**
* stashes the current selected catalog to restore after catalog close, when opening
* the catalog for background selection
* @params ... <--- Insert here the parameter type and name
*/
export function stashSelectedCatalogService(service) {
return {
type: STASH_SELECTED_SERVICE,
service
};
}

7 changes: 5 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,
addBackupBackground
} from '../actions/backgroundselector';

import { setControlProperty } from '../actions/controls';
Expand All @@ -36,14 +37,16 @@ import { getCustomTileGridProperties, getLayerOptions } from '../utils/WMSUtils'
import { getLayerTileMatrixSetsInfo } from '../api/WMTS';
import { generateGeoServerWMTSUrl } from '../utils/WMTSUtils';

const accessMetadataExplorer = (action$) =>
const accessMetadataExplorer = (action$, store) =>
action$.ofType(ADD_BACKGROUND)
.switchMap(() => Rx.Observable.of(
setControlProperty('metadataexplorer', 'enabled', true),
allowBackgroundsDeletion(false),
addBackupBackground(store.getState().catalog.selectedService),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use selectors when available in this case selectedServiceSelector in selectors/catalog.
This helps future refactors (e.g. internal restructuration of state) without having to find around the code all the x.y.z strings.

changeSelectedService('default_map_backgrounds')
));


const addBackgroundPropertiesEpic = (action$) =>
action$.ofType(ADD_BACKGROUND_PROPERTIES)
.switchMap(({modalParams}) => {
Expand Down
3 changes: 1 addition & 2 deletions web/client/epics/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,12 @@ export default (API) => ({
.switchMap(() => {
const state = store.getState();
const metadataSource = metadataSourceSelector(state);
const services = servicesSelector(state);
return Rx.Observable.of(...([
setControlProperties('metadataexplorer', "enabled", false, "group", null),
changeCatalogMode("view"),
resetCatalog()
].concat(metadataSource === 'backgroundSelector' ?
[changeSelectedService(head(keys(services))), allowBackgroundsDeletion(true)] : [])));
[changeSelectedService(state.backgroundSelector.backupBackground), allowBackgroundsDeletion(true)] : [])));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in this case, create a selector for that value and use it here.

}),

/**
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,
ADD_BACKUP_BACKGROUND
} 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 ADD_BACKUP_BACKGROUND : {
return assign({}, state, {
backupBackground: action.background
});
}


default:
return state;
}
Expand Down
Loading