Skip to content

Commit

Permalink
NONE open new tab instead of popup
Browse files Browse the repository at this point in the history
  • Loading branch information
gxueatlassian committed Aug 8, 2023
1 parent 68dba45 commit 468d460
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
2 changes: 1 addition & 1 deletion spa/src/pages/ConfigSteps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const ConfigSteps = () => {
};

const logout = () => {
popup("https://github.com/logout", { width: 400, height: 600 });
popup("https://github.com/logout");
clearGitHubToken();
analyticsClient.sendUIEvent({ actionSubject: "switchGitHubAccount", action: "clicked" });
};
Expand Down
2 changes: 1 addition & 1 deletion spa/src/services/app-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function installNewApp(callbacks: {
};
window.addEventListener("message", handler);

const winInstall = popup(app.data.appInstallationUrl, { width: 1024, height: 760 });
const winInstall = popup(app.data.appInstallationUrl);

// Still need below interval for window close
// As user might not finish the app install flow, there's no guarantee that above message
Expand Down
2 changes: 1 addition & 1 deletion spa/src/services/oauth-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function authenticateInGitHub(onWinClosed: () => void): Promise<void> {
const res = await Api.auth.generateOAuthUrl();
if (res.data.redirectUrl && res.data.state) {
window.localStorage.setItem(STATE_KEY, res.data.state);
const win = popup(res.data.redirectUrl, { width: 400, height: 600 });
const win = popup(res.data.redirectUrl);
if (win) {
const winCloseCheckHandler = setInterval(() => {
if (win.closed) {
Expand Down
22 changes: 2 additions & 20 deletions spa/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const getJiraJWT = (): Promise<string> => new Promise(resolve => {
});
});

export function popup (url: string, opts: { width: number, height: number }) {
return window.open(url, "_blank", `popup,${popup_params(opts.width, opts.height)}`);
export function popup (url: string) {
return window.open(url, "_blank");
}

export function reportError(err: unknown) {
Expand All @@ -17,21 +17,3 @@ export function reportError(err: unknown) {
//do nothing
}
}

//https://stackoverflow.com/a/4682246
function popup_params(width: number, height: number) {
try {
const a = typeof window.screenX != "undefined" ? window.screenX : window.screenLeft;
const i = typeof window.screenY != "undefined" ? window.screenY : window.screenTop;
const g = typeof window.outerWidth!="undefined" ? window.outerWidth : document.documentElement.clientWidth;
const f = typeof window.outerHeight != "undefined" ? window.outerHeight: (document.documentElement.clientHeight - 22);
const h = (a < 0) ? window.screen.width + a : a;
const left = h + ((g - width) / 2);
const top = i + ((f-height) / 2.5);
return "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",scrollbars=1";
} catch (e) {
reportError(e);
return "";
}
}

0 comments on commit 468d460

Please sign in to comment.