Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-4193: Redirect to project identifier on Project Health page #2290

Merged
merged 5 commits into from
Mar 18, 2024

Conversation

minnakt
Copy link
Contributor

@minnakt minnakt commented Mar 6, 2024

DEVPROD-4193

Description

This PR creates a new hook called useProjectRedirect which handles the redirect. I made it a bit general since I think it might be reused for other pages.

I also slightly tweaked the logic of how the CURRENT_PROJECT cookie is set so that it is never set to an Object ID.

Testing

  • Jest tests

Copy link

cypress bot commented Mar 6, 2024

2 failed and 3 flaky tests on run #16252 ↗︎

2 547 7 0 Flakiness 3
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Fix case for analytics event
Project: Spruce Commit: fb38177cbe
Status: Failed Duration: 20:30 💡
Started: Mar 18, 2024 11:21 PM Ended: Mar 18, 2024 11:41 PM

Review all test suite changes for PR #2290 ↗︎

@minnakt minnakt marked this pull request as ready for review March 6, 2024 21:02
@minnakt minnakt requested a review from a team March 6, 2024 21:02
if (projectFromUrl && projectFromUrl !== Cookies.get(CURRENT_PROJECT)) {
if (
projectFromUrl &&
!validateObjectId(projectFromUrl) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Great improvement! I think it's possible this has a large impact on the issue altogether.

const { identifier } = projectData.project;
const currentUrl = location.pathname.concat(location.search);
const redirectPathname = currentUrl.replace(project, identifier);
navigate(redirectPathname);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be overkill, but maybe adding an analytics event would be helpful to track whether we're still seeing this behavior frequently after the cookie change.

Copy link
Contributor Author

@minnakt minnakt Mar 8, 2024

Choose a reason for hiding this comment

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

for sure! I think the only clickable way to get to an ID link now is from the legacy UI 🫠 (DEVPROD-5194)

},
});

return { isRedirecting: needsRedirect && loading };
Copy link
Contributor

Choose a reason for hiding this comment

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

This works great but would you mind explaining what && loading does? Just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in theory it should never really happen, but it handles the case where someone visits /commits/{repoId}! Without && loading, isRedirecting will keep being true even though the repo could never redirect to an identifier

(loading && !versions) || !projectIdentifier || isResizing
(loading && !versions) ||
!projectIdentifier ||
isRedirecting ||
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Is this maybe overkill since we check loading for a function that is skipped if we're redirecting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good question, I checked it manually, and it looks like the screen will flicker without isRedirecting 😔

@minnakt minnakt requested a review from sophstad March 18, 2024 14:19
Copy link
Contributor

@sophstad sophstad left a comment

Choose a reason for hiding this comment

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

wahoo!

@minnakt
Copy link
Contributor Author

minnakt commented Mar 18, 2024

failing tests on Hosts page seems unrelated

@minnakt minnakt merged commit c94a593 into evergreen-ci:main Mar 18, 2024
2 of 5 checks passed
@minnakt minnakt deleted the DEVPROD-4193 branch March 18, 2024 23:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants