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

Redirect to asset page if no installation selected #2049

Merged
merged 2 commits into from
Feb 27, 2025

Conversation

mrica-equinor
Copy link
Contributor

@mrica-equinor mrica-equinor commented Feb 25, 2025

Ready for review checklist:

  • A self-review has been performed
  • All commits run individually
  • Temporary changes have been removed, like console.log, TODO, etc.
  • The PR has been tested locally
  • A test have been written
    • This change doesn't need a new test
  • Relevant issues are linked
  • Remaining work is documented in issues
    • There is no remaining work from this PR that require new issues
  • The changes does not introduce dead code as unused imports, functions etc.

@mrica-equinor mrica-equinor changed the title Redirect to asset page Redirect to asset page if no installation selected Feb 25, 2025
@mrica-equinor
Copy link
Contributor Author

Closes #2042

@mrica-equinor mrica-equinor force-pushed the redirect-to-asset-page branch 3 times, most recently from 1acbaa2 to 1adfbd5 Compare February 25, 2025 15:16
@mrica-equinor mrica-equinor self-assigned this Feb 25, 2025
Copy link
Contributor

@andchiind andchiind left a comment

Choose a reason for hiding this comment

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

Looks good otherwise

import { config } from 'config'

export function validateURL() {
const { installationCode, installationName } = useInstallationContext()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does using contexts inside non-component functions not cause an error/warning in the frontend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What i got after redirect:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rename the function so that it's clear that it will navigate away, and not just validate the inspection?

@@ -15,6 +16,8 @@ const StyledFrontPage = styled.div`
`

export const FrontPage = () => {
redirectIfNoInstallationSelected()
Copy link
Contributor

Choose a reason for hiding this comment

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

If we wanted to be even more optimal we could useMemo, or a useEffect with empty conditionals here, to prevent this function from needing to be rerun on each render, but it's not too important.

Copy link
Contributor

@andchiind andchiind left a comment

Choose a reason for hiding this comment

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

Looks good otherwise. Maybe consider prevent the function from being rerun too often, but otherwise ready to merge.

@mrica-equinor mrica-equinor merged commit 225d546 into equinor:main Feb 27, 2025
12 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.

Gray out "Send robots to dock" button if user does not have access to installation
2 participants