Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: make non-http external app links open in the current window
  • Loading branch information
kylecarbs committed Sep 26, 2023
commit f8c61ae35b15edd0994edab8daae3caf764605f7
21 changes: 16 additions & 5 deletions site/src/components/Resources/AppLink/AppLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,22 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
canClick
? (event) => {
event.preventDefault();
window.open(
href,
Language.appTitle(appDisplayName, generateRandomString(12)),
"width=900,height=600",
);
// This is an external URI like "vscode://", so
// it needs to be opened with the browser protocol handler.
if (app.external && !app.url.startsWith("http")) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm still pretty convinced this should be an ||

Copy link
Member Author

Choose a reason for hiding this comment

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

If app.external and the URL is https://my-internal-jira.com we wouldn't want to replace window.location.href, otherwise it would redirect the user from the dashboard.

Copy link
Member Author

Choose a reason for hiding this comment

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

@aslilac lmk async if I'm thinking of this wrong, going to merge since it's blocking some registry work, but I'm happy to change it!

Copy link
Member

Choose a reason for hiding this comment

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

OH. I think I misunderstood what external meant here. It's probably fine.

// If the protocol is external the browser does not
// redirect the user from the page.
window.location.href = href;
} else {
window.open(
href,
Language.appTitle(
appDisplayName,
generateRandomString(12),
),
"width=900,height=600",
);
}
}
: undefined
}
Expand Down