Merge branch 'main' into mgn-dv

# Conflicts:
#	Dockerfile
#	docker/nginx.conf
#	package.json
#	pnpm-lock.yaml
#	src/hooks.client.ts
#	src/lib/components/breadcrumbs.svelte
#	src/lib/components/filePicker.svelte
#	src/lib/components/index.ts
#	src/lib/layout/activity.svelte
#	src/lib/layout/cover.svelte
#	src/lib/layout/coverTitle.svelte
#	src/lib/stores/sdk.ts
#	src/lib/system.ts
#	src/routes/(console)/+layout.svelte
#	src/routes/(console)/onboarding/create-project/+page.svelte
#	src/routes/(console)/organization-[organization]/+page.svelte
#	src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte
#	src/routes/(console)/organization-[organization]/header.svelte
#	src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
#	src/routes/(console)/organization-[organization]/wizard/store.ts
#	src/routes/(console)/project-[project]/auth/user-[user]/sessions/+page.svelte
#	src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+page.svelte
#	src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/header.svelte
#	src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/file-[file]/manageFileToken.svelte
#	src/routes/+page.ts
This commit is contained in:
ernstmul committed 2025-06-02 06:08:20 +02:00
commit 8df2f2791c
1022 files changed
+11729 -11688

No files matched your search

