Skip to content
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

fix: Github connection follow ups #5378

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
} from "@rilldata/web-common/components/alert-dialog";
import { Button } from "@rilldata/web-common/components/button";
import Github from "@rilldata/web-common/components/icons/Github.svelte";
import { openPopupWindow } from "@rilldata/web-common/lib/openPopupWindow";
import { behaviourEvent } from "@rilldata/web-common/metrics/initMetrics";
import { BehaviourEventAction } from "@rilldata/web-common/metrics/service/BehaviourEventTypes";

Expand All @@ -28,11 +29,7 @@
},
);
// we need a popup window so we cannot use href
window.open(
"https://github.com/new",
"githubNewWindow",
"width=1024,height=600",
);
openPopupWindow("https://github.com/new", "githubNewWindow");
}

function handleContinue() {
Expand Down
4 changes: 2 additions & 2 deletions web-admin/src/features/projects/github/GithubData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getAdminServiceListGithubUserReposQueryKey,
type RpcStatus,
} from "@rilldata/web-admin/client";
import { openPopupWindow } from "@rilldata/web-common/lib/openPopupWindow";
import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient";
import { waitUntil } from "@rilldata/web-common/lib/waitUtils";
import { getContext, setContext } from "svelte";
Expand Down Expand Up @@ -98,11 +99,10 @@ export class GithubData {
// no-op
}
if (this.windowCheckTimer) clearInterval(this.windowCheckTimer);
this.userPromptWindow = window.open(
this.userPromptWindow = openPopupWindow(
// add `remote` to indicate the callback success dialog should auto close
`${url}?remote=autoclose`,
"githubWindow",
"width=1024,height=600",
);

// periodically check if the new window was closed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@

// update data from project, this is needed if the user never leaves the status page and this component is not unmounted
$: githubConnectionUpdater = new ProjectGithubConnectionUpdater(
project,
organization,
project,
currentUrl,
currentSubpath,
currentBranch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<DeployIcon size="150px" />
<div class="flex flex-col">
<AlertDialogHeader>
<AlertDialogTitle>Deploy this project for free</AlertDialogTitle>
<AlertDialogTitle>Deploy this project</AlertDialogTitle>
<AlertDialogDescription>
You’re about to deploy to Rill Cloud, where you can set alerts,
share dashboards, and more. <a
Expand Down
39 changes: 39 additions & 0 deletions web-common/src/lib/openPopupWindow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const WindowWidth = 1024;
const WindowHeight = 600;

/**
* Opens a popup window with {@link WindowWidth} and {@link WindowHeight}
*/
export function openPopupWindow(url: string, title: string) {
const dualScreenLeft =
window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop =
window.screenTop !== undefined ? window.screenTop : window.screenY;

const width = window.innerWidth
? window.innerWidth
: document.documentElement.clientWidth
? document.documentElement.clientWidth
: screen.width;
const height = window.innerHeight
? window.innerHeight
: document.documentElement.clientHeight
? document.documentElement.clientHeight
: screen.height;

const systemZoom = width / window.screen.availWidth;
const left = (width - WindowWidth) / 2 / systemZoom + dualScreenLeft;
const top = (height - WindowHeight) / 2 / systemZoom + dualScreenTop;

return window.open(
url,
title,
`
scrollbars=yes,
width=${WindowWidth / systemZoom},
height=${WindowHeight / systemZoom},
top=${top},
left=${left}
`,
);
}
Loading