Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

I35 valkyrize hyku routes and redirects #2149

Merged
merged 9 commits into from
Jan 16, 2024

Conversation

kirkkwang
Copy link
Collaborator

🧹 Add custom presenters for resource work types

1ff3036

The Hyrax generator does not generate presenters for resource work
types so I'm adding them here and ensuring the respective resource work
type controllers use them.

🧹 Add redirects for work types

83e7dab

This commit will add redirects for the the work types so when viewing or
editing them, the user will be redirected to the Valkyrie (Resource)
version of the work type. The won't work unless turbolinks is disabled.
We are opting for using an ENV variable to disable turbolinks for now so
it can be easily removed in the future.

⚙️ Set TURBOLINKS_FOR_VALKYRIE to false

3f37899

This allows for the redirects of AF works to Valkyrie works to function
correctly because turbolinks was not allowing the redirect to happen.

Ref:

Kirk Wang added 3 commits January 9, 2024 13:34
The Hyrax generator does not generate presenters for resource work
types so I'm adding them here and ensuring the respective resource work
type controllers use them.
This commit will add redirects for the the work types so when viewing or
editing them, the user will be redirected to the Valkyrie (Resource)
version of the work type.  The won't work unless turbolinks is disabled.
We are opting for using an ENV variable to disable turbolinks for now so
it can be easily removed in the future.
This allows for the redirects of AF works to Valkyrie works to function
correctly because turbolinks was not allowing the redirect to happen.

Ref:
  - notch8/hykuup_knapsack#100
@kirkkwang kirkkwang added the patch-ver for release notes label Jan 9, 2024
This commit will move the turbolinks logic to a helper so that it can be
be a little more sturdier than checking for the string values of the ENV
variable especially because it is a boolean.
@kirkkwang kirkkwang force-pushed the i35-valkyrize-hyku-routes-and-redirects branch from dfb7aa7 to 751b97c Compare January 9, 2024 22:45
@kirkkwang kirkkwang requested a review from bkiahstroud January 9, 2024 22:47
@kirkkwang kirkkwang force-pushed the i35-valkyrize-hyku-routes-and-redirects branch from 9a6b1b6 to dff0efd Compare January 9, 2024 23:07
@kirkkwang kirkkwang requested a review from bkiahstroud January 9, 2024 23:07
@ShanaLMoore
Copy link
Collaborator

ShanaLMoore commented Jan 10, 2024

This may or may not be related to this work. I took this branch for a spin and the routes are working now 🎉

But when I try to save a GenericWorkResource it fails because @form doesn't exist.

Should valkyrie objects be routed to a different create? We can dig in tomorrow if you'd like.

image

@ShanaLMoore
Copy link
Collaborator

ShanaLMoore commented Jan 10, 2024

Should valkyrie objects be routed to a different create?

x
Looks like the answer is yes? I'll see if I can confirm. On save it currently goes to the wrong controller.

image

@kirkkwang kirkkwang force-pushed the i35-valkyrize-hyku-routes-and-redirects branch from dff0efd to 4137515 Compare January 10, 2024 02:13
This commit will correct the logic because when our ENV var is true, turbolinks needs to be false and vice versa.

Co-authored-by: Benjamin Kiah Stroud <32469930+bkiahstroud@users.noreply.github.com>
@kirkkwang kirkkwang force-pushed the i35-valkyrize-hyku-routes-and-redirects branch from 4137515 to 7c7699b Compare January 10, 2024 14:09
This refactor will simply remove the ENV variable have the helper method
return false with a TODO.  This should give us enough documentation in
the future.
Copy link
Collaborator

@bkiahstroud bkiahstroud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirkkwang why was the ENV variable removed?

Copy link
Collaborator

@bkiahstroud bkiahstroud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see the commit message:

This refactor will simply remove the ENV variable have the helper method return false with a TODO. This should give us enough documentation in the future.

@kirkkwang
Copy link
Collaborator Author

@kirkkwang why was the ENV variable removed?

basically it introduced a lot of extra complexity that wasn't needed, instead we document why in the code comments

Copy link
Collaborator

@bkiahstroud bkiahstroud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically it introduced a lot of extra complexity that wasn't needed, instead we document why in the code comments

It certainly increases complexity, I agree with you there. However, there are significant benefits to using an ENV variable in a situation like this:

  1. We can toggle it on/off in rancher without changing any code. Even if we did want to change it in the code, it would be a single line, which we could do quickly and safely.
  2. Because this is Hyku, other institutions who are mid-migration can use this. In its current form, an institution mid-migration will not be able to upgrade their Hyku once this changes is removed.

There may be a couple other benefits, but those two are the most significant and relevant.

@kirkkwang
Copy link
Collaborator Author

Cool that sounds good too. I'm going to have to bring in @jeremyf on this because I can go either way and I'll let the difference of opinions be put forth here so we have it tracked. I'll put this PR back into draft for now.

@kirkkwang kirkkwang marked this pull request as draft January 10, 2024 17:32
Copy link
Collaborator

@bkiahstroud bkiahstroud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I agree with @jeremyf's suggested rename of the ENV variable to HYKU_BLOCK_VALKYRIE_REDIRECT. That way we don't have to flip the polarity


resource = resource.to_s.underscore

get "/concern/#{resource}s/:id/edit", to: redirect("/concern/#{resource}_resources/%{id}/edit")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that we don't need to use a redirect but could instead specify the controller/action pair. Since this route is declared earlier than Hyrax, this route will take precedence.

Why avoid using a redirect? It saves at least one HTTP request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool i'm not sure what that means but i'll do some research

@jeremyf jeremyf requested a review from bkiahstroud January 16, 2024 15:21
@jeremyf jeremyf dismissed bkiahstroud’s stale review January 16, 2024 15:21

We've moved past it.

Kirk Wang added 2 commits January 16, 2024 08:14
This commit will bring back the ENV variable so that we have the option
to turn back on the turbolinks without having to redeploy code.
@kirkkwang kirkkwang marked this pull request as ready for review January 16, 2024 16:24
@kirkkwang kirkkwang merged commit f0145c9 into i35-valkyrize-hyku Jan 16, 2024
2 of 3 checks passed
@kirkkwang kirkkwang deleted the i35-valkyrize-hyku-routes-and-redirects branch January 16, 2024 18:13
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
patch-ver for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants