Skip to content

Commit 4ea706d

Browse files
authored
Implementation of redirect system (#2038)
1 parent 4ed63e3 commit 4ea706d

File tree

11 files changed

+77
-279
lines changed

11 files changed

+77
-279
lines changed

geonode_mapstore_client/client/js/apps/gn-catalogue.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import context from '@mapstore/framework/reducers/context';
3939

4040
import ViewerRoute from '@js/routes/Viewer';
4141
import ComponentsRoute from '@js/routes/Components';
42-
import CatalogueRoute from '@js/routes/Catalogue';
4342
import MapViewerRoute from '@js/routes/MapViewer';
43+
import RedirectRoute from '@js/routes/Redirect';
4444

4545
import gnresource from '@js/reducers/gnresource';
4646
import resourceservice from '@js/reducers/resourceservice';
@@ -84,6 +84,7 @@ import * as geoNodeMediaApi from '@js/observables/media/geonode';
8484
registerMediaAPI('geonode', geoNodeMediaApi);
8585

8686
import '@js/observables/persistence';
87+
import { getGeoNodeLocalConfig } from '@js/utils/APIUtils';
8788

8889
const requires = {
8990
ReactSwipe,
@@ -98,15 +99,19 @@ const ConnectedRouter = connect(
9899
})
99100
)(Router);
100101