+3 -1
View File
@@ -1,4 +1,6 @@
PUBLIC_APPWRITE_ENDPOINT=https://localhost/v1
PUBLIC_CONSOLE_MODE=self-hosted
PUBLIC_APPWRITE_MULTI_REGION=false
PUBLIC_APPWRITE_ENDPOINT=http://localhost/v1
PUBLIC_STRIPE_KEY=
PUBLIC_GROWTH_ENDPOINT=
+41
View File
@@ -39,6 +39,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"PUBLIC_CONSOLE_MODE=cloud"
"PUBLIC_APPWRITE_MULTI_REGION=true"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY }}"
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
@@ -77,6 +78,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"PUBLIC_CONSOLE_MODE=cloud"
"PUBLIC_APPWRITE_MULTI_REGION=true"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
publish-self-hosted:
@@ -113,4 +115,43 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"PUBLIC_CONSOLE_MODE=self-hosted"
"PUBLIC_APPWRITE_MULTI_REGION=false"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
publish-cloud-no-regions:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: appwrite/console-cloud-no-regions
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"PUBLIC_CONSOLE_MODE=cloud"
"PUBLIC_APPWRITE_MULTI_REGION=false"
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
+2
View File
@@ -21,6 +21,7 @@ ADD ./src /app/src
ADD ./static /app/static
ARG PUBLIC_CONSOLE_MODE
ARG PUBLIC_APPWRITE_MULTI_REGION
ARG PUBLIC_APPWRITE_ENDPOINT
ARG PUBLIC_GROWTH_ENDPOINT
ARG PUBLIC_STRIPE_KEY
@@ -31,6 +32,7 @@ ARG SENTRY_RELEASE
ENV PUBLIC_APPWRITE_ENDPOINT=$PUBLIC_APPWRITE_ENDPOINT
ENV PUBLIC_GROWTH_ENDPOINT=$PUBLIC_GROWTH_ENDPOINT
ENV PUBLIC_CONSOLE_MODE=$PUBLIC_CONSOLE_MODE
ENV PUBLIC_APPWRITE_MULTI_REGION=$PUBLIC_APPWRITE_MULTI_REGION
ENV PUBLIC_STRIPE_KEY=$PUBLIC_STRIPE_KEY
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_RELEASE=$SENTRY_RELEASE
+1
View File
@@ -24,6 +24,7 @@ async function main() {
log(bold().magenta('APPWRITE CONSOLE'));
log();
logEnv('CONSOLE MODE', env?.PUBLIC_CONSOLE_MODE);
logEnv('MULTI REGION', env?.PUBLIC_APPWRITE_MULTI_REGION);
logEnv('APPWRITE ENDPOINT', env?.PUBLIC_APPWRITE_ENDPOINT, 'relative');
logEnv('GROWTH ENDPOINT', env?.PUBLIC_GROWTH_ENDPOINT);
log();
+2
View File
@@ -5,6 +5,7 @@ services:
context: .
args:
PUBLIC_CONSOLE_MODE: ${PUBLIC_CONSOLE_MODE}
PUBLIC_APPWRITE_MULTI_REGION: ${PUBLIC_APPWRITE_MULTI_REGION}
PUBLIC_APPWRITE_ENDPOINT: ${PUBLIC_APPWRITE_ENDPOINT}
PUBLIC_GROWTH_ENDPOINT: ${PUBLIC_GROWTH_ENDPOINT}
PUBLIC_STRIPE_KEY: ${PUBLIC_STRIPE_KEY}
@@ -21,6 +22,7 @@ services:
- build/
environment:
- PUBLIC_CONSOLE_MODE
- PUBLIC_APPWRITE_MULTI_REGION
- PUBLIC_APPWRITE_ENDPOINT
- PUBLIC_GROWTH_ENDPOINT
- PUBLIC_STRIPE_KEY
+13 -7
View File
@@ -2,22 +2,17 @@ server {
listen 80;
server_name localhost;
# serve compressed file if filename.gz exists
gzip_static on;
# serve static files from root directory
root /usr/share/nginx/html;
# deny IE browsers from going into quirks mode
# Security headers for all locations
add_header X-UA-Compatible "IE=Edge";
# X-Frame-Options is to prevent from clickJacking attack
add_header X-Frame-Options SAMEORIGIN;
# this header enables the Cross-site scripting (XSS) filter
add_header X-XSS-Protection "1; mode=block;";
# disable content-type sniffing on some browsers.
add_header X-Content-Type-Options nosniff;
# only cache files in /console/_app/immutable/
# Only cache files in /console/_app/immutable/ for 1 year
location /console/_app/immutable/ {
try_files $uri =404;
@@ -26,9 +21,20 @@ server {
add_header Cache-Control "public";
}
# Cache, but revalidate, for images, css, fonts, and icons folders
location ~* ^/console/(images|css|fonts|icons)/ {
expires 1d;
add_header Cache-Control "public, must-revalidate";
}
# All other /console requests (no cache)
location /console {
index index.html index.html;
try_files $uri /console/index.html;
expires 0;
add_header Cache-Control "no-cache, no-store";
add_header Pragma "no-cache";
}
location / {
+1 -1
View File
@@ -12,7 +12,7 @@ export function getOrganizationIdFromUrl(pathname: string) {
export function getProjectIdFromUrl(pathname: string) {
// TODO: use base path from svelte here
const regex = /\/console\/project-([^/]+)(\/.*)?/;
const regex = /\/console\/project-(?:[a-z]{2,3}-)?([^/]+)(\/.*)?/;
const match = pathname.match(regex);
if (match) {
+2 -2
View File
@@ -8,12 +8,12 @@ test('upgrade - free tier', async ({ page }) => {
await createFreeProject(page);
await test.step('upgrade project', async () => {
await page.getByRole('link', { name: 'Upgrade', exact: true }).click();
await page.waitForURL('./organization-**/change-plan');
await page.waitForURL(/\/organization-[^/]+\/change-plan/);
await page.locator('input[value="tier-1"]').click();
await page.getByRole('button', { name: 'add' }).first().click();
await enterCreditCard(page);
// skip members
await page.getByRole('button', { name: 'change plan' }).click();
await page.waitForURL('**/console/project-*/overview/platforms');
await page.waitForURL(/\/console\/project-(?:[a-z0-9]+-)?([^/]+)\/get-started/);
});
});
+2 -3
View File
@@ -10,7 +10,6 @@ export function registerUserStep(page: Page): Promise<Metadata> {
return test.step('register user', async () => {
const seed = crypto.randomUUID();
await page.goto('./register');
// await page.getByRole('button', { name: 'only required' }).click();
const inputs = {
name: page.locator('id=name'),
email: page.locator('id=email'),
@@ -25,9 +24,9 @@ export function registerUserStep(page: Page): Promise<Metadata> {
await inputs.name.fill(values.name);
await inputs.email.fill(values.email);
await inputs.password.fill(values.password);
await inputs.terms.check();
await inputs.terms.check({ force: true });
await page.getByRole('button', { name: 'Sign up', exact: true }).click();
await page.waitForURL('./onboarding');
await page.waitForURL('./onboarding/create-project');
return values;
});
+7 -12
View File
@@ -9,23 +9,18 @@ type Metadata = {
export async function createFreeProject(page: Page): Promise<Metadata> {
const organizationId = await test.step('create organization', async () => {
await page.goto('./');
await page.waitForURL('./onboarding');
await page.locator('id=name').fill('test org');
await page.locator('id=plan').selectOption('tier-0');
await page.getByRole('button', { name: 'get started' }).click();
await page.waitForURL('./organization-**');
await page.waitForURL(/\/organization-[^/]+/);
return getOrganizationIdFromUrl(page.url());
});
const projectId = await test.step('create project', async () => {
await page.waitForURL('./organization-**');
await page.waitForURL(/\/organization-[^/]+/);
await page.getByRole('button', { name: 'create project' }).first().click();
await page.locator('id=name').fill('test project');
await page.getByRole('button', { name: 'next' }).click();
await page.locator('label').filter({ hasText: 'Frankfurt' }).click();
await page.getByRole('button', { name: 'create' }).click();
await page.waitForURL('./project-**/overview/platforms');
expect(page.url()).toContain('/console/project-');
const dialog = page.locator('dialog[open]');
await dialog.getByPlaceholder('Project name').fill('test project');
await dialog.getByRole('button', { name: 'create' }).click();
await page.waitForURL(/\/project-fra-[^/]+/);
expect(page.url()).toContain('/console/project-fra-');
return getProjectIdFromUrl(page.url());
});
+12 -14
View File
@@ -19,7 +19,7 @@ export async function enterCreditCard(page: Page) {
await stripe.locator('id=Field-expiryInput').fill('1250');
await stripe.locator('id=Field-cvcInput').fill('123');
await stripe.locator('id=Field-countryInput').selectOption('DE');
await page.getByRole('button', { name: 'Add', exact: true }).click();
await dialog.getByRole('button', { name: 'Add', exact: true }).click();
await dialog.waitFor({
state: 'hidden'
});
@@ -27,30 +27,28 @@ export async function enterCreditCard(page: Page) {
export async function createProProject(page: Page): Promise<Metadata> {
const organizationId = await test.step('create organization', async () => {
await page.goto('./');
await page.waitForURL('./onboarding');
await page.goto('./create-organization');
await page.locator('id=name').fill('test org');
await page.locator('id=plan').selectOption('tier-1');
await page.getByRole('button', { name: 'get started' }).click();
await page.waitForURL('./create-organization**');
await page.getByRole('radio', { name: /^Pro\b/ }).check();
// `create organization` because there's already free created on start!
await page.getByRole('button', { name: 'create organization' }).click();
await page.getByRole('button', { name: 'add' }).first().click();
await enterCreditCard(page);
// skip members
await page.getByRole('button', { name: 'create organization' }).click();
await page.waitForURL('./organization-**');
await page.waitForURL(/\/organization-[^/]+/);
return getOrganizationIdFromUrl(page.url());
});
const projectId = await test.step('create project', async () => {
await page.waitForURL('./organization-**');
await page.waitForURL(/\/organization-[^/]+/);
await page.getByRole('button', { name: 'create project' }).first().click();
await page.getByPlaceholder('project name').fill('test project');
await page.getByRole('button', { name: 'next' }).click();
await page.locator('label').filter({ hasText: 'frankfurt' }).click();
await page.getByRole('button', { name: 'create' }).click();
await page.waitForURL('./project-**/overview/platforms');
expect(page.url()).toContain('/project-');
const dialog = page.locator('dialog[open]');
await dialog.getByPlaceholder('Project name').fill('test project');
await dialog.getByRole('button', { name: 'create' }).click();
await page.waitForURL(/\/project-fra-[^/]+/);
expect(page.url()).toContain('/console/project-fra-');
return getProjectIdFromUrl(page.url());
});
+6 -5
View File
@@ -21,13 +21,12 @@
"e2e:ui": "playwright test --ui"
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.22",
"@appwrite.io/console": "https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@f76aff1",
"@appwrite.io/pink": "0.25.0",
"@ai-sdk/svelte": "^1.1.24",
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@e190a19",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fpink-icons-svelte@282a767",
"@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1",
"@appwrite.io/pink-legacy": "^1.0.3",
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@325",
"@appwrite.io/pink-svelte": "https://try-module.cloud/-/@appwrite/@appwrite.io/pink-svelte@d74b893",
"@popperjs/core": "^2.11.8",
"@sentry/sveltekit": "^8.38.0",
"@stripe/stripe-js": "^3.5.0",
@@ -70,6 +69,7 @@
"@vitest/ui": "^3.0.9",
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
"color": "^5.0.0",
"eslint": "^9.23.0",
"eslint-config-prettier": "^10.1.0",
"eslint-plugin-svelte": "^3.3.3",
@@ -85,6 +85,7 @@
"svelte-check": "^4.1.5",
"svelte-preprocess": "^6.0.3",
"svelte-sequential-preprocessor": "^2.0.2",
"tldts": "^7.0.7",
"tslib": "^2.8.1",
"typescript": "^5.8.2",
"typescript-eslint": "^8.30.1",
+1
View File
@@ -15,6 +15,7 @@ const config: PlaywrightTestConfig = {
env: {
PUBLIC_APPWRITE_ENDPOINT: 'https://stage.cloud.appwrite.io/v1',
PUBLIC_CONSOLE_MODE: 'cloud',
PUBLIC_APPWRITE_MULTI_REGION: 'true',
PUBLIC_STRIPE_KEY:
'pk_test_51LT5nsGYD1ySxNCyd7b304wPD8Y1XKKWR6hqo6cu3GIRwgvcVNzoZv4vKt5DfYXL1gRGw4JOqE19afwkJYJq1g3K004eVfpdWn'
},
+141 -711
View File
File diff suppressed because it is too large. Load diff
+12 -14
View File
@@ -1,7 +1,7 @@
import * as Sentry from '@sentry/sveltekit';
import { isCloud, isProd, isStudio } from '$lib/system';
import { AppwriteException } from '@appwrite.io/console';
import type { HandleClientError } from '@sveltejs/kit';
import { isCloud, isProd, isStudio } from '$lib/system';
Sentry.init({
enabled: isCloud && isProd,
@@ -30,17 +30,15 @@ function setLoader() {
setLoader();
export const handleError: HandleClientError = Sentry.handleErrorWithSentry(
async ({ error, message, status }) => {
console.error(error);
if (error instanceof AppwriteException) {
status = error.code === 0 ? undefined : error.code;
message = error.message;
}
return {
message,
status
};
export const handleError: HandleClientError = ({ error, message, status }) => {
console.error(error);
if (error instanceof AppwriteException) {
status = error.code === 0 ? undefined : error.code;
message = error.message;
}
);
return {
message,
status
};
};
+1
View File
@@ -314,6 +314,7 @@ export enum Submit {
VariableDelete = 'submit_variable_delete',
VariableUpdate = 'submit_variable_update',
VariableEditor = 'submit_variable_editor',
LogDelete = 'submit_log_delete',
KeyCreate = 'submit_key_create',
KeyDelete = 'submit_key_delete',
@@ -1,6 +1,6 @@
<script lang="ts">
import { initCreateAttribute } from '$routes/(console)/project-[project]/databases/database-[database]/collection-[collection]/+layout.svelte';
import { attributeOptions } from '$routes/(console)/project-[project]/databases/database-[database]/collection-[collection]/attributes/store';
import { initCreateAttribute } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+layout.svelte';
import { attributeOptions } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/attributes/store';
import Template from './template.svelte';
let search = '';
@@ -1,15 +1,15 @@
<script lang="ts">
import { providers } from '$routes/(console)/project-[project]/messaging/providers/store';
import { providers } from '$routes/(console)/project-[region]-[project]/messaging/providers/store';
import {
messageParams,
providerType,
targetsById
} from '$routes/(console)/project-[project]/messaging/wizard/store';
} from '$routes/(console)/project-[region]-[project]/messaging/wizard/store';
import { MessagingProviderType } from '@appwrite.io/console';
import Template from './template.svelte';
import { wizard } from '$lib/stores/wizard';
import Create from '$routes/(console)/project-[project]/messaging/create.svelte';
import { topicsById } from '$routes/(console)/project-[project]/messaging/store';
import Create from '$routes/(console)/project-[region]-[project]/messaging/create.svelte';
import { topicsById } from '$routes/(console)/project-[region]-[project]/messaging/store';
let search = '';
@@ -2,7 +2,7 @@
import {
Platform,
addPlatform
} from '$routes/(console)/project-[project]/overview/platforms/+page.svelte';
} from '$routes/(console)/project-[region]-[project]/overview/platforms/+page.svelte';
import Template from './template.svelte';
import { IconAndroid, IconApple, IconCode, IconFlutter } from '@appwrite.io/pink-icons-svelte';
+14 -5
View File
@@ -11,6 +11,7 @@
import { IconArrowSmRight } from '@appwrite.io/pink-icons-svelte';
import { Icon, Keyboard, Layout } from '@appwrite.io/pink-svelte';
import { Submit, trackEvent } from '$lib/actions/analytics';
import type { Action } from 'svelte/action';
/* eslint no-undef: "off" */
type Option = $$Generic<Omit<Command, 'group'> & { group?: string }>;
@@ -247,6 +248,10 @@
return isGroup(nextItem) || !nextItem?.nested;
};
const autofocus: Action<HTMLInputElement> = (node) => {
if (node) node.focus();
};
</script>
<svelte:window on:keydown={handleKeyDown} />
@@ -271,8 +276,11 @@
<slot name="search">
<div class="u-flex default-search u-width-full-line">
<!-- svelte-ignore a11y-autofocus -->
<input type="text" placeholder={searchPlaceholder} autofocus bind:value={search} />
<input
type="text"
placeholder={searchPlaceholder}
use:autofocus
bind:value={search} />
</div>
</slot>
</div>
@@ -305,7 +313,7 @@
on:mouseleave={getOptionBlurHandler()}
on:focus={getOptionFocusHandler(item)}>
<slot name="option" option={castOption(item)}>
<Layout.Stack direction="column" gap="s">
<Layout.Stack direction="row" gap="s" alignItems="center">
{#if item.icon}
<Icon
icon={item.icon}
@@ -448,8 +456,9 @@
.default-search {
input {
margin: -1rem;
padding: 1rem;
width: 100%;
margin: 0rem;
padding: 0rem;
border: none;
background-color: transparent;
}
+17 -11
View File
@@ -1,6 +1,6 @@
import { goto } from '$app/navigation';
import { sdk } from '$lib/stores/sdk';
import { project } from '$routes/(console)/project-[project]/store';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { Query, type Models } from '@appwrite.io/console';
import { get } from 'svelte/store';
import type { Command, Searcher } from '../commands';
@@ -14,12 +14,13 @@ import {
IconPuzzle,
IconSearch
} from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
const getBucketCommand = (bucket: Models.Bucket, projectId: string) => {
const getBucketCommand = (bucket: Models.Bucket, region: string, projectId: string) => {
return {
label: `${bucket.name}`,
callback() {
goto(`${base}/project-${projectId}/storage/bucket-${bucket.$id}`);
goto(`${base}/project-${region}-${projectId}/storage/bucket-${bucket.$id}`);
},
group: 'buckets',
icon: IconFolder
@@ -27,19 +28,24 @@ const getBucketCommand = (bucket: Models.Bucket, projectId: string) => {
};
export const bucketSearcher = (async (query: string) => {
const { buckets } = await sdk.forProject.storage.listBuckets([Query.orderDesc('$createdAt')]);
const $project = get(project);
const region = page.params.region;
const { buckets } = await sdk
.forProject(page.params.region, page.params.project)
.storage.listBuckets([Query.orderDesc('$createdAt')]);
const filtered = buckets.filter((bucket) => bucket.name.includes(query));
if (filtered.length === 1) {
const bucket = filtered[0];
return [
getBucketCommand(bucket, $project.$id),
getBucketCommand(bucket, region, $project.$id),
{
label: 'Find files',
async callback() {
await goto(`${base}/project-${$project.$id}/storage/bucket-${bucket.$id}`);
await goto(
`${base}/project-${$project.region}-${$project.$id}/storage/bucket-${bucket.$id}`
);
addSubPanel(FilesPanel);
},
group: 'buckets',
@@ -51,7 +57,7 @@ export const bucketSearcher = (async (query: string) => {
label: 'Permissions',
async callback() {
await goto(
`${base}/project-${$project.$id}/storage/bucket-${bucket.$id}/settings#permissions`
`${base}/project-${$project.region}-${$project.$id}/storage/bucket-${bucket.$id}/settings#permissions`
);
scrollBy({ top: -100 });
},
@@ -63,7 +69,7 @@ export const bucketSearcher = (async (query: string) => {
label: 'Extensions',
async callback() {
await goto(
`${base}/project-${$project.$id}/storage/bucket-${bucket.$id}/settings#extensions`
`${base}/project-${$project.region}-${$project.$id}/storage/bucket-${bucket.$id}/settings#extensions`
);
},
group: 'buckets',
@@ -74,7 +80,7 @@ export const bucketSearcher = (async (query: string) => {
label: 'File Security',
async callback() {
await goto(
`${base}/project-${$project.$id}/storage/bucket-${bucket.$id}/settings#file-security`
`${base}/project-${$project.region}-${$project.$id}/storage/bucket-${bucket.$id}/settings#file-security`
);
scrollBy({ top: -100 });
},
@@ -85,5 +91,5 @@ export const bucketSearcher = (async (query: string) => {
];
}
return filtered.map((bucket) => getBucketCommand(bucket, $project.$id));
return filtered.map((bucket) => getBucketCommand(bucket, $project.region, $project.$id));
}) satisfies Searcher;
@@ -1,16 +1,17 @@
import { goto } from '$app/navigation';
import { database } from '$routes/(console)/project-[project]/databases/database-[database]/store';
import { project } from '$routes/(console)/project-[project]/store';
import { database } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
import { base } from '$app/paths';
import { page } from '$app/state';
export const collectionsSearcher = (async (query: string) => {
const databaseId = get(database).$id;
const { collections } = await sdk.forProject.databases.listCollections(databaseId);
const { collections } = await sdk
.forProject(page.params.region, page.params.project)
.databases.listCollections(databaseId);
const projectId = get(project).$id;
return collections
.filter((col) => col.name.toLowerCase().includes(query.toLowerCase()))
.map(
@@ -20,7 +21,7 @@ export const collectionsSearcher = (async (query: string) => {
label: col.name,
callback: () => {
goto(
`${base}/project-${projectId}/databases/database-${databaseId}/collection-${col.$id}`
`${base}/project-${page.params.region}-${page.params.project}/databases/database-${databaseId}/collection-${col.$id}`
);
}
}) as const
+7 -4
View File
@@ -1,13 +1,14 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
import { base } from '$app/paths';
import { IconDatabase } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
export const dbSearcher = (async (query: string) => {
const { databases } = await sdk.forProject.databases.list();
const { databases } = await sdk
.forProject(page.params.region, page.params.project)
.databases.list();
return databases
.filter((db) => db.name.toLowerCase().includes(query.toLowerCase()))
@@ -17,7 +18,9 @@ export const dbSearcher = (async (query: string) => {
group: 'databases',
label: db.name,
callback: () => {
goto(`${base}/project-${get(project).$id}/databases/database-${db.$id}`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/databases/database-${db.$id}`
);
},
icon: IconDatabase
}) as const
+9 -8
View File
@@ -1,27 +1,28 @@
import { sdk } from '$lib/stores/sdk';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { bucket } from '$routes/(console)/project-[project]/storage/bucket-[bucket]/store';
import { bucket } from '$routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/store';
import { Query } from '@appwrite.io/console';
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[project]/store';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { base } from '$app/paths';
import { IconDocument } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
export const fileSearcher = (async (query: string) => {
const $bucket = get(bucket);
const $project = get(project);
const { files } = await sdk.forProject.storage.listFiles(
$bucket.$id,
[Query.orderDesc('')],
query || undefined
);
const { files } = await sdk
.forProject(page.params.region, page.params.project)
.storage.listFiles($bucket.$id, [Query.orderDesc('')], query || undefined);
return files.map((file) => ({
label: file.name,
callback: () => {
goto(`${base}/project-${$project.$id}/storage/bucket-${$bucket.$id}/file-${file.$id}`);
goto(
`${base}/project-${$project.region}-${$project.$id}/storage/bucket-${$bucket.$id}/file-${file.$id}`
);
},
icon: IconDocument,
group: 'files'
+26 -16
View File
@@ -1,19 +1,19 @@
import { goto } from '$app/navigation';
import { sdk } from '$lib/stores/sdk';
import { project } from '$routes/(console)/project-[project]/store';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import type { Models } from '@appwrite.io/console';
import { page } from '$app/stores';
import { showCreateDeployment } from '$routes/(console)/project-[project]/functions/function-[function]/store';
import { page } from '$app/state';
import { showCreateDeployment } from '$routes/(console)/project-[region]-[project]/functions/function-[function]/store';
import { base } from '$app/paths';
import { IconLightningBolt, IconPlus } from '@appwrite.io/pink-icons-svelte';
const getFunctionCommand = (fn: Models.Function, projectId: string) => {
const getFunctionCommand = (fn: Models.Function, region: string, projectId: string) => {
return {
label: fn.name,
callback: () => {
goto(`${base}/project-${projectId}/functions/function-${fn.$id}`);
goto(`${base}/project-${region}-${projectId}/functions/function-${fn.$id}`);
},
group: 'functions',
icon: IconLightningBolt
@@ -21,23 +21,25 @@ const getFunctionCommand = (fn: Models.Function, projectId: string) => {
};
export const functionsSearcher = (async (query: string) => {
const { functions } = await sdk.forProject.functions.list();
const projectId = get(project).$id;
const { functions } = await sdk
.forProject(page.params.region, page.params.project)
.functions.list();
const filtered = functions.filter((fn) => fn.name.toLowerCase().includes(query.toLowerCase()));
if (filtered.length === 1) {
const func = filtered[0];
return [
getFunctionCommand(func, projectId),
getFunctionCommand(func, page.params.region, projectId),
{
label: 'Create deployment',
nested: true,
async callback() {
const $page = get(page);
if (!$page.url.pathname.endsWith(func.$id)) {
await goto(`${base}/project-${projectId}/functions/function-${func.$id}`);
if (!page.url.pathname.endsWith(func.$id)) {
await goto(
`${base}/project-${page.params.region}-${projectId}/functions/function-${func.$id}`
);
}
showCreateDeployment.set(true);
},
@@ -48,7 +50,9 @@ export const functionsSearcher = (async (query: string) => {
label: 'Go to deployments',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}`);
goto(
`${base}/project-${page.params.region}-${projectId}/functions/function-${func.$id}`
);
},
group: 'functions'
},
@@ -56,7 +60,9 @@ export const functionsSearcher = (async (query: string) => {
label: 'Go to usage',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}/usage`);
goto(
`${base}/project-${page.params.region}-${projectId}/functions/function-${func.$id}/usage`
);
},
group: 'functions'
},
@@ -64,7 +70,9 @@ export const functionsSearcher = (async (query: string) => {
label: 'Go to executions',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}/executions`);
goto(
`${base}/project-${page.params.region}-${projectId}/functions/function-${func.$id}/executions`
);
},
group: 'functions'
},
@@ -72,12 +80,14 @@ export const functionsSearcher = (async (query: string) => {
label: 'Go to settings',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}/settings`);
goto(
`${base}/project-${page.params.region}-${projectId}/functions/function-${func.$id}/settings`
);
},
group: 'functions'
}
];
}
return filtered.map((fn) => getFunctionCommand(fn, projectId));
return filtered.map((fn) => getFunctionCommand(fn, page.params.region, projectId));
}) satisfies Searcher;
+7 -6
View File
@@ -1,11 +1,10 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[project]/store';
import { get } from 'svelte/store';
import { type Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
import { MessagingProviderType, type Models } from '@appwrite.io/console';
import { base } from '$app/paths';
import { IconAnnotation, IconDeviceMobile, IconMail } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
const getLabel = (message: Models.Message) => {
switch (message.providerType) {
@@ -34,9 +33,9 @@ const getIcon = (message: Models.Message) => {
};
export const messagesSearcher = (async (query: string) => {
const { messages } = await sdk.forProject.messaging.listMessages([], query || undefined);
const projectId = get(project).$id;
const { messages } = await sdk
.forProject(page.params.region, page.params.project)
.messaging.listMessages([], query || undefined);
return messages
.filter((message) => getLabel(message).toLowerCase().includes(query.toLowerCase()))
@@ -46,7 +45,9 @@ export const messagesSearcher = (async (query: string) => {
group: 'messages',
label: getLabel(message),
callback: () => {
goto(`${base}/project-${projectId}/messaging/message-${message.$id}`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/messaging/message-${message.$id}`
);
},
icon: getIcon(message)
}) as const
+1 -1
View File
@@ -18,7 +18,7 @@ export const projectsSearcher = (async (query: string) => {
return {
label: project.name,
callback: () => {
goto(`${base}/project-${project.$id}`);
goto(`${base}/project-${project.region}-${project.$id}`);
},
group: 'projects'
} as const;
+6 -7
View File
@@ -1,10 +1,9 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
import { getProviderDisplayNameAndIcon } from '$routes/(console)/project-[project]/messaging/provider.svelte';
import { getProviderDisplayNameAndIcon } from '$routes/(console)/project-[region]-[project]/messaging/provider.svelte';
import { base } from '$app/paths';
import { page } from '$app/state';
const getIcon = (provider: string) => {
const { icon } = getProviderDisplayNameAndIcon(provider);
@@ -12,9 +11,9 @@ const getIcon = (provider: string) => {
};
export const providersSearcher = (async (query: string) => {
const { providers } = await sdk.forProject.messaging.listProviders([], query || undefined);
const projectId = get(project).$id;
const { providers } = await sdk
.forProject(page.params.region, page.params.project)
.messaging.listProviders([], query || undefined);
return providers
.filter((provider) => provider.name.toLowerCase().includes(query.toLowerCase()))
@@ -25,7 +24,7 @@ export const providersSearcher = (async (query: string) => {
label: provider.name,
callback: () => {
goto(
`${base}/project-${projectId}/messaging/providers/provider-${provider.$id}`
`${base}/project-${page.params.region}-${page.params.project}/messaging/providers/provider-${provider.$id}`
);
},
image: getIcon(provider.provider)
+14 -10
View File
@@ -1,33 +1,35 @@
import { goto } from '$app/navigation';
import { sdk } from '$lib/stores/sdk';
import { project } from '$routes/(console)/project-[project]/store';
import { get } from 'svelte/store';
import type { Command, Searcher } from '../commands';
import type { Models } from '@appwrite.io/console';
import { base } from '$app/paths';
import { IconUserCircle } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
const getTeamCommand = (team: Models.Team<Models.Preferences>, projectId: string) =>
const getTeamCommand = (team: Models.Team<Models.Preferences>, region: string, projectId: string) =>
({
label: team.name,
callback: () => {
goto(`${base}/project-${projectId}/auth/teams/team-${team.$id}`);
goto(`${base}/project-${region}-${projectId}/auth/teams/team-${team.$id}`);
},
group: 'teams',
icon: IconUserCircle
}) satisfies Command;
export const teamSearcher = (async (query: string) => {
const { teams } = await sdk.forProject.teams.list([], query);
const projectId = get(project).$id;
const { teams } = await sdk
.forProject(page.params.region, page.params.project)
.teams.list([], query);
if (teams.length === 1) {
return [
getTeamCommand(teams[0], projectId),
getTeamCommand(teams[0], page.params.region, page.params.project),
{
label: 'Go to members',
callback: () => {
goto(`${base}/project-${projectId}/auth/teams/team-${teams[0].$id}/members`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/auth/teams/team-${teams[0].$id}/members`
);
},
group: 'teams',
nested: true
@@ -36,12 +38,14 @@ export const teamSearcher = (async (query: string) => {
{
label: 'Go to activity',
callback: () => {
goto(`${base}/project-${projectId}/auth/teams/team-${teams[0].$id}/activity`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/auth/teams/team-${teams[0].$id}/activity`
);
},
group: 'teams',
nested: true
}
];
}
return teams.map((team) => getTeamCommand(team, projectId));
return teams.map((team) => getTeamCommand(team, page.params.region, page.params.project));
}) satisfies Searcher;
+7 -6
View File
@@ -1,15 +1,14 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
import { base } from '$app/paths';
import { IconChevronRight } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
export const topicsSearcher = (async (query: string) => {
const { topics } = await sdk.forProject.messaging.listTopics([], query || undefined);
const projectId = get(project).$id;
const { topics } = await sdk
.forProject(page.params.region, page.params.project)
.messaging.listTopics([], query || undefined);
return topics
.filter((topic) => topic.name.toLowerCase().includes(query.toLowerCase()))
@@ -19,7 +18,9 @@ export const topicsSearcher = (async (query: string) => {
group: 'topics',
label: topic.name,
callback: () => {
goto(`${base}/project-${projectId}/messaging/topics/topic-${topic.$id}`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/messaging/topics/topic-${topic.$id}`
);
},
icon: IconChevronRight // TODO: @itznotabug - 'send' no replacement yet.
}) as const
+18 -12
View File
@@ -1,30 +1,30 @@
import { goto } from '$app/navigation';
import { sdk } from '$lib/stores/sdk';
import { project } from '$routes/(console)/project-[project]/store';
import { get } from 'svelte/store';
import type { Command, Searcher } from '../commands';
import type { Models } from '@appwrite.io/console';
import { promptDeleteUser } from '$routes/(console)/project-[project]/auth/user-[user]/dangerZone.svelte';
import { promptDeleteUser } from '$routes/(console)/project-[region]-[project]/auth/user-[user]/dangerZone.svelte';
import { base } from '$app/paths';
import { IconTrash, IconUserCircle } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
const getUserCommand = (user: Models.User<Models.Preferences>, projectId: string) =>
const getUserCommand = (user: Models.User<Models.Preferences>, region: string, projectId: string) =>
({
label: user.name,
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${user.$id}`);
goto(`${base}/project-${region}-${projectId}/auth/user-${user.$id}`);
},
group: 'users',
icon: IconUserCircle
}) satisfies Command;
export const userSearcher = (async (query: string) => {
const { users } = await sdk.forProject.users.list([], query || undefined);
const projectId = get(project).$id;
const { users } = await sdk
.forProject(page.params.region, page.params.project)
.users.list([], query || undefined);
if (users.length === 1) {
return [
getUserCommand(users[0], projectId),
getUserCommand(users[0], page.params.region, page.params.project),
{
label: 'Delete user',
callback: () => {
@@ -37,7 +37,9 @@ export const userSearcher = (async (query: string) => {
{
label: 'Go to activity',
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${users[0].$id}/activity`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/auth/user-${users[0].$id}/activity`
);
},
group: 'users',
nested: true
@@ -45,7 +47,9 @@ export const userSearcher = (async (query: string) => {
{
label: 'Go to sessions',
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${users[0].$id}/sessions`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/auth/user-${users[0].$id}/sessions`
);
},
group: 'users',
nested: true
@@ -53,12 +57,14 @@ export const userSearcher = (async (query: string) => {
{
label: 'Go to memberships',
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${users[0].$id}/memberships`);
goto(
`${base}/project-${page.params.region}-${page.params.project}/auth/user-${users[0].$id}/memberships`
);
},
group: 'users',
nested: true
}
];
}
return users.map((user) => getUserCommand(user, projectId));
return users.map((user) => getUserCommand(user, page.params.region, page.params.project));
}) satisfies Searcher;
+7 -1
View File
@@ -1,6 +1,12 @@
<script lang="ts">
import { Avatar } from '@appwrite.io/pink-svelte';
import type { AvatarProps } from '@appwrite.io/pink-svelte/dist/avatar/Avatar.svelte';
type AvatarProps = Partial<{
src: string;
alt: string;
size: 'xs' | 's' | 'm' | 'l' | 'xl';
empty: boolean;
}>;
export let size: AvatarProps['size'] = 'm';
export let src: AvatarProps['src'] = undefined;
+16 -11
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { sdk } from '$lib/stores/sdk';
import { realtime } from '$lib/stores/sdk';
import { type Payload } from '@appwrite.io/console';
import { onMount } from 'svelte';
import { isCloud, isSelfHosted } from '$lib/system';
@@ -34,6 +34,7 @@
function showRestoreNotification(newDatabaseId: string, newDatabaseName: string) {
if (newDatabaseId && newDatabaseName && lastDatabaseRestorationId !== newDatabaseId) {
const region = page.params.region;
const project = page.params.project;
lastDatabaseRestorationId = newDatabaseId;
@@ -45,7 +46,9 @@
{
name: 'View restored data',
method: () => {
goto(`${base}/project-${project}/databases/database-${newDatabaseId}`);
goto(
`${base}/project-${region}-${project}/databases/database-${newDatabaseId}`
);
}
}
]
@@ -123,16 +126,18 @@
// fast path: don't subscribe if org is on a free plan or is self-hosted.
if (isSelfHosted || (isCloud && $organization.billingPlan === BillingPlan.FREE)) return;
return sdk.forConsole.client.subscribe('console', (response) => {
if (!response.channels.includes(`projects.${getProjectId()}`)) return;
return realtime
.forProject(page.params.region, page.params.project)
.subscribe('console', (response) => {
if (!response.channels.includes(`projects.${getProjectId()}`)) return;
if (
response.events.includes('archives.*') ||
response.events.includes('restorations.*')
) {
updateOrAddItem(response.payload);
}
});
if (
response.events.includes('archives.*') ||
response.events.includes('restorations.*')
) {
updateOrAddItem(response.payload);
}
});
});
</script>
@@ -7,6 +7,8 @@
import { organization } from '$lib/stores/organization';
import { activeHeaderAlert } from '$routes/(console)/store';
import GradientBanner from '../gradientBanner.svelte';
import { isSmallViewport } from '$lib/stores/viewport';
import { Layout, Typography } from '@appwrite.io/pink-svelte';
let show = true;
@@ -23,8 +25,13 @@
{#if show && $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && !page.url.pathname.includes('/console/account')}
<GradientBanner on:close={handleClose}>
<div class="u-flex u-gap-24 u-main-center u-cross-center u-flex-vertical-mobile">
<span class="body-text-1">Get $50 Cloud credits for Appwrite Pro.</span>
<Layout.Stack
gap="m"
alignItems="center"
alignContent="center"
direction={$isSmallViewport ? 'column' : 'row'}>
<Typography.Text>Get $50 Cloud credits for Appwrite Pro.</Typography.Text>
<Button
secondary
fullWidthMobile
@@ -39,6 +46,6 @@
}}>
Claim credits
</Button>
</div>
</Layout.Stack>
</GradientBanner>
{/if}
@@ -1,12 +1,12 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { page } from '$app/state';
import { Button } from '$lib/elements/forms';
import { HeaderAlert } from '$lib/layout';
import { failedInvoice } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
$: isOnProjects = $page.route.id.includes('project-[project]');
$: isOnProjects = page.route.id.includes('project-[region]-[project]');
</script>
{#if $failedInvoice && $failedInvoice.teamId === $organization.$id && isOnProjects}
@@ -1,49 +0,0 @@
<script lang="ts">
import { formatCurrency } from '$lib/helpers/numbers';
import type { Coupon } from '$lib/sdk/billing';
import { IconX } from '@appwrite.io/pink-icons-svelte';
import { Icon } from '@appwrite.io/pink-svelte';
export let label: string;
export let value: number;
export let couponData: Partial<Coupon> = {
code: null,
status: null,
credits: null
};
export let fixedCoupon = false;
</script>
{#if value > 0}
<span class="u-flex u-main-space-between">
<div class="u-flex u-cross-center u-gap-4">
<p class="text">
<span class="icon-tag u-color-text-success" aria-hidden="true"></span>
<span>
{label}
</span>
</p>
{#if !fixedCoupon && label.toLowerCase() === 'credits'}
<button
type="button"
class="button is-text is-only-icon"
style="--button-size:1.5rem;"
aria-label="Close"
title="Close"
on:click={() =>
(couponData = {
code: null,
status: null,
credits: null
})}>
<Icon icon={IconX} />
</button>
{/if}
</div>
{#if value >= 100}
<p class="inline-tag">Credits applied</p>
{:else}
<span class="u-color-text-success">-{formatCurrency(value)}</span>
{/if}
</span>
{/if}
@@ -1,144 +0,0 @@
<script lang="ts">
import { InputChoice, InputNumber } from '$lib/elements/forms';
import { formatCurrency } from '$lib/helpers/numbers';
import type { Coupon, Estimation } from '$lib/sdk/billing';
import { sdk } from '$lib/stores/sdk';
import { AppwriteException } from '@appwrite.io/console';
import Card from '../card.svelte';
import DiscountsApplied from './discountsApplied.svelte';
import { addNotification } from '$lib/stores/notifications';
export let organizationId: string | undefined = undefined;
export let billingPlan: string;
export let collaborators: string[];
export let fixedCoupon = false;
export let couponData: Partial<Coupon>;
export let billingBudget: number;
let budgetEnabled = false;
let estimation: Estimation;
async function getEstimate(
billingPlan: string,
collaborators: string[],
couponId: string | undefined
) {
try {
estimation = await sdk.forConsole.billing.estimationCreateOrganization(
billingPlan,
couponId === '' ? null : couponId,
collaborators ?? []
);
} catch (e) {
if (e instanceof AppwriteException) {
if (
e.type === 'billing_coupon_not_found' ||
e.type === 'billing_coupon_already_used' ||
e.type === 'billing_credit_unsupported'
) {
couponData = {
code: null,
status: null,
credits: null
};
}
}
addNotification({
type: 'error',
isHtml: false,
message: e.message
});
}
}
async function getUpdatePlanEstimate(
organizationId: string,
billingPlan: string,
collaborators: string[],
couponId: string | undefined
) {
try {
estimation = await sdk.forConsole.billing.estimationUpdatePlan(
organizationId,
billingPlan,
couponId && couponId.length > 0 ? couponId : null,
collaborators ?? []
);
} catch (e) {
if (e instanceof AppwriteException) {
if (
e.type === 'billing_coupon_not_found' ||
e.type === 'billing_coupon_already_used' ||
e.type === 'billing_credit_unsupported'
) {
couponData = {
code: null,
status: null,
credits: null
};
}
}
addNotification({
type: 'error',
isHtml: false,
message: e.message
});
}
}
$: organizationId
? getUpdatePlanEstimate(organizationId, billingPlan, collaborators, couponData?.code)
: getEstimate(billingPlan, collaborators, couponData?.code);
</script>
{#if estimation}
<Card class="u-flex u-flex-vertical u-gap-8">
<slot />
{#if estimation}
{#each estimation.items ?? [] as item}
{#if item.value > 0}
<span class="u-flex u-main-space-between">
<p class="text">{item.label}</p>
<p class="text">{formatCurrency(item.value)}</p>
</span>
{/if}
{/each}
{#each estimation.discounts ?? [] as item}
<DiscountsApplied {fixedCoupon} bind:couponData {...item} />
{/each}
<div class="u-sep-block-start"></div>
<span class="u-flex u-main-space-between">
<p class="text">Total due</p>
<p class="text">
{formatCurrency(estimation.grossAmount)}
</p>
</span>
<p class="text u-margin-block-start-16">
You'll pay <span class="u-bold">{formatCurrency(estimation.grossAmount)}</span> now.
{#if couponData?.code}Once your credits run out,{:else}Then{/if} you'll be charged
<span class="u-bold">{formatCurrency(estimation.amount)}</span> every 30 days.
</p>
{/if}
<InputChoice
type="switchbox"
id="budget"
label="Enable budget cap"
tooltip="If enabled, you will be notified when your spending reaches 75% of the set cap. Update cap alerts in your organization settings."
fullWidth
bind:value={budgetEnabled}>
{#if budgetEnabled}
<div class="u-margin-block-start-16">
<InputNumber
id="budget"
label="Budget cap (USD)"
placeholder="0"
min={0}
bind:value={billingBudget} />
</div>
{/if}
</InputChoice>
</Card>
{/if}
@@ -1,96 +1,146 @@
<script lang="ts">
import { InputChoice, InputNumber } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { formatCurrency } from '$lib/helpers/numbers';
import type { Coupon, PlansMap } from '$lib/sdk/billing';
import type { Coupon, Estimation } from '$lib/sdk/billing';
import { type Tier } from '$lib/stores/billing';
import { Card, Divider, Layout, Typography } from '@appwrite.io/pink-svelte';
import { CreditsApplied } from '.';
import { sdk } from '$lib/stores/sdk';
import { AppwriteException } from '@appwrite.io/console';
export let billingPlan: Tier;
export let collaborators: string[];
export let couponData: Partial<Coupon>;
export let plans: PlansMap;
export let billingBudget: number;
export let fixedCoupon = false; // If true, the coupon cannot be removed
export let isDowngrade = false;
const today = new Date();
const billingPayDate = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
export let organizationId: string | undefined = undefined;
let budgetEnabled = false;
let estimation: Estimation;
async function getEstimate(
billingPlan: string,
collaborators: string[],
couponId: string | undefined
) {
try {
estimation = await sdk.forConsole.billing.estimationCreateOrganization(
billingPlan,
couponId === '' ? null : couponId,
collaborators ?? []
);
} catch (e) {
if (e instanceof AppwriteException) {
if (
e.type === 'billing_coupon_not_found' ||
e.type === 'billing_coupon_already_used' ||
e.type === 'billing_credit_unsupported'
) {
couponData = {
code: null,
status: null,
credits: null
};
}
}
}
}
async function getUpdatePlanEstimate(
organizationId: string,
billingPlan: string,
collaborators: string[],
couponId: string | undefined
) {
try {
estimation = await sdk.forConsole.billing.estimationUpdatePlan(
organizationId,
billingPlan,
couponId && couponId.length > 0 ? couponId : null,
collaborators ?? []
);
} catch (e) {
if (e instanceof AppwriteException) {
if (
e.type === 'billing_coupon_not_found' ||
e.type === 'billing_coupon_already_used' ||
e.type === 'billing_credit_unsupported'
) {
couponData = {
code: null,
status: null,
credits: null
};
}
}
}
}
$: organizationId
? getUpdatePlanEstimate(organizationId, billingPlan, collaborators, couponData?.code)
: getEstimate(billingPlan, collaborators, couponData?.code);
$: currentPlan = plans.get(billingPlan);
$: extraSeatsCost = 0; // 0 untile trial period later replace (collaborators?.length ?? 0) * (currentPlan?.addons?.member?.price ?? 0);
$: grossCost = currentPlan.price + extraSeatsCost;
$: estimatedTotal =
couponData?.status === 'active'
? grossCost - couponData.credits >= 0
? grossCost - couponData.credits
? estimation?.grossAmount - couponData.credits >= 0
? estimation?.grossAmount - couponData.credits
: 0
: grossCost;
$: trialEndDate = new Date(
billingPayDate.getTime() + currentPlan.trialDays * 24 * 60 * 60 * 1000
);
: estimation?.grossAmount;
</script>
<Card.Base padding="s">
<Layout.Stack>
<slot />
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Text>{currentPlan.name} plan</Typography.Text>
<Typography.Text>{formatCurrency(currentPlan.price)}</Typography.Text>
</Layout.Stack>
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Text variant={isDowngrade ? 'm-500' : 'm-400'}
>Additional seats ({collaborators?.length ?? 0})</Typography.Text>
<Typography.Text variant={isDowngrade ? 'm-500' : 'm-400'}
>{formatCurrency(extraSeatsCost)}</Typography.Text>
</Layout.Stack>
{#if couponData?.status === 'active'}
<CreditsApplied bind:couponData {fixedCoupon} />
{/if}
<Divider />
<Layout.Stack direction="row" justifyContent="space-between">
{#if estimation}
<Card.Base padding="s">
<Layout.Stack>
<slot />
{#each estimation.items ?? [] as item}
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Text variant={isDowngrade ? 'm-500' : 'm-400'}
>{item.label}</Typography.Text>
<Typography.Text variant={isDowngrade ? 'm-500' : 'm-400'}
>{formatCurrency(item.value)}</Typography.Text>
</Layout.Stack>
{/each}
{#if couponData?.status === 'active'}
<CreditsApplied bind:couponData {fixedCoupon} />
{/if}
<Divider />
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Text>Total due</Typography.Text>
<Typography.Text>
{formatCurrency(estimatedTotal)}
</Typography.Text>
</Layout.Stack>
<Typography.Text>
Upcoming charge<br />
Due on {!currentPlan.trialDays
? toLocaleDate(billingPayDate.toString())
: toLocaleDate(trialEndDate.toString())}</Typography.Text>
<Typography.Text>{formatCurrency(estimatedTotal)}</Typography.Text>
You'll pay <b>{formatCurrency(estimatedTotal)}</b>
now.
{#if couponData?.code}Once your credits run out,{:else}Then{/if} you'll be charged
<b>{formatCurrency(estimation.grossAmount)}</b> every 30 days.
</Typography.Text>
<InputChoice
type="switchbox"
id="budget"
label="Enable budget cap"
tooltip="If enabled, you will be notified when your spending reaches 75% of the set cap. Update cap alerts in your organization settings."
fullWidth
bind:value={budgetEnabled}>
{#if budgetEnabled}
<div class="u-margin-block-start-16">
<InputNumber
required
autofocus
id="budget"
label="Budget cap (USD)"
placeholder="0"
min={0}
bind:value={billingBudget} />
</div>
{/if}
</InputChoice>
</Layout.Stack>
<Typography.Text>
You'll pay <b>{formatCurrency(estimatedTotal)}</b> now, with your first billing cycle
starting on
<b
>{!currentPlan.trialDays
? toLocaleDate(billingPayDate.toString())
: toLocaleDate(trialEndDate.toString())}</b
>. {#if couponData?.status === 'active'}Once your credits run out, you'll be charged
<b>{formatCurrency(currentPlan.price)}</b> plus usage fees every 30 days.
{/if}
</Typography.Text>
<InputChoice
type="switchbox"
id="budget"
label="Enable budget cap"
tooltip="If enabled, you will be notified when your spending reaches 75% of the set cap. Update cap alerts in your organization settings."
fullWidth
bind:value={budgetEnabled}>
{#if budgetEnabled}
<div class="u-margin-block-start-16">
<InputNumber
required
autofocus
id="budget"
label="Budget cap (USD)"
placeholder="0"
min={0}
bind:value={billingBudget} />
</div>
{/if}
</InputChoice>
</Layout.Stack>
</Card.Base>
</Card.Base>
{/if}
@@ -1,11 +1,41 @@
<script lang="ts">
import { base } from '$app/paths';
import { createEventDispatcher } from 'svelte';
import { isTabletViewport } from '$lib/stores/viewport';
import { createEventDispatcher, onMount, onDestroy } from 'svelte';
import { Button } from '$lib/elements/forms';
import { Icon } from '@appwrite.io/pink-svelte';
import { IconX } from '@appwrite.io/pink-icons-svelte';
let container: HTMLElement;
const dispatch = createEventDispatcher();
const queryLayoutElements = () => ({
header: document.querySelector<HTMLElement>('main > header'),
sidebar: document.querySelector<HTMLElement>('main > div > nav'),
content: document.querySelector<HTMLElement>('main > div > section')
});
const setNavigationHeight = () => {
const alertHeight = container?.getBoundingClientRect()?.height || 0;
const { header, sidebar, content } = queryLayoutElements();
const headerHeight = header?.getBoundingClientRect().height || 0;
const offset = alertHeight + (!isTabletViewport && header ? headerHeight : 0);
if (header) header.style.top = `${alertHeight}px`;
if (sidebar) {
sidebar.style.top = `${offset}px`;
sidebar.style.height = `calc(100vh - ${offset}px)`;
}
if (content) content.style.paddingBlockStart = `${alertHeight}px`;
};
onMount(setNavigationHeight);
onDestroy(setNavigationHeight);
</script>
<div class="top-banner">
<svelte:window on:resize={setNavigationHeight} />
<div bind:this={container} class="top-banner alert is-action is-action-and-top-sticky">
<div class="top-banner-bg">
<div class="top-banner-bg-1">
<img
@@ -22,14 +52,28 @@
alt="" />
</div>
</div>
<div class="top-banner-content u-color-text-primary">
<slot />
</div>
<button
on:click|preventDefault={() => dispatch('close')}
type="button"
class="top-banner-button"
aria-label="close upgrade message">
<span class="icon-x" aria-hidden="true"></span>
</button>
<Button icon extraCompact class="top-banner-button position" on:click={() => dispatch('close')}>
<Icon icon={IconX} size="s" />
</Button>
</div>
<style>
.alert {
top: 0;
width: 100%;
z-index: 100;
position: fixed;
}
@media (max-width: 768px) {
:global(.top-banner-button.position) {
position: absolute;
padding-block-end: 3.7625rem;
}
}
</style>
-1
View File
@@ -6,5 +6,4 @@ export { default as PlanComparisonBox } from './planComparisonBox.svelte';
export { default as EmptyCardCloud } from './emptyCardCloud.svelte';
export { default as CreditsApplied } from './creditsApplied.svelte';
export { default as PlanSelection } from './planSelection.svelte';
export { default as EstimatedTotal } from './estimatedTotal.svelte';
export { default as SelectPlan } from './selectPlan.svelte';
+14 -4
View File
@@ -15,11 +15,12 @@
let name: string;
let error: string;
let modal: FakeModal;
async function handleSubmit() {
try {
const card = await submitStripeCard(name, page?.params?.organization ?? null);
show = false;
modal.closeModal();
invalidate(Dependencies.PAYMENT_METHODS);
dispatch('submit', card);
addNotification({
@@ -65,7 +66,12 @@
}
</script>
<FakeModal bind:show title="Add payment method" bind:error onSubmit={handleSubmit}>
<FakeModal
bind:this={modal}
bind:show
title="Add payment method"
bind:error
onSubmit={handleSubmit}>
<slot />
<InputText
id="name"
@@ -82,7 +88,10 @@
</div>
{/if}
<div class="stripe-element" bind:this={element}>
<div
style:display={isLoading ? 'none' : 'initial'}
class="stripe-element"
bind:this={element}>
<!-- Stripe will create form elements here -->
</div>
</div>
@@ -105,7 +114,8 @@
.loader-element {
width: 100%;
align-self: center;
justify-items: end;
justify-content: center;
display: flex;
}
}
</style>
@@ -21,6 +21,7 @@
async function cardSaved(event: CustomEvent<PaymentMethodData>) {
value = event.detail.$id;
invalidate(Dependencies.UPGRADE_PLAN);
invalidate(Dependencies.CREATE_ORGANIZATION);
}
onMount(() => {
+1 -2
View File
@@ -24,8 +24,7 @@
tooltipShow={plan.$id === BillingPlan.FREE && anyOrgFree}
tooltipText={plan.$id === BillingPlan.FREE
? 'You are limited to 1 Free organization per account.'
: ''}
padding={1.5}>
: ''}>
<svelte:fragment slot="custom" let:disabled>
<div
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
+25 -42
View File
@@ -17,39 +17,18 @@
? new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1).toString()
: org?.billingNextInvoiceDate;
const planData = [
{
id: 'members',
resource: 'Organization members',
unit: 'member'
},
{ id: 'bandwidth', resource: 'Bandwidth', unit: 'GB' },
{ id: 'storage', resource: 'Storage', unit: 'GB' },
{
id: 'executions',
resource: 'Function executions',
unit: ' executions'
},
{
id: 'users',
resource: 'Users',
unit: ' Users'
},
{
id: 'realtime',
resource: 'Concurrent connections',
unit: ' connections'
}
];
$: isFree = org.billingPlan === BillingPlan.FREE;
// equal or above means unlimited!
$: getCorrectSeatsCountValue = (count: number): string | number => {
const getCorrectSeatsCountValue = (count: number): string | number => {
// php int max is always larger than js
const exceedsSafeLimit = count >= Number.MAX_SAFE_INTEGER;
return exceedsSafeLimit ? 'Unlimited' : count || 0;
};
function getPlanLimit(key: string): number | false {
return plan[key] || false;
}
</script>
<Modal bind:show title="Usage rates">
@@ -77,29 +56,33 @@
<Table.Header.Cell column="limit" {root}>Limit</Table.Header.Cell>
<Table.Header.Cell column="rate" {root}>Rate</Table.Header.Cell>
</svelte:fragment>
{#each planData as usage}
{#if usage['id'] === 'members'}
<Table.Row.Base {root}>
<Table.Cell column="resource" {root}>{usage.resource}</Table.Cell>
<Table.Cell column="limit" {root}>
{getCorrectSeatsCountValue(plan.addons.seats.limit)}
</Table.Cell>
{#each Object.values(plan.addons) as addon}
<Table.Row.Base {root}>
<Table.Cell column="resource" {root}>{addon.invoiceDesc}</Table.Cell>
<Table.Cell column="limit" {root}>
{getCorrectSeatsCountValue(addon.limit)}
</Table.Cell>
{#if !isFree}
<Table.Cell column="rate" {root}>
{formatCurrency(plan.addons?.seats?.price)}/{usage?.unit}
{formatCurrency(addon.price)}/member
</Table.Cell>
</Table.Row.Base>
{:else}
{@const addon = plan.addons[usage.id]}
{/if}
</Table.Row.Base>
{/each}
{#each Object.entries(plan.usage) as [key, usage]}
{@const limit = getPlanLimit(key)}
{@const show = limit !== false}
{#if show}
<Table.Row.Base {root}>
<Table.Cell column="resource" {root}>{usage.resource}</Table.Cell>
<Table.Cell column="resource" {root}>{usage.name}</Table.Cell>
<Table.Cell column="limit" {root}>
{abbreviateNumber(plan[usage.id])}{usage?.unit}
{abbreviateNumber(limit)}{usage.unit}
</Table.Cell>
{#if !isFree}
<Table.Cell column="rate" {root}>
{formatCurrency(addon?.price)}/{['MB', 'GB', 'TB'].includes(addon?.unit)
? addon?.value
: abbreviateNumber(addon?.value, 0)}{usage?.unit}
{formatCurrency(usage.price)}/{abbreviateNumber(
usage.value
)}{usage.unit}
</Table.Cell>
{/if}
</Table.Row.Base>
@@ -38,14 +38,6 @@
message: 'Credits applied successfully'
});
}
couponData = response;
dispatch('validation', couponData);
coupon = null;
show = false;
addNotification({
type: 'success',
message: 'Credits applied successfully'
});
} catch (e) {
error = e.message;
}
+150 -54
View File
@@ -3,8 +3,9 @@
import { hideNotification, shouldShowNotification } from '$lib/helpers/notifications';
import { app } from '$lib/stores/app';
import {
type BottomModalAlertAction,
type BottomModalAlertItem,
bottomModalAlerts,
bottomModalAlertsConfig,
dismissBottomModalAlert,
hideAllModalAlerts
} from '$lib/stores/bottom-alerts';
@@ -13,15 +14,17 @@
import { BillingPlan } from '$lib/constants';
import { upgradeURL } from '$lib/stores/billing';
import { addBottomModalAlerts } from '$routes/(console)/bottomAlerts';
import { project } from '$routes/(console)/project-[project]/store';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { page } from '$app/state';
import { Click, trackEvent } from '$lib/actions/analytics';
import { goto } from '$app/navigation';
import { Typography } from '@appwrite.io/pink-svelte';
let currentIndex = 0;
let openModalOnMobile = false;
function getPageScope(pathname: string) {
const isProjectPage = pathname.includes('project-[project]');
const isProjectPage = pathname.includes('project-[region]-[project]');
const isOrganizationPage = pathname.includes('organization-[organization]');
return { isProjectPage, isOrganizationPage };
@@ -33,23 +36,27 @@
return alerts
.sort((a, b) => b.importance - a.importance)
.filter((alert) => {
return (
alert.show &&
shouldShowNotification(alert.id) &&
// if no scope > show in projects & org pages.
((!alert.scope && (isProjectPage || isOrganizationPage)) ||
// project scope, show only in project pages
(isProjectPage && alert.scope === 'project') ||
// organization scope, show only in organization pages
(isOrganizationPage && alert.scope === 'organization'))
);
if (!alert.show || !shouldShowNotification(alert.id)) return false;
switch (alert.scope) {
case 'everywhere':
return true;
case 'project':
return isProjectPage;
case 'organization':
return isOrganizationPage;
default:
return false;
}
});
}
$: filteredModalAlerts = filterModalAlerts($bottomModalAlerts, page.route.id);
$: filteredModalAlerts = filterModalAlerts($bottomModalAlertsConfig.alerts, page.route.id);
$: currentModalAlert = filteredModalAlerts[currentIndex] as BottomModalAlertItem;
$: hasOnlyPrimaryCta = typeof currentModalAlert?.learnMore === 'undefined';
function handleClose() {
filteredModalAlerts.forEach((alert) => {
const modalAlert = alert;
@@ -67,9 +74,76 @@
currentIndex = (currentIndex - 1 + filteredModalAlerts.length) % filteredModalAlerts.length;
}
function getMobileWindowConfig(): {
html: boolean;
cta: boolean;
title: string;
message: string;
} {
const config = $bottomModalAlertsConfig?.mobileSingleLayout;
const visibleAlerts = $bottomModalAlertsConfig.alerts.filter((a) => a.show);
const fallback = {
title: 'New features available',
message: 'Explore new features to enhance your projects and improve security.'
};
const shouldApplyConfig = config?.enabled === true && visibleAlerts.length === 1;
return {
cta: !!(shouldApplyConfig && config.cta),
html: !!(shouldApplyConfig && config.isHtml),
title: shouldApplyConfig && config.title ? config.title : fallback.title,
message: shouldApplyConfig && config.message ? config.message : fallback.message
};
}
function triggerMobileWindowLink() {
handleClose();
const url = $bottomModalAlertsConfig.mobileSingleLayout.cta.link({
organization: $organization,
project: $project
});
if ($bottomModalAlertsConfig.mobileSingleLayout.cta.external) {
window.open(url, '_blank');
} else {
goto(url);
}
}
// the button component cannot have both href and on:click!
function triggerWindowLink(alertAction: BottomModalAlertAction, event?: string) {
const shouldShowUpgrade = showUpgrade();
const url = shouldShowUpgrade
? $upgradeURL
: alertAction.link({
organization: $organization,
project: $project
});
if (!shouldShowUpgrade && alertAction.external) {
window.open(url, '_blank');
} else {
goto(url);
}
if (alertAction?.hideOnClick === true) {
// be careful of this one.
// once clicked, its gone!
handleClose();
}
trackEvent(Click.PromoClick, {
promo: currentModalAlert.id,
type: shouldShowUpgrade ? 'upgrade' : (event ?? `cta_click_${currentModalAlert.id}`)
});
}
function showUpgrade() {
const plan = currentModalAlert.plan;
const organizationPlan = $organization.billingPlan;
const organizationPlan = $organization?.billingPlan;
switch (plan) {
case 'free':
return false;
@@ -87,7 +161,7 @@
});
</script>
{#if filteredModalAlerts.length > 0 && currentModalAlert}
{#if filteredModalAlerts.length > 0 && currentModalAlert && !page.url.pathname.includes('console/onboarding')}
{@const shouldShowUpgrade = showUpgrade()}
<div class="main-alert-wrapper is-not-mobile">
<div class="alert-container">
@@ -150,7 +224,9 @@
{/if}
<div class="u-flex-vertical u-gap-4 u-padding-inline-8">
<h3 class="body-text-2 u-bold">{currentModalAlert.title}</h3>
<Typography.Text variant="m-500" color="--fgcolor-neutral-primary">
{currentModalAlert.title}
</Typography.Text>
<span class="u-width-fit-content">
{#if currentModalAlert.isHtml}
@@ -164,34 +240,23 @@
<div
class="buttons u-flex u-flex-vertical-mobile u-gap-4 u-padding-inline-8 u-padding-block-8">
<Button
secondary
class="button"
href={shouldShowUpgrade
? $upgradeURL
: currentModalAlert.cta.link({
organization: $organization,
project: $project
})}
external={!!currentModalAlert.cta.external}
fullWidthMobile
on:click={() => {
trackEvent(Click.PromoClick, {
promo: currentModalAlert.id,
type: shouldShowUpgrade ? 'upgrade' : 'try_now'
});
}}>
secondary={!hasOnlyPrimaryCta}
class={`${hasOnlyPrimaryCta ? 'only-primary-cta' : ''}`}
on:click={() => triggerWindowLink(currentModalAlert.cta)}>
{currentModalAlert.cta.text}
</Button>
{#if currentModalAlert.learnMore}
<!-- docs, learn-more, etc always external -->
<Button
text
class="button"
external
fullWidthMobile
href={currentModalAlert.learnMore.link({
organization: $organization,
project: $project
project: $project,
organization: $organization
})}>
{currentModalAlert.learnMore.text}
</Button>
@@ -266,7 +331,9 @@
{/if}
<div class="u-flex-vertical u-gap-8 u-padding-inline-8">
<h3 class="body-text-2 u-bold">{currentModalAlert.title}</h3>
<Typography.Text variant="m-500" color="--fgcolor-neutral-primary">
{currentModalAlert.title}
</Typography.Text>
<span class="u-width-fit-content">
{#if currentModalAlert.isHtml}
@@ -280,22 +347,12 @@
<div
class="buttons u-flex u-flex-vertical-mobile u-gap-4 u-padding-inline-8 u-padding-block-8">
<Button
secondary
secondary={!hasOnlyPrimaryCta}
class="button"
href={shouldShowUpgrade
? $upgradeURL
: currentModalAlert.cta.link({
organization: $organization,
project: $project
})}
external={!!currentModalAlert.cta.external}
fullWidthMobile
on:click={() => {
openModalOnMobile = false;
trackEvent(Click.PromoClick, {
promo: currentModalAlert.id,
type: shouldShowUpgrade ? 'upgrade' : 'try_now'
});
triggerWindowLink(currentModalAlert.cta);
}}>
{shouldShowUpgrade
? 'Upgrade plan'
@@ -303,6 +360,7 @@
</Button>
{#if currentModalAlert.learnMore}
<!-- docs, learn-more, etc always external -->
<Button
text
class="button"
@@ -310,8 +368,8 @@
fullWidthMobile
on:click={() => (openModalOnMobile = false)}
href={currentModalAlert.learnMore.link({
organization: $organization,
project: $project
project: $project,
organization: $organization
})}>
{currentModalAlert.learnMore.text}
</Button>
@@ -322,20 +380,41 @@
</article>
</div>
{:else}
<button
{@const mobileConfig = getMobileWindowConfig()}
<!-- we don't need keydown because we show this only on mobile -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
tabindex="0"
role="button"
class:showing={!openModalOnMobile}
class="card notification-card u-width-full-line"
on:click={() => (openModalOnMobile = true)}>
on:click={() => {
if (mobileConfig.cta) {
// navigate manually!
triggerMobileWindowLink();
} else {
openModalOnMobile = true;
}
}}>
<div class="u-flex-vertical u-gap-4">
<div class="u-flex u-cross-center u-main-space-between">
<h3 class="body-text-2 u-bold">New features available</h3>
<Typography.Text variant="m-500" color="--fgcolor-neutral-primary">
{currentModalAlert.title}
</Typography.Text>
<button on:click={hideAllModalAlerts} aria-label="Close">
<span class="icon-x"></span>
</button>
</div>
<span class="u-width-fit-content">
Explore new features to enhance your projects and improve security.
{#if mobileConfig.html}
{@html mobileConfig.message}
{:else}
{mobileConfig.message}
{/if}
</span>
</div>
</button>
</div>
{/if}
</div>
{/if}
@@ -364,6 +443,7 @@
top: 1rem;
right: 1rem;
cursor: pointer;
background: #fff;
position: absolute;
display: inline-flex;
@@ -377,6 +457,22 @@
border: hsl(var(--color-neutral-80)) solid 1px;
}
:global(.main-alert-wrapper .only-primary-cta) {
width: 100%;
text-align: center;
justify-content: center;
}
.showcase-image.u-only-light {
border-radius: 8px;
border: 0.795px solid var(--border-neutral-strong, #d8d8db);
}
.showcase-image.u-only-dark {
border-radius: 8px;
border: 0.795px solid var(--border-neutral-strong, #414146);
}
.u-gap-10 {
gap: 0.625rem;
}
+3 -4
View File
@@ -1,10 +1,9 @@
<script lang="ts">
import { Card } from '@appwrite.io/pink-svelte';
import type Base from '@appwrite.io/pink-svelte/dist/card/Base.svelte';
import type { ComponentProps } from 'svelte';
import type { BaseCardProps } from './card.svelte';
export let radius: ComponentProps<Base>['radius'] = 'm';
export let padding: ComponentProps<Base>['padding'] = 's';
export let radius: BaseCardProps['radius'] = 'm';
export let padding: BaseCardProps['padding'] = 's';
</script>
<Card.Base variant="secondary" {radius} {padding}>
+21 -19
View File
@@ -21,6 +21,7 @@
name: string;
$id: string;
isSelected: boolean;
region: string;
};
type Organization = {
name: string;
@@ -65,7 +66,7 @@
export let organizations: Organization[] = [];
$: selectedOrg = organizations.find((organization) => organization.isSelected);
$: selectedProject = selectedOrg?.projects.find((project) => project.isSelected);
$: selectedProject = $page.data.project;
let organisationBottomSheetOpen = false;
let projectsBottomSheetOpen = false;
@@ -98,7 +99,7 @@
$: organizationsBottomSheet = !selectedOrg
? switchOrganization
: {
: ({
top: {
items: [
{
@@ -127,8 +128,8 @@
}
]
}
};
let projectsBottomSheet: SheetMenu;
} satisfies SheetMenu);
$: projectsBottomSheet = {
top:
selectedOrg?.projects.length > 1
@@ -141,7 +142,7 @@
if (index < 4) {
return {
name: project.name,
href: `${base}/project-${project.$id}/overview`
href: `${base}/project-${project.region}-${project.$id}/overview`
};
} else if (index === 4) {
return {
@@ -174,7 +175,7 @@
]
}
: undefined
};
} satisfies SheetMenu;
function onResize() {
if ((organisationBottomSheetOpen || projectsBottomSheetOpen) && !$isSmallViewport) {
@@ -319,17 +320,20 @@
{#if index < 4}
<div use:melt={$itemProjects}>
<ActionMenu.Root>
<ActionMenu.Item.Anchor href={`${base}/project-${project.$id}`}
>{project.name}</ActionMenu.Item.Anchor
></ActionMenu.Root>
<ActionMenu.Item.Anchor
href={`${base}/project-${project.region}-${project.$id}`}>
{project.name}
</ActionMenu.Item.Anchor>
</ActionMenu.Root>
</div>
{:else if index === 4}
<div use:melt={$itemProjects}>
<ActionMenu.Root>
<ActionMenu.Item.Anchor
href={`${base}/organization-${selectedOrg.$id}`}
>All projects</ActionMenu.Item.Anchor
></ActionMenu.Root>
href={`${base}/organization-${selectedOrg.$id}`}>
All projects
</ActionMenu.Item.Anchor>
</ActionMenu.Root>
</div>
{/if}
{/each}
@@ -339,18 +343,16 @@
<ActionMenu.Root>
<ActionMenu.Item.Anchor
leadingIcon={IconPlusSm}
href={`${base}/organization-${selectedOrg?.$id}?create-project`}
>Create project</ActionMenu.Item.Anchor
></ActionMenu.Root>
href={`${base}/organization-${selectedOrg?.$id}?create-project`}>
Create project
</ActionMenu.Item.Anchor></ActionMenu.Root>
</div>
</Card.Base>
</div>
{/if}
</div>
<BottomSheet.Menu bind:isOpen={organisationBottomSheetOpen} menu={organizationsBottomSheet}
></BottomSheet.Menu>
<BottomSheet.Menu bind:isOpen={projectsBottomSheetOpen} menu={projectsBottomSheet}
></BottomSheet.Menu>
<BottomSheet.Menu bind:isOpen={organisationBottomSheetOpen} menu={organizationsBottomSheet} />
<BottomSheet.Menu bind:isOpen={projectsBottomSheetOpen} menu={projectsBottomSheet} />
<style lang="scss">
.menu {
+12 -3
View File
@@ -1,7 +1,16 @@
<script context="module" lang="ts">
export type BaseCardProps = Partial<{
variant: 'primary' | 'secondary';
radius: 's' | 'm' | 'l';
padding: 'none' | 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l';
border: 'solid' | 'dashed';
shadow?: boolean;
disabled?: boolean;
}>;
</script>
<script lang="ts">
import { Card, Layout } from '@appwrite.io/pink-svelte';
import type Base from '@appwrite.io/pink-svelte/dist/card/Base.svelte';
import type { ComponentProps } from 'svelte';
type BaseProps = {
isDashed?: boolean;
@@ -20,7 +29,7 @@
isButton?: never;
};
type $$Props = BaseProps & (ButtonProps | AnchorProps | BaseProps) & ComponentProps<Base>;
type $$Props = BaseProps & (ButtonProps | AnchorProps | BaseProps) & BaseCardProps;
export let isDashed = false;
export let isButton = false;
+8 -3
View File
@@ -2,10 +2,11 @@
import { page } from '$app/state';
import { Empty } from '$lib/components';
import { CARD_LIMIT } from '$lib/constants';
import { getServiceLimit, type PlanServices } from '$lib/stores/billing';
import { preferences } from '$lib/stores/preferences';
import { isCloud } from '$lib/system';
import CardPlanLimit from './cardPlanLimit.svelte';
import { preferences } from '$lib/stores/preferences';
import { isSmallViewport } from '$lib/stores/viewport';
import { getServiceLimit, type PlanServices } from '$lib/stores/billing';
export let disableEmpty = true;
export let offset = 0;
@@ -17,9 +18,13 @@
$: planLimit = getServiceLimit(serviceId) || Infinity;
$: limit = preferences.get(page.route)?.limit ?? CARD_LIMIT;
$: gridItemStyle = $isSmallViewport
? undefined
: `--grid-item-size: ${total > 3 ? '22rem' : '25rem'}`;
</script>
<ul class="grid-box" style={`--grid-item-size:${total > 3 ? '22rem' : '25rem'};`} data-private>
<ul data-private class="grid-box" style={gridItemStyle}>
<slot />
{#if total > 3 ? total < limit + offset : total % 2 !== 0}
+2 -1
View File
@@ -9,8 +9,9 @@
export let event: string = null;
export let eventContext = 'click_id_tag';
export let tooltipDisabled = false;
export let copyText: string = 'Click to copy';
let content = 'Click to copy';
let content = copyText;
async function handleClick() {
const success = await copy(value);
@@ -9,7 +9,7 @@
function getCreditCardImage(brand: string, width = 46, height = 32) {
if (!isValueOfStringEnum(CreditCard, brand)) return '';
return sdk.forConsole.avatars.getCreditCard(brand, width, height).toString();
return sdk.forConsole.avatars.getCreditCard(brand, width, height);
}
</script>
+5 -4
View File
@@ -2,9 +2,9 @@
import type { PaymentMethodData } from '$lib/sdk/billing';
import { Badge, Layout, Link, Popover, Table } from '@appwrite.io/pink-svelte';
import CreditCardBrandImage from './creditCardBrandImage.svelte';
import type { RootProp } from '@appwrite.io/pink-svelte/dist/table';
import type { TableRootProp } from '$lib/helpers/types';
export let root: RootProp;
export let root: TableRootProp;
export let paymentMethod: PaymentMethodData;
export let isBackup: boolean = false;
</script>
@@ -19,8 +19,9 @@
</Layout.Stack>
</Table.Cell>
<Table.Cell column="name" {root}>{paymentMethod?.name}</Table.Cell>
<Table.Cell column="expiry" {root}
>{paymentMethod?.expiryMonth}/{paymentMethod?.expiryYear}</Table.Cell>
<Table.Cell column="expiry" {root}>
{paymentMethod?.expiryMonth}/{paymentMethod?.expiryYear}
</Table.Cell>
<Table.Cell column="status" {root}>
{#if paymentMethod?.lastError || paymentMethod?.expired}
<Popover let:toggle>
+9 -8
View File
@@ -31,9 +31,8 @@
collectionId: string,
importData: Payload
) {
const projectId = page.params.project;
await invalidate(Dependencies.DOCUMENTS);
const url = `${base}/project-${projectId}/databases/database-${databaseId}/collection-${collectionId}`;
const url = `${base}/project-${page.params.region}-${page.params.project}/databases/database-${databaseId}/collection-${collectionId}`;
// extract clean message from nested backend error.
const match = importData.errors.join('').match(/message: '(.*)' Message:/i);
@@ -73,10 +72,9 @@
if (!collectionName && collectionId) {
try {
const collection = await sdk.forProject.databases.getCollection(
databaseId,
collectionId
);
const collection = await sdk
.forProject(page.params.region, page.params.project)
.databases.getCollection(databaseId, collectionId);
collectionName = collection.name;
} catch {
collectionName = null;
@@ -142,8 +140,11 @@
}
onMount(() => {
sdk.forProject.migrations
.list([Query.equal('source', 'CSV'), Query.equal('status', ['pending', 'processing'])])
sdk.forProject(page.params.region, page.params.project)
.migrations.list([
Query.equal('source', 'CSV'),
Query.equal('status', ['pending', 'processing'])
])
.then((migrations) => {
migrations.migrations.forEach(updateOrAddItem);
});
+6 -12
View File
@@ -1,6 +1,5 @@
<script lang="ts">
import { Link } from '$lib/elements';
import { consoleVariables } from '$routes/(console)/store';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import {
Badge,
@@ -10,9 +9,10 @@
Icon,
InteractiveText
} from '@appwrite.io/pink-svelte';
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
export let domain: string;
export let verified = false;
export let verified = undefined;
let subdomain = domain.split('.').slice(0, -2).join('.');
</script>
@@ -23,16 +23,10 @@
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
{domain}
</Typography.Text>
{#if verified}
<Badge variant="secondary" type="success" content="Verified" />
{#if verified === true}
<Badge variant="secondary" type="success" size="xs" content="Verified" />
{:else if verified === false}
<Badge variant="secondary" type="error" content="Verification failed" />
{:else}
<Badge
variant="secondary"
type="warning"
size="xs"
content="Pending verification" />
<Badge variant="secondary" type="error" size="xs" content="Verification failed" />
{/if}
</Layout.Stack>
<Typography.Text variant="m-400">
@@ -54,7 +48,7 @@
<InteractiveText
variant="copy"
isVisible
text={$consoleVariables._APP_DOMAIN_TARGET_CNAME} />
text={$regionalConsoleVariables._APP_DOMAIN_TARGET_CNAME} />
</Table.Cell>
</Table.Row.Base>
</Table.Root>
@@ -1,13 +1,13 @@
<script lang="ts">
import { consoleVariables } from '$routes/(console)/store';
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
import { Badge, Layout, Typography, Table, InteractiveText } from '@appwrite.io/pink-svelte';
export let domain: string;
export let verified = false;
export let verified = undefined;
const nameserverList = $consoleVariables?._APP_DOMAINS_NAMESERVERS
? $consoleVariables?._APP_DOMAINS_NAMESERVERS?.split(',')
const nameserverList = $regionalConsoleVariables?._APP_DOMAINS_NAMESERVERS
? $regionalConsoleVariables?._APP_DOMAINS_NAMESERVERS?.split(',')
: ['ns1.appwrite.io', 'ns2.appwrite.io'];
</script>
@@ -16,10 +16,10 @@
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
{domain}
</Typography.Text>
{#if verified}
<Badge variant="secondary" type="success" content="Verified" />
{#if verified === true}
<Badge variant="secondary" type="success" size="xs" content="Verified" />
{:else if verified === false}
<Badge variant="secondary" type="warning" size="xs" content="Pending verification" />
<Badge variant="secondary" type="warning" size="xs" content="Verification failed" />
{/if}
</Layout.Stack>
<Typography.Text variant="m-400">
+31 -25
View File
@@ -1,30 +1,32 @@
<script lang="ts">
import { Link } from '$lib/elements';
import { consoleVariables } from '$routes/(console)/store';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import {
Badge,
Layout,
Typography,
Table,
Icon,
InteractiveText
InteractiveText,
Alert
} from '@appwrite.io/pink-svelte';
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
export let domain: string;
export let verified = false;
export let verified = undefined;
export let variant: 'cname' | 'a' | 'aaaa';
export let service: 'sites' | 'general' = 'general';
let subdomain = domain?.split('.')?.slice(0, -2)?.join('.');
function setTarget() {
switch (variant) {
case 'cname':
return $consoleVariables._APP_DOMAIN_TARGET_CNAME;
return service === 'general'
? $regionalConsoleVariables._APP_DOMAIN_TARGET_CNAME
: $regionalConsoleVariables._APP_DOMAIN_SITES;
case 'a':
return $consoleVariables._APP_DOMAIN_TARGET_A;
return $regionalConsoleVariables._APP_DOMAIN_TARGET_A;
case 'aaaa':
return $consoleVariables._APP_DOMAIN_TARGET_AAAA;
return $regionalConsoleVariables._APP_DOMAIN_TARGET_AAAA;
}
}
</script>
@@ -35,16 +37,10 @@
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
{domain}
</Typography.Text>
{#if verified}
<Badge variant="secondary" type="success" content="Verified" />
{#if verified === true}
<Badge variant="secondary" type="success" size="xs" content="Verified" />
{:else if verified === false}
<Badge variant="secondary" type="error" content="Verification failed" />
{:else}
<Badge
variant="secondary"
type="warning"
size="xs"
content="Pending verification" />
<Badge variant="secondary" type="error" size="xs" content="Verification failed" />
{/if}
</Layout.Stack>
<Typography.Text variant="m-400">
@@ -68,13 +64,23 @@
</Table.Row.Base>
</Table.Root>
<Layout.Stack gap="s" direction="row" alignItems="center">
<Icon icon={IconInfo} size="s" color="--fgcolor-neutral-secondary" />
<Typography.Text variant="m-400" color="--fgcolor-neutral-secondary">
A list of all domain providers and their DNS setting is available <Link
variant="muted"
external
href="https://appwrite.io/docs/advanced/platform/custom-domains">here</Link
>.
</Typography.Text>
{#if variant === 'cname'}
<Alert.Inline>
If your domain uses CAA records, ensure certainly.com is authorized — otherwise, SSL
setup may fail. A list of all domain providers and their DNS setting is available <Link
variant="muted"
external
href="https://appwrite.io/docs/advanced/platform/custom-domains">here</Link
>.
</Alert.Inline>
{:else}
<Typography.Text variant="m-400" color="--fgcolor-neutral-secondary">
A list of all domain providers and their DNS setting is available <Link
variant="muted"
external
href="https://appwrite.io/docs/advanced/platform/custom-domains">here</Link
>.
</Typography.Text>
{/if}
</Layout.Stack>
</Layout.Stack>
+1 -1
View File
@@ -110,7 +110,7 @@
<InteractiveText
isVisible
variant="copy"
text={toLocaleDateTime(time, 'UTC')}
text={toLocaleDateTime(time, false, 'UTC')}
value={toISOString(time)} />
<Badge variant="secondary" content="UTC" size="xs" />
@@ -4,7 +4,6 @@
import { Card, Layout, Typography } from '@appwrite.io/pink-svelte';
export let source = 'empty_state_card';
export let noAspectRatio = false;
</script>
<Card.Base variant="secondary" padding="s" radius="s">
@@ -1,3 +1,10 @@
<script context="module" lang="ts">
export type ExpirationOptions = {
label: string;
value: string;
};
</script>
<script lang="ts">
import { InputDateTime, InputSelect } from '$lib/elements/forms';
import { isSameDay, isValidDate, toLocaleDate } from '$lib/helpers/date';
@@ -19,7 +26,7 @@
return date.toISOString();
}
const defaultOptions = [
const defaultOptions: ExpirationOptions[] = [
{
label: 'Never',
value: null
@@ -46,7 +53,7 @@
}
];
const limitedOptions = [
const limitedOptions: ExpirationOptions[] = [
{
label: '1 Day',
value: incrementToday(1, 'day')
@@ -62,9 +69,16 @@
];
export let value: string | null = null;
export let keyType: 'api' | 'dev' = 'api';
export let dateSelectorLabel: string | undefined = undefined;
export let selectorLabel: string | undefined = 'Expiration date';
export let resourceType: string | 'key' | 'token' | undefined = 'key';
export let expiryOptions: 'default' | 'limited' | ExpirationOptions[] = 'default';
const options = keyType === 'api' ? defaultOptions : limitedOptions;
const options = Array.isArray(expiryOptions)
? expiryOptions
: expiryOptions === 'default'
? defaultOptions
: limitedOptions;
function initExpirationSelect() {
if (value === null || !isValidDate(value)) {
@@ -83,8 +97,16 @@
return result;
}
/**
* Custom picker only supports `dd/mm/yy` format.
*/
function splitDateValue(value: string): string {
return value.slice(0, 10);
}
let expirationSelect = initExpirationSelect();
let expirationCustom: string | null = value ?? null;
let expirationCustom: string | null = value ? splitDateValue(value) : null;
$: {
if (!isSameDay(new Date(expirationSelect), new Date(value))) {
@@ -94,8 +116,8 @@
$: helper =
expirationSelect !== 'custom' && expirationSelect !== null
? `Your key will expire in ${toLocaleDate(value)}`
: undefined;
? `Your ${resourceType} will expire in ${toLocaleDate(value)}`
: null;
</script>
<InputSelect
@@ -103,9 +125,9 @@
{helper}
{options}
id="preset"
label="Expiration date"
label={selectorLabel}
bind:value={expirationSelect} />
{#if expirationSelect === 'custom'}
<InputDateTime required id="expire" label="" bind:value={expirationCustom} />
<InputDateTime required id="expire" label={dateSelectorLabel} bind:value={expirationCustom} />
{/if}
+1 -1
View File
@@ -30,7 +30,7 @@
}
}
function closeModal() {
export function closeModal() {
document.documentElement.classList.remove('u-overflow-hidden');
show = false;
}
+1 -1
View File
@@ -11,7 +11,7 @@
import { addNotification } from '$lib/stores/notifications';
import { page } from '$app/state';
import { Typography } from '@appwrite.io/pink-svelte';
import { project } from '$routes/(console)/project-[project]/store';
import { project } from '$routes/(console)/project-[region]-[project]/store';
$: $selectedFeedback = feedbackOptions.find((option) => option.type === $feedback.type);
+20 -17
View File
@@ -29,7 +29,7 @@
import Form from '$lib/elements/forms/form.svelte';
import { isSmallViewport } from '$lib/stores/viewport';
import { IconViewGrid, IconViewList } from '@appwrite.io/pink-icons-svelte';
import { showCreateBucket } from '$routes/(console)/project-[project]/storage/+page.svelte';
import { showCreateBucket } from '$routes/(console)/project-[region]-[project]/storage/+page.svelte';
import { consoleProfile, isStudio } from '$lib/system';
export let show: boolean;
@@ -59,20 +59,21 @@
function getPreview(bucketId: string, fileId: string, size: number = 64) {
return (
sdk.forProject.storage.getFilePreview(bucketId, fileId, size, size).toString() +
'&mode=admin'
sdk
.forProject(page.params.region, page.params.project)
.storage.getFilePreview(bucketId, fileId, size, size)
.toString() + '&mode=admin'
);
}
async function uploadFile() {
try {
uploading = true;
const file = await sdk.forProject.storage.createFile(
selectedBucket,
ID.unique(),
fileSelector.files[0],
[Permission.read(Role.any())]
);
const file = await sdk
.forProject(page.params.region, page.params.project)
.storage.createFile(selectedBucket, ID.unique(), fileSelector.files[0], [
Permission.read(Role.any())
]);
search.set($search === null ? '' : null);
selectFile(file);
} catch (e) {
@@ -120,7 +121,9 @@
let buckets: Promise<Models.BucketList> = loadBuckets();
async function loadBuckets() {
const response = await sdk.forProject.storage.listBuckets();
const response = await sdk
.forProject(page.params.region, page.params.project)
.storage.listBuckets();
const bucket = response.buckets[0] ?? null;
if (bucket) {
currentBucket = bucket;
@@ -149,8 +152,9 @@
$: files =
currentBucket &&
sdk.forProject.storage
.listFiles(currentBucket.$id, getProperQuery(), $search || undefined)
sdk
.forProject(page.params.region, page.params.project)
.storage.listFiles(currentBucket.$id, getProperQuery(), $search || undefined)
.then((response) => {
if ($search === '') {
searchEnabled = response.total > 0;
@@ -164,8 +168,6 @@
}
$: extension = allowedExtension === '*' ? mimeTypeQuery : `.${allowedExtension}`;
$: console.log(`Allowed extensions: ${allowedExtension}, MimeType: ${mimeTypeQuery}`);
</script>
<svelte:document on:visibilitychange={handleVisibilityChange} />
@@ -187,6 +189,7 @@
required
disabled
id="bucket"
value={null}
options={[]}
label="Bucket"
placeholder="Loading buckets..." />
@@ -535,7 +538,7 @@
secondary
on:click={async () => {
await goto(
`${base}/project-${page.params.project}/storage`
`${base}/project-${page.params.region}-${page.params.project}/storage`
);
$showCreateBucket = true;
}}>
@@ -547,8 +550,8 @@
{/if}
{/await}
</Layout.Stack>
</div>
</Layout.Stack>
</div></Layout.Stack>
<svelte:fragment slot="footer">
<Layout.Stack direction="row" justifyContent="flex-end">
<Button text on:click={closeModal}>Cancel</Button>
@@ -65,8 +65,6 @@
items: filterCols.map((col) => {
return {
name: col.title,
onClick: () =>
console.log(subSheets.find((sheet) => sheet?.title === col?.title)),
subMenu: subSheets.find((sheet) => sheet?.title === col?.title),
trailingIcon: IconChevronRight
};
@@ -111,8 +109,6 @@
return arrayValue;
}
}
$inspect(subSheets);
</script>
<BottomSheet.Menu bind:isOpen={openBottomSheet} menu={filtersBottomSheet} />
@@ -11,14 +11,7 @@
} from '$lib/elements/forms';
import type { Writable } from 'svelte/store';
import Modal from '../modal.svelte';
import {
addFilter,
generateTag,
operators,
queries,
ValidOperators,
type TagValue
} from './store';
import { generateTag, operators, ValidOperators, type TagValue } from './store';
import type { Column } from '$lib/helpers/types';
import { TagList } from '.';
import { Icon, Layout } from '@appwrite.io/pink-svelte';
@@ -1,7 +1,7 @@
<script lang="ts">
import type { Column } from '$lib/helpers/types';
import { type Writable } from 'svelte/store';
import { CustomFilters, FiltersBottomSheet } from '$lib/components/filters';
import { CustomFilters } from '$lib/components/filters';
import { addFilterAndApply, type FilterData } from './quickFilters';
import { parsedTags } from './setFilters';
import Menu from '../menu/menu.svelte';
@@ -19,8 +19,6 @@
filterCols: FilterData[];
analyticsSource?: string;
} = $props();
$inspect(filterCols);
</script>
<Menu>
-1
View File
@@ -133,7 +133,6 @@ export function setStatusCodeFilter(filter: FilterData, columns: Column[]) {
tag: `**${filter.title}** is **${codeRange.label}**`,
value: statusCodeTag.value
};
console.log(codeRange);
parsedTags.update((tags) => {
tags.push(newTag);
return tags;
@@ -1,9 +1,9 @@
<script lang="ts">
import { LabelCard } from '$lib/components';
import { consoleVariables } from '$routes/(console)/store';
import { Layout } from '@appwrite.io/pink-svelte';
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
const isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
const isVcsEnabled = $regionalConsoleVariables?._APP_VCS_ENABLED === true;
export let connectBehaviour: 'now' | 'later' = isVcsEnabled ? 'now' : 'later';
</script>
+5 -5
View File
@@ -1,14 +1,14 @@
<script lang="ts">
import Button from '$lib/elements/forms/button.svelte';
import { consoleVariables } from '$routes/(console)/store';
import { IconGithub } from '@appwrite.io/pink-icons-svelte';
import { Alert, Card, Empty, Icon, Layout } from '@appwrite.io/pink-svelte';
import { isSelfHosted } from '$lib/system';
import { connectGitHub } from '$lib/stores/git';
import Button from '$lib/elements/forms/button.svelte';
import { IconGithub } from '@appwrite.io/pink-icons-svelte';
import { Alert, Card, Empty, Icon, Layout } from '@appwrite.io/pink-svelte';
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
export let callbackState: Record<string, string> = null;
let isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
let isVcsEnabled = $regionalConsoleVariables?._APP_VCS_ENABLED === true;
</script>
<Layout.Stack>
@@ -12,6 +12,7 @@
import { addNotification } from '$lib/stores/notifications';
import { Click, trackEvent } from '$lib/actions/analytics';
import RepositoryBehaviour from '$lib/components/git/repositoryBehaviour.svelte';
import { page } from '$app/state';
let {
show = $bindable(false),
@@ -38,12 +39,14 @@
let error = $state('');
onMount(async () => {
installations = await sdk.forProject.vcs.listInstallations();
installations = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listInstallations();
if (!$installation?.$id && installations?.total) {
$installation = installations.installations[0];
}
selectedInstallationId = installations.total ? installations.installations[0]?.$id : '';
if (!!installations?.total) {
if (installations?.total) {
repositoryBehaviour = 'existing';
}
});
@@ -51,11 +54,9 @@
async function connectRepo() {
try {
if (repositoryBehaviour === 'new') {
const repo = await sdk.forProject.vcs.createRepository(
$installation.$id,
repositoryName,
repositoryPrivate
);
const repo = await sdk
.forProject(page.params.region, page.params.project)
.vcs.createRepository($installation.$id, repositoryName, repositoryPrivate);
repository.set(repo);
selectedRepository = repo.id;
}
@@ -2,10 +2,10 @@
import { Trim } from '$lib/components';
import { Link } from '$lib/elements';
import { Button } from '$lib/elements/forms';
import { protocol } from '$routes/(console)/store';
import type { Models } from '@appwrite.io/console';
import { IconExternalLink, IconQrcode } from '@appwrite.io/pink-icons-svelte';
import { ActionMenu, Icon, Layout, Popover, Tag, Typography } from '@appwrite.io/pink-svelte';
import { regionalProtocol } from '$routes/(console)/project-[region]-[project]/store';
let {
domains,
@@ -31,7 +31,7 @@
<Layout.Stack gap="xxs" direction="row" alignItems="center">
{#if domains?.total}
<Link external href={`${$protocol}${sortedDomains[0]?.domain}`} variant="muted">
<Link external href={`${$regionalProtocol}${sortedDomains[0]?.domain}`} variant="muted">
<Layout.Stack gap="xxs" direction="row" alignItems="center">
<Trim alternativeTrim>
<Typography.Text variant="m-400" color="--fgcolor-neutral-primary">
@@ -51,7 +51,7 @@
{#each sortedDomains as rule, i}
{#if i !== 0}
<ActionMenu.Item.Anchor
href={`${$protocol}${rule.domain}`}
href={`${$regionalProtocol}${rule.domain}`}
external
leadingIcon={IconExternalLink}>
<Trim alternativeTrim>
@@ -1,9 +1,10 @@
<script lang="ts">
import { Button, InputSelect, InputText } from '$lib/elements/forms';
import { Button, InputText } from '$lib/elements/forms';
import { Fieldset, Input, Layout, Selector, Skeleton } from '@appwrite.io/pink-svelte';
import SelectRootModal from './selectRootModal.svelte';
import { sdk } from '$lib/stores/sdk';
import { sortBranches } from '$lib/stores/vcs';
import { page } from '$app/state';
export let branch = 'main';
export let rootDir: string;
@@ -15,10 +16,9 @@
let show = false;
async function loadBranches() {
const { branches } = await sdk.forProject.vcs.listRepositoryBranches(
installationId,
repositoryId
);
const { branches } = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositoryBranches(installationId, repositoryId);
const sorted = sortBranches(branches);
branch = sorted[0]?.name ?? null;
@@ -65,7 +65,6 @@
id="branch"
label="Production branch"
placeholder="Select branch"
isSearchable
bind:value={branch}
on:select={(event) => {
branch = event.detail.value;
+152 -139
View File
@@ -1,9 +1,9 @@
<script lang="ts">
import { Empty, EmptySearch, Paginator } from '$lib/components';
import { EmptySearch, Paginator } from '$lib/components';
import { Button, InputSearch, InputSelect } from '$lib/elements/forms';
import { timeFromNow } from '$lib/helpers/date';
import { sdk } from '$lib/stores/sdk';
import { repositories } from '$routes/(console)/project-[project]/functions/function-[function]/store';
import { repositories } from '$routes/(console)/project-[region]-[project]/functions/function-[function]/store';
import { installation, installations, repository } from '$lib/stores/vcs';
import {
Layout,
@@ -11,7 +11,6 @@
Typography,
Icon,
Avatar,
Skeleton,
Button as PinkButton
} from '@appwrite.io/pink-svelte';
import { IconLockClosed, IconPlus } from '@appwrite.io/pink-icons-svelte';
@@ -20,7 +19,10 @@
import { VCSDetectionType, type Models } from '@appwrite.io/console';
import { getFrameworkIcon } from '$lib/stores/sites';
import { connectGitHub } from '$lib/stores/git';
import { page } from '$app/state';
import Card from '../card.svelte';
import SkeletonRepoList from './skeletonRepoList.svelte';
import { untrack } from 'svelte';
let {
action = $bindable('select'),
@@ -42,11 +44,12 @@
let search = $state('');
let selectedInstallation = $state(null);
let isLoadingRepositories = $state(null);
async function loadInstallations() {
if (installationList) {
if (installationList.installations.length) {
selectedInstallation = installationList.installations[0].$id;
untrack(() => (selectedInstallation = installationList.installations[0].$id));
installation.set(
installationList.installations.find(
(entry) => entry.$id === selectedInstallation
@@ -55,9 +58,11 @@
}
return installationList.installations;
} else {
const { installations } = await sdk.forProject.vcs.listInstallations();
const { installations } = await sdk
.forProject(page.params.region, page.params.project)
.vcs.listInstallations();
if (installations.length) {
selectedInstallation = installations[0].$id;
untrack(() => (selectedInstallation = installations[0].$id));
installation.set(installations.find((entry) => entry.$id === selectedInstallation));
}
return installations;
@@ -73,9 +78,6 @@
await fetchRepos(installationId, search);
}
$repositories.search = search;
$repositories.installationId = installationId;
if ($repositories.repositories.length && action === 'select') {
selectedRepository = $repositories.repositories[0].id;
$repository = $repositories.repositories[0];
@@ -86,22 +88,31 @@
async function fetchRepos(installationId: string, search: string) {
if (product === 'functions') {
$repositories.repositories = (
(await sdk.forProject.vcs.listRepositories(
installationId,
VCSDetectionType.Runtime,
search || undefined
)) as unknown as Models.ProviderRepositoryRuntimeList
(await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositories(
installationId,
VCSDetectionType.Runtime,
search || undefined
)) as unknown as Models.ProviderRepositoryRuntimeList
).runtimeProviderRepositories; //TODO: remove forced cast after backend fixes
} else {
$repositories.repositories = (
(await sdk.forProject.vcs.listRepositories(
installationId,
VCSDetectionType.Framework,
search || undefined
)) as unknown as Models.ProviderRepositoryFrameworkList
(await sdk
.forProject(page.params.region, page.params.project)
.vcs.listRepositories(
installationId,
VCSDetectionType.Framework,
search || undefined
)) as unknown as Models.ProviderRepositoryFrameworkList
).frameworkProviderRepositories;
}
$repositories.search = search;
$repositories.installationId = installationId;
}
selectedRepository;
</script>
{#if hasInstallations}
@@ -146,6 +157,11 @@
installation.set(
installations.find((entry) => entry.$id === selectedInstallation)
);
isLoadingRepositories = true;
loadRepositories(selectedInstallation, search).then(() => {
isLoadingRepositories = false;
});
}}
bind:value={selectedInstallation} />
<InputSearch
@@ -156,133 +172,130 @@
{/await}
</Layout.Stack>
{#if selectedInstallation}
{#await loadRepositories(selectedInstallation, search)}
<Table.Root columns={1} let:root>
{#each Array(4) as _}
<Table.Row.Base {root}>
<Table.Cell {root}>
<Layout.Stack direction="row" alignItems="center">
<Skeleton variant="circle" width={24} />
<Layout.Stack gap="s" direction="row" alignItems="center">
<Skeleton variant="line" width={200} height={20} />
</Layout.Stack>
<Skeleton variant="line" width={76} height={32} />
</Layout.Stack>
</Table.Cell>
</Table.Row.Base>
{/each}
</Table.Root>
{:then response}
{#if response?.length}
<Paginator items={response} hideFooter={response?.length <= 6} limit={6}>
{#snippet children(
paginatedItems: Models.ProviderRepositoryRuntime[] &
Models.ProviderRepositoryFramework[]
)}
<Table.Root columns={1} let:root>
{#each paginatedItems as repo}
<Table.Row.Base {root}>
<Table.Cell {root}>
<Layout.Stack
direction="row"
alignItems="center"
gap="s">
{#if action === 'select'}
<input
class="is-small u-margin-inline-end-8"
type="radio"
name="repositories"
bind:group={selectedRepository}
onchange={() => repository.set(repo)}
value={repo.id} />
{/if}
{#if product === 'sites'}
{#if repo?.framework && repo.framework !== 'other'}
<Avatar size="xs" alt={repo.name}>
<!-- manual installation change -->
{#if isLoadingRepositories}
<SkeletonRepoList />
{:else}
{#await loadRepositories(selectedInstallation, search)}
<SkeletonRepoList />
{:then response}
{#if response?.length}
<Paginator items={response} hideFooter={response?.length <= 6} limit={6}>
{#snippet children(
paginatedItems: Models.ProviderRepositoryRuntime[] &
Models.ProviderRepositoryFramework[]
)}
<Table.Root columns={1} let:root>
{#each paginatedItems as repo}
<Table.Row.Base {root}>
<Table.Cell {root}>
<Layout.Stack
direction="row"
alignItems="center"
gap="s">
{#if action === 'select'}
<input
class="is-small u-margin-inline-end-8"
type="radio"
name="repositories"
bind:group={selectedRepository}
onchange={() => repository.set(repo)}
value={repo.id} />
{/if}
{#if product === 'sites'}
{#if repo?.framework && repo.framework !== 'other'}
<Avatar size="xs" alt={repo.name}>
<SvgIcon
name={getFrameworkIcon(
repo.framework
)}
iconSize="small" />
</Avatar>
{:else}
<Avatar
size="xs"
alt={repo.name}
empty />
{/if}
{:else}
{@const iconName = repo?.runtime
? repo.runtime.split('-')[0]
: undefined}
<Avatar
size="xs"
alt={repo.name}
empty={!iconName}>
<SvgIcon
name={getFrameworkIcon(
repo.framework
)}
name={iconName}
iconSize="small" />
</Avatar>
{:else}
<Avatar size="xs" alt={repo.name} empty />
{/if}
{:else}
{@const iconName = repo?.runtime
? repo.runtime.split('-')[0]
: undefined}
<Avatar
size="xs"
alt={repo.name}
empty={!iconName}>
<SvgIcon name={iconName} iconSize="small" />
</Avatar>
{/if}
<Layout.Stack
gap="s"
direction="row"
alignItems="center">
<Typography.Text
truncate
color="--fgcolor-neutral-secondary">
{repo.name}
</Typography.Text>
{#if repo.private}
<Icon
size="s"
icon={IconLockClosed}
color="--fgcolor-neutral-tertiary" />
{/if}
<time datetime={repo.pushedAt}>
<Typography.Caption
variant="400"
truncate
color="--fgcolor-neutral-tertiary">
{timeFromNow(repo.pushedAt)}
</Typography.Caption>
</time>
</Layout.Stack>
{#if action === 'button'}
<Layout.Stack
gap="s"
direction="row"
justifyContent="flex-end">
<PinkButton.Button
size="xs"
variant="secondary"
on:click={() => connect(repo)}>
Connect
</PinkButton.Button>
alignItems="center">
<Typography.Text
truncate
color="--fgcolor-neutral-secondary">
{repo.name}
</Typography.Text>
{#if repo.private}
<Icon
size="s"
icon={IconLockClosed}
color="--fgcolor-neutral-tertiary" />
{/if}
<time datetime={repo.pushedAt}>
<Typography.Caption
variant="400"
truncate
color="--fgcolor-neutral-tertiary">
{timeFromNow(repo.pushedAt)}
</Typography.Caption>
</time>
</Layout.Stack>
{/if}
</Layout.Stack>
</Table.Cell>
</Table.Row.Base>
{/each}
</Table.Root>
{/snippet}
</Paginator>
{:else if search}
<EmptySearch hidePages hidePagination bind:search target="repositories">
<svelte:fragment slot="actions">
{#if search}
<Button secondary on:click={() => (search = '')}>
Clear search
</Button>
{/if}
</svelte:fragment>
</EmptySearch>
{:else}
<Card>
<Layout.Stack alignItems="center" justifyContent="center">
<Typography.Text variation="m-500" color="--fgcolor-neutral-tertiary">
No repositories available
</Typography.Text>
</Layout.Stack>
</Card>
{/if}
{/await}
{#if action === 'button'}
<Layout.Stack
direction="row"
justifyContent="flex-end">
<PinkButton.Button
size="xs"
variant="secondary"
on:click={() => connect(repo)}>
Connect
</PinkButton.Button>
</Layout.Stack>
{/if}
</Layout.Stack>
</Table.Cell>
</Table.Row.Base>
{/each}
</Table.Root>
{/snippet}
</Paginator>
{:else if search}
<EmptySearch hidePages hidePagination bind:search target="repositories">
<svelte:fragment slot="actions">
{#if search}
<Button secondary on:click={() => (search = '')}>
Clear search
</Button>
{/if}
</svelte:fragment>
</EmptySearch>
{:else}
<Card>
<Layout.Stack alignItems="center" justifyContent="center">
<Typography.Text
variation="m-500"
color="--fgcolor-neutral-tertiary">
No repositories available
</Typography.Text>
</Layout.Stack>
</Card>
{/if}
{/await}
{/if}
{/if}
</Layout.Stack>
{:else}
+19 -22
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { page } from '$app/state';
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { iconPath } from '$lib/stores/app';
@@ -39,12 +40,9 @@
onMount(async () => {
try {
const content = await sdk.forProject.vcs.getRepositoryContents(
$installation.$id,
$repository.id,
currentPath
);
// console.log(content);
const content = await sdk
.forProject(page.params.region, page.params.project)
.vcs.getRepositoryContents($installation.$id, $repository.id, currentPath);
directories[0].fileCount = content.contents?.length ?? 0;
directories[0].children = content.contents
.filter((e) => e.isDirectory)
@@ -56,10 +54,9 @@
loading: false
}));
currentDir = directories[0];
// console.log(directories);
isLoading = false;
} catch (e) {
console.log(e);
} catch {
return;
}
});
@@ -83,12 +80,10 @@
directories = [...directories];
try {
const content = await sdk.forProject.vcs.getRepositoryContents(
$installation.$id,
$repository.id,
path
);
// console.log(content);
const content = await sdk
.forProject(page.params.region, page.params.project)
.vcs.getRepositoryContents($installation.$id, $repository.id, path);
const fileCount = content.contents?.length ?? 0;
const contentDirectories = content.contents.filter((e) => e.isDirectory);
@@ -103,12 +98,14 @@
fileCount: undefined,
thumbnailUrl: undefined
}));
const runtime = await sdk.forProject.vcs.createRepositoryDetection(
$installation.$id,
$repository.id,
product === 'sites' ? VCSDetectionType.Framework : VCSDetectionType.Runtime,
path
);
const runtime = await sdk
.forProject(page.params.region, page.params.project)
.vcs.createRepositoryDetection(
$installation.$id,
$repository.id,
product === 'sites' ? VCSDetectionType.Framework : VCSDetectionType.Runtime,
path
);
if (product === 'sites') {
currentDir.children.forEach((dir) => {
dir.thumbnailUrl = $iconPath(runtime.framework, 'color');
@@ -145,6 +142,6 @@
<svelte:fragment slot="footer">
<Button secondary on:click={() => (show = false)}>Cancel</Button>
<Button submit>Save</Button>
<Button submit disabled={isLoading}>Save</Button>
</svelte:fragment>
</Modal>
@@ -0,0 +1,20 @@
<script lang="ts">
import { Layout, Table, Skeleton } from '@appwrite.io/pink-svelte';
</script>
<Table.Root columns={1} let:root>
{#each Array(4) as _}
<Table.Row.Base {root}>
<Table.Cell {root}>
<Layout.Stack direction="row" alignItems="center">
<Skeleton variant="circle" width={24} />
<Layout.Stack gap="s" direction="row" alignItems="center">
<Skeleton variant="line" width={200} height={20} />
</Layout.Stack>
<Skeleton variant="line" width={76} height={32} />
</Layout.Stack>
</Table.Cell>
</Table.Row.Base>
{/each}
</Table.Root>
+11 -9
View File
@@ -1,12 +1,5 @@
<script lang="ts">
import { Icon, Tag } from '@appwrite.io/pink-svelte';
import { Copy } from '.';
import { IconDuplicate } from '@appwrite.io/pink-icons-svelte';
export let value: string;
export let event: string = null;
function truncateText(node: HTMLElement) {
<script context="module" lang="ts">
export function truncateText(node: HTMLElement) {
const MAX_TRIES = 100;
let originalText = node.textContent;
function checkOverflow() {
@@ -48,6 +41,15 @@
}
</script>
<script lang="ts">
import { Icon, Tag } from '@appwrite.io/pink-svelte';
import { Copy } from '.';
import { IconDuplicate } from '@appwrite.io/pink-icons-svelte';
export let value: string;
export let event: string = null;
</script>
<Copy {value} {event}>
<Tag size="xs" variant="code">
<Icon icon={IconDuplicate} size="s" slot="start" />
+2
View File
@@ -84,3 +84,5 @@ export { default as UsageCard } from './usageCard.svelte';
export { default as ViewToggle } from './viewToggle.svelte';
export { default as Terminal } from './studio/terminal.svelte';
export { default as ActionDropdown } from './actionDropdown.svelte';
export { default as RegionEndpoint } from './regionEndpoint.svelte';
export { default as ExpirationInput } from './expirationInput.svelte';
+19 -4
View File
@@ -1,9 +1,24 @@
<script lang="ts">
import { Card, Tooltip, Icon } from '@appwrite.io/pink-svelte';
import { type ComponentProps } from 'svelte';
import type Selector from '@appwrite.io/pink-svelte/dist/card/Selector.svelte';
import { Card, Tooltip } from '@appwrite.io/pink-svelte';
import type { HTMLAttributes } from 'svelte/elements';
import type { BaseCardProps } from './card.svelte';
import type { ComponentType } from 'svelte';
type Props = ComponentProps<Selector>;
type Props = BaseCardProps &
HTMLAttributes<HTMLInputElement> & {
name: string;
value: string;
group: string;
title: string;
info?: string | undefined;
icon?: ComponentType;
imageHeight?: number;
imageWidth?: number;
imageRadius?: 'xxs' | 'xs' | 's' | 'm' | 'l';
disabled?: boolean;
src?: string;
alt?: string | undefined;
};
export let group: string;
export let value: string;
+2 -2
View File
@@ -11,7 +11,7 @@
<Alert.Inline status="info" title="Your logs are disabled">
To view logs and errors, enable them in your
<Link
href={`${base}/project-${page.params.project}/sites/site-${page.params.site}/settings`}>
href={`${base}/project-${page.params.region}-${page.params.project}/sites/site-${page.params.site}/settings`}>
site settings</Link
>.
</Alert.Inline>
@@ -19,7 +19,7 @@
<Alert.Inline status="info" title="Your execution logs are disabled">
To view execution logs and errors, enable them in your
<Link
href={`${base}/project-${page.params.project}/functions/function-${page.params.function}/settings`}>
href={`${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/settings`}>
function settings</Link
>.
</Alert.Inline>
+16 -5
View File
@@ -13,11 +13,22 @@
} from '@appwrite.io/pink-svelte';
import { onMount } from 'svelte';
export let selectedLog: Models.Execution;
let {
selectedLog,
product
}: {
selectedLog: Models.Execution;
product: 'site' | 'function';
} = $props();
let requestTab: 'parameters' | 'headers' = 'parameters';
let requestTab: 'parameters' | 'headers' = $state('parameters');
let parameters = [];
let parameters = $state([]);
const href =
product === 'site'
? 'https://appwrite.io/docs/products/sites/logs#log-details'
: 'https://appwrite.io/docs/products/functions/develop#logging';
onMount(() => {
try {
@@ -121,8 +132,8 @@
<Input.Helper state="default">
<span>
Missing headers? Check the <Link variant="muted" href="#" external>docs</Link> to
see the supported data and how to log it.
Missing headers? Check the <Link variant="muted" {href} external>docs</Link> to see
the supported data and how to log it.
</span>
</Input.Helper>
{:else}
+8 -15
View File
@@ -16,10 +16,6 @@
import { onMount } from 'svelte';
import LoggingAlert from './loggingAlert.svelte';
// export let selectedLog: Models.Execution;
// export let product: 'site' | 'function';
// export let logging: boolean;
let {
selectedLog,
product,
@@ -32,11 +28,10 @@
let responseTab: 'logs' | 'errors' | 'headers' | 'body' = $state('logs');
let href = $derived(
const href =
product === 'site'
? 'https://appwrite.io/docs/products/sites/logs#log-details'
: 'https://appwrite.io/docs/products/functions/develop#logging'
);
: 'https://appwrite.io/docs/products/functions/develop#logging';
onMount(() => {
if (selectedLog?.errors) {
@@ -58,14 +53,12 @@
on:click={() => (responseTab = 'logs')}>
Logs
</Tabs.Item.Button>
{#if product !== 'site'}
<Tabs.Item.Button
{root}
active={responseTab === 'errors'}
on:click={() => (responseTab = 'errors')}>
Errors
</Tabs.Item.Button>
{/if}
<Tabs.Item.Button
{root}
active={responseTab === 'errors'}
on:click={() => (responseTab = 'errors')}>
Errors
</Tabs.Item.Button>
<Tabs.Item.Button
{root}
active={responseTab === 'headers'}
+20 -4
View File
@@ -1,23 +1,39 @@
<script lang="ts">
import { setContext, onMount } from 'svelte';
import { Card } from '@appwrite.io/pink-svelte';
import { createMenubar, melt } from '@melt-ui/svelte';
import { menuOpen } from '$lib/components/menu/store';
import { activeMenuId, menuOpen } from '$lib/components/menu/store';
const menuId = Math.random().toString(36).slice(2);
const {
elements: { menubar },
builders: { createMenu }
} = createMenubar();
const {
elements: { trigger: trigger, menu: menu, separator: separator },
states: { open }
elements: { trigger, menu, separator },
states: { open },
builders // for submenu for same toggle state
} = createMenu();
function toggle() {
open.update((state) => !state);
}
$: menuOpen.set($open);
open.subscribe((state) => {
if (state) activeMenuId.set(menuId);
else activeMenuId.update((current) => (current === menuId ? null : current));
});
onMount(() => {
return activeMenuId.subscribe((id) => {
if (id !== menuId) open.set(false);
});
});
$: menuOpen.set($open as boolean);
setContext('menuBuilder', { builders, separator });
</script>
<div use:melt={$menubar}>
+14
View File
@@ -1,3 +1,17 @@
import { writable } from 'svelte/store';
import type { createMenubar } from '@melt-ui/svelte';
export const menuOpen = writable(false);
export const activeMenuId = writable<string | null>(null);
/**
* Full menu context passed to submenus —
* includes `builders` and shared `separator`.
*/
export type MenuContext = {
separator: ReturnType<
ReturnType<typeof createMenubar>['builders']['createMenu']
>['elements']['separator'];
builders: ReturnType<ReturnType<typeof createMenubar>['builders']['createMenu']>['builders'];
};
+6 -9
View File
@@ -1,15 +1,12 @@
<script lang="ts">
import { getContext } from 'svelte';
import { melt } from '@melt-ui/svelte';
import type { MenuContext } from './store';
import { Card } from '@appwrite.io/pink-svelte';
import { createMenubar, melt } from '@melt-ui/svelte';
const {
builders: { createMenu }
} = createMenubar();
const {
elements: { separator: separator },
builders: { createSubmenu: createSubmenu }
} = createMenu();
// get parent builder for toggle state!
const { builders, separator } = getContext<MenuContext>('menuBuilder');
const { createSubmenu } = builders;
const {
elements: { subMenu: subMenu, subTrigger: subTrigger }
@@ -3,7 +3,7 @@
export async function verify(challenge: Models.MfaChallenge, code: string) {
try {
if (challenge == null) {
if (challenge === null) {
challenge = await sdk.forConsole.account.createMfaChallenge(
AuthenticationFactor.Totp
);
@@ -59,9 +59,9 @@
onMount(async () => {
const enabledNonRecoveryFactors = enabledFactors.filter(
([factor, _]) => factor != 'recoveryCode'
([factor, _]) => factor !== 'recoveryCode'
);
if (enabledNonRecoveryFactors.length == 1) {
if (enabledNonRecoveryFactors.length === 1) {
if (factors.phone) {
createChallenge(AuthenticationFactor.Phone);
} else if (factors.email) {
@@ -77,7 +77,7 @@
</Typography.Text>
<InputText id="recovery-code" bind:value={code} required autofocus />
{:else}
{#if factors.totp && (challengeType == AuthenticationFactor.Totp || challengeType == null)}
{#if factors.totp && (challengeType === AuthenticationFactor.Totp || challengeType === null)}
<Typography.Text align="center"
>Enter below a 6-digit one-time code generated by your authentication app.</Typography.Text>
{:else if challengeType === AuthenticationFactor.Email}
@@ -95,7 +95,7 @@
{#if enabledFactors.length > 1}
<span class="with-separators eyebrow-heading-3">or</span>
<div class="u-flex-vertical u-gap-8">
{#if factors.totp && challengeType != null && challengeType != AuthenticationFactor.Totp}
{#if factors.totp && challengeType !== null && challengeType !== AuthenticationFactor.Totp}
<Button
secondary
fullWidth
+11 -8
View File
@@ -1,7 +1,8 @@
<script lang="ts" context="module">
import { page } from '$app/state';
import { parseIfString } from '$lib/helpers/object';
import { getProjectId } from '$lib/helpers/project';
import { sdk } from '$lib/stores/sdk';
import { realtime } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
import { onMount } from 'svelte';
import { writable } from 'svelte/store';
@@ -49,13 +50,15 @@
})();
onMount(() => {
return sdk.forConsole.client.subscribe<Models.Migration>(['console'], async (response) => {
if (!response.channels.includes(`projects.${getProjectId()}`)) return;
if (response.events.includes('migrations.*')) {
if (response.payload.source === 'Backup') return;
migration = response.payload;
}
});
return realtime
.forProject(page.params.region, page.params.project)
.subscribe<Models.Migration>(['console'], async (response) => {
if (!response.channels.includes(`projects.${getProjectId()}`)) return;
if (response.events.includes('migrations.*')) {
if (response.payload.source === 'Backup') return;
migration = response.payload;
}
});
});
</script>
+2 -1
View File
@@ -6,6 +6,7 @@
export let show = false;
export let size: 'small' | 'big' | 'huge' = null;
export let closable = true;
export let closeByEscape = true;
export let headerDivider = true;
export let style = '';
@@ -48,7 +49,7 @@
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
if (event.key === 'Escape' && closeByEscape) {
event.preventDefault();
trackEvent(Click.ModalCloseClick, {
from: 'escape'
+14 -2
View File
@@ -2,10 +2,20 @@
export type NavbarProject = {
name: string;
$id: string;
region: string;
isSelected: boolean;
platformCount: number;
pingCount: number;
};
export type BaseNavbarProps = HTMLAttributes<HTMLHeadElement> & {
logo: {
src: string;
alt: string;
};
avatar: string;
sideBarIsOpen: boolean;
};
</script>
<script lang="ts">
@@ -23,7 +33,6 @@
Typography
} from '@appwrite.io/pink-svelte';
import { toggleCommandCenter } from '$lib/commandCenter/commandCenter.svelte';
import type { BaseNavbarProps } from '@appwrite.io/pink-svelte/dist/navbar/Base.svelte';
import {
IconChevronRight,
IconLogoutRight,
@@ -45,6 +54,8 @@
import { isCloud } from '$lib/system.js';
import { user } from '$lib/stores/user';
import { Click, trackEvent } from '$lib/actions/analytics';
import type { HTMLAttributes } from 'svelte/elements';
import { beforeNavigate } from '$app/navigation';
let showSupport = false;
@@ -105,6 +116,7 @@
$: currentOrg = organizations.find((org) => org.isSelected);
$: selectedProject = currentOrg?.projects.find((project) => project.isSelected);
beforeNavigate(() => (showAccountMenu = false));
</script>
<Navbar.Base {...$$props}>
@@ -125,7 +137,7 @@
{#if selectedProject && selectedProject.pingCount === 0}
<div class="only-desktop" style:margin-inline-start="-16px">
<Button.Anchor
href={`${base}/project-${selectedProject.$id}/get-started`}
href={`${base}/project-${selectedProject.region}-${selectedProject.$id}/get-started`}
variant="secondary"
size="xs">Connect</Button.Anchor>
</div>
+24 -18
View File
@@ -12,7 +12,7 @@
$: totalPages = Math.ceil(total / limit);
$: currentPage = Math.floor(offset / limit + 1);
$: pages = pagination(currentPage, totalPages);
// $: pages = pagination(currentPage, totalPages);
function handleOptionClick(e: CustomEvent) {
if (currentPage !== e.detail) {
@@ -35,26 +35,32 @@
}
}
function pagination(page: number, total: number) {
const pagesShown = 5;
const start = Math.max(
1,
Math.min(page - Math.floor((pagesShown - 3) / 2), total - pagesShown + 2)
);
const end = Math.min(
total,
Math.max(page + Math.floor((pagesShown - 2) / 2), pagesShown - 1)
);
return [
...(start > 2 ? [1, '...'] : start > 1 ? [1] : []),
...Array.from({ length: end + 1 - start }, (_, i) => i + start),
...(end < total - 1 ? ['...', total] : end < total ? [total] : [])
];
}
// function pagination(page: number, total: number) {
// const pagesShown = 5;
// const start = Math.max(
// 1,
// Math.min(page - Math.floor((pagesShown - 3) / 2), total - pagesShown + 2)
// );
// const end = Math.min(
// total,
// Math.max(page + Math.floor((pagesShown - 2) / 2), pagesShown - 1)
// );
// return [
// ...(start > 2 ? [1, '...'] : start > 1 ? [1] : []),
// ...Array.from({ length: end + 1 - start }, (_, i) => i + start),
// ...(end < total - 1 ? ['...', total] : end < total ? [total] : [])
// ];
// }
</script>
{#if !hidePages}
<Pagination {limit} page={currentPage} {total} type="button" on:page={handleOptionClick} />
<Pagination
{limit}
page={currentPage}
{total}
type="button"
on:page={handleOptionClick}
createLink={undefined as never} />
{:else}
<Layout.Stack direction="row" inline>
<Button.Button
+2 -2
View File
@@ -12,6 +12,7 @@
hasLimit = false,
name = 'items',
gap = 's',
offset = $bindable(0),
children
}: {
items: T[];
@@ -23,13 +24,12 @@
gap?:
| ('none' | 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl')
| undefined;
offset?: number;
children: Snippet<[T[], number]>;
} = $props();
let total = $derived(items.length);
let offset = $state(0);
let paginatedItems = $derived(items.slice(offset, offset + limit));
</script>
+10 -4
View File
@@ -27,10 +27,16 @@
const role = permission.split(':')[0];
const id = permission.split(':')[1].split('/')[0];
if (role === 'user') {
return await sdk.forProject.users.get(id);
const user = await sdk
.forProject(page.params.region, page.params.project)
.users.get(id);
return user;
}
if (role === 'team') {
return await sdk.forProject.teams.get(id);
const team = await sdk
.forProject(page.params.region, page.params.project)
.teams.get(id);
return team;
}
}
</script>
@@ -82,7 +88,7 @@
{/if}
<div>
<Button.Anchor
href={`${base}/project-${page.params.project}/auth/user-${data?.$id}`}
href={`${base}/project-${page.params.region}-${page.params.project}/auth/user-${data?.$id}`}
size="xs"
target="_blank"
variant="secondary">
@@ -94,7 +100,7 @@
<Typography.Text>Members: {data?.total}</Typography.Text>
<div>
<Button.Anchor
href={`${base}/project-${page.params.project}/auth/teams/team-${data?.$id}`}
href={`${base}/project-${page.params.region}-${page.params.project}/auth/teams/team-${data?.$id}`}
size="s"
target="_blank"
variant="secondary">
+4 -4
View File
@@ -15,6 +15,7 @@
Table,
Typography
} from '@appwrite.io/pink-svelte';
import { page } from '$app/state';
export let show: boolean;
export let groups: Writable<Map<string, Permission>>;
@@ -40,10 +41,9 @@
async function request() {
if (!show) return;
results = await sdk.forProject.teams.list(
[Query.limit(5), Query.offset(offset)],
search || undefined
);
results = await sdk
.forProject(page.params.region, page.params.project)
.teams.list([Query.limit(5), Query.offset(offset)], search || undefined);
}
function onSelection(role: string) {
+4 -4
View File
@@ -18,6 +18,7 @@
Typography
} from '@appwrite.io/pink-svelte';
import { IconAnonymous, IconMinusSm } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
export let show: boolean;
export let groups: Writable<Map<string, Permission>>;
@@ -43,10 +44,9 @@
async function request() {
if (!show) return;
results = await sdk.forProject.users.list(
[Query.limit(5), Query.offset(offset)],
search || undefined
);
results = await sdk
.forProject(page.params.region, page.params.project)
.users.list([Query.limit(5), Query.offset(offset)], search || undefined);
}
function onSelection(role: string) {
+42
View File
@@ -0,0 +1,42 @@
<script lang="ts">
import { Copy } from '.';
import { sdk } from '$lib/stores/sdk';
import { Flag } from '@appwrite.io/console';
import { truncateText } from '$lib/components/id.svelte';
import { isValueOfStringEnum } from '$lib/helpers/types';
import { getProjectEndpoint } from '$lib/helpers/project';
import { projectRegion } from '$routes/(console)/project-[region]-[project]/store';
$: flagSrc =
$projectRegion && isValueOfStringEnum(Flag, $projectRegion.flag)
? sdk.forConsole.avatars.getFlag($projectRegion.flag, 30, 20, 100)
: '';
</script>
{#if $projectRegion}
<Copy value={getProjectEndpoint()} copyText="Copy endpoint">
<div
class="flex u-gap-8 u-cross-center interactive-text-output is-buttons-on-top u-text-center"
style:min-inline-size="0"
style:display="inline-flex">
<span
style:white-space="nowrap"
class="text u-line-height-1-5"
style:overflow="hidden"
style:word-break="break-all"
use:truncateText
style:font-family="unset">
{$projectRegion?.name}
</span>
{#if flagSrc}
<img
style="border-radius: 2.5px"
src={flagSrc}
alt={$projectRegion?.name}
width={16}
height={12} />
{/if}
</div>
</Copy>
{/if}
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/state';
import { goto } from '$app/navigation';
import { onMount, onDestroy } from 'svelte';
import { onDestroy } from 'svelte';
import { trackEvent } from '$lib/actions/analytics';
import { Icon, Input } from '@appwrite.io/pink-svelte';
import { IconSearch, IconX } from '@appwrite.io/pink-icons-svelte';
+10 -9
View File
@@ -39,10 +39,11 @@
import { Click, trackEvent } from '$lib/actions/analytics';
import type { HTMLAttributes } from 'svelte/elements';
import type { Models } from '@appwrite.io/console';
type $$Props = HTMLAttributes<HTMLElement> & {
state?: 'closed' | 'open' | 'icons';
project: { $id: string } | undefined;
project: Models.Project | undefined;
avatar: string;
progressCard?: {
title: string;
@@ -83,7 +84,7 @@
</script>
<div
class:only-mobile-tablet={project === undefined}
class:only-mobile-tablet={!project}
style:--overlay-on-neutral={$app.themeInUse === 'dark'
? 'var(--neutral-750)'
: 'var(--neutral-100)'}>
@@ -118,7 +119,7 @@
<Tooltip placement="right" disabled={state !== 'icons'}>
<a
class="progress-card"
href={`/console/project-${project.$id}/get-started`}
href={`/console/project-${project.region}-${project.$id}/get-started`}
on:click={() => {
trackEvent('click_menu_get_started');
sideBarIsOpen = false;
@@ -142,7 +143,7 @@
<Layout.Stack direction="column" gap="s">
<Tooltip placement="right" disabled={state !== 'icons'}>
<a
href={`/console/project-${project.$id}/overview`}
href={`/console/project-${project.region}-${project.$id}/overview`}
class="link"
class:active={page.url.pathname.includes('overview')}
on:click={() => {
@@ -172,7 +173,7 @@
{#each buildProjectOptions as projectOption}
<Tooltip placement="right" disabled={state !== 'icons'}>
<a
href={`/console/project-${project.$id}/${projectOption.slug}`}
href={`/console/project-${project.region}-${project.$id}/${projectOption.slug}`}
class="link"
class:active={page.url.pathname.includes(projectOption.slug)}
on:click={() => {
@@ -203,7 +204,7 @@
{#each deployProjectOptions as projectOption}
<Tooltip placement="right" disabled={state !== 'icons'}>
<a
href={`/console/project-${project.$id}/${projectOption.slug}`}
href={`/console/project-${project.region}-${project.$id}/${projectOption.slug}`}
class="link"
class:active={page.url.pathname.includes(projectOption.slug)}
on:click={() => {
@@ -222,7 +223,7 @@
<Badge
variant="secondary"
content={projectOption.badge}
size="s" />
size="xs" />
{/if}
</span>
</a>
@@ -235,7 +236,7 @@
<div class="only-mobile">
<Tooltip placement="right" disabled={state !== 'icons'}>
<a
href={`/console/project-${project.$id}/settings`}
href={`/console/project-${project.region}-${project.$id}/settings`}
on:click={() => {
trackEvent('click_menu_settings');
}}
@@ -293,7 +294,7 @@
<div class="only-desktop">
<Tooltip placement="right" disabled={state !== 'icons'}>
<a
href={`/console/project-${project.$id}/settings`}
href={`/console/project-${project.region}-${project.$id}/settings`}
class="link"
on:click={() => {
trackEvent('click_menu_settings');
+17 -5
View File
@@ -5,18 +5,30 @@
import { isSupportOnline, showSupportModal } from '$routes/(console)/wizard/support/store';
import { Click, trackEvent } from '$lib/actions/analytics';
import { localeShortTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date';
import { upgradeURL } from '$lib/stores/billing';
import { plansInfo } from '$lib/stores/billing';
import { Card } from '$lib/components/index';
import { app } from '$lib/stores/app';
import { currentPlan } from '$lib/stores/organization';
import { currentPlan, type Organization, organizationList } from '$lib/stores/organization';
import { isCloud } from '$lib/system';
import { Typography } from '@appwrite.io/pink-svelte';
import { base } from '$app/paths';
export let show = false;
export let showHeader = true;
$: hasPremiumSupport = $currentPlan?.premiumSupport ?? false;
$: hasPremiumSupport = $currentPlan?.premiumSupport ?? allOrgsHavePremiumSupport ?? false;
$: allOrgsHavePremiumSupport = $organizationList.teams.every(
(team) => $plansInfo.get((team as Organization).billingPlan)?.premiumSupport
);
// there can only be one free organization
$: freeOrganization = $organizationList.teams.find(
(team) => !$plansInfo.get((team as Organization).billingPlan)?.premiumSupport
);
$: upgradeURL = `${base}/organization-${freeOrganization?.$id}/change-plan`;
$: supportTimings = `${utcHourToLocaleHour('16:00')} - ${utcHourToLocaleHour('00:00')} ${localeShortTimezoneName()}`;
@@ -55,7 +67,7 @@
}
];
const showCloudSupport = (index) => {
const showCloudSupport = (index: number) => {
return (index === 0 && isCloud) || index > 0;
};
</script>
@@ -79,7 +91,7 @@
<div class="u-flex u-gap-12 u-cross-center">
{#if !hasPremiumSupport}
<Button
href={$upgradeURL}
href={upgradeURL}
on:click={() => {
trackEvent(Click.OrganizationClickUpgrade, {
from: 'button',
+1 -2
View File
@@ -5,13 +5,12 @@
import { getElementDir } from '$lib/helpers/style';
import { waitUntil } from '$lib/helpers/waitUntil';
import { Tabs } from '@appwrite.io/pink-svelte';
import type { Variant } from '@appwrite.io/pink-svelte/dist/tabs/types';
export let selected = false;
export let href: string = null;
export let event: string = null;
export let noscroll = false;
export let root: { variant: Variant; stretch: boolean } = {
export let root: { variant: 'primary' | 'secondary'; stretch: boolean } = {
variant: 'primary',
stretch: false
};
+3 -2
View File
@@ -13,8 +13,9 @@
</Typography.Caption>
<slot>
{#if value !== null && value !== undefined}
<Typography.Text size="s" truncate color="--fgcolor-neutral-primary"
>{value}</Typography.Text>
<Typography.Text size="s" truncate color="--fgcolor-neutral-primary">
{value}
</Typography.Text>
{:else}
<Skeleton variant="line" width="100%" height={19.5} />
{/if}
+21
View File
@@ -3,6 +3,14 @@ export const CARD_LIMIT = 6; // default card limit
export const INTERVAL = 5 * 60000; // default interval to check for feedback
export const NEW_DEV_PRO_UPGRADE_COUPON = 'appw50';
export const REGION_FRA = 'fra';
export const REGION_SYD = 'syd';
export const REGION_NYC = 'nyc';
export const SUBDOMAIN_FRA = 'fra.';
export const SUBDOMAIN_SYD = 'syd.';
export const SUBDOMAIN_NYC = 'nyc.';
export enum Dependencies {
FACTORS = 'dependency:factors',
IDENTITIES = 'dependency:identities',
@@ -10,6 +18,7 @@ export enum Dependencies {
INVOICES = 'dependency:invoices',
ADDRESS = 'dependency:address',
UPGRADE_PLAN = 'dependency:upgrade_plan',
CREATE_ORGANIZATION = 'dependency:create_organization',
PAYMENT_METHODS = 'dependency:paymentMethods',
ORGANIZATION = 'dependency:organization',
MEMBERS = 'dependency:members',
@@ -371,6 +380,18 @@ export const scopes: {
category: 'Other',
icon: 'globe'
},
{
scope: 'tokens.read',
description: "Access to read your project's file tokens",
category: 'Other',
icon: 'globe'
},
{
scope: 'tokens.write',
description: 'Access to create file tokens',
category: 'Other',
icon: 'globe'
},
{
scope: 'sites.read',
description: "Access to read your project's sites and deployments",
Loaded 100 of 1022 files, more files were not shown because too many files have changed in this diff. Show more