Merge pull request #1284 from appwrite/mock-numbers-review

Mock numbers review
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2024-08-12 19:20:08 +02:00
commit 44237f04f0
9 files changed
+9285 -51

No files matched your search

+9187
View File
File diff suppressed because it is too large. Load diff
+2 -14
View File
@@ -1,7 +1,5 @@
<script>
import { trackEvent } from '$lib/actions/analytics';
import { Button } from '$lib/elements/forms';
import { getNextTier, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { getNextTier, tierToPlan } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import Card from './card.svelte';
@@ -26,17 +24,7 @@
<p class="u-margin-block-start-8">
<slot nextTier={tierToPlan(getNextTier($organization.billingPlan)).name} />
</p>
<Button
class="u-margin-block-start-32"
secondary
fullWidth
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
source
});
}}>Upgrade plan</Button>
<slot name="cta" {source} />
</div>
</div>
</Card>
+9 -2
View File
@@ -5,7 +5,7 @@
</script>
<p
class="helper u-margin-block-start-8 {classes}"
class="helper u-margin-block-start-8 {classes} u-align-baseline"
class:u-color-text-info={type === 'info'}
class:u-color-text-danger={type === 'error'}
class:u-color-text-success={type === 'success'}
@@ -18,7 +18,14 @@
class:icon-exclamation={type === 'warning'}
aria-hidden="true" />
{/if}
<span class="text">
<span class="text u-line-height-1-5">
<slot />
</span>
</p>
<style>
[class^='icon-']::before,
[class*=' icon-']::before {
vertical-align: baseline;
}
</style>
+1 -1
View File
@@ -116,6 +116,6 @@
<slot />
</div>
{#if error}
<Helper type="warning">{error}</Helper>
<Helper type="warning" class="u-line-height-1">{error}</Helper>
{/if}
</svelte:component>
+7 -2
View File
@@ -19,7 +19,7 @@
export let popoverProps: Record<string, unknown> = {};
export let fullWidth = false;
const pattern = String.raw`^\+?[1-9]\d{1,14}$`;
const pattern = String.raw`^\+[1-9]\d{1,14}$`;
let element: HTMLInputElement;
let error: string;
@@ -40,7 +40,12 @@
}
if (element.validity.patternMismatch) {
error = "Allowed characters: leading '+' and maximum of 15 digits";
error = `Allowed characters: leading '+' and maximum of ${maxlength - 1} digits`;
return;
}
if (element.validity.tooShort) {
error = `The value must contain leading ‘+’ and at least ${minlength - 1} digits `;
return;
}
@@ -12,11 +12,11 @@
<Container>
<UpdateUsersLimit />
<UpdateMockNumbers />
<UpdateSessionLength />
<UpdateSessionsLimit />
<UpdatePasswordHistory />
<UpdatePasswordDictionary />
<UpdatePersonalDataCheck />
<UpdateSessionAlerts />
<UpdateMockNumbers />
</Container>
@@ -10,7 +10,7 @@
import { Dependencies } from '$lib/constants';
import { organization } from '$lib/stores/organization';
import { BillingPlan } from '$lib/constants';
import { isCloud } from '$lib/system';
import { isCloud, isSelfHosted } from '$lib/system';
import MockNumbersLight from './mock-numbers-light.png';
import MockNumbersDark from './mock-numbers-dark.png';
import EmptyCardImageCloud from '$lib/components/emptyCardImageCloud.svelte';
@@ -24,7 +24,18 @@
let projectId: string = $project.$id;
$: initialNumbers = $project?.authMockNumbers?.map((num) => ({ ...num })) ?? [];
$: submitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers);
$: isSubmitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers);
// temporarily enable the component for design review
let isComponentDisabled: boolean =
(false && isSelfHosted) || (isCloud && $organization?.billingPlan === BillingPlan.FREE);
let emptyStateTitle: string = isSelfHosted
? 'Available on Appwrite Cloud'
: 'Upgrade to add mock phone numbers';
let emptyStateDescription: string = isSelfHosted
? 'Sign up to Cloud to add mock phone numbers to your projects.'
: 'Upgrade to a Pro plan to add mock phone numbers to your project.';
let cta: string = isSelfHosted ? 'Sign up' : 'Upgrade plan';
async function updateMockNumbers() {
try {
@@ -71,15 +82,21 @@
</script>
<Form onSubmit={updateMockNumbers}>
<CardGrid>
<Heading tag="h6" size="7" id="variables">Mock Phone Numbers</Heading>
<CardGrid hideFooter={isComponentDisabled}>
<Heading tag="h6" size="7" id="variables">Mock phone numbers</Heading>
<p>
Generate <b>fictional</b> numbers to simulate phone verification when testing demo accounts
for submitting your application to the App Store or Google Play. Learn more
Generate <b>fictional</b> numbers to simulate phone verification when testing demo
accounts for submitting your application to the App Store or Google Play.
<a
href="https://appwrite.io/docs/products/auth/security#mock-numbers"
target="_blank"
class="u-underline"
rel="noopener noreferrer">
Learn more</a>
</p>
<svelte:fragment slot="aside">
{#if isCloud && $organization?.billingPlan === BillingPlan.FREE}
<EmptyCardImageCloud source="email_signature_card" let:nextTier noAspectRatio>
{#if isComponentDisabled}
<EmptyCardImageCloud source="email_signature_card" noAspectRatio>
<svelte:fragment slot="image">
<div class=" is-only-mobile u-width-full-line u-height-100-percent">
{#if $app.themeInUse === 'dark'}
@@ -114,22 +131,35 @@
{/if}
</div>
</svelte:fragment>
<svelte:fragment slot="title"
>Upgrade to add mock phone numbers</svelte:fragment>
Upgrade to a {nextTier} to add mock phone numbers to your project.
<svelte:fragment slot="title">{emptyStateTitle}</svelte:fragment>
{emptyStateDescription}
<svelte:fragment let:source slot="cta">
<Button
class="u-margin-block-start-32"
secondary
fullWidth
href="https://cloud.appwrite.io/register"
external
on:click={() => {
trackEvent('click_cloud_signup', {
from: 'button',
source
});
}}>{cta}</Button>
</svelte:fragment>
</EmptyCardImageCloud>
{:else if numbers?.length > 0}
<ul class="form-list">
<ul class="form-list u-gap-8">
{#each numbers as number, index}
<FormItem isMultiple>
<InputPhone
id={`key-${index}`}
bind:value={number.phone}
fullWidth
placeholder="Enter Phone Number"
label="Phone Number"
placeholder="Enter phone number"
label="Phone number"
showLabel={index === 0}
minlength={8}
minlength={9}
maxlength={16}
required>
<button
@@ -147,10 +177,10 @@
bind:value={number.otp}
fullWidth
placeholder="Enter value"
label="Verification Code"
label="Verification code"
maxlength={6}
pattern={'^[0-9]{6}$'}
patternError="Value must be a 6 digit number"
patternError="The value must contain 6 digits"
showLabel={index === 0}
required>
<button
@@ -163,18 +193,18 @@
<span class="icon-refresh" aria-hidden="true"></span>
</button>
</InputOTP>
<div class="u-margin-block-start-24">
<FormItemPart>
<Button
text
disabled={numbers.length === 0}
on:click={() => {
deletePhoneNumber(index);
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</FormItemPart>
</div>
<FormItemPart>
<Button
text
disabled={numbers.length === 0}
class={'u-padding-4 ' +
(index === 0 ? 'u-margin-block-start-24' : '')}
on:click={() => {
deletePhoneNumber(index);
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</FormItemPart>
</FormItem>
{/each}
</ul>
@@ -204,7 +234,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={submitDisabled} submit>Update</Button>
<Button disabled={isSubmitDisabled} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -44,7 +44,7 @@
<form class="form u-grid u-gap-16">
<ul class="form-list is-multiple">
<InputNumber id="length" label="Length" bind:value={$value} min={0} />
<InputSelect id="period" label="Time Period" bind:value={$unit} {options} />
<InputSelect id="period" label="Time period" bind:value={$unit} {options} />
</ul>
</form>
</svelte:fragment>
@@ -1,6 +1,9 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { CardGrid, EmptyCardImageCloud, Heading } from '$lib/components';
import Button from '$lib/elements/forms/button.svelte';
import { app } from '$lib/stores/app';
import { upgradeURL } from '$lib/stores/billing';
import EmailDark from './email-footer-dark.png';
import EmailLight from './email-footer-light.png';
import EmailMobileDark from './email-footer-mobile-dark.png';
@@ -49,6 +52,20 @@
</svelte:fragment>
<svelte:fragment slot="title">Upgrade to edit email signature</svelte:fragment>
Upgrade to a {nextTier} plan to enable or disable Appwrite branding in your emails.
<svelte:fragment let:source slot="cta">
<Button
class="u-margin-block-start-32"
secondary
fullWidth
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
source
});
}}>Upgrade plan</Button>
</svelte:fragment>
</EmptyCardImageCloud>
</svelte:fragment>
</CardGrid>