Skip to content

Commit

Permalink
feat: deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmanNik committed Nov 13, 2024
1 parent b0bb470 commit b15d7cb
Show file tree
Hide file tree
Showing 23 changed files with 1,369 additions and 28 deletions.
40 changes: 21 additions & 19 deletions src/lib/components/emptyFilter.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<script lang="ts">
import { Card, Empty, Layout } from '@appwrite.io/pink-svelte';
import { Button } from '$lib/elements/forms';
import { EmptySearch } from '.';
import { queries } from './filters';
export let resource: string;
</script>

<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<b class="body-text-2 u-bold">Sorry, we couldn't find any {resource}.</b>
<p>There are no {resource} that match your filters.</p>
</div>
<div class="u-flex common-section u-main-center">
<Button
secondary
on:click={() => {
queries.clearAll();
queries.apply();
}}>
Clear filters
</Button>
</div>
</div>
</EmptySearch>
<Card.Base padding="none">
<Empty
title={`Sorry, we couldn't find any ${resource}`}
description={`There are no ${resource} that match your filters.`}
type="secondary">
<svelte:fragment slot="actions">
<Layout.Stack direction="row" justifyContent="center">
<Button
secondary
on:click={() => {
queries.clearAll();
queries.apply();
}}>
Clear filters
</Button>
<slot />
</Layout.Stack>
</svelte:fragment>
</Empty>
</Card.Base>
2 changes: 1 addition & 1 deletion src/lib/components/emptySearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<Card.Base padding="none">
<Empty
title={`Sorry, we couldn't find ‘${search}’`}
title={`Sorry, we couldn't find ${search ? `‘${search}’` : `any ${target}`}`}
description={`There are no ${target} that match your search.`}
type="secondary">
<svelte:fragment slot="actions">
Expand Down
15 changes: 8 additions & 7 deletions src/lib/components/filters/filters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@
{/if}
<div class="u-flex u-gap-8">
{#if singleCondition}
<Button text on:click={toggleDropdown}>Cancel</Button>
<Button size="s" text on:click={toggleDropdown}>Cancel</Button>
{:else}
<Button disabled={applied === 0} text on:click={clearAll}>
<Button size="s" disabled={applied === 0} text on:click={clearAll}>
Clear all
</Button>
{/if}
<Button on:click={apply} disabled={isButtonDisabled}>Apply</Button>
<Button size="s" on:click={apply} disabled={isButtonDisabled}>Apply</Button>
</div>
</div>
</div>
Expand All @@ -174,7 +174,7 @@

<div class="is-only-mobile">
<slot name="mobile" {disabled} toggle={toggleMobileModal}>
<Button secondary on:click={toggleMobileModal} {fullWidthMobile}>
<Button size="s" secondary on:click={toggleMobileModal} {fullWidthMobile}>
<i class="icon-filter u-opacity-50" />
Filters
{#if applied > 0}
Expand Down Expand Up @@ -219,11 +219,12 @@
{/if}
<div class="u-flex u-gap-8">
{#if singleCondition}
<Button text on:click={() => (showFiltersMobile = false)}>Cancel</Button>
<Button size="s" text on:click={() => (showFiltersMobile = false)}
>Cancel</Button>
{:else}
<Button text on:click={clearAll}>Clear all</Button>
<Button size="s" text on:click={clearAll}>Clear all</Button>
{/if}
<Button on:click={apply} disabled={isButtonDisabled}>Apply</Button>
<Button size="s" on:click={apply} disabled={isButtonDisabled}>Apply</Button>
</div>
</div>
</svelte:fragment>
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/viewSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
{#if $columns?.length}
<DropList bind:show={showSelectColumns} scrollable wrapperFullWidth={fullWidthMobile}>
<Button
size="s"
secondary
on:click={() => (showSelectColumns = !showSelectColumns)}
{fullWidthMobile}>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/elements/forms/button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
export let danger = false;
export let icon = false;
export let link = false;
export let size: Props['size'] = 'medium';
export let size: Props['size'] = 'm';
export let disabled = false;
export let external = false;
export let href: string = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Breadcrumbs } from '$lib/layout';
import { organization } from '$lib/stores/organization';
import { project } from '../../store';
Expand All @@ -16,6 +17,10 @@
{
href: `${base}/project-${$project?.$id}/sites`,
title: 'Sites'
},
{
href: `${base}/project-${$project?.$id}/sites/site-${$page.params.site}`,
title: $page.params.site
}
];
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { sdk } from '$lib/stores/sdk';
import { Dependencies } from '$lib/constants';
import { invalidate, goto } from '$app/navigation';
import { registerCommands } from '$lib/commandCenter';
import { project } from '../../../store';
import type { Models } from '@appwrite.io/console';
import { base } from '$app/paths';
import { canWriteSites } from '$lib/stores/roles';
onMount(() => {
let previousStatus = null;
return sdk.forConsole.client.subscribe<Models.Deployment>('console', (message) => {
if (previousStatus === message.payload.status) {
return;
}
previousStatus = message.payload.status;
if (message.events.includes('sites.*.deployments.*.create')) {
invalidate(Dependencies.DEPLOYMENTS);
return;
}
if (message.events.includes('sites.*.deployments.*.update')) {
invalidate(Dependencies.DEPLOYMENTS);
invalidate(Dependencies.FUNCTION);
return;
}
if (message.events.includes('sites.*.deployments.*.delete')) {
invalidate(Dependencies.DEPLOYMENTS);
return;
}
});
});
$: $registerCommands([
{
label: 'Create deployment',
async callback() {
if (!$page.url.pathname.endsWith($page.params.site)) {
await goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}`);
}
},
keys: $page.url.pathname.endsWith($page.params.site) ? ['c'] : ['c', 'd'],
group: 'functions',
icon: 'plus',
disabled: !$canWriteSites
},
{
label: 'Permissions',
async callback() {
await goto(
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#permissions`
);
scrollBy({ top: -100 });
},
icon: 'search',
group: 'functions',
disabled: !$canWriteSites
},
{
label: 'Events',
async callback() {
await goto(
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#events`
);
scrollBy({ top: -100 });
},
icon: 'calendar',
group: 'functions',
disabled: !$canWriteSites
},
{
label: 'Variables',
async callback() {
await goto(
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#variables`
);
},
icon: 'list',
group: 'functions',
disabled: !$canWriteSites
},
{
label: 'Timeout',
callback() {
goto(
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#timeout`
);
},
icon: 'x-circle',
group: 'functions',
disabled: !$canWriteSites
},
{
label: 'Schedule',
async callback() {
await goto(
`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings#schedule`
);
scrollBy({ top: -100 });
},
icon: 'clock',
group: 'functions',
disabled: !$canWriteSites
},
{
label: 'Go to deployments',
callback() {
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}`);
},
keys: ['g', 'd'],
group: 'navigation',
rank: 10,
disabled: $page.url.pathname.endsWith($page.params.site)
},
{
label: 'Go to usage',
callback() {
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}/usage`);
},
keys: ['g', 'u'],
group: 'navigation',
rank: 10,
disabled: $page.url.pathname.endsWith('usage')
},
{
label: 'Go to executions',
callback() {
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}/executions`);
},
keys: ['g', 'e'],
group: 'navigation',
rank: 10,
disabled: $page.url.pathname.endsWith('executions')
},
{
label: 'Go to settings',
callback() {
goto(`${base}/project-${$project.$id}/sites/site-${$page.params.site}/settings`);
},
keys: ['g', 's'],
group: 'navigation',
rank: 10,
disabled: $page.url.pathname.endsWith('settings') || !$canWriteSites
}
]);
</script>

<slot />
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { sdk } from '$lib/stores/sdk';
import { Dependencies } from '$lib/constants';
import type { LayoutLoad } from './$types';
import { error } from '@sveltejs/kit';
import { Query } from '@appwrite.io/console';

export const load: LayoutLoad = async ({ params, depends }) => {
depends(Dependencies.SITE);
depends(Dependencies.DEPLOYMENTS);

try {
const [site, proxyRuleList] = await Promise.all([
sdk.forProject.sites.get(params.site),
sdk.forProject.proxy.listRules([
Query.equal('resourceType', 'sites'),
Query.equal('resourceId', params.site),
Query.limit(1)
])
]);

return {
site,
proxyRuleList
};
} catch (e) {
error(e.code, e.message);
}
};
Loading

0 comments on commit b15d7cb

Please sign in to comment.