forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client - Download link for documents page (#454)
- Loading branch information
1 parent
34acab1
commit 652f8fc
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
geonode_mapstore_client/client/js/plugins/DownloadResource.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,57 @@ | ||
/* | ||
* Copyright 2021, 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 Message from '@mapstore/framework/components/I18N/Message'; | ||
import Button from '@js/components/Button'; | ||
import { | ||
getResourceData | ||
} from '@js/selectors/resource'; | ||
|
||
|
||
function DownloadDocumentButton({ | ||
resource, | ||
variant, | ||
size | ||
}) { | ||
return ( | ||
resource ? <Button | ||
download={`${resource?.title}.${resource?.extension}`} | ||
href={resource?.href} | ||
variant={variant} | ||
size={size} | ||
> | ||
<Message msgId="gnviewer.download" /> | ||
</Button> : null); | ||
} | ||
|
||
const ConnectedDownloadResource = connect( | ||
createSelector([ | ||
getResourceData | ||
], (resource) => ({ | ||
resource | ||
})), | ||
{ | ||
} | ||
)(DownloadDocumentButton); | ||
|
||
|
||
export default createPlugin('DownloadResource', { | ||
component: ConnectedDownloadResource, | ||
containers: { | ||
ActionNavbar: { | ||
name: 'DownloadResource', | ||
Component: ConnectedDownloadResource | ||
} | ||
}, | ||
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