Skip to content
Draft
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 @@ -34,7 +34,11 @@
import { setCloudReadonlyNotice } from "@rilldata/web-common/features/entity-management/actions/protected-files.ts";
import { isProjectWelcomePage } from "@rilldata/web-admin/features/navigation/nav-utils.ts";
import WelcomeRedirector from "@rilldata/web-admin/features/welcome/project/WelcomeRedirector.svelte";
<<<<<<< Updated upstream
import { InfoIcon } from "lucide-svelte";
=======
import RemoteProjectManager from "@rilldata/web-common/features/project/RemoteProjectManager.svelte";
>>>>>>> Stashed changes

$: organization = $page.params.organization;
$: project = $page.params.project;
Expand Down Expand Up @@ -175,6 +179,7 @@
editContext={true}
/>
<EditSessionTimeoutBanner sessionStartedAt={deployment.createdOn} />
<RemoteProjectManager />
{/if}
<FileAndResourceWatcher
lifecycle="none"
Expand Down
38 changes: 22 additions & 16 deletions web-common/src/features/project/RemoteProjectManager.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<script lang="ts">
import { page } from "$app/stores";
import type { ConnectError } from "@connectrpc/connect";
import { isMergeConflictError } from "@rilldata/web-common/features/project/deploy/github-utils.ts";
import MergeConflictResolutionDialog from "@rilldata/web-common/features/project/MergeConflictResolutionDialog.svelte";
import ProjectContainsRemoteChangesDialog from "@rilldata/web-common/features/project/ProjectContainsRemoteChangesDialog.svelte";
import { eventBus } from "@rilldata/web-common/lib/event-bus/event-bus.ts";
import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient.ts";
import type { GitStatusResponse } from "@rilldata/web-common/proto/gen/rill/local/v1/api_pb.ts";
import { getLocalServiceGitStatusQueryKey } from "@rilldata/web-common/runtime-client/local-service";
import {
createLocalServiceGitPull,
createLocalServiceGitStatus,
getLocalServiceGitStatusQueryKey,
} from "@rilldata/web-common/runtime-client/local-service";
createRuntimeServiceGitPullMutation,
createRuntimeServiceGitStatus,
getRuntimeServiceGitStatusQueryKey,
type V1GitStatusResponse,
} from "@rilldata/web-common/runtime-client";
import { useRuntimeClient } from "@rilldata/web-common/runtime-client/v2";

const gitStatusQuery = createLocalServiceGitStatus();
const gitPullMutation = createLocalServiceGitPull();
const runtimeClient = useRuntimeClient();

const gitStatusQuery = createRuntimeServiceGitStatus(runtimeClient, {});
const gitPullMutation = createRuntimeServiceGitPullMutation(
runtimeClient,
{},
);

let remoteChangeDialog = false;
let mergeConflictResolutionDialog = false;
$: inDeployPage = $page.route.id?.startsWith("/(misc)/deploy") ? true : false;

$: if ($gitStatusQuery.data) {
processGithubStatus($gitStatusQuery.data);
Expand All @@ -27,16 +32,14 @@
$: ({ isPending: githubPullPending, error: githubPullError } =
$gitPullMutation);
let errorFromGitCommand: ConnectError | null = null;
$: error = githubPullError ?? errorFromGitCommand;
$: error = (githubPullError ?? errorFromGitCommand) as ConnectError | null;

function processGithubStatus(status: GitStatusResponse) {
remoteChangeDialog = status.remoteCommits > 0;
function processGithubStatus(status: V1GitStatusResponse) {
remoteChangeDialog = !!status.remoteCommits;
}

async function handleFetchRemoteCommits() {
if (inDeployPage) return; // Do not show the modal in deploy pages

if ($gitStatusQuery.data!.localCommits > 0) {
if ($gitStatusQuery.data?.localCommits) {
// Since we can't really merge remote commits with local commits,
// we just show the user the merge conflicts dialog for confirmation to clear it.
// We could directly show it since the data is in gitStatusQuery, but it feels like weird UX.
Expand All @@ -51,7 +54,10 @@
// TODO: download diff once API is ready

void queryClient.invalidateQueries({
queryKey: getLocalServiceGitStatusQueryKey(),
queryKey: getRuntimeServiceGitStatusQueryKey(
runtimeClient.instanceId,
{},
),
});

remoteChangeDialog = false;
Expand Down
3 changes: 2 additions & 1 deletion web-local/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
isPreviewMode && showPreviewNav($page.url.pathname) && !onDeployPage;

$: onWelcomePage = route.id?.startsWith("/(misc)/welcome");
$: onDeployPage = route.id?.startsWith("/(misc)/deploy");
</script>

<Tooltip.Provider>
Expand All @@ -119,7 +120,7 @@
{#if shouldShowPreviewNav}
<PreviewModeNav />
{/if}
{#if $deploy}
{#if $deploy && !onDeployPage}
<RemoteProjectManager />
{/if}
{/if}
Expand Down
Loading