From b15d7cbb56a0b9cfd2d771ea79b1bd395c3df6da Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 13 Nov 2024 15:30:44 +0100 Subject: [PATCH] feat: deployments --- src/lib/components/emptyFilter.svelte | 40 +-- src/lib/components/emptySearch.svelte | 2 +- src/lib/components/filters/filters.svelte | 15 +- src/lib/components/viewSelector.svelte | 1 + src/lib/elements/forms/button.svelte | 2 +- .../sites/site-[site]/breadcrumbs.svelte | 5 + .../site-[site]/deployments/+layout.svelte | 153 ++++++++++ .../sites/site-[site]/deployments/+layout.ts | 28 ++ .../site-[site]/deployments/+page.svelte | 198 ++++++++++++ .../sites/site-[site]/deployments/+page.ts | 32 ++ .../site-[site]/deployments/cancel.svelte | 49 +++ .../site-[site]/deployments/delete.svelte | 49 +++ .../deployment-[deployment]/+page.svelte | 36 +++ .../deployment-[deployment]/+page.ts | 13 + .../deployment-[deployment]/store.ts | 5 + .../deployments/deploymentCard.svelte | 121 ++++++++ .../deployments/deploymentCreatedBy.svelte | 14 + .../deployments/deploymentDomains.svelte | 38 +++ .../deployments/deploymentSource.svelte | 38 +++ .../deployments/quickFilters.svelte | 281 ++++++++++++++++++ .../deployments/redeployModal.svelte | 56 ++++ .../sites/site-[site]/deployments/store.ts | 25 ++ .../site-[site]/deployments/table.svelte | 196 ++++++++++++ 23 files changed, 1369 insertions(+), 28 deletions(-) create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/+layout.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/+layout.ts create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.ts create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/cancel.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/delete.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.ts create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/store.ts create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCreatedBy.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentDomains.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentSource.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/quickFilters.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/redeployModal.svelte create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/store.ts create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/table.svelte diff --git a/src/lib/components/emptyFilter.svelte b/src/lib/components/emptyFilter.svelte index 6e13c0cd8c..41b7fcccae 100644 --- a/src/lib/components/emptyFilter.svelte +++ b/src/lib/components/emptyFilter.svelte @@ -1,26 +1,28 @@ - -
-
- Sorry, we couldn't find any {resource}. -

There are no {resource} that match your filters.

