(href: string)
| 87 | // null out `opener` (durable on the opened window); and navigate `popup` |
| 88 | // to the target URL. The Coder UI keeps access to `popup`s handle |
| 89 | export const openAppInNewWindow = (href: string) => { |
| 90 | const popup = window.open("about:blank", "_blank", "width=900,height=600"); |
| 91 | if (!popup) { |
| 92 | toast.error("Failed to open app in new window.", { |
| 93 | description: "Popup blocked. Allow popups to open this app.", |
| 94 | }); |
| 95 | return; |
| 96 | } |
| 97 | try { |
| 98 | // Setting the opener to null persists in the `popup` window over refresh |
| 99 | // and navigation. The opening window retains its connection to `popup` |
| 100 | popup.opener = null; |
| 101 | } catch { |
| 102 | // Electron can throw |
| 103 | } |
| 104 | popup.location.href = href; |
| 105 | }; |
| 106 | |
| 107 | type GetAppHrefParams = { |
| 108 | path: string; |
no test coverage detected