19793: Make browser back button work on nav to PDH 19793-collection-back
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 14 Aug 2023 20:40:32 +0000 (16:40 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 14 Aug 2023 20:40:32 +0000 (16:40 -0400)
When navigating to a collection by PDH, if there is only one match, it
the portable data hash page automatically directs the user to the
appropriate collection page.  However, if the user pushes the back
button, they go back to portable data hash page which automatically
takes them to the collection page again.  This effectively breaks the
back button.

This fixes the bug by replacing (instead of "pushing") the top of the
location history with the collection page, so that the back button
from the collection page takes the user to their previous page without
revisiting the portable data hash page (so they are not endlessly
redirected).

This commit message is longer than the actual code fix.

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/store/collections-content-address-panel/collections-content-address-middleware-service.ts

index 18023affdb4f449202336a8b28c53addb81b34fa..56255860eebaf5644201db66d51f3ee20f4a6dbe 100644 (file)
@@ -21,6 +21,8 @@ import { ResourceKind, extractUuidKind } from 'models/resource';
 import { ownerNameActions } from 'store/owner-name/owner-name-actions';
 import { getUserDisplayName } from 'models/user';
 import { CollectionResource } from 'models/collection';
+import { replace } from "react-router-redux";
+import { getNavUrl } from 'routes/routes';
 
 export class CollectionsWithSameContentAddressMiddlewareService extends DataExplorerMiddlewareService {
     constructor(private services: ServiceRepository, id: string) {
@@ -89,7 +91,7 @@ export class CollectionsWithSameContentAddressMiddlewareService extends DataExpl
                 api.dispatch<any>(updateFavorites(response.items.map(item => item.uuid)));
                 api.dispatch<any>(updatePublicFavorites(response.items.map(item => item.uuid)));
                 if (response.itemsAvailable === 1) {
-                    api.dispatch<any>(navigateTo(response.items[0].uuid));
+                    api.dispatch<any>(replace(getNavUrl(response.items[0].uuid, api.getState().auth)));
                     api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
                 } else {
                     api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));