Skip to content
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
@@ -1,4 +1,4 @@
import { Query } from '@appwrite.io/console';
import { Query, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getQuery, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
Expand All @@ -15,17 +15,27 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) =>

const parsedQueries = queryParamToMap(query || '[]');
queries.set(parsedQueries);
let activeDeployment: Models.Deployment | null = null;
if (data.function.deploymentId) {
try {
activeDeployment = await sdk
.forProject(params.region, params.project)
.functions.getDeployment({
functionId: params.function,
deploymentId: data.function.deploymentId
});
} catch (error) {
// active deployment with the requested ID could not be found
activeDeployment = null;
}
}

return {
offset,
limit,
query,
installations: data.installations,
activeDeployment: data.function.deploymentId
? await sdk.forProject(params.region, params.project).functions.getDeployment({
functionId: params.function,
deploymentId: data.function.deploymentId
})
: null,
activeDeployment,
deploymentList: await sdk
.forProject(params.region, params.project)
.functions.listDeployments({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sdk } from '$lib/stores/sdk';
import { Dependencies } from '$lib/constants';
import { Query } from '@appwrite.io/console';
import { Query, type Models } from '@appwrite.io/console';
import { RuleType } from '$lib/stores/sdk';
import { DeploymentResourceType } from '$lib/stores/sdk';

Expand Down Expand Up @@ -46,11 +46,18 @@ export const load = async ({ params, depends, parent }) => {
})
]);

const deployment = deploymentList?.total
? await sdk
.forProject(params.region, params.project)
.sites.getDeployment({ siteId: params.site, deploymentId: site.deploymentId })
: null;
let deployment: Models.Deployment | null = null;
if (deploymentList?.total && site.deploymentId) {
try {
deployment = await sdk
.forProject(params.region, params.project)
.sites.getDeployment({ siteId: params.site, deploymentId: site.deploymentId });
} catch (error) {
// active deployment with the requested ID could not be found
deployment = null;
}
}

return {
site,
deploymentList,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Query } from '@appwrite.io/console';
import { Query, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getQuery, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
Expand Down Expand Up @@ -37,17 +37,24 @@ export const load = async ({ params, depends, url, route, parent }) => {
sdk.forProject(params.region, params.project).vcs.listInstallations()
]);

let activeDeployment: Models.Deployment | null = null;
if (site.deploymentId && deploymentList?.total) {
try {
activeDeployment = await sdk
.forProject(params.region, params.project)
.sites.getDeployment({ siteId: params.site, deploymentId: site.deploymentId });
} catch (error) {
// active deployment with the requested ID could not be found
activeDeployment = null;
}
}

return {
offset,
limit,
query,
deploymentList,
activeDeployment:
site.deploymentId && deploymentList?.total
? await sdk
.forProject(params.region, params.project)
.sites.getDeployment({ siteId: params.site, deploymentId: site.deploymentId })
: null,
activeDeployment,
installations
};
};