Skip to content

Commit

Permalink
Merge branch 'main' into feat-prop-1297-login-for-github-education-pr…
Browse files Browse the repository at this point in the history
…ogram

# Conflicts:
#	src/routes/(console)/organization-[organization]/billing/planSummary.svelte
  • Loading branch information
ernstmul committed Nov 4, 2024
2 parents eca8420 + 3d1cc2e commit e14a0a3
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 55 deletions.
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config: PlaywrightTestConfig = {
timeout: 120000,
reportSlowTests: null,
reporter: [['html', { open: 'never' }]],
retries: 1,
retries: 3,
use: {
baseURL: 'http://localhost:4173/console/',
trace: 'on-first-retry'
Expand Down
19 changes: 15 additions & 4 deletions src/lib/components/billing/estimatedTotalBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,28 @@
{/if}
<div class="u-sep-block-start" />
<span class="u-flex u-main-space-between">
<p class="text">Estimated total</p>
<p class="text">
Upcoming charge<br /><span class="u-color-text-gray"
>Due on {!currentPlan.trialDays
? toLocaleDate(billingPayDate.toString())
: toLocaleDate(trialEndDate.toString())}</span>
</p>
<p class="text">
{formatCurrency(estimatedTotal)}
</p>
</span>

<p class="text u-margin-block-start-16">
Your payment method will be charged this amount plus usage fees every 30 days {!currentPlan.trialDays
? `starting ${toLocaleDate(billingPayDate.toString())}`
: ` after your trial period ends on ${toLocaleDate(trialEndDate.toString())}`}.
You'll pay <span class="u-bold">{formatCurrency(estimatedTotal)}</span> now, with our first
billing cycle starting on
<span class="u-bold"
>{!currentPlan.trialDays
? toLocaleDate(billingPayDate.toString())
: toLocaleDate(trialEndDate.toString())}</span
>. Once your credits run out, you'll be charged
<span class="u-bold">{formatCurrency(currentPlan.price)}</span> plus usage fees every 30 days.
</p>

<FormList class="u-margin-block-start-24">
<InputChoice
type="switchbox"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/elements/forms/inputId.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let element: HTMLInputElement;
let icon = 'info';
const pattern = String.raw`^[a-zA-Z0-9][a-zA-Z0-9\-]*$`;
const pattern = String.raw`^[a-zA-Z0-9][a-zA-Z0-9._\-]*$`;
onMount(() => {
if (element && autofocus) {
Expand Down Expand Up @@ -55,6 +55,6 @@
class="u-cross-center u-line-height-1 u-color-text-gray"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric and non-leading hyphen
Allowed characters: alphanumeric, non-leading hyphen, underscore, period
</span>
</div>
7 changes: 6 additions & 1 deletion src/lib/helpers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ export type NotificationCoolOffOptions = {
exponentialBackoffFactor?: number;
};

const userPreferences = () => get(user).prefs;
const userPreferences = () => get(user)?.prefs;

const notificationPrefs = (): Record<string, NotificationPrefItem> => {
const prefs = userPreferences();

if (prefs === null) {
return {};
}

// for some reason, the prefs become array as default or on all clear. let's reset.
return Array.isArray(prefs.notificationPrefs) ? {} : prefs.notificationPrefs || {};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
Query.limit(limit),
Query.offset(offset),
Query.notEqual('from', $organization.billingCurrentInvoiceDate),
Query.notEqual('status', 'pending'),
Query.orderDesc('$createdAt')
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
availableCredit = creditList.available;
});
$: extraUsage = (currentInvoice?.amount ?? 0) - (currentPlan?.price ?? 0);
$: extraUsage = currentInvoice && currentPlan ? currentInvoice.amount - currentPlan.price : 0;
$: extraAddons = currentInvoice?.usage?.length ?? 0;
$: isTrial =
new Date($organization?.billingStartDate).getTime() - today.getTime() > 0 &&
Expand Down Expand Up @@ -66,7 +66,9 @@
<div class="body-text-2 u-margin-inline-start-auto">
{isTrial || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION
? formatCurrency(0)
: formatCurrency(currentPlan?.price)}
: currentPlan
? formatCurrency(currentPlan?.price)
: ''}
</div>
</CollapsibleItem>
{#if $organization?.billingPlan !== BillingPlan.FREE && $organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION && extraUsage > 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
})
});
await goto(`${base}/organization-${$organization.$id}`);
await goto(previousPage);
addNotification({
type: 'success',
isHtml: true,
Expand Down Expand Up @@ -217,7 +217,7 @@
await invalidate(Dependencies.ACCOUNT);
await invalidate(Dependencies.ORGANIZATION);
await goto(`${base}/organization-${org.$id}`);
await goto(previousPage);
addNotification({
type: 'success',
message: 'Your organization has been upgraded'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { members, organization, organizationList } from '$lib/stores/organization';
import { goto, invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { Dependencies } from '$lib/constants';
import { BillingPlan, Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { projects } from '../store';
import { toLocaleDate } from '$lib/helpers/date';
Expand Down Expand Up @@ -55,7 +55,10 @@
showDelete = false;
addNotification({
type: 'success',
message: `${$organization.name} has been flagged for deletion`
message:
$organization.billingPlan === BillingPlan.FREE
? `${$organization.name} has been deleted`
: `${$organization.name} has been flagged for deletion`
});
} catch (e) {
error = e.message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<CustomId
bind:show={showCustomId}
name="Project"
isProject={true}
bind:id={$createProject.id}
fullWidth />
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
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"
href="https://appwrite.io/docs/products/auth/security#mock-phone-numbers"
target="_blank"
class="u-underline"
rel="noopener noreferrer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export const load: LayoutLoad = async ({ params, depends }) => {
try {
const [collection, allCollections] = await Promise.all([
sdk.forProject.databases.getCollection(params.database, params.collection),
sdk.forProject.databases.listCollections(params.database, [Query.orderDesc('')])
sdk.forProject.databases.listCollections(params.database, [
Query.orderDesc(''),
Query.limit(100)
])
]);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@
$: handleDefaultState($required || $array);
</script>

<InputNumber id="size" label="Size" placeholder="Enter size" bind:value={data.size} />
<InputNumber
id="size"
label="Size"
placeholder="Enter size"
bind:value={data.size}
required={true} />
{#if data.size >= 50}
<InputTextarea
id="default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import { goto, invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { page } from '$app/stores';
import { addNotification, dismissAllNotifications } from '$lib/stores/notifications';
import { addNotification } from '$lib/stores/notifications';
import { base } from '$app/paths';
import type { Attributes } from './store';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { preferences } from '$lib/stores/preferences';
import { feedback } from '$lib/stores/feedback';
export let showCreate = false;
export let selectedOption: Option['name'] = null;
Expand Down Expand Up @@ -42,37 +41,6 @@
type: 'success',
message: `Attribute ${key ?? data?.key} has been created`
});
if ($option.type === 'relationship') {
let counter = localStorage.getItem('createRelationshipCounter');
if (counter) {
const parsedCounter = parseInt(counter);
if (parsedCounter === 2) {
addNotification({
type: 'info',
icon: 'question-mark-circle',
message: `How is your experience with our new "Relationships" feature? We'd love to hear your feedback!`,
timeout: 15000,
buttons: [
{
name: 'Give Feedback',
method: () => {
feedback.toggleFeedback();
dismissAllNotifications();
}
}
]
});
} else if (parsedCounter < 2) {
localStorage.setItem(
'createRelationshipCounter',
(parsedCounter + 1).toString()
);
}
} else {
localStorage.setItem('createRelationshipCounter', '1');
}
}
showCreate = false;
trackEvent(Submit.AttributeCreate);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@
</span></Pill>
</div>
{:else}
<CustomId bind:show={showCustomId} name="Collection" bind:id autofocus={false} />
<CustomId
bind:show={showCustomId}
name="Collection"
bind:id
autofocus={false}
fullWidth={true} />
{/if}
</FormList>
<svelte:fragment slot="footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export async function load({ depends }) {
const { migrations } = await sdk.forProject.migrations.list([
// hides backups/restorations from migrations page.
Query.equal('source', ['Appwrite', 'Firebase', 'NHost', 'Supabase']),
Query.equal('destination', ['Appwrite', 'Firebase', 'NHost', 'Supabase'])
Query.or([
Query.equal('destination', ['Appwrite', 'Firebase', 'NHost', 'Supabase']),
Query.isNull('destination')
])
]);

return {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/journeys/upgrade-free-tier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ test('upgrade - free tier', async ({ page }) => {
await enterCreditCard(page);
// skip members
await page.getByRole('button', { name: 'change plan' }).click();
await page.waitForURL('./organization-**');
await page.waitForURL('**/console/project-*/overview/platforms');
});
});
4 changes: 2 additions & 2 deletions tests/unit/elements/inputId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { render } from '@testing-library/svelte';
import userEvent from '@testing-library/user-event';
import { InputId } from '../../../src/lib/elements/forms';

const validStrings = ['valid-string', 'validstring', 'validstring123', 'valid-'];
const validStrings = ['valid_string', 'valid-string', 'valid.string', 'validstring123', 'valid_'];

const invalidStrings = ['-invalid', '.invalid', 'in_valid', 'in.va.lid'];
const invalidStrings = ['-invalid', '.invalid', '_invalid'];

test('shows id input', () => {
const { getByPlaceholderText } = render(InputId);
Expand Down

0 comments on commit e14a0a3

Please sign in to comment.