Skip to content

Redirect to asset page if no installation selected#2049

Merged
mrica-equinor merged 2 commits intoequinor:mainfrom
mrica-equinor:redirect-to-asset-page
Feb 27, 2025
Merged

Redirect to asset page if no installation selected#2049
mrica-equinor merged 2 commits intoequinor:mainfrom
mrica-equinor:redirect-to-asset-page

Conversation

@mrica-equinor
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

`

export const FrontPage = () => {
redirectIfNoInstallationSelected()
Copy link
Copy Markdown
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
Copy Markdown
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
9 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