Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove the remaining bits of the authenticated middleware #11266

Merged
merged 3 commits into from
Jul 26, 2024

Conversation

codyrancher
Copy link
Contributor

@codyrancher codyrancher commented Jun 18, 2024

Summary

Remove the remaining bits of the authenticated middleware

Technical notes summary

Moving the remaining bits to navigation guards.

Areas which could experience regressions

Harvester clusters, products and cluster loading

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

@codyrancher codyrancher force-pushed the final-countdown branch 3 times, most recently from d424b68 to 15090eb Compare June 19, 2024 17:10
@codyrancher codyrancher changed the title Removing the back_to code since it's non-functional Remove the remaining bits of the authenticated middleware Jun 20, 2024
@codyrancher codyrancher added this to the v2.9.0 milestone Jun 20, 2024
Comment on lines 202 to 205
// Call the authenticated middleware. This used to attempt to load the error layout but because it was missing it would:
// 1. load the default layout instead
// 2. then call the authenticated middleware
// 3. Authenticated middleware would then load plugins and check to see if there was a valid route and navigate to that if it existed
// 4. This would allow harvester cluster pages to load on page reload
// We should really make authenticated middleware do less...
await callMiddleware.call(this, [{ options: { middleware: ['authenticated'] } }], app.context);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could cause problems with loading harvester cluster pages. I haven't been able to test yet.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should do that, so we do not risk rollback.
@torchiaf is it something we can try?

@@ -151,9 +111,7 @@ export default async function({
})
]);

if (localCheckResource) {
Copy link
Contributor Author

@codyrancher codyrancher Jun 20, 2024

Choose a reason for hiding this comment

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

This check doesn't appear to be needed any longer.

It looked like it was previously needed because some of the code we only wanted to be executed once while others we wanted on every page with authenticated.

Comment on lines -21 to -23
const backTo = window.localStorage.getItem(BACK_TO);

if (backTo) {
window.localStorage.removeItem(BACK_TO);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't port backTo over. It's non-functional in master and Neil seems keen to remove it. You can view a thread in team-container-ui where this was discussed.

I added an issue to track the removal of the rest of this feature #11268

Copy link
Member

Choose a reason for hiding this comment

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

Seen the conversation already 👍
UI/UX should be approved by Ken though and not Neil.
As he did not express any opinion, I take it as a tacit agreement.

@codyrancher codyrancher requested a review from cnotv June 20, 2024 04:08
@codyrancher codyrancher marked this pull request as ready for review June 20, 2024 04:08
Copy link
Member

@cnotv cnotv left a comment

Choose a reason for hiding this comment

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

Thanks for finally implementing routing guards as replacement of the middleware.

I added some side notes.
Trivial question outside of this PR scope: should not the config folder contain just static configuration?

shell/initialize/entry-helpers.js Show resolved Hide resolved
shell/config/router/navigation-guards/history.js Outdated Show resolved Hide resolved
@codyrancher
Copy link
Contributor Author

Trivial question outside of this PR scope: should not the config folder contain just static configuration?

I don't feel too strongly about this, I've seen a fair amount of config which included executable code. I'd be comfortable moving all of this to the initialize code though. I can understand the desire to keep it static.

@codyrancher codyrancher force-pushed the final-countdown branch 2 times, most recently from 8f07fd4 to 41cb67c Compare June 25, 2024 18:11
@codyrancher codyrancher removed this from the v2.9.0 milestone Jun 27, 2024
@codyrancher codyrancher force-pushed the final-countdown branch 3 times, most recently from b3de10c to 41ffbcd Compare July 3, 2024 23:44
@codyrancher codyrancher requested a review from cnotv July 4, 2024 00:37
@codyrancher
Copy link
Contributor Author

I'll wait to merge after we branch for the 2.9 release.

Copy link
Member

@cnotv cnotv left a comment

Choose a reason for hiding this comment

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

I think is pretty much fine. There are some comments to clarify some choices and so on.

}, 1);
});
}
const route = to;
Copy link
Member

Choose a reason for hiding this comment

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

Why this assignment? Are we trying to clone or what? Also, the name in such cases should have more specificity and a comment with an explanation.

Copy link
Contributor Author

@codyrancher codyrancher Jul 9, 2024

Choose a reason for hiding this comment

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

I only wanted to make this easier to diff with the original implementation so it was obvious the logic wasn't being changed. I change change all references.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -71,8 +31,12 @@ export default async function({
const oldPkg = getPackageFromRoute(from);
const oldProduct = getProductFromRoute(from);

// TODO: Replace all references to store.$plugin.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarifying the change in the comment and sorry for asking again, could you please add an issue for this?

Copy link
Member

Choose a reason for hiding this comment

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

Since I'll have to migrate this part, may I ask you where we assign the global $plugin to the store? Or is it something from Vuex?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the issue: #11386

I've added a reference to where $plugin is set in the tech debt issue but here's a reference here as well

commit('setPlugin', nuxt.app.$plugin);

Copy link
Member

Choose a reason for hiding this comment

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

I add it to the Nuxt removal bits, since it was listed 😅
#11070


export async function loadHistory(to, from, next) {
// Clear state used to record if back button was used for navigation
// TODO: Investigate if this can be removed. This is only used on the templates/error.vue page and seems hacky.
Copy link
Member

Choose a reason for hiding this comment

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

Do we still use the template/error page?
Because I think it was just on initialization.
Should we maybe open an issue to make an investigation in general on how is handled the 404, so we could merge all to failWhale instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opened two issues, one for this todo and one for the requests 404/failwhale investigation.

#11384

#11385

Copy link
Member

Choose a reason for hiding this comment

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

Thank you! 🍺

store.dispatch('gcRouteChanged', to);

await applyProducts(store, store.$plugin);
setProduct(store, to);
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the naive question, would not be better an action in the store for this?

Copy link
Contributor Author

@codyrancher codyrancher Jul 9, 2024

Choose a reason for hiding this comment

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

I'm happy to move it if you'd like. Is there a store that you think fits this best?

It seems a bit awkward for our existing stores since it touches the gc stuff, products and plugins.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it minimal and think about it in another phase then, e.g. review of the store.

cnotv
cnotv previously approved these changes Jul 9, 2024
Copy link
Member

@cnotv cnotv left a comment

Choose a reason for hiding this comment

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

LGTM


export async function loadHistory(to, from, next) {
// Clear state used to record if back button was used for navigation
// TODO: Investigate if this can be removed. This is only used on the templates/error.vue page and seems hacky.
Copy link
Member

Choose a reason for hiding this comment

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

Thank you! 🍺

store.dispatch('gcRouteChanged', to);

await applyProducts(store, store.$plugin);
setProduct(store, to);
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it minimal and think about it in another phase then, e.g. review of the store.

@codyrancher codyrancher merged commit 380ece8 into rancher:master Jul 26, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants