diff --git a/src/routes/console/project-[project]/functions/function-[function]/+layout.ts b/src/routes/console/project-[project]/functions/function-[function]/+layout.ts index e7362d9d8a..dd5c790811 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+layout.ts +++ b/src/routes/console/project-[project]/functions/function-[function]/+layout.ts @@ -14,8 +14,8 @@ export const load: LayoutLoad = async ({ params, depends }) => { return { header: Header, breadcrumbs: Breadcrumbs, - function: sdk.forProject.functions.get(params.function), - proxyRuleList: sdk.forProject.proxy.listRules([ + function: await sdk.forProject.functions.get(params.function), + proxyRuleList: await sdk.forProject.proxy.listRules([ Query.equal('resourceType', 'function'), Query.equal('resourceId', params.function), Query.limit(1) diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte index 6e686948ff..18f42e9d79 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -29,10 +29,9 @@ import { Container } from '$lib/layout'; import { app } from '$lib/stores/app'; import { calculateSize, humanFileSize } from '$lib/helpers/sizeConvertion'; - import { Query, type Models } from '@appwrite.io/console'; + import type { Models } from '@appwrite.io/console'; import Delete from './delete.svelte'; import Create from './create.svelte'; - import { sdk } from '$lib/stores/sdk'; import Activate from './activate.svelte'; import { calculateTime } from '$lib/helpers/timeConversion'; import { Pill } from '$lib/elements'; @@ -50,34 +49,10 @@ let showAlert = true; let selectedDeployment: Models.Deployment = null; - let activeDeployment: Models.Deployment = null; - - async function getActiveDeployment() { - if (!$func?.deployment) return null; - const list = await sdk.forProject.functions.listDeployments($page.params.function, [ - Query.equal('$id', $func.deployment) - ]); - return list?.deployments?.[0]; - } function handleActivate() { invalidate(Dependencies.DEPLOYMENTS); } - - deploymentList.subscribe((list: Models.DeploymentList | null) => { - if (list?.deployments) { - let activeDep = list.deployments.find( - (deployment) => deployment.$id === $func.deployment - ); - if (!activeDep) { - getActiveDeployment().then((deployment) => { - activeDeployment = deployment; - }); - } else { - activeDeployment = activeDep; - } - } - }); @@ -86,6 +61,7 @@ {#if $deploymentList?.total} + {@const activeDeployment = data.activeDeployment}
Active
@@ -113,8 +89,8 @@

Deployment ID

- - {$func.deployment} + + {activeDeployment.$id}
@@ -197,7 +173,6 @@ {/if} -
All
diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.ts b/src/routes/console/project-[project]/functions/function-[function]/+page.ts index d09a6161f5..1d85970ce8 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.ts +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.ts @@ -5,7 +5,7 @@ import { Dependencies, PAGE_LIMIT } from '$lib/constants'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ params, depends, url, route, parent }) => { - await parent(); + const data = await parent(); depends(Dependencies.DEPLOYMENTS); const page = getPage(url); const limit = getLimit(url, route, PAGE_LIMIT); @@ -14,6 +14,12 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) => return { offset, limit, + activeDeployment: data.function.deployment + ? await sdk.forProject.functions.getDeployment( + params.function, + data.function.deployment + ) + : null, deploymentList: await sdk.forProject.functions.listDeployments(params.function, [ Query.limit(limit), Query.offset(offset),