forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1947: Harmonization of download actions inside the GeoNode client
- Loading branch information
Showing
23 changed files
with
196 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
geonode_mapstore_client/client/js/plugins/DatasetDownload.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright 2025, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import React from "react"; | ||
import { connect } from 'react-redux'; | ||
import { createSelector } from 'reselect'; | ||
|
||
import { createPlugin } from "@mapstore/framework/utils/PluginsUtils"; | ||
|
||
import Dropdown from '@js/components/Dropdown'; | ||
import FaIcon from '@js/components/FaIcon/FaIcon'; | ||
import { getSelectedLayerDataset } from '@js/selectors/resource'; | ||
import { SOURCE_TYPES } from "@js/utils/ResourceUtils"; | ||
|
||
const DatasetDownload = connect( | ||
createSelector([ | ||
getSelectedLayerDataset | ||
], (resource) => ({ | ||
resource | ||
})) | ||
)(({ | ||
items, | ||
selectedNodes, | ||
status, | ||
statusTypes, | ||
resource, // the selected layer's dataset resource | ||
allowedSources = [SOURCE_TYPES.LOCAL] // allowed sources for download | ||
}) => { | ||
const toolbarItems = items?.filter(item => item.target === "toolbar"); | ||
const layer = selectedNodes?.[0]?.node; | ||
if ([statusTypes?.LAYER].includes(status) && layer && !layer?.error && toolbarItems.length > 0) { | ||
return ( | ||
<div className="gn-layer-download"> | ||
<Dropdown className={"download-dropdown"}> | ||
<Dropdown.Toggle | ||
id={ `gn-toggle-dropdown-layer-download`} | ||
bsStyle={"primary"} | ||
noCaret | ||
> | ||
<FaIcon name={"download"} /> | ||
</Dropdown.Toggle> | ||
<Dropdown.Menu> | ||
{toolbarItems.map(({Component, name}, idx) => ( | ||
<Dropdown.Item eventKey={idx}> | ||
<Component | ||
key={`${name}-item-${idx}`} | ||
resource={resource} | ||
allowedSources={allowedSources} | ||
variant="default" | ||
/> | ||
</Dropdown.Item> | ||
))} | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
</div> | ||
); | ||
} | ||
return null; | ||
}); | ||
|
||
/** | ||
* Plugin for downloading the dataset resource | ||
* via direct download or export the data associated | ||
* @name DatasetDownload | ||
* @example | ||
* { | ||
* "name": "DatasetDownload" | ||
* } | ||
*/ | ||
export default createPlugin('DatasetDownload', { | ||
component: DatasetDownload, | ||
containers: { | ||
TOC: { | ||
doNotHide: true, | ||
name: "DatasetDownload", | ||
target: 'toolbar', | ||
Component: DatasetDownload, | ||
position: 11 | ||
} | ||
}, | ||
epics: {}, | ||
reducers: {} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.