Skip to content

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

Merged
offtherailz merged 3 commits intogeosolutions-it:masterfrom
rowheat02:fix/defaultcatalogservicebug
Oct 4, 2024
Merged

The default catalog changes after the catalog is opened from the background tool #10486#10586
offtherailz merged 3 commits intogeosolutions-it:masterfrom
rowheat02:fix/defaultcatalogservicebug

Conversation

@rowheat02
Copy link
Copy Markdown
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 requested a review from offtherailz October 3, 2024 09:49
@tdipisa tdipisa linked an issue Oct 3, 2024 that may be closed by this pull request
1 task
Copy link
Copy Markdown
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
Copy Markdown
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
};
}

.switchMap(() => Rx.Observable.of(
setControlProperty('metadataexplorer', 'enabled', true),
allowBackgroundsDeletion(false),
addBackupBackground(store.getState().catalog.selectedService),
Copy link
Copy Markdown
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.

resetCatalog()
].concat(metadataSource === 'backgroundSelector' ?
[changeSelectedService(head(keys(services))), allowBackgroundsDeletion(true)] : [])));
[changeSelectedService(state.backgroundSelector.backupBackground), allowBackgroundsDeletion(true)] : [])));
Copy link
Copy Markdown
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.

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
Copy Markdown
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
@rowheat02 rowheat02 requested a review from offtherailz October 4, 2024 12:01
@offtherailz offtherailz merged commit 52f0248 into geosolutions-it:master Oct 4, 2024
@offtherailz
Copy link
Copy Markdown
Member

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

@ElenaGallo
Copy link
Copy Markdown
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