Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Jul 18, 2024
1 parent ec24980 commit 860211b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { getRepoNameFromGithubUrl } from "web-admin/src/features/projects/github/github-utils";
import { getRepoNameFromGithubUrl } from "@rilldata/web-admin/features/projects/github/github-utils";
export let githubUrl: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
createAdminServiceGetProject,
createAdminServiceUpdateProject,
getAdminServiceGetGithubUserStatusQueryKey,
getAdminServiceGetProjectQueryKey,
type RpcStatus,
} from "@rilldata/web-admin/client";
import { GithubRepoUpdater } from "@rilldata/web-admin/features/projects/github/GithubRepoUpdater";
import { GithubReposConnection } from "@rilldata/web-admin/features/projects/github/GithubReposConnection";
import {
AlertDialog,
AlertDialogContent,
Expand All @@ -25,13 +27,14 @@
import type { AxiosError } from "axios";
export let open = false;
export let currentUrl: string;
export let project: string;
export let organization: string;
let githubUrl = "";
const githubRepoUpdater = new GithubRepoUpdater();
const githubRepos = githubRepoUpdater.userRepos;
const status = githubRepoUpdater.status;
let githubUrl = currentUrl;
const githubReposConnection = new GithubReposConnection();
const githubRepos = githubReposConnection.userRepos;
const status = githubReposConnection.status;
const projectQuery = createAdminServiceGetProject(organization, project);
$: repoSelections =
Expand All @@ -53,9 +56,10 @@
message: `Set github repo to ${githubUrl}`,
type: "success",
});
void queryClient.refetchQueries(
void queryClient.refetchQueries([
getAdminServiceGetGithubUserStatusQueryKey(),
);
getAdminServiceGetProjectQueryKey(organization, project),
]);
void invalidateRuntimeQueries(
queryClient,
$projectQuery.data.prodDeployment.runtimeInstanceId,
Expand All @@ -65,10 +69,11 @@
function handleVisibilityChange() {
if (document.visibilityState !== "visible") return;
void githubRepoUpdater.focused();
void githubReposConnection.focused();
}
$: error = ($status.error ?? $updateProject.error) as unknown as AxiosError;
$: error = ($status.error ??
$updateProject.error) as unknown as AxiosError<RpcStatus>;
</script>

<svelte:window on:visibilitychange={handleVisibilityChange} />
Expand All @@ -83,11 +88,11 @@
<div class="flex flex-col">
<AlertDialogHeader>
<AlertDialogTitle>Select Github repository</AlertDialogTitle>
<AlertDialogDescription class="flex flex-col gap-y-1">
<AlertDialogDescription class="flex flex-col gap-y-2">
<span>
Which Github repo would you like to connect to this Rill project?
</span>
{#if $status.isLoading}
{#if $status.isFetching}
<div class="flex flex-row items-center ml-5 h-8">
<Spinner status={EntityStatus.Running} />
</div>
Expand All @@ -114,7 +119,7 @@
<Button
outline={false}
type="link"
on:click={() => githubRepoUpdater.check()}
on:click={() => githubReposConnection.check()}
>
Choose other repos
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryCl
import { waitUntil } from "@rilldata/web-common/lib/waitUtils";
import { derived, get } from "svelte/store";

export class GithubRepoUpdater {
export class GithubReposConnection {
public readonly userStatus = createAdminServiceGetGithubUserStatus();
public readonly userRepos = derived([this.userStatus], ([userStatus], set) =>
createAdminServiceListGithubUserRepos({
Expand All @@ -30,13 +30,13 @@ export class GithubRepoUpdater {
([userStatus, userRepos]) => {
if (userStatus.isFetching || userRepos.isFetching) {
return {
isLoading: true,
isFetching: true,
error: undefined,
};
}

return {
isLoading: false,
isFetching: false,
error: userStatus.error ?? userRepos.error,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import EditIcon from "@rilldata/web-common/components/icons/EditIcon.svelte";
import Github from "@rilldata/web-common/components/icons/Github.svelte";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { createAdminServiceGetProject } from "web-admin/src/client";
import { useDashboardsLastUpdated } from "web-admin/src/features/dashboards/listing/selectors";
import { createAdminServiceGetProject } from "@rilldata/web-admin/client";
import { useDashboardsLastUpdated } from "@rilldata/web-admin/features/dashboards/listing/selectors";
import { getRepoNameFromGithubUrl } from "@rilldata/web-admin/features/projects/github/github-utils";
export let organization: string;
Expand All @@ -29,15 +29,16 @@
let githubSelectionOpen = false;
const githubConnection = new GithubConnection(() => {
if (isGithubConnected) {
githubSelectionOpen = true;
} else {
confirmDialogOpen = true;
}
githubSelectionOpen = true;
});
const userStatus = githubConnection.userStatus;
function connectToGithub() {
confirmDialogOpen = true;
}
function confirmConnectToGithub() {
confirmDialogOpen = false;
void githubConnection.check();
}
Expand Down Expand Up @@ -116,14 +117,12 @@

<ConnectToGithubConfirmDialog
bind:open={confirmDialogOpen}
onContinue={() => {
confirmDialogOpen = false;
githubSelectionOpen = true;
}}
onContinue={confirmConnectToGithub}
/>

<GithubRepoSelectionDialog
bind:open={githubSelectionOpen}
currentUrl={$proj.data?.project?.githubUrl}
{organization}
{project}
/>
2 changes: 1 addition & 1 deletion web-admin/src/routes/-/github/connect/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import CtaLayoutContainer from "@rilldata/web-common/components/calls-to-action/CTALayoutContainer.svelte";
import CtaMessage from "@rilldata/web-common/components/calls-to-action/CTAMessage.svelte";
import Github from "@rilldata/web-common/components/icons/Github.svelte";
import GithubRepoInline from "web-admin/src/features/projects/github/GithubRepoInline.svelte";
import GithubRepoInline from "@rilldata/web-admin/features/projects/github/GithubRepoInline.svelte";
const urlParams = new URLSearchParams(window.location.search);
const redirectURL = urlParams.get("redirect");
Expand Down
2 changes: 1 addition & 1 deletion web-admin/src/routes/-/github/connect/request/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import CtaMessage from "@rilldata/web-common/components/calls-to-action/CTAMessage.svelte";
import KeyboardKey from "@rilldata/web-common/components/calls-to-action/KeyboardKey.svelte";
import Github from "@rilldata/web-common/components/icons/Github.svelte";
import GithubRepoInline from "web-admin/src/features/projects/github/GithubRepoInline.svelte";
import GithubRepoInline from "@rilldata/web-admin/features/projects/github/GithubRepoInline.svelte";
const remote = new URLSearchParams(window.location.search).get("remote");
const user = createAdminServiceGetCurrentUser({
Expand Down
4 changes: 2 additions & 2 deletions web-admin/src/routes/-/github/connect/retry-auth/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import CtaLayoutContainer from "@rilldata/web-common/components/calls-to-action/CTALayoutContainer.svelte";
import CtaMessage from "@rilldata/web-common/components/calls-to-action/CTAMessage.svelte";
import GithubFail from "@rilldata/web-common/components/icons/GithubFail.svelte";
import GithubRepoInline from "web-admin/src/features/projects/github/GithubRepoInline.svelte";
import GithubUserInline from "web-admin/src/features/projects/github/GithubUserInline.svelte";
import GithubRepoInline from "@rilldata/web-admin/features/projects/github/GithubRepoInline.svelte";
import GithubUserInline from "@rilldata/web-admin/features/projects/github/GithubUserInline.svelte";
const urlParams = new URLSearchParams(window.location.search);
const remote = urlParams.get("remote");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import CtaMessage from "@rilldata/web-common/components/calls-to-action/CTAMessage.svelte";
import KeyboardKey from "@rilldata/web-common/components/calls-to-action/KeyboardKey.svelte";
import GithubFail from "@rilldata/web-common/components/icons/GithubFail.svelte";
import GithubRepoInline from "web-admin/src/features/projects/github/GithubRepoInline.svelte";
import GithubRepoInline from "@rilldata/web-admin/features/projects/github/GithubRepoInline.svelte";
const remote = new URLSearchParams(window.location.search).get("remote");
Expand Down

0 comments on commit 860211b

Please sign in to comment.