Skip to content

Commit

Permalink
Fix geosolutions-it#9197 Disable apply media editor button while load…
Browse files Browse the repository at this point in the history
…ing a selected item (geosolutions-it#9198)
  • Loading branch information
allyoucanmap committed May 29, 2023
1 parent a82f99e commit 7fc36de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion web/client/selectors/__tests__/mediaEditor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
getCurrentMediaResourcesParams,
getCurrentMediaResourcesTotalCount,
getLoadingSelectedMedia,
getLoadingMediaList
getLoadingMediaList,
disableApplyMapMedia
} from "../mediaEditor";

describe('mediaEditor selectors', () => {
Expand Down Expand Up @@ -278,4 +279,16 @@ describe('mediaEditor selectors', () => {
}
})).toBe(true);
});
it('disableApplyMapMedia', () => {
expect(disableApplyMapMedia({
mediaEditor: {
loadingSelected: true
}
})).toBe(true);
expect(disableApplyMapMedia({
mediaEditor: {
loadingSelected: false
}
})).toBe(false);
});
});
4 changes: 3 additions & 1 deletion web/client/selectors/mediaEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const disabledMediaTypeSelector = state => get(state, "mediaEditor.disabl
/**
* Disable `apply` on empty selection for map media editor when geostory section is GeoCarousel,
* here disable media type value is available only in GeoCarousel section
* The apply button should be disabled also when a selected item is loading
*/
export const disableApplyMapMedia = (state) =>
disabledMediaTypeSelector(state).length && !selectedItemSelector(state) && currentMediaTypeSelector(state) === 'map';
(disabledMediaTypeSelector(state).length && !selectedItemSelector(state) && currentMediaTypeSelector(state) === 'map')
|| getLoadingSelectedMedia(state);

0 comments on commit 7fc36de

Please sign in to comment.