From 7634062a85aaf4125a4318a65c3f0a8cf7ac7140 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Tue, 14 Nov 2023 20:42:17 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Error=20object=20not=20compa?= =?UTF-8?q?tible=20with=20json=20parsing=20of=20gssp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Onboarding/database-not-writeable.tsx | 14 +++++++---- src/pages/onboard.tsx | 24 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/components/Onboarding/database-not-writeable.tsx b/src/components/Onboarding/database-not-writeable.tsx index ac1e92527..b2d313a9d 100644 --- a/src/components/Onboarding/database-not-writeable.tsx +++ b/src/components/Onboarding/database-not-writeable.tsx @@ -1,7 +1,13 @@ import { Center, Code, List, Stack, Text, Title } from '@mantine/core'; import Head from 'next/head'; -export const DatabaseNotWriteable = ({ error, errorMessage }: { error: any | unknown, errorMessage: string | undefined }) => { +export const DatabaseNotWriteable = ({ + stringifiedError, + errorMessage, +}: { + stringifiedError: string | undefined; + errorMessage: string | undefined; +}) => { return ( <> @@ -30,11 +36,9 @@ export const DatabaseNotWriteable = ({ error, errorMessage }: { error: any | unk - {error && JSON.stringify(error)} + {stringifiedError} - {errorMessage && ( - {errorMessage} - )} + {errorMessage && {errorMessage}} diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index ab7b4b55d..bad0f1f23 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -21,8 +21,8 @@ const exec = util.promisify(require('child_process').exec); export default function OnboardPage({ configSchemaVersions, databaseNotWriteable, - error, - errorMessage + stringifiedError, + errorMessage, }: InferGetServerSidePropsType) { const { fn, colors, colorScheme } = useMantineTheme(); const background = colorScheme === 'dark' ? 'dark.6' : 'gray.1'; @@ -49,7 +49,7 @@ export default function OnboardPage({ {databaseNotWriteable == true ? ( - + ) : ( <> {onboardingSteps ? ( @@ -117,7 +117,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { ...translations, configSchemaVersions: configSchemaVersions, databaseNotWriteable: true, - error: error, + errorMessage: 'Database is not writeable', + stringifiedError: JSON.stringify(error), }, }; } @@ -128,13 +129,18 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const { stdout, stderr } = await exec("mount | grep '/data'"); if (stderr.split('\n').length > 1 || stdout.split('\n').length <= 1) { - Consola.error(`Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace('\n', '\\n')} ${stderr.replace('\n', '\\n')}`); + Consola.error( + `Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace( + '\n', + '\\n' + )} ${stderr.replace('\n', '\\n')}` + ); return { props: { ...translations, configSchemaVersions: configSchemaVersions, databaseNotWriteable: true, - error: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`, + errorMessage: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`, }, }; } @@ -146,8 +152,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { ...translations, configSchemaVersions: configSchemaVersions, databaseNotWriteable: true, - error: error, - errorMessage: errorMessage + stringifiedError: JSON.stringify(error), + errorMessage: errorMessage, }, }; } @@ -160,7 +166,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { props: { ...translations, configSchemaVersions: configSchemaVersions, - databaseNotWriteable: false + databaseNotWriteable: false, }, }; }; From 6484ed59766dacfa175a76f9a7f17d8df1fe60cf Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 14 Nov 2023 21:10:04 +0100 Subject: [PATCH 2/3] add `country` again --- src/tools/language.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/tools/language.ts b/src/tools/language.ts index b351e1e76..62c3abc86 100644 --- a/src/tools/language.ts +++ b/src/tools/language.ts @@ -6,7 +6,7 @@ export type Language = { /** * https://www.iso.org/obp/ui/#search */ - + country: string; locale: string; }; @@ -15,6 +15,7 @@ export const languages = [ shortName: 'en', originalName: 'English', translatedName: 'English', + country: 'GB', locale: 'en-gb', }, { @@ -22,161 +23,188 @@ export const languages = [ originalName: 'Crowdin', translatedName: '(Live translation)', locale: 'cr', + country: 'CROWDIN', }, { shortName: 'fr', originalName: 'Français', translatedName: 'French', + country: 'FR', locale: 'fr', }, { shortName: 'cn', originalName: '中文', translatedName: 'Chinese (Simplified)', + country: 'CN', locale: 'zh-cn', }, { shortName: 'cs', originalName: 'Čeština', translatedName: 'Czech', + country: 'CZ', locale: 'cs', }, { shortName: 'da', originalName: 'Dansk', translatedName: 'Danish', + country: 'DK', locale: 'da', }, { shortName: 'de', originalName: 'Deutsch', translatedName: 'German', + country: 'DE', locale: 'de', }, { + shortName: 'el', originalName: 'Ελληνικά', translatedName: 'Greek', - shortName: 'el', + country: 'GR', locale: 'el', }, { shortName: 'es', originalName: 'Español', translatedName: 'Spanish', + country: 'ES', locale: 'es', }, { shortName: 'he', originalName: 'עברית', translatedName: 'Hebrew', + country: 'IL', locale: 'he', }, { shortName: 'hr', originalName: 'Hrvatski', translatedName: 'Croatian', + country: 'HR', locale: 'hr', }, { shortName: 'hu', originalName: 'Magyar', translatedName: 'Hungarian', + country: 'HU', locale: 'hu', }, { shortName: 'it', originalName: 'Italiano', translatedName: 'Italian', + country: 'IT', locale: 'it', }, { shortName: 'ja', originalName: '日本語', translatedName: 'Japanese', + country: 'JP', locale: 'ja', }, { shortName: 'ko', originalName: '한국어', translatedName: 'Korean', + country: 'KR', locale: 'ko', }, { shortName: 'lv', originalName: 'Latvian', translatedName: 'Latvian', + country: 'LV', locale: 'lv', }, { shortName: 'nl', originalName: 'Nederlands', translatedName: 'Dutch', + country: 'NL', locale: 'nl', }, { shortName: 'no', originalName: 'Norsk', translatedName: 'Norwegian', + country: 'NO', locale: 'no', }, { shortName: 'pl', originalName: 'Polski', translatedName: 'Polish', + country: 'PL', locale: 'pl', }, { shortName: 'pt', originalName: 'Português', translatedName: 'Portuguese', + country: 'PT', locale: 'pt', }, { shortName: 'ru', originalName: 'Русский', translatedName: 'Russian', + country: 'RU', locale: 'ru', }, { shortName: 'sk', originalName: 'Slovenčina', translatedName: 'Slovak', + country: 'SK', locale: 'sk', }, { shortName: 'sl', originalName: 'Slovenščina', translatedName: 'Slovenian', + country: 'SI', locale: 'sl', }, { shortName: 'sv', originalName: 'Svenska', translatedName: 'Swedish', + country: 'SE', locale: 'sv', }, { shortName: 'tr', originalName: 'Türkçe', translatedName: 'Turkish', + country: 'TR', locale: 'tr', }, { shortName: 'tw', originalName: '中文', translatedName: 'Chinese (Traditional)', + country: 'TW', locale: 'zh-tw', }, { shortName: 'uk', originalName: 'Українська', translatedName: 'Ukrainian', + country: 'UA', locale: 'uk', }, { shortName: 'vi', originalName: 'Tiếng Việt', translatedName: 'Vietnamese', + country: 'VN', locale: 'vi', }, ] as const satisfies Readonly; From 687c7587df6ab1dc61cc21a3eff58bcd45af8a38 Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 14 Nov 2023 21:11:41 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Remove=20the=20checks?= =?UTF-8?q?=20for=20mounts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/onboard.tsx | 40 ---------------------------------- src/pages/user/preferences.tsx | 2 +- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index bad0f1f23..de85c4eff 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -15,9 +15,6 @@ import { getTotalUserCountAsync } from '~/server/db/queries/user'; import { getConfig } from '~/tools/config/getConfig'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; -const util = require('util'); -const exec = util.promisify(require('child_process').exec); - export default function OnboardPage({ configSchemaVersions, databaseNotWriteable, @@ -123,43 +120,6 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { }; } Consola.info('Database is writeable'); - - if (process.platform !== 'win32') { - try { - const { stdout, stderr } = await exec("mount | grep '/data'"); - - if (stderr.split('\n').length > 1 || stdout.split('\n').length <= 1) { - Consola.error( - `Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace( - '\n', - '\\n' - )} ${stderr.replace('\n', '\\n')}` - ); - return { - props: { - ...translations, - configSchemaVersions: configSchemaVersions, - databaseNotWriteable: true, - errorMessage: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`, - }, - }; - } - } catch (error) { - const errorMessage = `Database at '${rawDatabaseUrl}' has not been mounted: ${error}`; - Consola.error(errorMessage); - return { - props: { - ...translations, - configSchemaVersions: configSchemaVersions, - databaseNotWriteable: true, - stringifiedError: JSON.stringify(error), - errorMessage: errorMessage, - }, - }; - } - } - - Consola.info(`Database at '${rawDatabaseUrl}' is writeable and mounted`); } return { diff --git a/src/pages/user/preferences.tsx b/src/pages/user/preferences.tsx index e2eba85f0..85b81532f 100644 --- a/src/pages/user/preferences.tsx +++ b/src/pages/user/preferences.tsx @@ -11,7 +11,6 @@ import { } from '@mantine/core'; import { createFormContext } from '@mantine/form'; import { IconArrowLeft } from '@tabler/icons-react'; -import { changeLanguage } from 'i18next'; import { GetServerSideProps } from 'next'; import { useTranslation } from 'next-i18next'; import Head from 'next/head'; @@ -74,6 +73,7 @@ const SettingsComponent = ({ label: language.originalName, description: language.translatedName, value: language.shortName, + country: language.country, })); const { t, i18n } = useTranslation(['user/preferences', 'common']);