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
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
}
});
</script>

<Container>
Expand All @@ -86,6 +61,7 @@
<Create main />
</div>
{#if $deploymentList?.total}
{@const activeDeployment = data.activeDeployment}
<div class="common-section">
<Heading tag="h3" size="7">Active</Heading>
</div>
Expand Down Expand Up @@ -113,8 +89,8 @@
<div class="u-grid-equal-row-size u-gap-4 u-line-height-1">
<p><b>Deployment ID</b></p>

<Id value={$func.deployment}>
{$func.deployment}
<Id value={activeDeployment.$id}>
{activeDeployment.$id}
</Id>
</div>
</div>
Expand Down Expand Up @@ -197,7 +173,6 @@
</div>
</Empty>
{/if}

<div class="common-section">
<Heading tag="h3" size="7">All</Heading>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down