Skip to content
Open
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
25 changes: 18 additions & 7 deletions src/lib/components/git/repositories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
let isLoadingRepositories = $state(null);
let installationsMap = $state(null);
let offset = $state(0);
let connectingRepositoryId = $state<string | null>(null);
let loadRepositoriesRequestId = 0;
const limit = 5;

onMount(() => {
isLoadingRepositories = true;
loadInstallations();
});

Expand Down Expand Up @@ -115,6 +118,8 @@
}

async function loadRepositories(installationId: string, search: string) {
const requestId = ++loadRepositoriesRequestId;

const result = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositories({
Expand All @@ -125,6 +130,11 @@
queries: [Query.limit(limit), Query.offset(offset)]
});

// Stale request
if (requestId !== loadRepositoriesRequestId) {
return;
}

$repositories.repositories =
product === 'functions'
? (result as unknown as Models.ProviderRepositoryRuntimeList)
Expand Down Expand Up @@ -186,10 +196,7 @@
debouncedLoadRepositories.cancel();
}}
bind:value={selectedInstallation} />
<InputSearch
placeholder="Search repositories"
bind:value={search}
disabled={!search && !$repositories?.repositories?.length} />
<InputSearch placeholder="Search repositories" bind:value={search} />
</Layout.Stack>
{/if}
</Layout.Stack>
Expand Down Expand Up @@ -266,7 +273,11 @@
size="xs"
variant="secondary"
style="flex-shrink: 0;"
on:click={() => connect(repo)}>
disabled={!!connectingRepositoryId}
on:click={() => {
connectingRepositoryId = repo.id;
connect(repo);
}}>
Connect
</PinkButton.Button>
{/if}
Expand Down Expand Up @@ -300,12 +311,12 @@
alignItems="center"
wrap="wrap">
<Typography.Text variant="m-400" color="--fgcolor-neutral-secondary">
Total results: {$repositories.total}
Total results: {isLoadingRepositories ? 0 : $repositories.total}
</Typography.Text>
<PaginationInline
{limit}
bind:offset
total={$repositories.total}
total={isLoadingRepositories ? 0 : $repositories.total}
hidePages={true}
on:change={loadRepositoryPage} />
</Layout.Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Click, trackEvent } from '$lib/actions/analytics';
import type { Models } from '@appwrite.io/console';
import { isSelfHosted } from '$lib/system';
import { afterNavigate, goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { installation, repository } from '$lib/stores/vcs';
import { Repositories } from '$lib/components/git';
import {
Expand All @@ -27,10 +27,6 @@

const isVcsEnabled = $regionalConsoleVariables?._APP_VCS_ENABLED === true;
const wizardBase = `${base}/project-${page.params.region}-${page.params.project}/functions`;
let previousPage: string = wizardBase;
afterNavigate(({ from }) => {
previousPage = from?.url?.pathname || previousPage;
});

let selectedRepository: string;

Expand Down Expand Up @@ -60,7 +56,7 @@
}
</script>

<Wizard title="Create function" href={previousPage} column columnSize="l" hideFooter>
<Wizard title="Create function" href={wizardBase} column columnSize="l" hideFooter>
<Layout.Stack gap="l">
<Layout.GridFraction start={4} end={6} gap="l" rowSize="auto">
<Card.Base>
Expand Down Expand Up @@ -105,10 +101,13 @@
}}
{connect} />
</Layout.Stack>
{#if data.installations.total}
{#if $installation}
<Layout.Stack gap="l">
<Divider />
<Link variant="quiet" href="#/">
<Link
variant="quiet"
external
href={`https://github.com/settings/installations/${$installation.providerInstallationId}`}>
<Layout.Stack direction="row" gap="xs">
Missing a repository? check your permissions <Icon
icon={IconArrowSmRight} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@
href="https://appwrite.io/docs/products/sites/deploy-from-git"
external
secondary>Docs</Button>
<Button
href={`https://github.com/${data.installations.installations[0].organization}`}
text>Go to GitHub</Button>
{#if $installation}
<Button
href={`https://github.com/settings/installations/${$installation.providerInstallationId}`}
external
text>Go to GitHub</Button>
{/if}
</Layout.Stack>
{/if}
</Layout.Stack>
Expand Down