mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge remote-tracking branch 'origin/main' into spatial-type-attributes
This commit is contained in:
commit
324a5edf03
38 files changed
+964
-325
No files matched your search
@@ -0,0 +1,79 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { get } from 'svelte/store';
|
||||
import { page } from '$app/state';
|
||||
import { Card, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let { show = $bindable(false) } = $props();
|
||||
let creating = $state(false);
|
||||
let emailSent = $state(false);
|
||||
|
||||
let cleanUrl = $derived(page.url.origin + page.url.pathname);
|
||||
|
||||
async function onSubmit() {
|
||||
if (creating) return;
|
||||
creating = true;
|
||||
try {
|
||||
await sdk.forConsole.account.createVerification({ url: cleanUrl });
|
||||
addNotification({ message: 'Verification email has been sent', type: 'success' });
|
||||
emailSent = true;
|
||||
show = false;
|
||||
} catch (error) {
|
||||
addNotification({ message: error.message, type: 'error' });
|
||||
} finally {
|
||||
creating = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function updateEmailVerification() {
|
||||
const searchParams = page.url.searchParams;
|
||||
const userId = searchParams.get('userId');
|
||||
const secret = searchParams.get('secret');
|
||||
|
||||
if (userId && secret) {
|
||||
try {
|
||||
await sdk.forConsole.account.updateVerification({ userId, secret });
|
||||
addNotification({
|
||||
message: 'Email verified successfully',
|
||||
type: 'success'
|
||||
});
|
||||
await Promise.all([
|
||||
invalidate(Dependencies.ACCOUNT),
|
||||
invalidate(Dependencies.FACTORS)
|
||||
]);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
updateEmailVerification();
|
||||
});
|
||||
</script>
|
||||
|
||||
<Modal bind:show title="Send verification email" {onSubmit}>
|
||||
<Card.Base variant="secondary" padding="s">
|
||||
<Layout.Stack gap="m">
|
||||
<Typography.Text gap="m">
|
||||
To continue using Appwrite Cloud, please verify your email address. An email will be
|
||||
sent to <Typography.Text variant="m-600" style="display: inline;"
|
||||
>{get(user)?.email}</Typography.Text>
|
||||
</Typography.Text>
|
||||
</Layout.Stack>
|
||||
</Card.Base>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit disabled={creating}>{emailSent ? 'Resend email' : 'Send email'}</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -1,55 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { goto } from '$app/navigation';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { HeaderAlert } from '$lib/layout';
|
||||
import { Typography } from '@appwrite.io/pink-svelte';
|
||||
import { hideNotification, shouldShowNotification } from '$lib/helpers/notifications';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { page } from '$app/state';
|
||||
|
||||
const { emailBannerClosed, onEmailBannerClose } = $props<{
|
||||
emailBannerClosed: boolean;
|
||||
onEmailBannerClose: (closed: boolean) => void;
|
||||
}>();
|
||||
|
||||
const isOnOnboarding = $derived(page.url?.pathname?.includes('/console/onboarding'));
|
||||
import SendVerificationEmailModal from '../account/sendVerificationEmailModal.svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { wizard, isNewWizardStatusOpen } from '$lib/stores/wizard';
|
||||
import { isCloud } from '$lib/system';
|
||||
|
||||
const hasUser = $derived(!!$user);
|
||||
const needsEmailVerification = $derived(hasUser && !$user.emailVerification);
|
||||
const shouldShowNotificationBanner = $derived.by(() =>
|
||||
shouldShowNotification('email-verification-banner')
|
||||
);
|
||||
const wizardNotActive = $derived(!$wizard.show && !$wizard.cover);
|
||||
const bannerNotClosed = $derived(!emailBannerClosed);
|
||||
const notOnOnboarding = $derived(!isOnOnboarding);
|
||||
|
||||
const notOnOnboarding = $derived(!$page.route.id.includes('/onboarding'));
|
||||
const notOnWizard = $derived(!$wizard.show && !$isNewWizardStatusOpen);
|
||||
const shouldShowEmailBanner = $derived(
|
||||
hasUser &&
|
||||
needsEmailVerification &&
|
||||
shouldShowNotificationBanner &&
|
||||
wizardNotActive &&
|
||||
bannerNotClosed &&
|
||||
notOnOnboarding
|
||||
isCloud && hasUser && needsEmailVerification && notOnOnboarding && notOnWizard
|
||||
);
|
||||
|
||||
function navigateToAccount() {
|
||||
goto(`${base}/account`);
|
||||
}
|
||||
|
||||
function handleDismiss() {
|
||||
onEmailBannerClose(true);
|
||||
hideNotification('email-verification-banner', { coolOffPeriod: 24 * 365 * 100 });
|
||||
}
|
||||
let showSendVerification = $state(false);
|
||||
</script>
|
||||
|
||||
{#if shouldShowEmailBanner}
|
||||
<HeaderAlert
|
||||
type="warning"
|
||||
title="Your email address needs to be verified"
|
||||
dismissible
|
||||
on:dismiss={handleDismiss}>
|
||||
<HeaderAlert type="warning" title="Your email address needs to be verified">
|
||||
<svelte:fragment>
|
||||
To avoid losing access to your projects, make sure <Typography.Text
|
||||
variant="m-500"
|
||||
@@ -57,7 +28,9 @@
|
||||
verification will be required soon.
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button secondary size="s" on:click={navigateToAccount}>Update email address</Button>
|
||||
<Button secondary size="s" on:click={() => (showSendVerification = true)}
|
||||
>Verify email</Button>
|
||||
</svelte:fragment>
|
||||
</HeaderAlert>
|
||||
<SendVerificationEmailModal bind:show={showSendVerification} />
|
||||
{/if}
|
||||
@@ -11,7 +11,6 @@
|
||||
Tabs,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let {
|
||||
selectedLog,
|
||||
@@ -23,29 +22,30 @@
|
||||
|
||||
let requestTab: 'parameters' | 'headers' = $state('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(() => {
|
||||
// Make parameters reactive to selectedLog changes
|
||||
let parameters = $derived.by(() => {
|
||||
try {
|
||||
// Add dummy base URL to parse relative paths
|
||||
const url = new URL(selectedLog.requestPath, 'http://dummy.local');
|
||||
if (url.search) {
|
||||
parameters = Array.from(url.searchParams.entries()).map(([name, value]) => ({
|
||||
return Array.from(url.searchParams.entries()).map(([name, value]) => ({
|
||||
name,
|
||||
value: decodeURIComponent(value)
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
} catch (error) {
|
||||
parameters = [];
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
// Update requestTab when parameters or selectedLog changes
|
||||
$effect(() => {
|
||||
if (parameters?.length) {
|
||||
requestTab = 'parameters';
|
||||
} else if (selectedLog.requestHeaders?.length) {
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
<script context="module" lang="ts">
|
||||
let inputDigitFields: InputDigits;
|
||||
|
||||
export async function verify(challenge: Models.MfaChallenge, code: string) {
|
||||
export async function verify(
|
||||
challenge: Models.MfaChallenge,
|
||||
code: string,
|
||||
challengeType: AuthenticationFactor = AuthenticationFactor.Totp,
|
||||
factors?: Models.MfaFactors & { recoveryCode: boolean }
|
||||
) {
|
||||
try {
|
||||
if (challenge === null) {
|
||||
if (!challenge) {
|
||||
// Validate that the challengeType is actually enabled
|
||||
if (factors) {
|
||||
const factorMap = {
|
||||
[AuthenticationFactor.Totp]: factors.totp,
|
||||
[AuthenticationFactor.Email]: factors.email,
|
||||
[AuthenticationFactor.Phone]: factors.phone,
|
||||
[AuthenticationFactor.Recoverycode]: factors.recoveryCode
|
||||
};
|
||||
|
||||
if (!factorMap[challengeType]) {
|
||||
throw new Error(`Authentication factor ${challengeType} is not enabled`);
|
||||
}
|
||||
}
|
||||
|
||||
challenge = await sdk.forConsole.account.createMFAChallenge({
|
||||
factor: AuthenticationFactor.Totp
|
||||
factor: challengeType
|
||||
});
|
||||
}
|
||||
|
||||
await sdk.forConsole.account.updateMFAChallenge({
|
||||
challengeId: challenge.$id,
|
||||
otp: code
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
trackEvent(Submit.AccountLogin, { mfa_used: true });
|
||||
} catch (error) {
|
||||
inputDigitFields?.clearInputsAndRefocus();
|
||||
trackError(error, Submit.AccountLogin);
|
||||
throw error;
|
||||
}
|
||||
@@ -24,18 +42,17 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Button, InputDigits, InputText } from '$lib/elements/forms';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { AuthenticationFactor, type Models } from '@appwrite.io/console';
|
||||
import { Button, InputText, InputDigits } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { Icon, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { IconChatAlt, IconDeviceMobile, IconMail } from '@appwrite.io/pink-icons-svelte';
|
||||
|
||||
export let factors: Models.MfaFactors & { recoveryCode: boolean };
|
||||
/** If true, the form will be submitted automatically when the code is entered. */
|
||||
export let showVerifyButton: boolean = true;
|
||||
export let disabled: boolean = false;
|
||||
export let challenge: Models.MfaChallenge;
|
||||
@@ -43,13 +60,24 @@
|
||||
|
||||
let challengeType: AuthenticationFactor;
|
||||
|
||||
const enabledFactors = Object.entries(factors).filter(([_, enabled]) => enabled);
|
||||
// Get enabled non-recovery factors for main factors
|
||||
$: enabledMainFactors = [
|
||||
factors.totp && 'totp',
|
||||
factors.email && 'email',
|
||||
factors.phone && 'phone'
|
||||
].filter(Boolean);
|
||||
|
||||
async function createChallenge(factor: AuthenticationFactor) {
|
||||
disabled = true;
|
||||
challengeType = factor;
|
||||
code = '';
|
||||
try {
|
||||
challenge = await sdk.forConsole.account.createMFAChallenge({ factor });
|
||||
if (
|
||||
factor !== AuthenticationFactor.Totp &&
|
||||
factor !== AuthenticationFactor.Recoverycode
|
||||
) {
|
||||
challenge = await sdk.forConsole.account.createMFAChallenge({ factor });
|
||||
}
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
@@ -60,57 +88,70 @@
|
||||
}
|
||||
}
|
||||
|
||||
export async function verifyCurrent() {
|
||||
try {
|
||||
return await verify(challenge, code, challengeType, factors);
|
||||
} catch (error) {
|
||||
// Clear input fields on verification failure
|
||||
code = '';
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
const enabledNonRecoveryFactors = enabledFactors.filter(
|
||||
([factor, _]) => factor !== 'recoveryCode'
|
||||
);
|
||||
if (enabledNonRecoveryFactors.length === 1) {
|
||||
if (factors.phone) {
|
||||
await createChallenge(AuthenticationFactor.Phone);
|
||||
} else if (factors.email) {
|
||||
await createChallenge(AuthenticationFactor.Email);
|
||||
} else if (factors.totp) {
|
||||
challengeType = AuthenticationFactor.Totp;
|
||||
}
|
||||
if (enabledMainFactors.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (factors.totp) {
|
||||
challengeType = AuthenticationFactor.Totp;
|
||||
} else if (factors.email) {
|
||||
await createChallenge(AuthenticationFactor.Email);
|
||||
} else if (factors.phone) {
|
||||
await createChallenge(AuthenticationFactor.Phone);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if challengeType === AuthenticationFactor.Recoverycode}
|
||||
{#if enabledMainFactors.length === 0}
|
||||
<!-- Skip MFA completely if no factors enabled -->
|
||||
{:else if challengeType === AuthenticationFactor.Recoverycode}
|
||||
<Typography.Text align="center">
|
||||
Enter below one of the recovery codes you received when enabling MFA for this account.
|
||||
Enter one of the recovery codes you received when enabling MFA.
|
||||
</Typography.Text>
|
||||
<InputText id="recovery-code" bind:value={code} required autofocus />
|
||||
{:else}
|
||||
{#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}
|
||||
<Typography.Text align="center"
|
||||
>A 6-digit verification code was sent to your email, enter it below.</Typography.Text>
|
||||
{:else if challengeType === AuthenticationFactor.Phone}
|
||||
<Typography.Text align="center"
|
||||
>A 6-digit verification code was sent to your phone, enter it below.</Typography.Text>
|
||||
{/if}
|
||||
{:else if challengeType === AuthenticationFactor.Totp}
|
||||
<Typography.Text align="center">
|
||||
Enter a 6-digit one-time code from your authenticator app.
|
||||
</Typography.Text>
|
||||
<InputDigits bind:value={code} required autofocus />
|
||||
{:else if challengeType === AuthenticationFactor.Email}
|
||||
<Typography.Text align="center">
|
||||
A 6-digit verification code was sent to your email. Enter it below.
|
||||
</Typography.Text>
|
||||
<InputDigits bind:value={code} required autofocus />
|
||||
{:else if challengeType === AuthenticationFactor.Phone}
|
||||
<Typography.Text align="center">
|
||||
A 6-digit verification code was sent to your phone. Enter it below.
|
||||
</Typography.Text>
|
||||
<InputDigits bind:value={code} required autofocus />
|
||||
{/if}
|
||||
{#if showVerifyButton}
|
||||
|
||||
{#if showVerifyButton && enabledMainFactors.length > 0}
|
||||
<Button fullWidth submit {disabled}>Verify</Button>
|
||||
{/if}
|
||||
{#if enabledFactors.length > 1}
|
||||
<span class="with-separators eyebrow-heading-3">or</span>
|
||||
<div class="u-flex-vertical u-gap-8">
|
||||
{#if factors.totp}
|
||||
{#if (challengeType === null || challengeType === AuthenticationFactor.Totp || challengeType === AuthenticationFactor.Recoverycode) && factors.email}
|
||||
<Button
|
||||
secondary
|
||||
fullWidth
|
||||
{disabled}
|
||||
on:click={() => createChallenge(AuthenticationFactor.Email)}>
|
||||
<Icon icon={IconMail} slot="start" size="s" />
|
||||
Email verification
|
||||
</Button>
|
||||
{:else if (challengeType === AuthenticationFactor.Recoverycode && !factors.email) || challengeType === AuthenticationFactor.Email}
|
||||
|
||||
{#if enabledMainFactors.length > 0}
|
||||
{@const hasSecondaryOptions =
|
||||
enabledMainFactors.length > 1 ||
|
||||
(factors.recoveryCode && challengeType !== AuthenticationFactor.Recoverycode) ||
|
||||
(enabledMainFactors.length === 1 && factors.recoveryCode)}
|
||||
|
||||
{#if hasSecondaryOptions}
|
||||
<span class="with-separators eyebrow-heading-3">or</span>
|
||||
<div class="u-flex-vertical u-gap-8">
|
||||
<!-- Show non-active main factors -->
|
||||
{#if factors.totp && challengeType !== AuthenticationFactor.Totp}
|
||||
<Button
|
||||
secondary
|
||||
fullWidth
|
||||
@@ -120,7 +161,7 @@
|
||||
Authenticator app
|
||||
</Button>
|
||||
{/if}
|
||||
{:else}
|
||||
|
||||
{#if factors.email && challengeType !== AuthenticationFactor.Email}
|
||||
<Button
|
||||
secondary
|
||||
@@ -131,6 +172,7 @@
|
||||
Email verification
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
{#if factors.phone && challengeType !== AuthenticationFactor.Phone}
|
||||
<Button
|
||||
secondary
|
||||
@@ -141,15 +183,16 @@
|
||||
Phone verification
|
||||
</Button>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if factors.recoveryCode && challengeType !== AuthenticationFactor.Recoverycode}
|
||||
<Button
|
||||
text
|
||||
fullWidth
|
||||
{disabled}
|
||||
on:click={() => createChallenge(AuthenticationFactor.Recoverycode)}>
|
||||
<span class="text">Use recovery code</span>
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if factors.recoveryCode && challengeType !== AuthenticationFactor.Recoverycode}
|
||||
<Button
|
||||
text
|
||||
fullWidth
|
||||
{disabled}
|
||||
on:click={() => createChallenge(AuthenticationFactor.Recoverycode)}>
|
||||
<span class="text">Use recovery code</span>
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -3,7 +3,9 @@ export function getNestedRootDirectory(repository: string): string | null {
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
export function getRepositoryInfo(repository: string): { owner: string; name: string } | null {
|
||||
export function getRepositoryInfo(
|
||||
repository: string
|
||||
): { owner: string; name: string; url: string } | null {
|
||||
const match = repository
|
||||
.trim()
|
||||
.match(/(?:^|\/\/|@)github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?(?:$|[/?#])/i);
|
||||
@@ -13,7 +15,9 @@ export function getRepositoryInfo(repository: string): { owner: string; name: st
|
||||
const owner = decodeURIComponent(match[1]);
|
||||
const name = decodeURIComponent(match[2].replace(/\.git$/i, ''));
|
||||
|
||||
return { owner, name };
|
||||
const url = `https://github.com/${owner}/${name}`;
|
||||
|
||||
return { owner, name, url };
|
||||
}
|
||||
|
||||
export async function getLatestTag(owner: string, name: string): Promise<string | null> {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* determines the badge color based on HTTP status code
|
||||
*
|
||||
* @param statusCode
|
||||
* @returns badge color
|
||||
*/
|
||||
export function getBadgeTypeFromStatusCode(
|
||||
statusCode: number
|
||||
): 'error' | 'warning' | 'success' | undefined {
|
||||
if (statusCode >= 500) {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
if (statusCode >= 400) {
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
if (statusCode === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return 'success';
|
||||
}
|
||||
@@ -66,6 +66,19 @@ function safePrefsKey(widthPreferences: TeamPreferences['widths'], from: string,
|
||||
}
|
||||
}
|
||||
|
||||
function safePrefsKeyForOrder(
|
||||
orderPreferences: TeamPreferences['order'],
|
||||
from: string,
|
||||
to: string
|
||||
) {
|
||||
if (orderPreferences.includes(from)) {
|
||||
const index = orderPreferences.indexOf(from);
|
||||
if (index !== -1) {
|
||||
orderPreferences[index] = to;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rare cases where the value was an array, probably due to PHP backend.
|
||||
function ensureObjectProperty<T extends Record<string, unknown>, K extends keyof T>(
|
||||
obj: T | null | undefined,
|
||||
@@ -239,7 +252,9 @@ function createPreferences() {
|
||||
},
|
||||
|
||||
getColumnOrder(tableId: string): TeamPreferences['order'] {
|
||||
return teamPreferences?.columnOrder?.[tableId] ?? [];
|
||||
const columnOrder = teamPreferences?.columnOrder?.[tableId] ?? [];
|
||||
safePrefsKeyForOrder(columnOrder, '$uid', '$id');
|
||||
return columnOrder;
|
||||
},
|
||||
|
||||
async saveColumnOrder(orgId: string, tableId: string, columnIds: TeamPreferences['order']) {
|
||||
@@ -247,6 +262,10 @@ function createPreferences() {
|
||||
|
||||
teamPreferences.columnOrder[tableId] = columnIds;
|
||||
|
||||
for (const tableOrder of Object.values(teamPreferences.columnOrder)) {
|
||||
safePrefsKeyForOrder(tableOrder, '$id', '$uid');
|
||||
}
|
||||
|
||||
await sdk.forConsole.teams.updatePrefs({
|
||||
teamId: orgId,
|
||||
prefs: teamPreferences
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
import type { LayoutData } from './$types';
|
||||
|
||||
export let data: LayoutData;
|
||||
let emailBannerClosed = false;
|
||||
|
||||
function kebabToSentenceCase(str: string) {
|
||||
return str
|
||||
@@ -347,9 +346,7 @@
|
||||
<Footer slot="footer" />
|
||||
</Shell>
|
||||
|
||||
<EmailVerificationBanner
|
||||
{emailBannerClosed}
|
||||
onEmailBannerClose={(closed) => (emailBannerClosed = closed)} />
|
||||
<EmailVerificationBanner />
|
||||
|
||||
{#if $wizard.show && $wizard.component}
|
||||
<svelte:component this={$wizard.component} {...$wizard.props} />
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { onMount } from 'svelte';
|
||||
import { Badge, Layout } from '@appwrite.io/pink-svelte';
|
||||
|
||||
let email: string = null;
|
||||
let emailPassword: string = null;
|
||||
@@ -40,7 +41,14 @@
|
||||
|
||||
<Form onSubmit={updateEmail}>
|
||||
<CardGrid>
|
||||
<svelte:fragment slot="title">Email</svelte:fragment>
|
||||
<svelte:fragment slot="title">
|
||||
<Layout.Stack direction="row" gap="s" alignItems="center">
|
||||
Email
|
||||
{#if $user.emailVerification}
|
||||
<Badge variant="secondary" type="success" size="s" content="verified" />
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="aside">
|
||||
<InputText
|
||||
id="email"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import { factors } from './store';
|
||||
import MfaRecoveryCodes from './mfaRecoveryCodes.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { AuthenticationFactor } from '@appwrite.io/console';
|
||||
import MfaRegenerateCodes from './mfaRegenerateCodes.svelte';
|
||||
import { page } from '$app/state';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -56,15 +57,11 @@
|
||||
const userId = searchParams.get('userId');
|
||||
const secret = searchParams.get('secret');
|
||||
|
||||
history.replaceState(null, '', cleanUrl);
|
||||
|
||||
if (userId && secret) {
|
||||
history.replaceState(null, '', cleanUrl);
|
||||
try {
|
||||
await sdk.forConsole.account.updateVerification({ userId, secret });
|
||||
addNotification({
|
||||
message: 'Email verified successfully',
|
||||
type: 'success'
|
||||
});
|
||||
// Don't show notification here - the modal will handle it
|
||||
await Promise.all([
|
||||
invalidate(Dependencies.ACCOUNT),
|
||||
invalidate(Dependencies.FACTORS)
|
||||
@@ -81,7 +78,20 @@
|
||||
async function updateMfa() {
|
||||
try {
|
||||
await sdk.forConsole.account.updateMFA({ mfa: !$user.mfa });
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
|
||||
if (!$user.mfa && $user.emailVerification && !$factors.email) {
|
||||
// Automatically set up email MFA when enabling MFA if the user has a verified email
|
||||
// This provides a fallback authentication method without requiring user interaction
|
||||
try {
|
||||
await sdk.forConsole.account.createMFAChallenge({
|
||||
factor: AuthenticationFactor.Email
|
||||
});
|
||||
} catch (emailError) {
|
||||
// Silently ignore - email MFA is optional and shouldn't block MFA enablement
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all([invalidate(Dependencies.ACCOUNT), invalidate(Dependencies.FACTORS)]);
|
||||
addNotification({
|
||||
message: `Multi-factor authentication has been ${$user.mfa ? 'enabled' : 'disabled'}`,
|
||||
type: 'success'
|
||||
@@ -280,6 +290,7 @@
|
||||
<Button
|
||||
secondary
|
||||
class="recovery-codes-button"
|
||||
disabled={enabledMethods.length === 0}
|
||||
on:click={() => (showRegenerateRecoveryCodes = true)}>
|
||||
Regenerate
|
||||
</Button>
|
||||
@@ -287,6 +298,7 @@
|
||||
<Button
|
||||
secondary
|
||||
class="recovery-codes-button"
|
||||
disabled={enabledMethods.length === 0}
|
||||
on:click={createRecoveryCodes}>View</Button>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
|
||||
@@ -20,13 +20,26 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { writable } from 'svelte/store';
|
||||
import Create from './createUser.svelte';
|
||||
import { Badge, Icon, Table, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import {
|
||||
Badge,
|
||||
Icon,
|
||||
Table,
|
||||
Layout,
|
||||
Typography,
|
||||
FloatingActionBar
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { Tag } from '@appwrite.io/pink-svelte';
|
||||
import { IconDuplicate, IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import { canWriteUsers } from '$lib/stores/roles';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import ViewSelector from '$lib/components/viewSelector.svelte';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import Confirm from '$lib/components/confirm.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -46,11 +59,46 @@
|
||||
}
|
||||
]);
|
||||
|
||||
let selectedUsers: string[] = [];
|
||||
let showDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
async function userCreated(event: CustomEvent<Models.User<Record<string, unknown>>>) {
|
||||
await goto(
|
||||
`${base}/project-${page.params.region}-${page.params.project}/auth/user-${event.detail.$id}`
|
||||
);
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
showDelete = false;
|
||||
deleting = true;
|
||||
|
||||
const promises = selectedUsers.map((userId) =>
|
||||
sdk.forProject(page.params.region, page.params.project).users.delete(userId)
|
||||
);
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.UserDelete, {
|
||||
total: selectedUsers.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedUsers.length} user${selectedUsers.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
invalidate(Dependencies.USERS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.UserDelete);
|
||||
} finally {
|
||||
selectedUsers = [];
|
||||
showDelete = false;
|
||||
deleting = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -68,7 +116,11 @@
|
||||
</Layout.Stack>
|
||||
|
||||
{#if data.users.total}
|
||||
<Table.Root columns={$columns} let:root>
|
||||
<Table.Root
|
||||
columns={$columns}
|
||||
allowSelection={$canWriteUsers}
|
||||
bind:selectedRows={selectedUsers}
|
||||
let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $columns as { id, title } (id)}
|
||||
<Table.Header.Cell column={id} {root}>{title}</Table.Header.Cell>
|
||||
@@ -77,7 +129,8 @@
|
||||
{#each data.users.users as user}
|
||||
<Table.Row.Link
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/auth/user-${user.$id}`}
|
||||
{root}>
|
||||
{root}
|
||||
id={user.$id}>
|
||||
{#each $columns as { id } (id)}
|
||||
<Table.Cell column={id} {root}>
|
||||
{#if id === '$id'}
|
||||
@@ -175,6 +228,33 @@
|
||||
allowCreate={$canWriteUsers}
|
||||
on:click={() => showCreateUser.set(true)} />
|
||||
{/if}
|
||||
|
||||
{#if selectedUsers.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selectedUsers.length.toString()} />
|
||||
<span>
|
||||
{selectedUsers.length > 1 ? 'users' : 'user'}
|
||||
selected
|
||||
</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selectedUsers = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<Create bind:showCreate={$showCreateUser} on:created={userCreated} />
|
||||
|
||||
<Confirm title="Delete users" bind:open={showDelete} onSubmit={handleDelete} disabled={deleting}>
|
||||
<Typography.Text>
|
||||
Are you sure you want to delete <b>{selectedUsers.length}</b>
|
||||
{selectedUsers.length > 1 ? 'users' : 'user'}?
|
||||
</Typography.Text>
|
||||
<Typography.Text>
|
||||
This action is irreversible and will permanently remove the selected users and all their
|
||||
data.
|
||||
</Typography.Text>
|
||||
</Confirm>
|
||||
@@ -1,11 +1,13 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { PAGE_LIMIT, Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import { showCreateUser } from './+page.svelte';
|
||||
|
||||
export const load: PageLoad = async ({ url, route, params }) => {
|
||||
export const load: PageLoad = async ({ url, route, params, depends }) => {
|
||||
depends(Dependencies.USERS);
|
||||
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
|
||||
@@ -19,17 +19,72 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { writable } from 'svelte/store';
|
||||
import { canWriteTeams } from '$lib/stores/roles';
|
||||
import { Icon, Layout, Table } from '@appwrite.io/pink-svelte';
|
||||
import {
|
||||
Icon,
|
||||
Layout,
|
||||
Table,
|
||||
FloatingActionBar,
|
||||
Badge,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import DualTimeView from '$lib/components/dualTimeView.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import Confirm from '$lib/components/confirm.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
const region = page.params.region;
|
||||
const project = page.params.project;
|
||||
|
||||
let selectedTeams: string[] = [];
|
||||
let showDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
const columns = writable([
|
||||
{ id: 'name', title: 'Name', type: 'string', width: { min: 200, max: 300 } },
|
||||
{ id: 'members', title: 'Members', type: 'string', width: { min: 120, max: 150 } },
|
||||
{ id: 'created', title: 'Created', type: 'string', width: { min: 120, max: 180 } }
|
||||
]);
|
||||
|
||||
const teamCreated = async (event: CustomEvent<Models.Team<Record<string, unknown>>>) => {
|
||||
await goto(`${base}/project-${region}-${project}/auth/teams/team-${event.detail.$id}`);
|
||||
};
|
||||
|
||||
async function handleDelete() {
|
||||
showDelete = false;
|
||||
deleting = true;
|
||||
|
||||
const promises = selectedTeams.map((teamId) =>
|
||||
sdk.forProject(page.params.region, page.params.project).teams.delete(teamId)
|
||||
);
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.TeamDelete, {
|
||||
total: selectedTeams.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedTeams.length} team${selectedTeams.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
invalidate(Dependencies.TEAMS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.TeamDelete);
|
||||
} finally {
|
||||
selectedTeams = [];
|
||||
showDelete = false;
|
||||
deleting = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -46,32 +101,55 @@
|
||||
</Layout.Stack>
|
||||
|
||||
{#if data.teams.total}
|
||||
<Table.Root columns={3} let:root>
|
||||
<Table.Root
|
||||
columns={$columns}
|
||||
allowSelection={$canWriteTeams}
|
||||
bind:selectedRows={selectedTeams}
|
||||
let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
<Table.Header.Cell {root}>Name</Table.Header.Cell>
|
||||
<Table.Header.Cell {root}>Members</Table.Header.Cell>
|
||||
<Table.Header.Cell {root}>Created</Table.Header.Cell>
|
||||
{#each $columns as { id, title }}
|
||||
<Table.Header.Cell column={id} {root}>{title}</Table.Header.Cell>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
{#each data.teams.teams as team}
|
||||
{#each data.teams.teams as team (team.$id)}
|
||||
<Table.Row.Link
|
||||
{root}
|
||||
href={`${base}/project-${region}-${project}/auth/teams/team-${team.$id}`}>
|
||||
<Table.Cell {root}>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<AvatarInitials size="xs" name={team.name} />
|
||||
<span class="u-trim">{team.name}</span>
|
||||
</Layout.Stack>
|
||||
</Table.Cell>
|
||||
<Table.Cell {root}>
|
||||
{team.total} members
|
||||
</Table.Cell>
|
||||
<Table.Cell {root}>
|
||||
<DualTimeView time={team.$createdAt} />
|
||||
</Table.Cell>
|
||||
href={`${base}/project-${region}-${project}/auth/teams/team-${team.$id}`}
|
||||
id={team.$id}>
|
||||
{#each $columns as column}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
{#if column.id === 'name'}
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<AvatarInitials size="xs" name={team.name} />
|
||||
<span class="u-trim">{team.name}</span>
|
||||
</Layout.Stack>
|
||||
{:else if column.id === 'members'}
|
||||
{team.total} members
|
||||
{:else if column.id === 'created'}
|
||||
<DualTimeView time={team.$createdAt} />
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Link>
|
||||
{/each}
|
||||
</Table.Root>
|
||||
|
||||
{#if selectedTeams.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selectedTeams.length.toString()} />
|
||||
<span>
|
||||
{selectedTeams.length > 1 ? 'teams' : 'team'}
|
||||
selected
|
||||
</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selectedTeams = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Teams"
|
||||
limit={data.limit}
|
||||
@@ -94,3 +172,14 @@
|
||||
</Container>
|
||||
|
||||
<Create bind:showCreate={$showCreateTeam} on:created={teamCreated} />
|
||||
|
||||
<Confirm title="Delete teams" bind:open={showDelete} onSubmit={handleDelete} disabled={deleting}>
|
||||
<Typography.Text>
|
||||
Are you sure you want to delete <b>{selectedTeams.length}</b>
|
||||
{selectedTeams.length > 1 ? 'teams' : 'team'}?
|
||||
</Typography.Text>
|
||||
<Typography.Text>
|
||||
This action is irreversible and will permanently remove the selected teams and all their
|
||||
memberships.
|
||||
</Typography.Text>
|
||||
</Confirm>
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { PAGE_LIMIT, Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ url, route, params }) => {
|
||||
export const load: PageLoad = async ({ url, route, params, depends }) => {
|
||||
depends(Dependencies.TEAMS);
|
||||
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
|
||||
+85
-5
@@ -11,15 +11,28 @@
|
||||
import CreateMember from '../createMembership.svelte';
|
||||
import DeleteMembership from '../deleteMembership.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Click, trackEvent } from '$lib/actions/analytics';
|
||||
import { Table, Layout, Icon } from '@appwrite.io/pink-svelte';
|
||||
import { Click, trackEvent, Submit, trackError } from '$lib/actions/analytics';
|
||||
import {
|
||||
Table,
|
||||
Layout,
|
||||
Icon,
|
||||
FloatingActionBar,
|
||||
Badge,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import Confirm from '$lib/components/confirm.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showCreate = false;
|
||||
let showDelete = false;
|
||||
let selectedMembership: Models.Membership;
|
||||
let selectedMemberships: string[] = [];
|
||||
let showBulkDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
const region = page.params.region;
|
||||
const project = page.params.project;
|
||||
@@ -27,6 +40,40 @@
|
||||
async function memberCreated() {
|
||||
invalidate(Dependencies.MEMBERSHIPS);
|
||||
}
|
||||
|
||||
async function handleBulkDelete() {
|
||||
showBulkDelete = false;
|
||||
deleting = true;
|
||||
|
||||
const promises = selectedMemberships.map((membershipId) =>
|
||||
sdk.forProject(page.params.region, page.params.project).teams.deleteMembership({
|
||||
teamId: page.params.team,
|
||||
membershipId
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.MembershipUpdate, {
|
||||
total: selectedMemberships.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedMemberships.length} membership${selectedMemberships.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
invalidate(Dependencies.MEMBERSHIPS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MembershipUpdate);
|
||||
} finally {
|
||||
selectedMemberships = [];
|
||||
showBulkDelete = false;
|
||||
deleting = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -40,6 +87,8 @@
|
||||
{#if data.memberships.total}
|
||||
<Table.Root
|
||||
let:root
|
||||
allowSelection
|
||||
bind:selectedRows={selectedMemberships}
|
||||
columns={[
|
||||
{ id: 'name' },
|
||||
{ id: 'roles' },
|
||||
@@ -52,11 +101,12 @@
|
||||
<Table.Header.Cell column="joined" {root}>Joined</Table.Header.Cell>
|
||||
<Table.Header.Cell column="actions" {root} />
|
||||
</svelte:fragment>
|
||||
{#each data.memberships.memberships as membership}
|
||||
{#each data.memberships.memberships as membership (membership.$id)}
|
||||
{@const username = membership.userName ? membership.userName : '-'}
|
||||
<Table.Row.Link
|
||||
{root}
|
||||
href={`${base}/project-${region}-${project}/auth/user-${membership.userId}`}>
|
||||
href={`${base}/project-${region}-${project}/auth/user-${membership.userId}`}
|
||||
id={membership.$id}>
|
||||
<Table.Cell column="name" {root}>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<AvatarInitials size="xs" name={username} />
|
||||
@@ -85,6 +135,22 @@
|
||||
{/each}
|
||||
</Table.Root>
|
||||
|
||||
{#if selectedMemberships.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selectedMemberships.length.toString()} />
|
||||
<span>
|
||||
{selectedMemberships.length > 1 ? 'memberships' : 'membership'}
|
||||
selected
|
||||
</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selectedMemberships = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showBulkDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Memberships"
|
||||
limit={data.limit}
|
||||
@@ -93,7 +159,7 @@
|
||||
{:else if data.search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find ‘{data.search}'</b>
|
||||
<b>Sorry, we couldn't find '{data.search}'</b>
|
||||
<p>There are no members that match your search.</p>
|
||||
</div>
|
||||
<Button
|
||||
@@ -118,3 +184,17 @@
|
||||
{selectedMembership}
|
||||
bind:showDelete
|
||||
on:deleted={() => invalidate(Dependencies.MEMBERSHIPS)} />
|
||||
|
||||
<Confirm
|
||||
title="Delete memberships"
|
||||
bind:open={showBulkDelete}
|
||||
onSubmit={handleBulkDelete}
|
||||
disabled={deleting}>
|
||||
<Typography.Text>
|
||||
Are you sure you want to delete <b>{selectedMemberships.length}</b>
|
||||
{selectedMemberships.length > 1 ? 'memberships' : 'membership'}?
|
||||
</Typography.Text>
|
||||
<Typography.Text>
|
||||
This action is irreversible and will remove the selected members from this team.
|
||||
</Typography.Text>
|
||||
</Confirm>
|
||||
+92
-3
@@ -6,23 +6,81 @@
|
||||
import { Container } from '$lib/layout';
|
||||
import DeleteMembership from '../deleteMembership.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { trackEvent, Submit, trackError } from '$lib/actions/analytics';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { Table, Layout, Empty, Card } from '@appwrite.io/pink-svelte';
|
||||
import {
|
||||
Table,
|
||||
Layout,
|
||||
Empty,
|
||||
Card,
|
||||
FloatingActionBar,
|
||||
Badge,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import Confirm from '$lib/components/confirm.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
let selectedMembership: Models.Membership;
|
||||
let showDelete = false;
|
||||
let selectedMemberships: string[] = [];
|
||||
let showBulkDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
const region = page.params.region;
|
||||
const project = page.params.project;
|
||||
|
||||
async function handleBulkDelete() {
|
||||
showBulkDelete = false;
|
||||
deleting = true;
|
||||
|
||||
// Precompute a lookup map from membershipId to teamId for efficient access
|
||||
const membershipIdToTeamId: Record<string, string> = {};
|
||||
for (const m of data.memberships.memberships) {
|
||||
membershipIdToTeamId[m.$id] = m.teamId;
|
||||
}
|
||||
|
||||
const promises = selectedMemberships.map((membershipId) =>
|
||||
sdk.forProject(page.params.region, page.params.project).teams.deleteMembership({
|
||||
teamId: membershipIdToTeamId[membershipId] || '',
|
||||
membershipId
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.MembershipUpdate, {
|
||||
total: selectedMemberships.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedMemberships.length} membership${selectedMemberships.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
invalidate(Dependencies.MEMBERSHIPS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MembershipUpdate);
|
||||
} finally {
|
||||
selectedMemberships = [];
|
||||
showBulkDelete = false;
|
||||
deleting = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.memberships.total}
|
||||
<Table.Root
|
||||
let:root
|
||||
allowSelection
|
||||
bind:selectedRows={selectedMemberships}
|
||||
columns={[
|
||||
{ id: 'name' },
|
||||
{ id: 'roles' },
|
||||
@@ -38,7 +96,8 @@
|
||||
{#each data.memberships.memberships as membership}
|
||||
<Table.Row.Link
|
||||
{root}
|
||||
href={`${base}/project-${region}-${project}/auth/teams/team-${membership.teamId}`}>
|
||||
href={`${base}/project-${region}-${project}/auth/teams/team-${membership.teamId}`}
|
||||
id={membership.$id}>
|
||||
<Table.Cell column="name" {root}>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<AvatarInitials size="xs" name={membership.teamName} />
|
||||
@@ -83,6 +142,36 @@
|
||||
</Empty>
|
||||
</Card.Base>
|
||||
{/if}
|
||||
|
||||
{#if selectedMemberships.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selectedMemberships.length.toString()} />
|
||||
<span>
|
||||
{selectedMemberships.length > 1 ? 'memberships' : 'membership'}
|
||||
selected
|
||||
</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selectedMemberships = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showBulkDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<DeleteMembership {selectedMembership} bind:showDelete />
|
||||
|
||||
<Confirm
|
||||
title="Delete memberships"
|
||||
bind:open={showBulkDelete}
|
||||
onSubmit={handleBulkDelete}
|
||||
disabled={deleting}>
|
||||
<Typography.Text>
|
||||
Are you sure you want to delete <b>{selectedMemberships.length}</b>
|
||||
{selectedMemberships.length > 1 ? 'memberships' : 'membership'}?
|
||||
</Typography.Text>
|
||||
<Typography.Text>
|
||||
This action is irreversible and will remove the user from the selected teams.
|
||||
</Typography.Text>
|
||||
</Confirm>
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
export const load: PageLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.MEMBERSHIPS);
|
||||
|
||||
const codes = await sdk.forProject(params.region, params.project).locale.listCodes();
|
||||
return {
|
||||
localeCodes: codes.localeCodes,
|
||||
|
||||
+15
@@ -359,6 +359,21 @@
|
||||
bottom: 35%;
|
||||
position: fixed;
|
||||
|
||||
@media (max-width: 768px) and (max-height: 768px) {
|
||||
left: unset;
|
||||
bottom: 12.5% !important;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) and (max-height: 1024px) {
|
||||
left: unset;
|
||||
bottom: 15% !important;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) and (max-height: 1024px) {
|
||||
left: unset;
|
||||
bottom: 15%;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
left: unset;
|
||||
bottom: 30%;
|
||||
|
||||
+52
-27
@@ -1,8 +1,10 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { Badge, Divider, Layout, Sheet, Tag, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { Copy } from '$lib/components';
|
||||
import { writable } from 'svelte/store';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { isTabletViewport } from '$lib/stores/viewport';
|
||||
import { Badge, Divider, Layout, Sheet, Tag, Typography } from '@appwrite.io/pink-svelte';
|
||||
|
||||
let {
|
||||
show = $bindable(false),
|
||||
@@ -38,6 +40,9 @@
|
||||
footer?: Snippet | null;
|
||||
} = $props();
|
||||
|
||||
let form: Form;
|
||||
let submitting = $state(writable(false));
|
||||
|
||||
let copyText = $state(undefined);
|
||||
</script>
|
||||
|
||||
@@ -74,6 +79,8 @@
|
||||
|
||||
<Layout.Stack direction="column" justifyContent="space-evenly">
|
||||
<Form
|
||||
bind:this={form}
|
||||
bind:isSubmitting={submitting}
|
||||
onSubmit={async () => {
|
||||
try {
|
||||
const keepOpen = await submit?.onClick?.();
|
||||
@@ -87,32 +94,38 @@
|
||||
<Layout.Stack gap="xl" class="sheet-content">
|
||||
{@render children?.()}
|
||||
</Layout.Stack>
|
||||
|
||||
{#if submit}
|
||||
<div class="sheet-footer">
|
||||
<Layout.Stack gap="l">
|
||||
<Divider />
|
||||
|
||||
<div class="sheet-footer-actions">
|
||||
<Layout.Stack
|
||||
gap="m"
|
||||
direction="row"
|
||||
justifyContent="flex-end"
|
||||
alignItems="center">
|
||||
{#if footer}
|
||||
{@render footer?.()}
|
||||
{/if}
|
||||
<Button size="s" secondary on:click={() => (show = false)}
|
||||
>Cancel</Button>
|
||||
<Button size="s" submit disabled={submit.disabled}>
|
||||
{submit.text}
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
</div>
|
||||
</Layout.Stack>
|
||||
</div>
|
||||
{/if}
|
||||
</Form>
|
||||
|
||||
{#if submit}
|
||||
<div class="sheet-footer">
|
||||
<Layout.Stack gap="l">
|
||||
<Divider />
|
||||
|
||||
<div class="sheet-footer-actions">
|
||||
<Layout.Stack
|
||||
gap="m"
|
||||
direction="row"
|
||||
justifyContent="flex-end"
|
||||
alignItems="center">
|
||||
{#if footer}
|
||||
{@render footer?.()}
|
||||
{/if}
|
||||
<Button size="s" secondary on:click={() => (show = false)}
|
||||
>Cancel</Button>
|
||||
<Button
|
||||
size="s"
|
||||
submit
|
||||
disabled={submit.disabled || $submitting}
|
||||
forceShowLoader={$submitting && $isTabletViewport}
|
||||
submissionLoader={$submitting && $isTabletViewport}
|
||||
on:click={() => form?.triggerSubmit()}>
|
||||
{submit.text}
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
</div>
|
||||
</Layout.Stack>
|
||||
</div>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
</Sheet>
|
||||
</div>
|
||||
@@ -131,6 +144,14 @@
|
||||
& :global(.sheet-content) {
|
||||
// overflow-y: auto;
|
||||
padding-bottom: 5rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
/*
|
||||
* different mobile browsers handle bottom spaces differently,
|
||||
* therefore, having extra bottom space doesn't hurt anyone imo!
|
||||
*/
|
||||
padding-bottom: 15rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +162,10 @@
|
||||
position: absolute;
|
||||
background: var(--bgcolor-neutral-primary);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
& .sheet-footer-actions {
|
||||
padding-inline: var(--space-8);
|
||||
padding-block-end: var(--space-6);
|
||||
|
||||
+8
-7
@@ -26,23 +26,24 @@
|
||||
let formStore = writable(formValues);
|
||||
|
||||
function removeArrayItem(key: string, index: number) {
|
||||
const currentArray = Array.isArray($formStore[key]) ? $formStore[key] : [];
|
||||
const filteredArray = currentArray.filter((_: object, i: number) => i !== index);
|
||||
const next = {
|
||||
...$formStore,
|
||||
[key]: $formStore[key].filter((_, i) => i !== index)
|
||||
...formValues,
|
||||
[key]: filteredArray.length === 0 ? [] : filteredArray
|
||||
};
|
||||
|
||||
formStore.set(next);
|
||||
onUpdateFormValues?.(next);
|
||||
}
|
||||
|
||||
function addArrayItem(key: string) {
|
||||
const currentArray = Array.isArray($formStore[key]) ? $formStore[key] : null;
|
||||
const next = {
|
||||
...$formStore,
|
||||
[key]: [...($formStore[key] ?? []), null]
|
||||
...formValues,
|
||||
[key]: currentArray ? [...currentArray, null] : [null]
|
||||
};
|
||||
|
||||
formStore.set(next);
|
||||
onUpdateFormValues?.(next);
|
||||
}
|
||||
|
||||
function getColumnType(column: Columns) {
|
||||
@@ -107,7 +108,7 @@
|
||||
on:click />
|
||||
{:else}
|
||||
<Layout.Stack>
|
||||
{#each [...($formStore[column.key]?.keys() ?? [])] as index}
|
||||
{#each [...($formStore[column.key]?.keys() ?? [])] as index (index)}
|
||||
<Layout.Stack direction="row" alignItems="flex-end" gap="xs">
|
||||
<Column
|
||||
{column}
|
||||
|
||||
+8
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { InputDateTime } from '$lib/elements/forms';
|
||||
import { toLocalDateTimeISO } from '$lib/helpers/date';
|
||||
import { IconCalendar } from '@appwrite.io/pink-icons-svelte';
|
||||
|
||||
export let id: string;
|
||||
@@ -15,6 +17,12 @@
|
||||
$: if (limited) {
|
||||
label = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* the value from backend will include timezone info,
|
||||
* and that's not compatible with the component as it'll go empty.
|
||||
*/
|
||||
onMount(() => (value = value ? toLocalDateTimeISO(value) : value));
|
||||
</script>
|
||||
|
||||
<InputDateTime
|
||||
|
||||
+6
-1
@@ -270,7 +270,12 @@
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/functions`}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button submit disabled={!name || !runtime || !specification}>
|
||||
<Button
|
||||
submit
|
||||
fullWidthMobile
|
||||
submissionLoader
|
||||
forceShowLoader={$isSubmitting}
|
||||
disabled={!name || !runtime || !specification || $isSubmitting}>
|
||||
Deploy function
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ export const load: PageLoad = async ({ url, params, parent }) => {
|
||||
redirect(302, `${base}/project-${params.region}-${params.project}/functions`);
|
||||
}
|
||||
|
||||
const info = getRepositoryInfo(repository!);
|
||||
const info = getRepositoryInfo(repository);
|
||||
if (!info) {
|
||||
redirect(302, `${base}/project-${params.region}-${params.project}/functions`);
|
||||
}
|
||||
@@ -41,8 +41,8 @@ export const load: PageLoad = async ({ url, params, parent }) => {
|
||||
installations,
|
||||
specificationsList,
|
||||
repository: {
|
||||
url: repository,
|
||||
name: info.owner,
|
||||
url: info.url,
|
||||
name: info.name,
|
||||
owner: info.owner,
|
||||
rootDirectory: getNestedRootDirectory(repository)
|
||||
}
|
||||
|
||||
+4
-5
@@ -17,6 +17,7 @@
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { timeFromNow, toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { getBadgeTypeFromStatusCode } from '$lib/helpers/httpStatus';
|
||||
import { Copy } from '$lib/components';
|
||||
import { logStatusConverter } from './store';
|
||||
import { LogsRequest, LogsResponse } from '$lib/components/logs';
|
||||
@@ -98,11 +99,9 @@
|
||||
<Badge
|
||||
content={selectedLog.responseStatusCode.toString()}
|
||||
variant="secondary"
|
||||
type={selectedLog?.responseStatusCode >= 400
|
||||
? 'error'
|
||||
: selectedLog.responseStatusCode === 0
|
||||
? undefined
|
||||
: 'success'} />
|
||||
type={getBadgeTypeFromStatusCode(
|
||||
selectedLog.responseStatusCode
|
||||
)} />
|
||||
</span>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack gap="xs" inline>
|
||||
|
||||
+2
-5
@@ -14,6 +14,7 @@
|
||||
import Sheet from './sheet.svelte';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { calculateTime } from '$lib/helpers/timeConversion';
|
||||
import { getBadgeTypeFromStatusCode } from '$lib/helpers/httpStatus';
|
||||
import { logStatusConverter } from './store';
|
||||
import DualTimeView from '$lib/components/dualTimeView.svelte';
|
||||
import { func } from '../store';
|
||||
@@ -96,11 +97,7 @@
|
||||
{:else if column.id === 'responseStatusCode'}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type={log.responseStatusCode >= 400
|
||||
? 'error'
|
||||
: log.responseStatusCode === 0
|
||||
? undefined
|
||||
: 'success'}
|
||||
type={getBadgeTypeFromStatusCode(log.responseStatusCode)}
|
||||
content={log.responseStatusCode.toString()} />
|
||||
{:else if column.id === 'requestMethod'}
|
||||
<Typography.Code size="m">
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
export let show = false;
|
||||
export let handleDisableAll;
|
||||
</script>
|
||||
|
||||
<Modal title="Disable all services" bind:show onSubmit={handleDisableAll}>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to disable all services? This will disable API requests to this
|
||||
project for all Client SDKs.
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (show = false)}>Cancel</Button>
|
||||
<Button secondary submit>Disable All</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -58,7 +58,7 @@
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
external
|
||||
href="#/"
|
||||
href="https://appwrite.io/docs/advanced/platform/custom-domains"
|
||||
text
|
||||
event="empty_documentation"
|
||||
size="s"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
export let show = false;
|
||||
export let handleEnableAll;
|
||||
</script>
|
||||
|
||||
<Modal title="Enable all services" bind:show onSubmit={handleEnableAll}>
|
||||
<p class="text" data-private>All project services will be enabled.</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (show = false)}>Cancel</Button>
|
||||
<Button secondary submit>Enable all</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -8,22 +8,47 @@
|
||||
import { services, type Service } from '$lib/stores/project-services';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { project } from '../store';
|
||||
import EnableAllServices from './enableAllServices.svelte';
|
||||
import DisableAllServices from './disableAllServices.svelte';
|
||||
import Button from '$lib/elements/forms/button.svelte';
|
||||
import { Divider, Layout } from '@appwrite.io/pink-svelte';
|
||||
import { Dialog, Divider, Layout, Spinner } from '@appwrite.io/pink-svelte';
|
||||
import type { ApiService } from '@appwrite.io/console';
|
||||
|
||||
let showDisableAll = false;
|
||||
let showEnableAll = false;
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
|
||||
let isUpdatingAllServices = $state(false);
|
||||
let showUpdateServiceDialog = $state(false);
|
||||
let updateServicesEnabledMode = $state<boolean | null>(null);
|
||||
|
||||
let apiServiceUpdates = new SvelteSet<ApiService>();
|
||||
|
||||
const isAnyServiceUpdating = $derived(apiServiceUpdates.size > 0);
|
||||
const isAnyUpdateInProgress = $derived(isUpdatingAllServices || isAnyServiceUpdating);
|
||||
|
||||
const allServicesEnabled = $derived.by(() => {
|
||||
if (isAnyUpdateInProgress) return false;
|
||||
return $services.list.every((service) => service.value);
|
||||
});
|
||||
|
||||
const allServicesDisabled = $derived.by(() => {
|
||||
if (isAnyUpdateInProgress) return false;
|
||||
return $services.list.every((service) => !service.value);
|
||||
});
|
||||
|
||||
const shouldDisableEnableAllButton = $derived(isAnyUpdateInProgress || allServicesEnabled);
|
||||
|
||||
const shouldDisableDisableAllButton = $derived(isAnyUpdateInProgress || allServicesDisabled);
|
||||
|
||||
async function serviceUpdate(service: Service) {
|
||||
apiServiceUpdates.add(service.method);
|
||||
|
||||
try {
|
||||
await sdk.forConsole.projects.updateServiceStatus({
|
||||
projectId: $project.$id,
|
||||
service: service.method,
|
||||
status: service.value
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.PROJECT);
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${service.label} service has been ${
|
||||
@@ -40,25 +65,22 @@
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.ProjectService);
|
||||
} finally {
|
||||
apiServiceUpdates.delete(service.method);
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleAllServices(status: boolean) {
|
||||
if (status && !showEnableAll) {
|
||||
showEnableAll = true;
|
||||
return;
|
||||
}
|
||||
if (!status && !showDisableAll) {
|
||||
showDisableAll = true;
|
||||
return;
|
||||
}
|
||||
isUpdatingAllServices = true;
|
||||
|
||||
try {
|
||||
await sdk.forConsole.projects.updateServiceStatusAll({
|
||||
projectId: $project.$id,
|
||||
status
|
||||
});
|
||||
invalidate(Dependencies.PROJECT);
|
||||
|
||||
await invalidate(Dependencies.PROJECT);
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message:
|
||||
@@ -75,12 +97,30 @@
|
||||
});
|
||||
trackError(error, Submit.ProjectService);
|
||||
} finally {
|
||||
showDisableAll = false;
|
||||
showEnableAll = false;
|
||||
isUpdatingAllServices = false;
|
||||
showUpdateServiceDialog = false;
|
||||
updateServicesEnabledMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
$: services.load($project);
|
||||
const dialogDetails = $derived.by(() => {
|
||||
if (updateServicesEnabledMode) {
|
||||
return {
|
||||
title: 'Enable all services',
|
||||
message: 'All project services will be enabled.',
|
||||
actionButton: 'Enable all'
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
title: 'Disable all services',
|
||||
message:
|
||||
'Are you sure you want to disable all services? This will disable API requests to this project for all Client SDKs.',
|
||||
actionButton: 'Disable all'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => services.load($project));
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
@@ -90,22 +130,43 @@
|
||||
<svelte:fragment slot="aside">
|
||||
<Layout.Stack gap="m">
|
||||
<Layout.Stack direction="row" alignItems="center" gap="s">
|
||||
<Button extraCompact on:click={() => toggleAllServices(true)}>Enable all</Button>
|
||||
<Button
|
||||
extraCompact
|
||||
on:click={() => {
|
||||
showUpdateServiceDialog = true;
|
||||
updateServicesEnabledMode = true;
|
||||
}}
|
||||
disabled={shouldDisableEnableAllButton}>Enable all</Button>
|
||||
<span style:height="20px">
|
||||
<Divider vertical />
|
||||
</span>
|
||||
<Button extraCompact on:click={() => toggleAllServices(false)}>Disable all</Button>
|
||||
<Button
|
||||
extraCompact
|
||||
on:click={() => {
|
||||
showUpdateServiceDialog = true;
|
||||
updateServicesEnabledMode = false;
|
||||
}}
|
||||
disabled={shouldDisableDisableAllButton}>Disable all</Button>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack gap="l">
|
||||
<Divider />
|
||||
<Layout.Stack direction="row" wrap="wrap">
|
||||
{#each $services.list as service}
|
||||
<span style:flex-basis="30%">
|
||||
<InputSwitch
|
||||
label={service.label}
|
||||
id={service.method}
|
||||
bind:value={service.value}
|
||||
on:change={() => serviceUpdate(service)} />
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<InputSwitch
|
||||
id={service.method}
|
||||
label={service.label}
|
||||
bind:value={service.value}
|
||||
on:change={() => serviceUpdate(service)}
|
||||
disabled={apiServiceUpdates.has(service.method)} />
|
||||
|
||||
{#if apiServiceUpdates.has(service.method)}
|
||||
<span style:opacity="0.75">
|
||||
<Spinner size="s" />
|
||||
</span>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
</span>
|
||||
{/each}
|
||||
</Layout.Stack>
|
||||
@@ -114,5 +175,20 @@
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<DisableAllServices handleDisableAll={() => toggleAllServices(false)} bind:show={showDisableAll} />
|
||||
<EnableAllServices handleEnableAll={() => toggleAllServices(true)} bind:show={showEnableAll} />
|
||||
<Dialog title={dialogDetails.title} bind:open={showUpdateServiceDialog}>
|
||||
<p class="text" data-private>{dialogDetails.message}</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Layout.Stack direction="row" gap="s" justifyContent="flex-end">
|
||||
<Button text on:click={() => (showUpdateServiceDialog = false)}>Cancel</Button>
|
||||
|
||||
<Button
|
||||
secondary
|
||||
submissionLoader
|
||||
disabled={isUpdatingAllServices}
|
||||
forceShowLoader={isUpdatingAllServices}
|
||||
on:click={() => toggleAllServices(updateServicesEnabledMode)}>
|
||||
{dialogDetails.actionButton}
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
</svelte:fragment>
|
||||
</Dialog>
|
||||
+3
-1
@@ -315,8 +315,10 @@
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
fullWidthMobile
|
||||
size="s"
|
||||
fullWidthMobile
|
||||
submissionLoader
|
||||
forceShowLoader={$isSubmitting}
|
||||
on:click={() => formComponent.triggerSubmit()}
|
||||
disabled={$isSubmitting || !domainIsValid || !domain}>
|
||||
Deploy
|
||||
|
||||
@@ -11,7 +11,7 @@ export const load: PageLoad = async ({ url, params }) => {
|
||||
redirect(302, `${base}/project-${params.region}-${params.project}/sites`);
|
||||
}
|
||||
|
||||
const info = getRepositoryInfo(repository!);
|
||||
const info = getRepositoryInfo(repository);
|
||||
if (!info) {
|
||||
redirect(302, `${base}/project-${params.region}-${params.project}/sites`);
|
||||
}
|
||||
@@ -32,10 +32,10 @@ export const load: PageLoad = async ({ url, params }) => {
|
||||
frameworks,
|
||||
installations,
|
||||
repository: {
|
||||
url: repository,
|
||||
url: info.url,
|
||||
name: info.name,
|
||||
owner: info.owner,
|
||||
rootDirectory: getNestedRootDirectory(repository!)
|
||||
rootDirectory: getNestedRootDirectory(repository)
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -15,6 +15,7 @@
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { timeFromNow } from '$lib/helpers/date';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { getBadgeTypeFromStatusCode } from '$lib/helpers/httpStatus';
|
||||
import { Copy } from '$lib/components';
|
||||
import { LogsRequest, LogsResponse } from '$lib/components/logs';
|
||||
import { site } from '../store';
|
||||
@@ -99,9 +100,9 @@
|
||||
<Badge
|
||||
content={selectedLog.responseStatusCode.toString()}
|
||||
variant="secondary"
|
||||
type={selectedLog?.responseStatusCode >= 400
|
||||
? 'error'
|
||||
: 'success'} />
|
||||
type={getBadgeTypeFromStatusCode(
|
||||
selectedLog.responseStatusCode
|
||||
)} />
|
||||
</span>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack gap="xs" inline>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { calculateTime } from '$lib/helpers/timeConversion';
|
||||
import { getBadgeTypeFromStatusCode } from '$lib/helpers/httpStatus';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
export let columns: Column[];
|
||||
@@ -87,7 +88,7 @@
|
||||
<div>
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type={log.responseStatusCode >= 400 ? 'error' : 'success'}
|
||||
type={getBadgeTypeFromStatusCode(log.responseStatusCode)}
|
||||
content={log.responseStatusCode.toString()} />
|
||||
</div>
|
||||
{:else if column.id === 'requestPath'}
|
||||
|
||||
+87
-32
@@ -14,7 +14,17 @@
|
||||
import { uploader } from '$lib/stores/uploader';
|
||||
import { sdk } from '$lib/stores/sdk.js';
|
||||
import DeleteFile from './deleteFile.svelte';
|
||||
import { Layout, Table, Icon, Popover, ActionMenu } from '@appwrite.io/pink-svelte';
|
||||
import { bucket } from './store';
|
||||
import Confirm from '$lib/components/confirm.svelte';
|
||||
import {
|
||||
Layout,
|
||||
Table,
|
||||
Icon,
|
||||
Popover,
|
||||
ActionMenu,
|
||||
FloatingActionBar,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import DualTimeView from '$lib/components/dualTimeView.svelte';
|
||||
import {
|
||||
@@ -28,6 +38,9 @@
|
||||
|
||||
let showDelete = false;
|
||||
let selectedFile: Models.File = null;
|
||||
let selectedFiles: string[] = [];
|
||||
let showBulkDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
const bucketId = page.params.bucket;
|
||||
|
||||
@@ -52,19 +65,41 @@
|
||||
}
|
||||
|
||||
async function deleteFile(file: Models.File) {
|
||||
selectedFile = file;
|
||||
showDelete = true;
|
||||
}
|
||||
|
||||
async function handleBulkDelete() {
|
||||
showBulkDelete = false;
|
||||
deleting = true;
|
||||
|
||||
const promises = selectedFiles.map((fileId) =>
|
||||
sdk.forProject(page.params.region, page.params.project).storage.deleteFile({
|
||||
bucketId,
|
||||
fileId
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.deleteFile({ bucketId: file.bucketId, fileId: file.$id });
|
||||
await invalidate(Dependencies.FILES);
|
||||
await uploader.removeFile(file);
|
||||
trackEvent(Submit.FileDelete);
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.FileDelete, {
|
||||
total: selectedFiles.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedFiles.length} file${selectedFiles.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
invalidate(Dependencies.FILES);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.FileDelete);
|
||||
} finally {
|
||||
selectedFiles = [];
|
||||
showBulkDelete = false;
|
||||
deleting = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +147,8 @@
|
||||
{#if data.files.total}
|
||||
<Table.Root
|
||||
let:root
|
||||
allowSelection
|
||||
bind:selectedRows={selectedFiles}
|
||||
columns={[
|
||||
{ id: 'filename' },
|
||||
{ id: 'type', width: { min: 140 } },
|
||||
@@ -128,7 +165,7 @@
|
||||
</svelte:fragment>
|
||||
{#each data.files.files as file}
|
||||
{#if file.chunksTotal / file.chunksUploaded !== 1}
|
||||
<Table.Row.Base {root}>
|
||||
<Table.Row.Base {root} id={file.$id}>
|
||||
<Table.Cell column="filename" {root}>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<span class="avatar is-size-small is-color-empty"></span>
|
||||
@@ -158,7 +195,7 @@
|
||||
</Table.Row.Base>
|
||||
{:else}
|
||||
{@const href = `${base}/project-${page.params.region}-${page.params.project}/storage/bucket-${bucketId}/file-${file.$id}`}
|
||||
<Table.Row.Link {href} {root}>
|
||||
<Table.Row.Link {href} {root} id={file.$id}>
|
||||
<Table.Cell column="filename" {root}>
|
||||
<div class="u-flex u-gap-12 u-cross-center">
|
||||
<Avatar size="xs" src={getPreview(file.$id)} alt={file.name} />
|
||||
@@ -213,37 +250,55 @@
|
||||
offset={data.offset}
|
||||
total={data.files.total} />
|
||||
{:else if data.search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{data.search}'</b>
|
||||
<p>There are no files that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/products/storage/upload-download"
|
||||
text>
|
||||
Documentation
|
||||
</Button>
|
||||
<Button
|
||||
secondary
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/storage/bucket-${page.params.bucket}`}>
|
||||
Clear Search
|
||||
</Button>
|
||||
</div>
|
||||
<EmptySearch target="files" search={data.search} hidePagination={data.files.total === 0}>
|
||||
<Button
|
||||
secondary
|
||||
size="s"
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/storage/bucket-${bucketId}`}>
|
||||
Clear Search
|
||||
</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/products/storage"
|
||||
target="file"
|
||||
href="https://appwrite.io/docs/products/storage/upload-download"
|
||||
allowCreate
|
||||
on:click={() =>
|
||||
goto(
|
||||
`${base}/project-${page.params.region}-${page.params.project}/storage/bucket-${page.params.bucket}/create`
|
||||
`${base}/project-${page.params.region}-${page.params.project}/storage/bucket-${bucketId}/create`
|
||||
)} />
|
||||
{/if}
|
||||
|
||||
{#if selectedFiles.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selectedFiles.length.toString()} />
|
||||
<span>
|
||||
{selectedFiles.length > 1 ? 'files' : 'file'}
|
||||
selected
|
||||
</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selectedFiles = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showBulkDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
{#if selectedFile}
|
||||
<DeleteFile file={selectedFile} bind:showDelete on:deleted={fileDeleted} />
|
||||
{/if}
|
||||
<DeleteFile bind:showDelete file={selectedFile} on:deleted={fileDeleted} />
|
||||
|
||||
<Confirm
|
||||
title="Delete files"
|
||||
bind:open={showBulkDelete}
|
||||
onSubmit={handleBulkDelete}
|
||||
disabled={deleting}>
|
||||
<Typography.Text>
|
||||
Are you sure you want to delete <b>{selectedFiles.length}</b>
|
||||
{selectedFiles.length > 1 ? 'files' : 'file'} from <b>{$bucket?.name}</b>?
|
||||
</Typography.Text>
|
||||
<Typography.Text>
|
||||
This action is irreversible and will permanently remove the selected files.
|
||||
</Typography.Text>
|
||||
</Confirm>
|
||||
@@ -54,7 +54,7 @@ export const load: PageLoad = async ({ parent, url }) => {
|
||||
// Get available runtimes
|
||||
const runtimesList = await sdk.forConsole.functions.listRuntimes();
|
||||
|
||||
const info = getRepositoryInfo(repository!);
|
||||
const info = getRepositoryInfo(repository);
|
||||
if (!info) {
|
||||
redirect(302, base + '/');
|
||||
}
|
||||
|
||||
@@ -62,9 +62,8 @@ export const load: PageLoad = async ({ parent, url }) => {
|
||||
error(404, `Template "${templateKey}" not found`);
|
||||
}
|
||||
} else {
|
||||
const info = getRepositoryInfo(repository!);
|
||||
const info = getRepositoryInfo(repository);
|
||||
if (!info) {
|
||||
console.log(info);
|
||||
redirect(302, base + '/');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { trackPageView } from '$lib/actions/analytics';
|
||||
import { Notifications, Progress } from '$lib/layout';
|
||||
import { app, type AppStore } from '$lib/stores/app';
|
||||
import { isCloud, isProductionCloud } from '$lib/system';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { onMount } from 'svelte';
|
||||
import { requestedMigration } from './store';
|
||||
import { parseIfString } from '$lib/helpers/object';
|
||||
@@ -173,11 +173,6 @@
|
||||
<link rel="preload" as="style" type="text/css" href="/console/fonts/cloud.css" />
|
||||
<link rel="stylesheet" href={`${base}/fonts/cloud.css`} />
|
||||
{/if}
|
||||
|
||||
<!-- add GTM only on main instance -->
|
||||
{#if isCloud && isProductionCloud(page.url)}
|
||||
<script defer src={`${base}/scripts/gtm.js`}></script>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
<Root theme={resolveTheme($app.themeInUse)}>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
(function (w, d, s, l, i) {
|
||||
w[l] = w[l] || [];
|
||||
w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
|
||||
var f = d.getElementsByTagName(s)[0],
|
||||
j = d.createElement(s),
|
||||
dl = l != 'dataLayer' ? '&l=' + l : '';
|
||||
j.async = true;
|
||||
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
|
||||
f.parentNode.insertBefore(j, f);
|
||||
})(window, document, 'script', 'dataLayer', 'GTM-WQ5WKK8');
|
||||
Reference in new issue
Block a user