diff --git a/geonode_mapstore_client/client/MapStore2 b/geonode_mapstore_client/client/MapStore2 index 9609174244..b82943a5ab 160000 --- a/geonode_mapstore_client/client/MapStore2 +++ b/geonode_mapstore_client/client/MapStore2 @@ -1 +1 @@ -Subproject commit 9609174244481266626d6b9656590d5f1bf86871 +Subproject commit b82943a5abf30348b7e6509f0ad3cb0da3ffe5d8 diff --git a/geonode_mapstore_client/client/js/api/geonode/v2/index.js b/geonode_mapstore_client/client/js/api/geonode/v2/index.js index c359d363d2..c6c859bdba 100644 --- a/geonode_mapstore_client/client/js/api/geonode/v2/index.js +++ b/geonode_mapstore_client/client/js/api/geonode/v2/index.js @@ -723,6 +723,10 @@ export const deleteAsset = (pk, assetId) => { }); }; +export const getMetadataDownloadLinkByPk = (pk) => { + return getEndpointUrl(RESOURCES, `/${pk}/iso_metadata_xml`); +} + export default { getEndpoints, getResources, @@ -759,5 +763,6 @@ export default { downloadResource, getDatasets, deleteExecutionRequest, - getResourceByTypeAndByPk + getResourceByTypeAndByPk, + getMetadataDownloadLinkByPk }; diff --git a/geonode_mapstore_client/client/js/epics/__tests__/gndownload-test.js b/geonode_mapstore_client/client/js/epics/__tests__/gndownload-test.js index ec9602ef23..ac20750595 100644 --- a/geonode_mapstore_client/client/js/epics/__tests__/gndownload-test.js +++ b/geonode_mapstore_client/client/js/epics/__tests__/gndownload-test.js @@ -13,9 +13,11 @@ import { gnDownloadMetaData } from '@js/epics/gndownload'; describe('gnDownloadMetaData epic', () => { beforeEach(done => { + global.__DEVTOOLS__ = true; setTimeout(done); }); afterEach(done => { + delete global.__DEVTOOLS__; setTimeout(done); }); it('should download metadata', (done) => { diff --git a/geonode_mapstore_client/client/js/epics/gndownload.js b/geonode_mapstore_client/client/js/epics/gndownload.js index c2bfb75a26..70c796f4a8 100644 --- a/geonode_mapstore_client/client/js/epics/gndownload.js +++ b/geonode_mapstore_client/client/js/epics/gndownload.js @@ -13,12 +13,14 @@ import { DOWNLOAD_METADATA, downloadMetaDataComplete } from '@js/actions/gndownl import { error as errorNotification } from '@mapstore/framework/actions/notifications'; +import { getMetadataDownloadLinkByPk } from '@js/api/geonode/v2'; + export const gnDownloadMetaData = (action$, store) => action$.ofType(DOWNLOAD_METADATA) .switchMap((action) => { const state = store.getState(); - const url = state.gnresource?.data?.links?.find((link) => link.name === action.link).url; + const url = getMetadataDownloadLinkByPk(action.pk); const resourceTitle = state.gnresource?.data?.title?.replace(/[\.\s]/g, '_'); return Observable diff --git a/geonode_mapstore_client/client/js/plugins/downloads/DublinCoreDownload.jsx b/geonode_mapstore_client/client/js/plugins/downloads/DublinCoreDownload.jsx deleted file mode 100644 index 38d4de3a4e..0000000000 --- a/geonode_mapstore_client/client/js/plugins/downloads/DublinCoreDownload.jsx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2022, 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 '@mapstore/framework/components/layout/Button'; -import { downloadMetaData } from '@js/actions/gndownload'; -import { gnDownloadMetaData } from '@js/epics/gndownload'; -import Spinner from '@mapstore/framework/components/layout/Spinner'; -import gnDownload from '@js/reducers/gndownload'; - -function DublinCoreDownload({ onDownload, resourcePk, isDownloading }) { - return ( - - ); -} - -const DublinCoreDownloadPlugin = connect( - createSelector([ - state => state?.gnresource?.data.pk || null, - state => state?.gnDownload?.downloads?.DublinCore || {} - ], (resourcePk, downloadingResources) => ({ - resourcePk, - isDownloading: downloadingResources[resourcePk] - })), - { - onDownload: downloadMetaData - } -)(DublinCoreDownload); - -DublinCoreDownload.defaultProps = { - onDownload: () => { }, - resourcePk: null, - isDownloading: false -}; - -export default createPlugin('DublinCoreDownload', { - component: () => null, - containers: { - ActionNavbar: { - name: 'DublinCoreDownload', - Component: DublinCoreDownloadPlugin - } - }, - epics: { gnDownloadMetaData }, - reducers: { gnDownload } -}); diff --git a/geonode_mapstore_client/client/js/plugins/index.js b/geonode_mapstore_client/client/js/plugins/index.js index 35c263a645..aadbb639f7 100644 --- a/geonode_mapstore_client/client/js/plugins/index.js +++ b/geonode_mapstore_client/client/js/plugins/index.js @@ -445,10 +445,6 @@ export const plugins = { 'IsoDownload', () => import(/* webpackChunkName: 'plugins/iso-download-plugin' */ '@js/plugins/downloads/IsoDownload') ), - DublinCoreDownloadPlugin: toModulePlugin( - 'DublinCoreDownload', - () => import(/* webpackChunkName: 'plugins/iso-download-plugin' */ '@js/plugins/downloads/DublinCoreDownload') - ), MapViewersCatalogPlugin: toModulePlugin( 'MapViewersCatalog', () => import(/* webpackChunkName: 'plugins/map-viewers-catalog' */ '@js/plugins/MapViewersCatalog') diff --git a/geonode_mapstore_client/static/mapstore/configs/localConfig.json b/geonode_mapstore_client/static/mapstore/configs/localConfig.json index 7815e9da26..dc54de1500 100644 --- a/geonode_mapstore_client/static/mapstore/configs/localConfig.json +++ b/geonode_mapstore_client/static/mapstore/configs/localConfig.json @@ -639,10 +639,6 @@ { "type": "plugin", "name": "IsoDownload" - }, - { - "type": "plugin", - "name": "DublinCoreDownload" } ] }, @@ -885,9 +881,6 @@ { "name": "IsoDownload" }, - { - "name": "DublinCoreDownload" - }, { "name": "LayerDownload", "cfg": { @@ -2489,10 +2482,6 @@ { "type": "plugin", "name": "IsoDownload" - }, - { - "type": "plugin", - "name": "DublinCoreDownload" } ] } @@ -2508,9 +2497,6 @@ { "name": "IsoDownload" }, - { - "name": "DublinCoreDownload" - }, { "name": "ResourceDetails", "cfg": {