mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fetch all branches via pagination in all branch selectors
This commit is contained in:
1 parent
bce2dce704
commit
80242cb89e
7 files changed
+163
-64
No files matched your search
+17
-7
@@ -10,6 +10,7 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { installation, repository, sortBranches } from '$lib/stores/vcs';
|
||||
import {
|
||||
Query,
|
||||
Runtime,
|
||||
VCSReferenceType,
|
||||
type Models,
|
||||
@@ -54,14 +55,23 @@
|
||||
});
|
||||
}
|
||||
selectedRepository = $repository?.id;
|
||||
const branchList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: $installation.$id,
|
||||
providerRepositoryId: selectedRepository
|
||||
});
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
while (true) {
|
||||
const { branches, total } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: $installation.$id,
|
||||
providerRepositoryId: selectedRepository,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
|
||||
const sorted = sortBranches(branchList.branches);
|
||||
const sorted = sortBranches(allBranches);
|
||||
|
||||
branch = sorted.find((b) => b.name === $func.providerBranch)
|
||||
? $func.providerBranch
|
||||
|
||||
+21
-7
@@ -26,12 +26,26 @@ export const load = async ({ parent, depends, params }) => {
|
||||
rules,
|
||||
domainsList,
|
||||
installations,
|
||||
branches:
|
||||
func?.installationId && func?.providerRepositoryId
|
||||
? await sdk.forProject(params.region, params.project).vcs.listRepositoryBranches({
|
||||
installationId: func.installationId,
|
||||
providerRepositoryId: func.providerRepositoryId
|
||||
})
|
||||
: undefined
|
||||
branches: await (async () => {
|
||||
if (!func?.installationId || !func?.providerRepositoryId) return undefined;
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
let total = 0;
|
||||
while (true) {
|
||||
const { branches, total: t } = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: func.installationId,
|
||||
providerRepositoryId: func.providerRepositoryId,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
total = t;
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
return { branches: allBranches, total };
|
||||
})()
|
||||
};
|
||||
};
|
||||
+35
-14
@@ -6,7 +6,7 @@
|
||||
import { Button, Form, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Runtime, type Models, type ProjectKeyScopes } from '@appwrite.io/console';
|
||||
import { Query, Runtime, type Models, type ProjectKeyScopes } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import DisconnectRepo from './disconnectRepo.svelte';
|
||||
import { installation, repository as repositoryStore, sortBranches } from '$lib/stores/vcs';
|
||||
@@ -110,12 +110,24 @@
|
||||
}
|
||||
}
|
||||
async function getBranches(installation: string, repo: string) {
|
||||
branchesList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: installation,
|
||||
providerRepositoryId: repo
|
||||
});
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
let total = 0;
|
||||
while (true) {
|
||||
const { branches, total: t } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: installation,
|
||||
providerRepositoryId: repo,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
total = t;
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
branchesList = { branches: allBranches, total };
|
||||
branchesList.branches = sortBranches(branchesList.branches);
|
||||
|
||||
selectedBranch = func?.providerBranch ?? branchesList.branches[0].name;
|
||||
@@ -133,13 +145,22 @@
|
||||
async function connect(selectedInstallationId: string, selectedRepository: string) {
|
||||
let nextBranch = func?.providerBranch ?? 'main';
|
||||
try {
|
||||
const branchList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository
|
||||
});
|
||||
const sorted = sortBranches(branchList.branches);
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
while (true) {
|
||||
const { branches, total } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
const sorted = sortBranches(allBranches);
|
||||
nextBranch =
|
||||
sorted.find((branch) => branch.name === func?.providerBranch)?.name ??
|
||||
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')?.name ??
|
||||
|
||||
+17
-8
@@ -2,7 +2,7 @@
|
||||
import { PaginationWithLimit, EmptyFilter, Empty } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container, ResponsiveContainerHeader } from '$lib/layout';
|
||||
import { Adapter, BuildRuntime, Framework, type Models } from '@appwrite.io/console';
|
||||
import { Adapter, BuildRuntime, Framework, Query, type Models } from '@appwrite.io/console';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { ActionMenu, Alert, Icon, Layout, Popover } from '@appwrite.io/pink-svelte';
|
||||
import Table from './table.svelte';
|
||||
@@ -43,13 +43,22 @@
|
||||
async function connect(selectedInstallationId: string, selectedRepository: string) {
|
||||
let nextBranch = data.site?.providerBranch ?? 'main';
|
||||
try {
|
||||
const branchList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository
|
||||
});
|
||||
const sorted = sortBranches(branchList.branches);
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
while (true) {
|
||||
const { branches, total } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
const sorted = sortBranches(allBranches);
|
||||
nextBranch =
|
||||
sorted.find((branch) => branch.name === data.site?.providerBranch)?.name ??
|
||||
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')?.name ??
|
||||
|
||||
+17
-7
@@ -14,6 +14,7 @@
|
||||
Adapter,
|
||||
BuildRuntime,
|
||||
Framework,
|
||||
Query,
|
||||
VCSReferenceType,
|
||||
type Models
|
||||
} from '@appwrite.io/console';
|
||||
@@ -55,14 +56,23 @@
|
||||
});
|
||||
}
|
||||
selectedRepository = $repository?.id;
|
||||
const branchList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: $installation.$id,
|
||||
providerRepositoryId: selectedRepository
|
||||
});
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
while (true) {
|
||||
const { branches, total } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: $installation.$id,
|
||||
providerRepositoryId: selectedRepository,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
|
||||
const sorted = sortBranches(branchList.branches);
|
||||
const sorted = sortBranches(allBranches);
|
||||
|
||||
branch = sorted.find((b) => b.name === site.providerBranch)
|
||||
? site.providerBranch
|
||||
|
||||
+21
-7
@@ -28,12 +28,26 @@ export const load = async ({ parent, depends, params }) => {
|
||||
rules,
|
||||
domainsList,
|
||||
installations,
|
||||
branches:
|
||||
site?.installationId && site?.providerRepositoryId
|
||||
? await sdk.forProject(params.region, params.project).vcs.listRepositoryBranches({
|
||||
installationId: site.installationId,
|
||||
providerRepositoryId: site.providerRepositoryId
|
||||
})
|
||||
: undefined
|
||||
branches: await (async () => {
|
||||
if (!site?.installationId || !site?.providerRepositoryId) return undefined;
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
let total = 0;
|
||||
while (true) {
|
||||
const { branches, total: t } = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: site.installationId,
|
||||
providerRepositoryId: site.providerRepositoryId,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
total = t;
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
return { branches: allBranches, total };
|
||||
})()
|
||||
};
|
||||
};
|
||||
+35
-14
@@ -6,7 +6,7 @@
|
||||
import { Button, Form, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Adapter, BuildRuntime, Framework, type Models } from '@appwrite.io/console';
|
||||
import { Adapter, BuildRuntime, Framework, Query, type Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import DisconnectRepo from './disconnectRepo.svelte';
|
||||
import { installation, repository as repositoryStore, sortBranches } from '$lib/stores/vcs';
|
||||
@@ -106,12 +106,24 @@
|
||||
}
|
||||
|
||||
async function getBranches(installation: string, repo: string) {
|
||||
branchesList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: installation,
|
||||
providerRepositoryId: repo
|
||||
});
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
let total = 0;
|
||||
while (true) {
|
||||
const { branches, total: t } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: installation,
|
||||
providerRepositoryId: repo,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
total = t;
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
branchesList = { branches: allBranches, total };
|
||||
branchesList.branches = sortBranches(branchesList.branches);
|
||||
|
||||
selectedBranch = site?.providerBranch ?? branchesList.branches[0].name;
|
||||
@@ -120,13 +132,22 @@
|
||||
async function connect(selectedInstallationId: string, selectedRepository: string) {
|
||||
let nextBranch = site?.providerBranch ?? 'main';
|
||||
try {
|
||||
const branchList = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository
|
||||
});
|
||||
const sorted = sortBranches(branchList.branches);
|
||||
const allBranches = [];
|
||||
let offset = 0;
|
||||
const limit = 100;
|
||||
while (true) {
|
||||
const { branches, total } = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
});
|
||||
allBranches.push(...branches);
|
||||
if (allBranches.length >= total || branches.length < limit) break;
|
||||
offset += limit;
|
||||
}
|
||||
const sorted = sortBranches(allBranches);
|
||||
nextBranch =
|
||||
sorted.find((branch) => branch.name === site?.providerBranch)?.name ??
|
||||
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')?.name ??
|
||||
|
||||
Reference in new issue
Block a user