diff --git a/src/lib/helpers/waitlist.ts b/src/lib/helpers/waitlist.ts new file mode 100644 index 000000000..773b04a24 --- /dev/null +++ b/src/lib/helpers/waitlist.ts @@ -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; +}; diff --git a/src/routes/(console)/project-[region]-[project]/sites/(images)/empty-sites-dark-mobile.svg b/src/routes/(console)/project-[region]-[project]/sites/(images)/empty-sites-dark-mobile.svg new file mode 100644 index 000000000..39c7917cf --- /dev/null +++ b/src/routes/(console)/project-[region]-[project]/sites/(images)/empty-sites-dark-mobile.svg @@ -0,0 +1,119 @@ + + +
+ + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/routes/(console)/project-[region]-[project]/sites/(images)/empty-sites-light-mobile.svg b/src/routes/(console)/project-[region]-[project]/sites/(images)/empty-sites-light-mobile.svg new file mode 100644 index 000000000..8bd4b239e --- /dev/null +++ b/src/routes/(console)/project-[region]-[project]/sites/(images)/empty-sites-light-mobile.svg @@ -0,0 +1,157 @@ + + +
+ + + + +
+
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/routes/(console)/project-[region]-[project]/sites/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/+page.svelte index 855274fa4..c8b85bdc9 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/+page.svelte @@ -11,12 +11,14 @@ import { isServiceLimited } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; import { canWriteSites } from '$lib/stores/roles.js'; - import { Icon, Layout } from '@appwrite.io/pink-svelte'; + import { Card, Icon, Layout, Typography } from '@appwrite.io/pink-svelte'; import { Button } from '$lib/elements/forms'; import { app } from '$lib/stores/app'; import CreateSiteModal from './createSiteModal.svelte'; import EmptyLight from './(images)/empty-sites-light.svg'; import EmptyDark from './(images)/empty-sites-dark.svg'; + import EmptyLightMobile from './(images)/empty-sites-light-mobile.svg'; + import EmptyDarkMobile from './(images)/empty-sites-dark-mobile.svg'; import Grid from './grid.svelte'; import { IconPlus } from '@appwrite.io/pink-icons-svelte'; import { columns } from './store'; @@ -26,6 +28,10 @@ import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; + import { APPWRITE_OFFICIALS_ORG, isCloud } from '$lib/system'; + import { addNotification } from '$lib/stores/notifications'; + import { isOnWaitlistSites, joinWaitlistSites } from '$lib/helpers/waitlist'; + import { isSmallViewport } from '$lib/stores/viewport'; export let data; let show = false; @@ -37,6 +43,7 @@ }, keys: ['c'], disabled: + !showSites || isServiceLimited('sites', $organization?.billingPlan, data.siteList?.total) || !$canWriteSites, icon: IconPlus, @@ -53,46 +60,126 @@ } }); }); + + /** + * Controls visibility of Sites feature: + * - Shown if running on self-hosted + * - Shown on cloud only if the organization is Appwrite's. + * - Hidden on cloud for any non-Appwrite organization. + */ + $: showSites = !isCloud || $organization.$id === APPWRITE_OFFICIALS_ORG; + + $: isOnWaitlist = isOnWaitlistSites(); + + const isDark = $app.themeInUse === 'dark'; + const isMobile = $isSmallViewport; + + const imgSrc = isDark + ? isMobile + ? EmptyDarkMobile + : EmptyDark + : isMobile + ? EmptyLightMobile + : EmptyLight; + + const imgClass = isMobile ? '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; + } - - - + {#if showSites} + + + + + + + {#if $canWriteSites} + + {/if} + - - - {#if $canWriteSites} - + {#if data.siteList.total} + {#if data.view === View.Grid} + + {:else} + {/if} - - - {#if data.siteList.total} - {#if data.view === View.Grid} - + + {:else if data.search} + {:else} -
+ (show = true)}> + {/if} - - {:else if data.search} - {:else} - (show = true)}> - + + + + + + {#if isOnWaitlist} + + You've successfully joined the Sites waitlist + + + + We can't wait for you to try out Sites on Cloud. You will get access + soon. + + {:else} + + + Appwrite Sites is in high demand + + +
+ + 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. + +
+ +
+ +
+
+ {/if} +
+
+
{/if} diff --git a/src/routes/(console)/project-[region]-[project]/sites/+page.ts b/src/routes/(console)/project-[region]-[project]/sites/+page.ts index 62eeb026a..7e6fd0ceb 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/+page.ts +++ b/src/routes/(console)/project-[region]-[project]/sites/+page.ts @@ -2,8 +2,16 @@ import { Query } 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 { APPWRITE_OFFICIALS_ORG, isCloud } from '$lib/system'; +import { organization } from '$lib/stores/organization'; +import { get } from 'svelte/store'; export const load = async ({ url, depends, route, params }) => { + // don't load anything on cloud unless org is appwrite atm! + if (isCloud && get(organization)?.$id !== APPWRITE_OFFICIALS_ORG) { + return; + } + depends(Dependencies.SITES); const page = getPage(url); diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/+layout.ts b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/+layout.ts index 491697969..a90375ffd 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/+layout.ts +++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/+layout.ts @@ -2,9 +2,18 @@ import Breadcrumbs from './breadcrumbs.svelte'; import Header from './header.svelte'; import { Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; -import { error } from '@sveltejs/kit'; +import { error, redirect } from '@sveltejs/kit'; +import { APPWRITE_OFFICIALS_ORG, isCloud } from '$lib/system'; +import { organization } from '$lib/stores/organization'; +import { get } from 'svelte/store'; +import { base } from '$app/paths'; export const load = async ({ depends, params }) => { + // don't load anything on cloud unless org is appwrite atm! + if (isCloud && get(organization)?.$id !== APPWRITE_OFFICIALS_ORG) { + redirect(307, `${base}/project-${params.region}-${params.project}/sites`); + } + depends(Dependencies.SITE); try { const [site] = await Promise.all([