NCEAS / metacatui

MetacatUI: A client-side web interface for DataONE data repositories
https://nceas.github.io/metacatui
Apache License 2.0
41 stars 26 forks source link

Forward /view/data-id routes to /view/metadata-id#data-id #1408

Closed laurenwalker closed 3 years ago

laurenwalker commented 4 years ago

In #83, we introduced hash fragments in the MetadataView URLs that allow people to route to data objects by using a path pattern of /view/{metadata-id}#{data-id}

Example: view/urn%3Auuid%3Ad64bca79-7bb7-4eb1-9b25-047fd64f32a9#urn%3Auuid%3Ad64bca79-7bb7-4eb1-9b25-047fd64f32a9

We have always supported and will continue to support direct navigation to data objects by using only the data identifier in the URL, e.g. view/{data-id}

However I propose the following change:

This was historically not supported by MetacatUI because for years we used hashes in ALL routes, but since we now leverage Apache's rewrite rules or FallbackResource, we can take advantage of these URL hashes

mbjones commented 4 years ago

This seems good. I would also propose a similar routing for our proposed /datasets routes that are not metacatui-centric. We had an extensive discussion on this topic in DataONE:

https://redmine.dataone.org/issues/8601

amoeba commented 3 years ago

I'm fairly sure this was working for quite a while but I think @mpsaloha and I realized it broke while checking it out the other week. I've added it to the salmon data label it's tightly related to existing deliverables.

laurenwalker commented 3 years ago

Thanks Bryce, I moved the issue to the Next pipeline since it sounds like you'll be taking a look at it sometime soon.

amoeba commented 3 years ago

Sounds good, @laurenwalker, I'll take a look this week.

amoeba commented 3 years ago

Had a look and I think I've got a nice solution.

When I looked at the coode, I found that the way MetadataView#getModel worked when passed a data PID was to look for a metadata PID to pair with the data PID and then recursively call getModel with the metadata PID it found. The change is just to Backbone.navigate instead of getModel to a URL of /view/$metadata#$data.

To test locally, checkout develop and:

  1. Set you config like:
MetacatUI.AppConfig = {
  root: "/",
  theme: "arctic",
  baseUrl: "https://test.arcticdata.io",
  metacatContext: "metacat",
  d1CNBaseUrl: "https://cn-stage.test.dataone.org",
}
  1. Run the local server and visit: http://localhost:3000/view/urn%3Auuid%3Aa35b96ff-e49b-433c-817d-ec0eb48b3f33

Note: You can test it out really any way you want by pointing your local MetacatUI at any node and visiting /view/$data_pid to see the behavior.

@laurenwalker this is ready for a review so I'll put it in that column on ZenHub. One thing I couldn't decide on was whether we were stressed about having both URLs (the /view/$data and the /view/$metadata#data URL) in the browser history or just the latter. I went with just the latter since it didn't seem useful or desirable to press back and get redirected forward again.