Skip to content

Add Sites waitlist functionality #1984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions src/lib/stores/waitlist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { get } from 'svelte/store';
import { user } from '$lib/stores/user';
import { sdk } from '$lib/stores/sdk';
const userPreferences = () => get(user)?.prefs;

export const joinWaitlistSites = () => {
const prefs = userPreferences();
const newPrefs = {
...prefs,
joinWaitlistSites: true
};

sdk.forConsole.account.updatePrefs(newPrefs);

if (sessionStorage) {
sessionStorage.setItem('joinWaitlistSites', 'true');
}
};

export const isOnWaitlistSites = (): boolean => {
const prefs = userPreferences();
const joinedInPrefs = 'joinWaitlistSites' in prefs;

let joinedInSession = false;
if (sessionStorage) {
joinedInSession = sessionStorage.getItem('joinWaitlistSites') === 'true';
}

return joinedInSession || joinedInPrefs;
};
10 changes: 7 additions & 3 deletions src/routes/(console)/project-[region]-[project]/sites/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import Breadcrumbs from './breadcrumbs.svelte';
import Header from './header.svelte';
import { Dependencies } from '$lib/constants';
import { isCloud } from '$lib/system';

export const load = async ({ depends }) => {
export const load = async ({ depends, parent }) => {
const { organization } = await parent();
depends(Dependencies.SITES);
const sitesLive = !isCloud || organization.$id === 'appwriteOfficials';

return {
header: Header,
breadcrumbs: Breadcrumbs
header: sitesLive ? Header : undefined,
breadcrumbs: Breadcrumbs,
sitesLive
};
};
50 changes: 41 additions & 9 deletions src/routes/(console)/project-[region]-[project]/sites/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
import { Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
import { isSmallViewport } from '$lib/stores/viewport';
import { isOnWaitlistSites, joinWaitlistSites } from '$lib/stores/waitlist';
import { addNotification } from '$lib/stores/notifications';

export let data;

let show = false;
let isOnWaitlist = isOnWaitlistSites();

$: $registerCommands([
{
Expand Down Expand Up @@ -68,6 +71,16 @@
? EmptyLightMobile
: EmptyLight;
$: imgClass = $isSmallViewport ? 'mobile' : 'desktop';

function addToWaitlist() {
joinWaitlistSites();
addNotification({
type: 'success',
title: 'Waitlist joined',
message: "We'll let you know as soon as Appwrite Sites is ready for you."
});
isOnWaitlist = true;
}
</script>

<Container>
Expand Down Expand Up @@ -120,18 +133,37 @@
<img src={imgSrc} alt="create" aria-hidden="true" height="242" class={imgClass} />

<Layout.Stack>
<Layout.Stack gap="m" alignItems="center">
{#if isOnWaitlist}
<Typography.Title size="s" align="center" color="--fgcolor-neutral-primary">
Appwrite Sites is in high demand
You've successfully joined the Sites waitlist
</Typography.Title>

<div style:max-width="600px">
<Typography.Text align="center" color="--fgcolor-neutral-secondary">
To ensure a smooth experience for everyone, we’re rolling out access
gradually.
</Typography.Text>
</div>
</Layout.Stack>
<Typography.Text align="center" color="--fgcolor-neutral-secondary">
We can't wait for you to try out Sites on Cloud. You will get access
soon.
</Typography.Text>
{:else}
<Layout.Stack gap="m" alignItems="center">
<Typography.Title
size="s"
align="center"
color="--fgcolor-neutral-primary">
Appwrite Sites is in high demand
</Typography.Title>

<div style:max-width="600px">
<Typography.Text align="center" color="--fgcolor-neutral-secondary">
To ensure a smooth experience for everyone, we’re rolling out
access gradually. Join the waitlist and be one of the first to
deploy with Sites.
</Typography.Text>
</div>

<div style:margin-block-start="1rem">
<Button on:click={addToWaitlist}>Join waitlist</Button>
</div>
</Layout.Stack>
{/if}
</Layout.Stack>
</Layout.Stack>
</Card.Base>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { Query, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getSearch, getView, pageToOffset, View } from '$lib/helpers/load';
import { CARD_LIMIT, Dependencies } from '$lib/constants';
import type { PageLoad } from './$types';

export const load: PageLoad = async ({ url, depends, route, params, parent }) => {
const { sitesLive } = await parent();

export const load = async ({ url, depends, route, params }) => {
depends(Dependencies.SITES);
const page = getPage(url);
const search = getSearch(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
const view = getView(url, route, View.Grid, View.Grid);

const sitesLive = false;

if (!sitesLive)
return {
sitesLive,
Expand Down