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

Conversation

rowheat02
Copy link
Contributor

Description

While adding the background layer, a backup for the selected catalog service is stored in the backgroundselector store.
And same service is set while closing the Catalog Modal.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?

#10486
The selected catalog service changes after trying to add a background layer

What is the new behavior?

Selected Catalog service remains same even after trying to add background layer

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

@rowheat02 rowheat02 changed the title fix: resetting selectedService for catalog while adding background la… The default catalog changes after the catalog is opened from the background tool #10486 Oct 2, 2024
@rowheat02 rowheat02 self-assigned this Oct 2, 2024
@rowheat02 rowheat02 added this to the 2024.02.01 milestone Oct 2, 2024
@rowheat02 rowheat02 marked this pull request as ready for review October 2, 2024 13:39
@tdipisa tdipisa linked an issue Oct 3, 2024 that may be closed by this pull request
1 task
Copy link
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

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

The fix works, but the code have to be written to be more maintainable and readable.

Comment on lines 130 to 135
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
};
}

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.

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.

@@ -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';

@offtherailz offtherailz added the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Oct 4, 2024
@offtherailz offtherailz merged commit 52f0248 into geosolutions-it:master Oct 4, 2024
6 checks passed
@offtherailz
Copy link
Member

@ElenaGallo, could you please test this on DEV ? Thank you

@ElenaGallo
Copy link
Contributor

Test passed, @rowheat02 please backport to 2024.02.xx. Thanks

rowheat02 added a commit to rowheat02/MapStore2 that referenced this pull request Oct 8, 2024
@tdipisa tdipisa removed the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The default catalog changes after the catalog is opened from the background tool
4 participants