Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Re-enabled palette warning for snapshot (#5962)

christof-wittreich06f4fab24a64
diff --git a/e2e/features/image-download/unsupported-test.spec.js b/e2e/features/image-download/unsupported-test.spec.js
index 2ca858547..cce0c6a18 100644
--- a/e2e/features/image-download/unsupported-test.spec.js
+++ b/e2e/features/image-download/unsupported-test.spec.js
@@ -1,7 +1,7 @@
// @ts-check
const { test, expect } = require('@playwright/test')
const createSelectors = require('../../test-utils/global-variables/selectors')
-const { closeModal } = require('../../test-utils/hooks/wvHooks')
+const { closeImageDownloadPanel, closeModal } = require('../../test-utils/hooks/wvHooks')
const { joinUrl } = require('../../test-utils/hooks/basicHooks')
let page
@@ -28,6 +28,31 @@ test.afterAll(async () => {
await page.close()
})
+test('Custom palettes are not supported dialog', async () => {
+ const { snapshotToolbarButton } = selectors
+ const url = await joinUrl(startParams, '&l=MODIS_Terra_Aerosol(palette=red_1)')
+ await page.goto(url)
+ await closeModal(page)
+ await snapshotToolbarButton.click()
+ await expect(notify).toBeVisible()
+})
+
+test('Custom palettes: Cancel button', async () => {
+ await cancelNotify.click()
+ await expect(notify).not.toBeVisible()
+ await expect(toolbarSnapshot).not.toBeVisible()
+})
+
+test('Custom palettes: OK button brings up download panel', async () => {
+ const { snapshotToolbarButton } = selectors
+ await snapshotToolbarButton.click()
+ await expect(notify).toBeVisible()
+ await acceptNotify.click()
+ await expect(notify).not.toBeVisible()
+ await expect(toolbarSnapshot).toBeVisible()
+ await closeImageDownloadPanel(page)
+})
+
test('Rotation is not supported dialog', async () => {
const { snapshotToolbarButton } = selectors
const url = await joinUrl(startParams, '&p=arctic&r=18')
diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.js
index f55953e5f..e4d891450 100644
--- a/web/js/containers/toolbar.js
+++ b/web/js/containers/toolbar.js
@@ -21,7 +21,7 @@ import {
requestNotifications,
setNotifications,
} from '../modules/notifications/actions';
-import { refreshPalettes } from '../modules/palettes/actions';
+import { clearCustomsSnapshot, refreshPalettes } from '../modules/palettes/actions';
import { clearRotate, refreshRotation } from '../modules/map/actions';
import {
showLayers, hideLayers,
@@ -136,6 +136,7 @@ class toolbarContainer extends Component {
const nonDownloadableLayers = hasNonDownloadableLayer ? getNonDownloadableLayers(visibleLayersForProj) : null;
const paletteStore = lodashCloneDeep(activePalettes);
toggleDialogVisible(false);
+ await this.getPromise(hasCustomPalette, 'palette', clearCustomsSnapshot, 'Notice');
await this.getPromise(isRotated, 'rotate', clearRotate, 'Reset rotation');
await this.getPromise(hasNonDownloadableLayer, 'layers', hideLayers, 'Remove Layers?');
await openModal(
@@ -452,6 +453,7 @@ const mapStateToProps = (state) => {
const { activeTab } = sidebar;
const isDataDownloadTabActive = activeTab === 'download';
const { isOpen: modalIsOpen } = modal;
+ const filteredLayers = activeLayersForProj.filter((layer) => !(layer.colormapType === 'classification' && layer.type !== 'vector'));
// Collapse when Image download / GIF / is open or measure tool active
const snapshotModalOpen = modalIsOpen && modal.id === 'TOOLBAR_SNAPSHOT';
@@ -475,7 +477,7 @@ const mapStateToProps = (state) => {
isMobile,
isRotated: Boolean(map.rotation !== 0),
hasCustomPalette: hasCustomPaletteInActiveProjection(
- activeLayersForProj,
+ filteredLayers,
activePalettes,
),
modalIsOpen,
diff --git a/web/js/modules/palettes/actions.js b/web/js/modules/palettes/actions.js
index 06060065a..4f68137da 100644
--- a/web/js/modules/palettes/actions.js
+++ b/web/js/modules/palettes/actions.js
@@ -165,11 +165,9 @@ export function setToggledClassification(layerId, classIndex, index, groupName)
/**
* Action to remove custom palettes
*
- * @param {String} layerId
- * @param {Number} index | Palette index value for multi-paletted layers
- * @param {String} groupName | layer group string
+ * @param {Boolean} keepDisabledClassification | Optionally keep disabled classification colormaps
*/
-export function clearCustoms() {
+export function clearCustoms(keepDisabledClassification) {
return (dispatch, getState) => {
const state = getState();
const { palettes, compare } = state;
@@ -184,13 +182,22 @@ export function clearCustoms() {
if (colormap.max || colormap.min || colormap.squash) {
dispatch(setThresholdRangeAndSquash(key, props, index, groupName));
}
- if (colormap.disabled) {
+ if (colormap.disabled && !keepDisabledClassification) {
dispatch(setToggledClassification(key, undefined, index, groupName));
}
});
});
};
}
+
+/**
+ * Helper function for snapshot functionality to prevent removing disabled colormaps
+ *
+ */
+export function clearCustomsSnapshot() {
+ return (dispatch) => dispatch(clearCustoms(true));
+}
+
/**
* Action signifying custom palettes have been loaded
*