Skip to content

Commit

Permalink
Merge pull request #5601 from nasa-gibs/UAT-v4.53.0-1
Browse files Browse the repository at this point in the history
UAT-v4.53.0-1 to release
  • Loading branch information
PatchesMaps authored Dec 6, 2024
2 parents 0ff2dab + d2ad36d commit 46a1ee1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 29 deletions.
27 changes: 26 additions & 1 deletion e2e/features/image-download/unsupported-test.spec.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')
Expand Down
4 changes: 0 additions & 4 deletions web/js/components/image-download/image-download-panel.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import googleTagManager from 'googleTagManager';
import { getActivePalettes } from '../../modules/palettes/selectors';
import {
imageSizeValid,
getDimensions,
Expand Down Expand Up @@ -59,7 +57,6 @@ function ImageDownloadPanel(props) {
const [currResolution, setResolution] = useState(resolution);
const [debugUrl, setDebugUrl] = useState('');
const [showGranuleWarning, setShowGranuleWarning] = useState(false);
const activePalettes = useSelector((state) => getActivePalettes(state, state.compare.activeString));

useEffect(() => {
const layerList = getLayers();
Expand All @@ -86,7 +83,6 @@ function ImageDownloadPanel(props) {
currFileType,
currFileType === 'application/vnd.google-earth.kmz' ? false : currIsWorldfile,
markerCoordinates,
activePalettes,
);

window.open(dlURL, '_blank');
Expand Down
3 changes: 2 additions & 1 deletion web/js/containers/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
requestNotifications,
setNotifications,
} from '../modules/notifications/actions';
import { refreshPalettes } from '../modules/palettes/actions';
import { clearCustoms, refreshPalettes } from '../modules/palettes/actions';
import { clearRotate, refreshRotation } from '../modules/map/actions';
import {
showLayers, hideLayers,
Expand Down Expand Up @@ -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', clearCustoms, 'Notice');
await this.getPromise(isRotated, 'rotate', clearRotate, 'Reset rotation');
await this.getPromise(hasNonDownloadableLayer, 'layers', hideLayers, 'Remove Layers?');
await openModal(
Expand Down
28 changes: 11 additions & 17 deletions web/js/modules/image-download/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
each as lodashEach,
get as lodashGet,
} from 'lodash';
import { transform } from 'ol/proj';
Expand Down Expand Up @@ -178,21 +179,18 @@ export function imageUtilCalculateResolution(
* @returns {array} array of layer ids
*
*/
export function imageUtilGetLayers(products, proj, activePalettes) {
const layers = products.map((layer) => {
let layerId = layer.id;
export function imageUtilGetLayers(products, proj) {
const layers = [];
lodashEach(products, (layer) => {
if (layer.downloadId) {
layerId = layer.downloadId;
layers.push(layer.downloadId);
} else if (layer.projections[proj].id) {
layerId = layer.projections[proj].id;
layers.push(layer.projections[proj].id);
} else if (layer.projections[proj].layer) {
layerId = layer.projections[proj].layer;
}
const disabled = activePalettes?.[layer.id]?.maps?.[0]?.disabled;
if (Array.isArray(disabled)) {
return `${layerId}(disabled=${disabled.join('-')})`;
layers.push(layer.projections[proj].layer);
} else {
layers.push(layer.id);
}
return layerId;
});
return layers;
}
Expand Down Expand Up @@ -308,15 +306,15 @@ export function getTruncatedGranuleDates(layerDefs) {
* @param {Boolean} isWorldfile
* @param {Array} markerCoordinates
*/
export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime, fileType, isWorldfile, markerCoordinates, activePalettes) {
export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime, fileType, isWorldfile, markerCoordinates) {
const { crs } = proj.selected;
const {
layersArray,
layerWraps,
opacities,
} = imageUtilProcessWrap(
fileType,
imageUtilGetLayers(layerDefs, proj.id, activePalettes),
imageUtilGetLayers(layerDefs, proj.id),
imageUtilGetLayerWrap(layerDefs),
imageUtilGetLayerOpacities(layerDefs),
);
Expand All @@ -325,7 +323,6 @@ export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime,
const { height, width } = dimensions;
const snappedDateTime = getLatestIntervalTime(layerDefs, dateTime);
const granuleDates = getTruncatedGranuleDates(layerDefs).value;
const colormaps = layerDefs.map((layer) => layer.palette?.id);
const params = [
'REQUEST=GetSnapshot',
`TIME=${util.toISOStringSeconds(snappedDateTime)}`,
Expand All @@ -337,9 +334,6 @@ export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime,
`WIDTH=${width}`,
`HEIGHT=${height}`,
];
if (Array.isArray(colormaps) && colormaps.length > 0) {
params.push(`colormaps=${colormaps.join(',')}`);
}
if (granuleDates.length > 0) {
params.push(`granule_dates=${granuleDates}`);
}
Expand Down
3 changes: 1 addition & 2 deletions web/js/modules/image-download/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ test('Download URL [imagedownload-url]', () => {
{ id: 1, longitude: 2.7117, latitude: -19.1609 },
{ id: 2, longitude: 71.173, latitude: -39.0961 },
];
const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, locationMarkers, undefined);
const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, locationMarkers);
const expectedURL = 'http://localhost:3002/api/v1/snapshot'
+ '?REQUEST=GetSnapshot'
+ '&TIME=2019-06-24T00:00:00Z'
Expand All @@ -228,7 +228,6 @@ test('Download URL [imagedownload-url]', () => {
+ '&WRAP=day'
+ '&FORMAT=image/jpeg'
+ '&WIDTH=300&HEIGHT=300'
+ '&colormaps='
+ '&MARKER=2.7117,-19.1609,71.173,-39.0961';
expect(dlURL.includes(expectedURL)).toBe(true);
});
4 changes: 0 additions & 4 deletions web/js/modules/palettes/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,3 @@ export function isPaletteAllowed(layerId, config) {
}
return Boolean(config.layers[layerId].palette);
}

export function getActivePalettes (state, activeString) {
return state.palettes[activeString];
}

0 comments on commit 46a1ee1

Please sign in to comment.