Skip to content

Commit 8056520

Browse files
authored
Merge pull request #2700 from appwrite/sync-main-studio
2 parents a719625 + 44fc77e commit 8056520

29 files changed

Lines changed: 473 additions & 293 deletions

File tree

src/lib/components/billing/planSelection.svelte

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
import { BillingPlan } from '$lib/constants';
33
import { formatCurrency } from '$lib/helpers/numbers';
44
import { currentPlan, organization } from '$lib/stores/organization';
5-
import { Badge, Layout, Typography } from '@appwrite.io/pink-svelte';
5+
import { Badge, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte';
66
import { LabelCard } from '..';
77
import type { Plan } from '$lib/sdk/billing';
88
import { page } from '$app/state';
99
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
1010
import { InputSelect } from '$lib/elements/forms';
11+
import { isFreePlan, isPaidPlan } from '$lib/helpers/billing';
1112
1213
export let disabled = false;
1314
export let isNewOrg = false;
@@ -113,52 +114,63 @@
113114
function handleTierChange(group: PlanGroup) {
114115
billingPlan = selectedTiers[group.key] as BillingPlan;
115116
}
117+
118+
function shouldShowTooltip(plan: Plan) {
119+
if (isPaidPlan(plan.$id)) return true;
120+
else return !anyOrgFree;
121+
}
116122
</script>
117123

118124
<Layout.Stack>
119125
{#each groupedPlans as group (group.key)}
120126
{@const basePlan = group.plans[0]}
121-
<LabelCard
122-
name="plan"
123-
bind:group={billingPlan}
124-
disabled={!selfService || (basePlan.$id === BillingPlan.FREE && anyOrgFree) || disabled}
125-
tooltipShow={basePlan.$id === BillingPlan.FREE && anyOrgFree}
126-
value={group.isGrouped ? selectedTiers[group.key] || basePlan.$id : basePlan.$id}
127-
title={basePlan.name}>
128-
<svelte:fragment slot="action">
129-
{#if group.plans.some((plan) => $organization?.billingPlan === plan.$id) && !isNewOrg}
130-
<Badge variant="secondary" size="xs" content="Current plan" />
131-
{/if}
132-
</svelte:fragment>
133-
134-
<Layout.Stack direction="column" gap="m">
135-
<Layout.Stack direction="column" gap="xxs">
136-
<Typography.Caption variant="400">
137-
{basePlan.desc}
138-
</Typography.Caption>
139-
140-
{#if !group.isGrouped}
141-
<Typography.Text>
142-
{@const isZeroPrice = (basePlan.price ?? 0) <= 0}
143-
{@const price = formatCurrency(basePlan.price ?? 0)}
144-
{#if resolvedProfile.id === ProfileMode.STUDIO}
145-
{getPlanLabel(basePlan)}
146-
{:else}
147-
{isZeroPrice ? price : getPlanLabel(basePlan)}
148-
{/if}
149-
</Typography.Text>
127+
<Tooltip disabled={shouldShowTooltip(basePlan)} maxWidth="fit-content">
128+
<LabelCard
129+
name="plan"
130+
bind:group={billingPlan}
131+
disabled={!selfService || (isFreePlan(basePlan.$id) && anyOrgFree) || disabled}
132+
tooltipShow={isFreePlan(basePlan.$id) && anyOrgFree}
133+
value={group.isGrouped ? selectedTiers[group.key] || basePlan.$id : basePlan.$id}
134+
title={basePlan.name}>
135+
<svelte:fragment slot="action">
136+
{#if group.plans.some((plan) => $organization?.billingPlan === plan.$id) && !isNewOrg}
137+
<Badge variant="secondary" size="xs" content="Current plan" />
138+
{/if}
139+
</svelte:fragment>
140+
141+
<Layout.Stack direction="column" gap="m">
142+
<Layout.Stack direction="column" gap="xxs">
143+
<Typography.Caption variant="400">
144+
{basePlan.desc}
145+
</Typography.Caption>
146+
147+
{#if !group.isGrouped}
148+
<Typography.Text>
149+
{@const isZeroPrice = (basePlan.price ?? 0) <= 0}
150+
{@const price = formatCurrency(basePlan.price ?? 0)}
151+
{#if resolvedProfile.id === ProfileMode.STUDIO}
152+
{getPlanLabel(basePlan)}
153+
{:else}
154+
{isZeroPrice ? price : getPlanLabel(basePlan)}
155+
{/if}
156+
</Typography.Text>
157+
{/if}
158+
</Layout.Stack>
159+
160+
{#if group.isGrouped}
161+
<InputSelect
162+
id="tier-{group.key}"
163+
bind:value={selectedTiers[group.key]}
164+
on:change={() => handleTierChange(group)}
165+
options={group.tierOptions} />
150166
{/if}
151167
</Layout.Stack>
168+
</LabelCard>
152169

153-
{#if group.isGrouped}
154-
<InputSelect
155-
id="tier-{group.key}"
156-
bind:value={selectedTiers[group.key]}
157-
on:change={() => handleTierChange(group)}
158-
options={group.tierOptions} />
159-
{/if}
160-
</Layout.Stack>
161-
</LabelCard>
170+
<svelte:fragment slot="tooltip">
171+
Only 1 free organization is allowed per account.
172+
</svelte:fragment>
173+
</Tooltip>
162174
{/each}
163175

164176
{#if $currentPlan && !currentPlanInList}

src/lib/components/filePicker.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import { IconInfo, IconPlus, IconViewGrid, IconViewList } from '@appwrite.io/pink-icons-svelte';
3434
import { showCreateBucket } from '$routes/(console)/project-[region]-[project]/storage/+page.svelte';
3535
import { preferences } from '$lib/stores/preferences';
36+
import { addNotification } from '$lib/stores/notifications';
3637
3738
export let show: boolean;
3839
export let mimeTypeQuery: string = 'image/';
@@ -110,7 +111,10 @@
110111
}
111112
selectFile(file);
112113
} catch (e) {
113-
console.error(e);
114+
addNotification({
115+
type: 'error',
116+
message: e.message
117+
});
114118
} finally {
115119
uploading = false;
116120
}
@@ -351,7 +355,9 @@
351355
<Layout.Stack gap="l">
352356
<Typography.Title size="s" color="--fgcolor-neutral-primary"
353357
>{localFileBucketTitle}</Typography.Title>
354-
<Upload.Dropzone bind:files={localFile} extensions={[allowedExtension]}>
358+
<Upload.Dropzone
359+
bind:files={localFile}
360+
extensions={allowedExtension === '*' ? undefined : [allowedExtension]}>
355361
<Layout.Stack alignItems="center" gap="s">
356362
<Layout.Stack alignItems="center" gap="s">
357363
<Layout.Stack
@@ -370,7 +376,9 @@
370376
<Icon icon={IconInfo} size="s" />
371377
</Layout.Stack>
372378
<svelte:fragment slot="tooltip"
373-
>{allowedExtension} files are allowed</svelte:fragment>
379+
>{allowedExtension === '*'
380+
? `${mimeTypeQuery} files are allowed`
381+
: `${allowedExtension} files are allowed`}</svelte:fragment>
374382
</Tooltip>
375383
</Layout.Stack>
376384
<Typography.Caption variant="400"

src/lib/components/filters/content.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import type { Column } from '$lib/helpers/types';
1515
import type { Writable } from 'svelte/store';
1616
import { TagList } from '.';
17+
import { toLocalDateTimeISO } from '$lib/helpers/date';
1718
import { Icon, Layout } from '@appwrite.io/pink-svelte';
1819
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
1920
@@ -79,7 +80,7 @@
7980
value = column?.array ? [] : null;
8081
if (column?.type === 'datetime') {
8182
const now = new Date();
82-
value = now.toISOString().slice(0, 16);
83+
value = toLocalDateTimeISO(now.toISOString()).slice(0, 16);
8384
}
8485
// Initialize spatial data with default values
8586
if (column?.type === 'point') {
@@ -108,7 +109,11 @@
108109
if (isDistanceOperator && distanceValue !== null && value !== null) {
109110
addFilter(columnsArray, columnId, operatorKey, value, arrayValues, distanceValue);
110111
} else {
111-
addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
112+
const preparedValue =
113+
column?.type === 'datetime' && typeof value === 'string' && value
114+
? new Date(value).toISOString()
115+
: value;
116+
addFilter(columnsArray, columnId, operatorKey, preparedValue, arrayValues);
112117
}
113118
114119
columnId = null;

src/lib/components/filters/filtersModal.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@
5757
}
5858
5959
function addCondition() {
60-
const newTag = generateTag(selectedColumn, operatorKey, value || arrayValues);
60+
const preparedValue =
61+
column?.type === 'datetime' && typeof value === 'string' && value
62+
? new Date(value).toISOString()
63+
: value;
64+
const newTag = generateTag(selectedColumn, operatorKey, preparedValue || arrayValues);
6165
if (localTags.some((t) => t.tag === newTag.tag && t.value === newTag.value)) {
6266
return;
6367
} else {
@@ -66,7 +70,7 @@
6670
{
6771
id: selectedColumn,
6872
operator: operatorKey,
69-
value: value,
73+
value: preparedValue,
7074
arrayValues: arrayValues
7175
}
7276
];

0 commit comments

Comments
 (0)