From 8d2c47915a2d60142d066eb1d789c424d04ccdaa Mon Sep 17 00:00:00 2001
From: DarShan Pandya
Date: Thu, 7 Mar 2024 04:48:00 -0500
Subject: [PATCH 01/23] Add methods for local time and timezone shorthand.
---
src/lib/helpers/date.ts | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts
index c8aaf0fc8..dcbeb7844 100644
--- a/src/lib/helpers/date.ts
+++ b/src/lib/helpers/date.ts
@@ -1,8 +1,10 @@
import { browser } from '$app/environment';
import dayjs from 'dayjs';
+import utc from 'dayjs/plugin/utc';
import relativeTime from 'dayjs/plugin/relativeTime';
if (browser) {
+ dayjs.extend(utc);
dayjs.extend(relativeTime);
}
@@ -41,6 +43,21 @@ export const toLocaleDateTime = (datetime: string | number) => {
return date.toLocaleDateString('en', options);
};
+export const utcHourToLocaleHour = (utcTimeString: string) => {
+ // we can use a default utc date format.
+ const utcDefaultDate = dayjs.utc(`1970-01-01T${utcTimeString}:00`);
+ return utcDefaultDate.local().format('HH:mm');
+};
+
+export const localeTimezoneShortHand = () => {
+ const options: Intl.DateTimeFormatOptions = {
+ timeZoneName: 'long'
+ };
+
+ const dateWithTimezone = new Intl.DateTimeFormat('en', options).format(new Date());
+ return dateWithTimezone.match(/\b([A-Z])/g).join('');
+};
+
export const isSameDay = (date1: Date, date2: Date) => {
return (
date1.getFullYear() === date2.getFullYear() &&
From 8eeb8794a6bfd0c76b2c22d96f31215be39290b6 Mon Sep 17 00:00:00 2001
From: DarShan Pandya
Date: Thu, 7 Mar 2024 04:51:47 -0500
Subject: [PATCH 02/23] Add support timings to support component and wizard.
---
src/lib/components/support.svelte | 5 ++++-
src/routes/console/supportWizard.svelte | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte
index fa36429ff..1e94163a9 100644
--- a/src/lib/components/support.svelte
+++ b/src/lib/components/support.svelte
@@ -13,12 +13,15 @@
import { BillingPlan } from '$lib/constants';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { trackEvent } from '$lib/actions/analytics';
+ import { localeTimezoneShortHand, utcHourToLocaleHour } from '$lib/helpers/date';
export let show = false;
$: isPaid =
$organization?.billingPlan === BillingPlan.PRO ||
$organization?.billingPlan === BillingPlan.SCALE;
+
+ $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneShortHand()}`;
{#if isCloud}
@@ -40,7 +43,7 @@
Premium support
{#if isPaid}
- Get personalized support from the Appwrite team from 09:00 - 17:00 UTC
+ Get personalized support from the Appwrite team from {supportTimings}
{/if}
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte
index a4e28d4c1..f576fc689 100644
--- a/src/routes/console/supportWizard.svelte
+++ b/src/routes/console/supportWizard.svelte
@@ -10,6 +10,7 @@
import { wizard } from '$lib/stores/wizard';
import { VARS } from '$lib/system';
import { organization } from '$lib/stores/organization';
+ import { localeTimezoneShortHand, utcHourToLocaleHour } from '$lib/helpers/date';
onDestroy(() => {
$supportData = {
@@ -76,6 +77,8 @@
}
$wizard.finalAction = handleSubmit;
+
+ $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneShortHand()}`;
@@ -85,7 +88,7 @@
If you found a bug or have questions, please reach out to the Appwrite team. We try to
respond to all messages within our office hours.
-
Available: Mon-Fri 09:00 - 17:00 UTC
+
Available: Mon-Fri, {supportTimings}
Currently:
{#if isSupportOnline()}
From 887b820eb088174a1c25321b40a7f7eb39d4d47b Mon Sep 17 00:00:00 2001
From: DarShan Pandya
Date: Fri, 8 Mar 2024 10:50:25 +0530
Subject: [PATCH 03/23] replace dayjs implementation with builtin
`DateTimeFormat`.
---
src/lib/helpers/date.ts | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts
index dcbeb7844..544863fd9 100644
--- a/src/lib/helpers/date.ts
+++ b/src/lib/helpers/date.ts
@@ -1,10 +1,8 @@
import { browser } from '$app/environment';
import dayjs from 'dayjs';
-import utc from 'dayjs/plugin/utc';
import relativeTime from 'dayjs/plugin/relativeTime';
if (browser) {
- dayjs.extend(utc);
dayjs.extend(relativeTime);
}
@@ -44,9 +42,15 @@ export const toLocaleDateTime = (datetime: string | number) => {
};
export const utcHourToLocaleHour = (utcTimeString: string) => {
- // we can use a default utc date format.
- const utcDefaultDate = dayjs.utc(`1970-01-01T${utcTimeString}:00`);
- return utcDefaultDate.local().format('HH:mm');
+ const defaultDate = new Date(`1970-01-01T${utcTimeString}:00Z`);
+
+ const options: Intl.DateTimeFormatOptions = {
+ hour: 'numeric',
+ minute: 'numeric',
+ hourCycle: 'h23'
+ };
+
+ return new Intl.DateTimeFormat('en', options).format(defaultDate);
};
export const localeTimezoneShortHand = () => {
From 41421c41fac96a716a27eb5b6f2ae834f5972cf6 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 8 Mar 2024 20:16:14 +1100
Subject: [PATCH 04/23] Use current date instead of default.
---
src/lib/helpers/date.ts | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts
index 544863fd9..c85c7ad87 100644
--- a/src/lib/helpers/date.ts
+++ b/src/lib/helpers/date.ts
@@ -42,7 +42,9 @@ export const toLocaleDateTime = (datetime: string | number) => {
};
export const utcHourToLocaleHour = (utcTimeString: string) => {
- const defaultDate = new Date(`1970-01-01T${utcTimeString}:00Z`);
+ const now = new Date();
+ const [hours, minutes] = utcTimeString.split(':').map(Number);
+ const currentDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes));
const options: Intl.DateTimeFormatOptions = {
hour: 'numeric',
@@ -50,7 +52,7 @@ export const utcHourToLocaleHour = (utcTimeString: string) => {
hourCycle: 'h23'
};
- return new Intl.DateTimeFormat('en', options).format(defaultDate);
+ return new Intl.DateTimeFormat('en', options).format(currentDate);
};
export const localeTimezoneShortHand = () => {
From d6ae9671b66894592482a8bbc611e527369d2281 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 8 Mar 2024 19:29:47 +1000
Subject: [PATCH 05/23] Add a method to convert UTC weekday to local weekday.
---
src/lib/helpers/date.ts | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts
index c85c7ad87..c87f9fb81 100644
--- a/src/lib/helpers/date.ts
+++ b/src/lib/helpers/date.ts
@@ -55,6 +55,25 @@ export const utcHourToLocaleHour = (utcTimeString: string) => {
return new Intl.DateTimeFormat('en', options).format(currentDate);
};
+export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string) => {
+ const now = new Date();
+
+ // easy mapping instead of passing numbers.
+ const dayMap = {
+ 'Sunday': 0, 'Monday': 1, 'Tuesday': 2,
+ 'Wednesday': 3, 'Thursday': 4, 'Friday': 5, 'Saturday': 6
+ };
+
+ const utcDayNumber = dayMap[utcDay];
+ const [hours, minutes] = utcTimeString.split(':').map(Number);
+
+ const daysUntilNextUtcDay = (7 + utcDayNumber - now.getUTCDay()) % 7;
+ now.setUTCDate(now.getUTCDate() + daysUntilNextUtcDay);
+ now.setUTCHours(hours, minutes, 0, 0);
+
+ return new Intl.DateTimeFormat('en', { weekday: 'short' }).format(now);
+};
+
export const localeTimezoneShortHand = () => {
const options: Intl.DateTimeFormatOptions = {
timeZoneName: 'long'
From 119d382b7966df2fc4e2ce6d52be5ec01d388ad1 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 8 Mar 2024 15:03:14 +0530
Subject: [PATCH 06/23] Update the support wizard to display local weekday.
---
src/routes/console/supportWizard.svelte | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte
index f576fc689..1beced944 100644
--- a/src/routes/console/supportWizard.svelte
+++ b/src/routes/console/supportWizard.svelte
@@ -10,7 +10,7 @@
import { wizard } from '$lib/stores/wizard';
import { VARS } from '$lib/system';
import { organization } from '$lib/stores/organization';
- import { localeTimezoneShortHand, utcHourToLocaleHour } from '$lib/helpers/date';
+ import { localeTimezoneShortHand, utcHourToLocaleHour, utcWeekDayToLocaleWeekDay } from '$lib/helpers/date';
onDestroy(() => {
$supportData = {
@@ -78,7 +78,9 @@
$wizard.finalAction = handleSubmit;
- $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneShortHand()}`;
+ const workTimings = { start: '09:00', end: '17:00', startDay: 'Monday', endDay: 'Friday' };
+ $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneShortHand()}`;
+ $: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`;
@@ -88,7 +90,7 @@
If you found a bug or have questions, please reach out to the Appwrite team. We try to
respond to all messages within our office hours.
-
Available: Mon-Fri, {supportTimings}
+
Available: {supportWeekDays}, {supportTimings}
Currently:
{#if isSupportOnline()}
From dc2672a4924afca31581adf8af92352fd3625832 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 8 Mar 2024 19:48:12 +1000
Subject: [PATCH 07/23] Fix format for build, misc.
---
src/lib/helpers/date.ts | 13 +++++++++----
src/routes/console/supportWizard.svelte | 10 ++++++++--
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts
index c87f9fb81..9102d5a3c 100644
--- a/src/lib/helpers/date.ts
+++ b/src/lib/helpers/date.ts
@@ -44,7 +44,7 @@ export const toLocaleDateTime = (datetime: string | number) => {
export const utcHourToLocaleHour = (utcTimeString: string) => {
const now = new Date();
const [hours, minutes] = utcTimeString.split(':').map(Number);
- const currentDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes));
+ const customTime = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes);
const options: Intl.DateTimeFormatOptions = {
hour: 'numeric',
@@ -52,7 +52,7 @@ export const utcHourToLocaleHour = (utcTimeString: string) => {
hourCycle: 'h23'
};
- return new Intl.DateTimeFormat('en', options).format(currentDate);
+ return new Intl.DateTimeFormat('en', options).format(new Date(customTime));
};
export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string) => {
@@ -60,8 +60,13 @@ export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string)
// easy mapping instead of passing numbers.
const dayMap = {
- 'Sunday': 0, 'Monday': 1, 'Tuesday': 2,
- 'Wednesday': 3, 'Thursday': 4, 'Friday': 5, 'Saturday': 6
+ Sunday: 0,
+ Monday: 1,
+ Tuesday: 2,
+ Wednesday: 3,
+ Thursday: 4,
+ Friday: 5,
+ Saturday: 6
};
const utcDayNumber = dayMap[utcDay];
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte
index 1beced944..ebcac1157 100644
--- a/src/routes/console/supportWizard.svelte
+++ b/src/routes/console/supportWizard.svelte
@@ -10,7 +10,11 @@
import { wizard } from '$lib/stores/wizard';
import { VARS } from '$lib/system';
import { organization } from '$lib/stores/organization';
- import { localeTimezoneShortHand, utcHourToLocaleHour, utcWeekDayToLocaleWeekDay } from '$lib/helpers/date';
+ import {
+ localeTimezoneShortHand,
+ utcHourToLocaleHour,
+ utcWeekDayToLocaleWeekDay
+ } from '$lib/helpers/date';
onDestroy(() => {
$supportData = {
@@ -90,7 +94,9 @@
If you found a bug or have questions, please reach out to the Appwrite team. We try to
respond to all messages within our office hours.
-
Get personalized support from the Appwrite team from {supportTimings}
-
{/if}
From d5197f7ee72bab37e54453a4d278fbd82449ddf3 Mon Sep 17 00:00:00 2001
From: ItzNotABug
Date: Wed, 10 Apr 2024 11:42:01 +0530
Subject: [PATCH 17/23] update: show the timezone with support timings.
---
src/routes/console/supportWizard.svelte | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte
index 0e7fb7d25..877b5a716 100644
--- a/src/routes/console/supportWizard.svelte
+++ b/src/routes/console/supportWizard.svelte
@@ -3,7 +3,6 @@
import { onDestroy } from 'svelte';
import { isSupportOnline, supportData } from './wizard/support/store';
import Step1 from './wizard/support/step1.svelte';
- import Label from '$lib/elements/forms/label.svelte';
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
import { user } from '$lib/stores/user';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
@@ -91,7 +90,7 @@
endDay: 'Friday' as WeekDay
};
- $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)}`;
+ $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneName()}`;
$: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`;
@@ -104,7 +103,6 @@
Available: {supportWeekDays}, {supportTimings}
-
Currently:
From 7049f663a2e12b8ef9ca64c303635a4acca6c210 Mon Sep 17 00:00:00 2001
From: Steven Nguyen
Date: Mon, 29 Apr 2024 14:38:45 -0700
Subject: [PATCH 18/23] fix(migrations): fix modal not closing
We should be using a bound show variable to control the modal. Prior to
this PR, we were indirectly controlling the modal by setting the
migration ID via the on close handler, but that event is never triggered
when the modal is closed.
This also refactors the modal to pass in the migration instead of a
list of migrations and a migration ID because the entire list is not
needed inside the modal.
---
.../settings/migrations/+page.svelte | 13 +++++++++---
.../settings/migrations/details.svelte | 20 ++++++++-----------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/routes/console/project-[project]/settings/migrations/+page.svelte b/src/routes/console/project-[project]/settings/migrations/+page.svelte
index 2a7877a02..8d5657b18 100644
--- a/src/routes/console/project-[project]/settings/migrations/+page.svelte
+++ b/src/routes/console/project-[project]/settings/migrations/+page.svelte
@@ -24,10 +24,12 @@
import Status from '$lib/components/status.svelte';
import { capitalize } from '$lib/helpers/string';
import { readOnly } from '$lib/stores/billing';
+ import type { Models } from '@appwrite.io/console';
export let data;
- let details: string | null = null;
+ let migration: Models.Migration = null;
let showExport = false;
+ let showMigration = false;
const getStatus = (status: string) => {
if (status === 'failed') {
@@ -129,6 +131,11 @@
// JSON.stringify(migrationData)
// )}`;
};
+
+ function showDetails(m: Models.Migration) {
+ showMigration = true;
+ migration = m;
+ }
@@ -182,7 +189,7 @@