The default catalog changes after the catalog is opened from the background tool #10486#10586
Conversation
offtherailz
left a comment
There was a problem hiding this comment.
The fix works, but the code have to be written to be more maintainable and readable.
| export function addBackupBackground(background) { | ||
| return { | ||
| type: ADD_BACKUP_BACKGROUND, | ||
| background | ||
| }; | ||
| } |
There was a problem hiding this comment.
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:
| 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), |
There was a problem hiding this comment.
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.
web/client/epics/catalog.js
Outdated
| resetCatalog() | ||
| ].concat(metadataSource === 'backgroundSelector' ? | ||
| [changeSelectedService(head(keys(services))), allowBackgroundsDeletion(true)] : []))); | ||
| [changeSelectedService(state.backgroundSelector.backupBackground), allowBackgroundsDeletion(true)] : []))); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
| export const ADD_BACKUP_BACKGROUND = 'BACKGROUND_SELECTOR:ADD_BACKUP_BACKGROUND'; | |
| export const ADD_BACKUP_BACKGROUND = 'BACKGROUND_SELECTOR:STASH_SELECTED_SERVICE'; |
|
@ElenaGallo, could you please test this on DEV ? Thank you |
|
Test passed, @rowheat02 please backport to 2024.02.xx. Thanks |
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)
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)
Other useful information