Skip to content

Commit

Permalink
review delete redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Oct 1, 2024
1 parent 763ec7a commit 7eed800
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions geonode_mapstore_client/client/js/utils/ResourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ export const getResourceTypesInfo = () => ({
name: 'Dataset',
formatMetadataUrl: (resource) => isDefaultDatasetSubtype(resource?.subtype)
? `/datasets/${resource.store ? resource.store + ":" : ''}${resource.alternate}/metadata`
: `/resources/${resource.pk}/metadata`,
catalogPageUrl: '/datasets'
: `/resources/${resource.pk}/metadata`
},
[ResourceTypes.MAP]: {
icon: 'map',
Expand All @@ -348,8 +347,7 @@ export const getResourceTypesInfo = () => ({
config: 'map_preview'
})),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/maps/${resource.pk}/metadata`),
catalogPageUrl: '/maps'
formatMetadataUrl: (resource) => (`/maps/${resource.pk}/metadata`)
},
[ResourceTypes.DOCUMENT]: {
icon: 'file',
Expand All @@ -359,35 +357,31 @@ export const getResourceTypesInfo = () => ({
formatEmbedUrl: (resource) => isDocumentExternalSource(resource) ? undefined : resource?.embed_url && parseDevHostname(resource.embed_url),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/documents/${resource.pk}/metadata`),
metadataPreviewUrl: (resource) => (`/documents/${resource.pk}/metadata_detail?preview`),
catalogPageUrl: '/documents'
metadataPreviewUrl: (resource) => (`/documents/${resource.pk}/metadata_detail?preview`)
},
[ResourceTypes.GEOSTORY]: {
icon: 'book',
name: 'GeoStory',
canPreviewed: (resource) => resourceHasPermission(resource, 'view_resourcebase'),
formatEmbedUrl: (resource) => resource?.embed_url && parseDevHostname(resource.embed_url),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`),
catalogPageUrl: '/geostories'
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`)
},
[ResourceTypes.DASHBOARD]: {
icon: 'dashboard',
name: 'Dashboard',
canPreviewed: (resource) => resourceHasPermission(resource, 'view_resourcebase'),
formatEmbedUrl: (resource) => resource?.embed_url && parseDevHostname(resource.embed_url),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`),
catalogPageUrl: '/dashboards'
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`)
},
[ResourceTypes.VIEWER]: {
icon: 'cogs',
name: 'MapViewer',
canPreviewed: (resource) => resourceHasPermission(resource, 'view_resourcebase'),
formatEmbedUrl: () => false,
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`),
catalogPageUrl: '/all'
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`)
}
});

Expand Down Expand Up @@ -831,14 +825,6 @@ export const getResourceAdditionalProperties = (_resource = {}) => {
};
};

export const onDeleteRedirectTo = (resources = []) => {
let redirectUrl = '/';
if (!isEmpty(resources) && resources?.length === 1) {
const types = getResourceTypesInfo();
const { catalogPageUrl } = types[resources[0].resource_type] ?? {};
if (catalogPageUrl) {
redirectUrl = catalogPageUrl;
}
}
return redirectUrl;
export const onDeleteRedirectTo = () => {
return '/';
};

0 comments on commit 7eed800

Please sign in to comment.