-
-
- -
-
-
+ + + + + + + + + + diff --git a/src/lib/components/emptySearch.svelte b/src/lib/components/emptySearch.svelte index 151ddcdc73..5a0b7e00dd 100644 --- a/src/lib/components/emptySearch.svelte +++ b/src/lib/components/emptySearch.svelte @@ -9,7 +9,7 @@ diff --git a/src/lib/components/filters/filters.svelte b/src/lib/components/filters/filters.svelte index af3920fff6..c6e64f47d7 100644 --- a/src/lib/components/filters/filters.svelte +++ b/src/lib/components/filters/filters.svelte @@ -158,13 +158,13 @@ {/if}
{#if singleCondition} - + {:else} - {/if} - +
@@ -174,7 +174,7 @@
- + {:else} - + {/if} - +
diff --git a/src/lib/components/viewSelector.svelte b/src/lib/components/viewSelector.svelte index d0d69ed658..83779794b5 100644 --- a/src/lib/components/viewSelector.svelte +++ b/src/lib/components/viewSelector.svelte @@ -78,6 +78,7 @@ {#if $columns?.length} + {#if $tags?.length} + +
+
+ + {/if} + + + + + +
+ + + + + +
+ + + + + + More filters + + + + +
+
+ {#if $deploymentList.total} + + {:else if data?.query} + + {/if} + + + + +{#if selectedDeployment} + +{/if} diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.ts b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.ts new file mode 100644 index 0000000000..aad33a0ee1 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.ts @@ -0,0 +1,32 @@ +import { Query } 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'; +import type { PageLoad } from './$types'; +import { queries, queryParamToMap } from '$lib/components/filters'; + +export const load: PageLoad = async ({ params, depends, url, route, parent }) => { + const data = await parent(); + depends(Dependencies.DEPLOYMENTS); + const page = getPage(url); + const limit = getLimit(url, route, PAGE_LIMIT); + const offset = pageToOffset(page, limit); + const query = getQuery(url); + + const parsedQueries = queryParamToMap(query || '[]'); + queries.set(parsedQueries); + return { + offset, + limit, + query, + activeDeployment: data.site.deploymentId + ? await sdk.forProject.sites.getDeployment(params.site, data.site.deploymentId) + : null, + deploymentList: await sdk.forProject.sites.listDeployments(params.site, [ + Query.limit(limit), + Query.offset(offset), + Query.orderDesc(''), + ...parsedQueries.values() + ]) + }; +}; diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/cancel.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/cancel.svelte new file mode 100644 index 0000000000..77f91bca23 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/cancel.svelte @@ -0,0 +1,49 @@ + + + +

Are you sure you want to cancel this deployment?

+ + + + +
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/delete.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/delete.svelte new file mode 100644 index 0000000000..b0b9ce6bf3 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/delete.svelte @@ -0,0 +1,49 @@ + + + +

Are you sure you want to delete this deployment?

+ + + + +
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.svelte new file mode 100644 index 0000000000..456ed16e28 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.svelte @@ -0,0 +1,36 @@ + + + diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.ts b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.ts new file mode 100644 index 0000000000..a50f78e131 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/+page.ts @@ -0,0 +1,13 @@ +import { sdk } from '$lib/stores/sdk'; +import { Dependencies } from '$lib/constants'; +import type { PageLoad } from './$types'; + +export const load: PageLoad = async ({ params, depends }) => { + depends(Dependencies.DEPLOYMENT); + + const deployment = await sdk.forProject.sites.getDeployment(params.site, params.deployment); + + return { + deployment + }; +}; diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/store.ts b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/store.ts new file mode 100644 index 0000000000..337a6b456e --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deployment-[deployment]/store.ts @@ -0,0 +1,5 @@ +import { page } from '$app/stores'; +import type { Models } from '@appwrite.io/console'; +import { derived } from 'svelte/store'; + +export const deployment = derived(page, ($page) => $page.data.deployment as Models.Deployment); diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte new file mode 100644 index 0000000000..e304a32ce1 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte @@ -0,0 +1,121 @@ + + + +
+ +
+

Deployment ID

+ + + {deployment.$id} + +
+
+ + {@const status = deployment.status} + {@const deploymentSize = humanFileSize(deployment.size)} + {@const buildSize = humanFileSize(deployment.buildSize)} + {@const totalSize = humanFileSize(deployment.buildSize + deployment.size)} +
    +
  • +

    Status

    + + + + +
  • +
  • +

    Build time

    +

    + {calculateTime(deployment.buildTime)} +

    +
  • +
  • +

    Total size

    +

    + {totalSize.value + totalSize.unit} + +

    +
  • +
  • +

    Updated

    +

    + +

    +
  • +
+ +
+

Source

+
+ +
+
+ + {#if $proxyRuleList?.rules?.length} +
+

Domains

+ +
+ {/if} +
+ + + + +
+ + diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCreatedBy.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCreatedBy.svelte new file mode 100644 index 0000000000..15e429722e --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCreatedBy.svelte @@ -0,0 +1,14 @@ + + +{timeFromNow(deployment.$updatedAt)} +{#if deployment.providerCommitAuthor} + by {deployment.providerCommitAuthor} +{/if} diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentDomains.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentDomains.svelte new file mode 100644 index 0000000000..bd441f17c7 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentDomains.svelte @@ -0,0 +1,38 @@ + + +
+ + + + {domain.rules[0].domain} + + + + {#if domain.rules.length > 1} + + (showDropdown = !showDropdown)}> + +{domain.rules.length - 1} + + + {#each domain.rules as rule, i} + {#if i !== 0} + + {rule.domain} + + {/if} + {/each} + + + {/if} +
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentSource.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentSource.svelte new file mode 100644 index 0000000000..0c5b765de1 --- /dev/null +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentSource.svelte @@ -0,0 +1,38 @@ + + +{#if deployment.type === 'vcs'} + + + + + {deployment.providerRepositoryOwner}/{deployment.providerRepositoryName} + + + {deployment.providerBranch} + + {#if deployment?.providerCommitMessage && deployment?.providerCommitHash && deployment?.providerCommitUrl} + + + {deployment?.providerCommitHash?.substring(0, 7)} + {deployment.providerCommitMessage} + + + {/if} + + +{:else if deployment.type === 'manual'} +