Skip to content

Commit

Permalink
Fixed bulk granule modal to correctly pass selected granules (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyhliu committed Dec 12, 2023
1 parent ee76f8e commit d2c4743
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- **CUMULUS-3265**
- Fixed bulk granule operation modal to correctly pass selected granules into bulk operation

## [v12.0.1] - 2023-05-25

### Breaking Changes

This version of the dashboard requires Cumulus API v2 (Core version >= v16.0.0)
Expand Down
16 changes: 6 additions & 10 deletions app/src/js/components/Granules/bulk-granule-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,17 @@ const BulkGranuleModal = ({
if (!inflight) {
try {
json = JSON.parse(query);
const granuleIds = json.ids.map((granule) => granule.granuleId);
json.ids = granuleIds;
} catch (jsonError) {
return setErrorState('Syntax error in JSON');
return setErrorState(`Syntax error in JSON ${jsonError.message}`);
}
dispatch(bulkRequestAction({ requestId, json }));
}
}

function queryGranulesWorkflows(queryParams) {
const { ids, index, query: esQuery } = queryParams;
if ((index && esQuery) || ids.length > 0) {
const granuleWorkflowsQuery = { ...queryParams, granules: ids };
delete granuleWorkflowsQuery[ids];
dispatch(getGranulesWorkflows(granuleWorkflowsQuery));
const { granules, index, query: esQuery } = queryParams;
if ((index && esQuery) || granules.length > 0) {
dispatch(getGranulesWorkflows(queryParams));
}
}

Expand All @@ -100,7 +96,7 @@ const BulkGranuleModal = ({
}

useEffect(() => {
const queryParams = { ...JSON.parse(query), ids: selected };
const queryParams = { ...JSON.parse(query), granules: selected };
setQuery(JSON.stringify(queryParams, null, 2));

if (showModal && queryWorkflowOptions) {
Expand Down Expand Up @@ -158,7 +154,7 @@ const BulkGranuleModal = ({
{selected &&
<>
<p>Selected granules:</p>
<p>[{selected.map((selection) => `"${selection.granuleId}"`).join(', ')}]</p>
<p>[{selected.map((selection) => `{"granuleId": "${selection.granuleId}", "collectionId": "${selection.collectionId}"}`).join(', ')}]</p>
</>
}
<br/>
Expand Down
2 changes: 1 addition & 1 deletion app/src/js/components/Granules/bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const bulkOperationsDefaultQuery = {
workflowName: '',
index: '',
query: '',
granules: '',
granules: [],
meta: {}
};

Expand Down

0 comments on commit d2c4743

Please sign in to comment.