mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: active deployment is updated correctly
This commit is contained in:
1 parent
dcbc74da17
commit
42b91fba92
5 files changed
+35
-19
No files matched your search
@@ -25,15 +25,13 @@
|
||||
TableRow,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { execute, func, proxyRuleList } from './store';
|
||||
import { deploymentList, execute, func, proxyRuleList } from './store';
|
||||
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 { PageData } from './$types';
|
||||
import Delete from './delete.svelte';
|
||||
import Create from './create.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import Activate from './activate.svelte';
|
||||
import { calculateTime } from '$lib/helpers/timeConversion';
|
||||
@@ -43,7 +41,7 @@
|
||||
import DeploymentCreatedBy from './deploymentCreatedBy.svelte';
|
||||
import DeploymentDomains from './deploymentDomains.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
export let data;
|
||||
|
||||
let showDropdown = [];
|
||||
let showDelete = false;
|
||||
@@ -53,10 +51,6 @@
|
||||
let selectedDeployment: Models.Deployment = null;
|
||||
let activeDeployment: Models.Deployment = null;
|
||||
|
||||
onMount(async () => {
|
||||
activeDeployment = await getActiveDeployment();
|
||||
});
|
||||
|
||||
async function getActiveDeployment() {
|
||||
const list = await sdk.forProject.functions.listDeployments($page.params.function, [
|
||||
Query.equal('$id', $func?.deployment)
|
||||
@@ -67,6 +61,19 @@
|
||||
function handleActivate() {
|
||||
invalidate(Dependencies.DEPLOYMENTS);
|
||||
}
|
||||
|
||||
deploymentList.subscribe((list: Models.DeploymentList | null) => {
|
||||
if (list?.deployments) {
|
||||
let active = list.deployments.find((deployment) => deployment.$id === $func.deployment);
|
||||
if (!active) {
|
||||
getActiveDeployment().then((deployment) => {
|
||||
activeDeployment = deployment;
|
||||
});
|
||||
} else {
|
||||
activeDeployment = active;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -74,7 +81,7 @@
|
||||
<Heading tag="h2" size="5">Deployments</Heading>
|
||||
<Create main />
|
||||
</div>
|
||||
{#if data.deployments.total}
|
||||
{#if $deploymentList.total}
|
||||
<div class="common-section">
|
||||
<Heading tag="h3" size="7">Active</Heading>
|
||||
</div>
|
||||
@@ -131,10 +138,11 @@
|
||||
danger={status === 'failed'}
|
||||
warning={status === 'building'}
|
||||
success={status === 'ready'}>
|
||||
<span class="text u-trim"
|
||||
>{activeDeployment.status === 'ready'
|
||||
<span class="text u-trim">
|
||||
{activeDeployment.status === 'ready'
|
||||
? 'active'
|
||||
: activeDeployment.status}</span>
|
||||
: activeDeployment.status}
|
||||
</span>
|
||||
</Pill>
|
||||
</div>
|
||||
</div>
|
||||
@@ -186,12 +194,12 @@
|
||||
<div class="common-section">
|
||||
<Heading tag="h3" size="7">All</Heading>
|
||||
</div>
|
||||
{#if data.deployments.total > 0}
|
||||
{#if $deploymentList.total}
|
||||
<div class="u-margin-block-start-24">
|
||||
<TableScroll noMargin>
|
||||
<TableHeader>
|
||||
<TableCellHead width={150}>Deployment ID</TableCellHead>
|
||||
<TableCellHead width={80}>Status</TableCellHead>
|
||||
<TableCellHead width={90}>Status</TableCellHead>
|
||||
<TableCellHead width={80}>Source</TableCellHead>
|
||||
<TableCellHead width={180}>Updated</TableCellHead>
|
||||
<TableCellHead width={80}>Build Time</TableCellHead>
|
||||
@@ -199,7 +207,7 @@
|
||||
<TableCellHead width={40} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.deployments.deployments as deployment, index}
|
||||
{#each $deploymentList.deployments as deployment, index (deployment.$id)}
|
||||
{@const status = deployment.status}
|
||||
<TableRow>
|
||||
<TableCell width={150} title="Deployment ID">
|
||||
@@ -336,7 +344,7 @@
|
||||
name="Deployments"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.deployments.total} />
|
||||
total={$deploymentList.total} />
|
||||
</Container>
|
||||
|
||||
{#if selectedDeployment}
|
||||
|
||||
@@ -14,7 +14,7 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) =>
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
deployments: await sdk.forProject.functions.listDeployments(params.function, [
|
||||
deploymentList: await sdk.forProject.functions.listDeployments(params.function, [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc('')
|
||||
|
||||
@@ -35,7 +35,11 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal title="Activate Deployment" bind:show={showActivate} onSubmit={handleSubmit}>
|
||||
<Modal
|
||||
title="Activate Deployment"
|
||||
bind:show={showActivate}
|
||||
onSubmit={handleSubmit}
|
||||
headerDivider={false}>
|
||||
<p>Are you sure you want to activate this deployment?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showActivate = false)}>Cancel</Button>
|
||||
|
||||
+1
-1
@@ -25,8 +25,8 @@
|
||||
});
|
||||
trackEvent(Submit.FunctionRedeploy);
|
||||
|
||||
invalidate(Dependencies.DEPLOYMENTS);
|
||||
invalidate(Dependencies.FUNCTION);
|
||||
invalidate(Dependencies.DEPLOYMENTS);
|
||||
show = false;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
@@ -3,6 +3,10 @@ import { derived, writable, type Writable } from 'svelte/store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export const func = derived(page, ($page) => $page.data.function as Models.Function);
|
||||
export const deploymentList = derived(
|
||||
page,
|
||||
($page) => $page.data.deploymentList as Models.DeploymentList
|
||||
);
|
||||
export const proxyRuleList = derived(
|
||||
page,
|
||||
($page) => $page.data.proxyRuleList as Models.ProxyRuleList
|
||||
|
||||
Reference in new issue
Block a user