-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Extend useNavigate hook to allow opening urls in a new tab
#1627
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
feat: Extend useNavigate hook to allow opening urls in a new tab
#1627
Conversation
8f5c8ed to
42b2488
Compare
d3e8df4 to
71956b8
Compare
useNavigate hook to allow opening urls in a new tab
42b2488 to
9999d20
Compare
71956b8 to
cd181ba
Compare
9999d20 to
e04aa29
Compare
a5a3ec7 to
7551981
Compare
7551981 to
744a795
Compare
maxy-shpfy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be highly risky overkill.
According to the doc, <Link> component supports this cmd+click behavior out of the box.
So one simple change (dont look at the div - inlinestack for some reason failed in this case - need to investigate) will get exactly same behavior:
<TableRow className="cursor-pointer text-gray-500 text-xs">
<TableCell className="text-sm flex items-center gap-2">
<Link to={clickThroughUrl}>
<div className="flex items-center gap-2">
<StatusIcon status={overallStatus} />
<Paragraph className="truncate max-w-[400px]" title={name}>
{name}
</Paragraph>
<span>{`#${runId}`}</span>
</div>
</Link>
</TableCell>
<TableCell>
<div className="w-2/3">
<StatusBar executionStatusStats={run.execution_status_stats} />
</div>
</TableCell>
<TableCell>
{run.created_at
? `${formatDate(convertUTCToLocalTime(run.created_at).toISOString())}`
: "Data not found..."}
</TableCell>
<TableCell>
{isTruncated ? createdByButtonWithTooltip : createdByButton}
</TableCell>
</TableRow>|
^ In some cases, such as I made this because there are places where we need to programatically navigate to a url; not via a UI element.
I'm currently not aware how that would be possible with the |
|
Closing this, as discussed. We will go with #1645 for now. |
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> Add support for `cmd + click` to open pages in a new tab where doing so is triggered by a click action on a UI component. Notably, this affects: - Row Row - Pipeline Row - Inspect Pipeline - Quick Start - View Run (after submission) ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> Closes Shopify/oasis-frontend#423 Supersedes #1627 ## Type of Change <!-- Please delete options that are not relevant --> - [x] New feature - [x] Improvement ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> no UI changes ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> Check the places where navigation has been updated that existing behaviour persists, and cmd + click opens in a new tab. ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->

Description
This adds a custom hook
useNavigatethat extends the existing React RouteruseNavigateto allow navigation to open in new tabs.Specifically, it adds:
newTabprop to thenavigatefunction. If true the url will open in a new tab. If false current behaviour is maintained.cmd/metais held down when thenavigatefunction executes and will open in a new tab as expected by usual link-clicking behaviour.The PR then propagates this to all the places where I judged this additionally functionality would be desired. Implementation of the hook is as simple as replacing the import path for
useNavigate, since the hook extends the React Router base hook (and thus the behaviour is unchanged when not opening in a new tab).Related Issue and Pull requests
Closes https://github.com/Shopify/oasis-frontend/issues/423
Type of Change
Checklist
Screenshots (if applicable)
No visible change to ui
Test Instructions
For the areas where this hook has been implemented check that:
Additional Comments