101-
const viewers = {
102-
[appRouteComponentTypes.VIEWER]: ViewerRoute,
103-
[appRouteComponentTypes.CATALOGUE]: CatalogueRoute,
104-
[appRouteComponentTypes.DATASET_UPLOAD]: ComponentsRoute,
105-
[appRouteComponentTypes.DOCUMENT_UPLOAD]: ComponentsRoute,
106-
[appRouteComponentTypes.MAP_VIEWER]: MapViewerRoute
102+
const getViewer = (component) => {
103+
const useRedirect = getGeoNodeLocalConfig('geoNodeSettings.catalogHomeRedirectsTo');
104+
const viewers = {
105+
[appRouteComponentTypes.VIEWER]: ViewerRoute,
106+
[appRouteComponentTypes.CATALOGUE]: useRedirect ? RedirectRoute : ComponentsRoute,
107+
[appRouteComponentTypes.DATASET_UPLOAD]: ComponentsRoute,
108+
[appRouteComponentTypes.DOCUMENT_UPLOAD]: ComponentsRoute,
109+
[appRouteComponentTypes.MAP_VIEWER]: MapViewerRoute
110+
};
111+
return viewers[component];
107112
};
108113

109-
const routes = CATALOGUE_ROUTES.map(({ component, ...config }) => ({ ...config, component: viewers[component] }));
114+
const routes = CATALOGUE_ROUTES.map(({ component, ...config }) => ({ ...config, component: getViewer(component) }));
110115

111116
initializeApp();
112117

geonode_mapstore_client/client/js/epics/resourceservice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const gnProcessResources = (action$, store) =>
9393
{ ...process.output, func_name: process.processType }
9494
];
9595
return updateResource({
96-
id: process.resource.id,
96+
id: process.resource.id ?? process.resource.pk,
9797
['@extras']: {
9898
...process.resource?.['@extras'],
9999
executions,

geonode_mapstore_client/client/js/plugins/Operation/components/ExecutionRequestTable.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ function ExecutionRequestTable({
9898
{viewResource && <RenderActionButton
9999
request={request}
100100
msgId={viewResourceLabelId ?? 'gnviewer.view'}
101-
href={detailUrls.length === 1 ? detailUrls[0] : getCataloguePath('/catalogue/#/all')}
101+
href={detailUrls.length === 1 ? detailUrls[0] : getCataloguePath('/catalogue/#/')}
102102
/> }
103103
{editMetadata && <RenderActionButton
104104
request={request}
105105
msgId={editMetadataLabelId ?? 'gnviewer.fillMetadata'}
106106
href={detailUrls.length === 1 ? detailUrls[0].replace(/\/[^/]+\/(\d+)$/, "/metadata/$1")
107-
: getCataloguePath('/catalogue/#/all')}
107+
: getCataloguePath('/catalogue/#/')}
108108
/>}
109109
</div>
110110
: null}

geonode_mapstore_client/client/js/routes/Catalogue.jsx

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2025, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
import { connect } from 'react-redux';
10+
import { createSelector } from 'reselect';
11+
import isEmpty from 'lodash/isEmpty';
12+
import { getGeoNodeLocalConfig } from '@js/utils/APIUtils';
13+
14+
function RedirectRoute({
15+
location
16+
}) {
17+
const search = location?.search ?? {};
18+
const catalogHomeRedirectsTo = getGeoNodeLocalConfig('geoNodeSettings.catalogHomeRedirectsTo');
19+
if (!isEmpty(catalogHomeRedirectsTo)) {
20+
window.location.href = `${catalogHomeRedirectsTo}#/${search ? search : ""}`;
21+
return null;
22+
}
23+
return null;
24+
}
25+
26+
RedirectRoute.propTypes = {};
27+
28+
const ConnectedRedirectRoute = connect(
29+
createSelector([], () => ({})),
30+
{}
31+
)(RedirectRoute);
32+
33+
ConnectedRedirectRoute.displayName = 'ConnectedRedirectRoute';
34+
35+
export default ConnectedRedirectRoute;

geonode_mapstore_client/client/themes/geonode/less/_brand-navbar.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
border: 2px solid var(--ms-primary);
9797
}
9898

99-
.gn-catalogue:has(.gn-catalogue-page) {
99+
.gn-catalogue:has(.ms-resources-grid) {
100100
.app-router {
101101
position: relative !important;
102102
}

geonode_mapstore_client/static/mapstore/configs/localConfig.json

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,10 @@
690690
}
691691
},
692692
{
693-
"name": "DeleteResource"
693+
"name": "DeleteResource",
694+
"cfg": {
695+
"redirectTo": "/"
696+
}
694697
},
695698
{
696699
"name": "DownloadResource",
@@ -1566,7 +1569,10 @@
15661569
},
15671570
{
15681571
"mandatory": true,
1569-
"name": "DeleteResource"
1572+
"name": "DeleteResource",
1573+
"cfg": {
1574+
"redirectTo": "/"
1575+
}
15701576
},
15711577
{
15721578
"mandatory": true,
@@ -2277,7 +2283,11 @@
22772283
"name": "FullScreen"
22782284
},
22792285
{
2280-
"name": "DeleteResource"
2286+
"name": "DeleteResource",
2287+
"cfg": {
2288+
"redirectTo": "/"
2289+
}
2290+
22812291
},
22822292
{
22832293
"name": "GeoStory",
@@ -2491,7 +2501,10 @@
24912501
}
24922502
},
24932503
{
2494-
"name": "DeleteResource"
2504+
"name": "DeleteResource",
2505+
"cfg": {
2506+
"redirectTo": "/"
2507+
}
24952508
},
24962509
{
24972510
"name": "Save"
@@ -2618,7 +2631,10 @@
26182631
}
26192632
},
26202633
{
2621-
"name": "DeleteResource"
2634+
"name": "DeleteResource",
2635+
"cfg": {
2636+
"redirectTo": "/"
2637+
}
26222638
},
26232639
{
26242640
"name": "Save"
@@ -3453,7 +3469,10 @@
34533469
"name": "FullScreen"
34543470
},
34553471
{
3456-
"name": "DeleteResource"
3472+
"name": "DeleteResource",
3473+
"cfg": {
3474+
"redirectTo": "/"
3475+
}
34573476
},
34583477
{
34593478
"name": "Notifications"

geonode_mapstore_client/templates/geonode-mapstore-client/_geonode_config.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
let extensionsFolder = geoNodeSettings.EXTENSIONS_FOLDER_PATH;
7070
let supportedDatasetFileTypes = geoNodeSettings.SUPPORTED_DATASET_FILE_TYPES;
7171
let catalogHomeRedirectsTo = geoNodeSettings.CATALOG_HOME_REDIRECTS_TO;
72-
let defaultCatalogPage = geoNodeSettings.DEFAULT_CATALOG_PAGE || "all";
7372
let catalogPagePath = geoNodeSettings.CATALOG_PAGE_PATH;
7473
let customFilters = geoNodeSettings.CUSTOM_FILTERS || {
7574
"my-resources": {
@@ -212,7 +211,6 @@
212211
},
213212
staticPath: "{% static '' %}",
214213
catalogHomeRedirectsTo: catalogHomeRedirectsTo,
215-
defaultCatalogPage: defaultCatalogPage,
216214
catalogPagePath: catalogPagePath
217215
}
218216
},

geonode_mapstore_client/templates/geonode-mapstore-client/snippets/header.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
{% include './hero.html' %}
88
{% endif %}
99

10-
{% include './topbar.html' with id='gn-topbar' %}
11-
1210
<script>
1311
(function () {
1412
const mainHeader = document.querySelector('.gn-main-header');

0 commit comments

Comments
 (0)