diff --git a/packages/console/src/pages/Settings/index.tsx b/packages/console/src/pages/Settings/index.tsx index 3634e51c9..59eb59c54 100644 --- a/packages/console/src/pages/Settings/index.tsx +++ b/packages/console/src/pages/Settings/index.tsx @@ -13,7 +13,6 @@ import CardTitle from '@/components/CardTitle'; import FormField from '@/components/FormField'; import Select from '@/components/Select'; import TabNav, { TabNavLink } from '@/components/TabNav'; -import TextInput from '@/components/TextInput'; import { themeStorageKey } from '@/consts'; import useApi, { RequestError } from '@/hooks/use-api'; import * as detailsStyles from '@/scss/details.module.scss'; @@ -26,7 +25,6 @@ const Settings = () => { const { reset, handleSubmit, - register, control, formState: { isSubmitting }, } = useForm(); @@ -66,9 +64,6 @@ const Settings = () => { {data && (
- - - { } }; - const seedTables = async (domain: string) => { + const seedTables = async () => { await Promise.all([ pool.query(insertInto(managementResource, 'resources')), - pool.query(insertInto(createDefaultSetting(domain), 'settings')), + pool.query(insertInto(createDefaultSetting(), 'settings')), pool.query(insertInto(defaultSignInExperience, 'sign_in_experiences')), ]); console.log(`${chalk.blue('[seed-tables]')} Seed tables succeeded.`); diff --git a/packages/core/src/env-set/create-pool-by-env.ts b/packages/core/src/env-set/create-pool-by-env.ts index b0ac898ca..3676799e1 100644 --- a/packages/core/src/env-set/create-pool-by-env.ts +++ b/packages/core/src/env-set/create-pool-by-env.ts @@ -55,7 +55,7 @@ const inquireForLogtoDsn = async (key: string): Promise<[Optional, boole return [dsn, true]; }; -const createPoolByEnv = async (isTest: boolean, localhostUrl: string) => { +const createPoolByEnv = async (isTest: boolean) => { // Database connection is disabled in unit test environment if (isTest) { return; @@ -82,14 +82,8 @@ const createPoolByEnv = async (isTest: boolean, localhostUrl: string) => { const cli = createDatabaseCli(dsn); if (needsSeed) { - const domain = await inquirer.prompt({ - name: 'value', - default: localhostUrl, - message: 'Enter your domain for Logto:', - }); - await cli.createTables(); - await cli.seedTables(domain.value); + await cli.seedTables(); } appendDotEnv(key, dsn); diff --git a/packages/core/src/env-set/index.ts b/packages/core/src/env-set/index.ts index 5797f381b..0f1fa7ae6 100644 --- a/packages/core/src/env-set/index.ts +++ b/packages/core/src/env-set/index.ts @@ -1,4 +1,4 @@ -import { conditionalString, getEnv, Optional } from '@silverhand/essentials'; +import { getEnv, Optional } from '@silverhand/essentials'; import { DatabasePool } from 'slonik'; import createPoolByEnv from './create-pool-by-env'; @@ -59,10 +59,7 @@ function createEnvSet() { load: async () => { values = await loadEnvValues(); - pool = await createPoolByEnv( - values.isTest, - `http${conditionalString(values.isHttpsEnabled && 's')}://localhost:${values.port}` - ); + pool = await createPoolByEnv(values.isTest); }, }; } diff --git a/packages/core/src/queries/setting.test.ts b/packages/core/src/queries/setting.test.ts index 9f8996c5b..9671c0382 100644 --- a/packages/core/src/queries/setting.test.ts +++ b/packages/core/src/queries/setting.test.ts @@ -40,22 +40,24 @@ describe('setting query', () => { }); it('updateSetting', async () => { - const customDomain = 'logto.io'; + const { adminConsole } = mockSetting; const expectSql = sql` update ${table} - set ${fields.customDomain}=$1 + set + ${fields.adminConsole}= + coalesce("admin_console",'{}'::jsonb)|| $1 where ${fields.id}=$2 returning * `; mockQuery.mockImplementationOnce(async (sql, values) => { expectSqlAssert(sql, expectSql.sql); - expect(values).toEqual([customDomain, defaultSettingId]); + expect(values).toEqual([JSON.stringify(adminConsole), defaultSettingId]); return createMockQueryResult([dbvalue]); }); - await expect(updateSetting({ customDomain })).resolves.toEqual(dbvalue); + await expect(updateSetting({ adminConsole })).resolves.toEqual(dbvalue); }); }); diff --git a/packages/core/src/routes/setting.test.ts b/packages/core/src/routes/setting.test.ts index 9a62b0fb9..c44e1a507 100644 --- a/packages/core/src/routes/setting.test.ts +++ b/packages/core/src/routes/setting.test.ts @@ -26,17 +26,14 @@ describe('settings routes', () => { }); it('PATCH /settings', async () => { - const customDomain = 'silverhand-logto.io'; const { adminConsole } = mockSetting; const response = await roleRequester.patch('/settings').send({ - customDomain, adminConsole, }); expect(response.status).toEqual(200); expect(response.body).toEqual({ - customDomain, adminConsole, }); }); diff --git a/packages/schemas/src/db-entries/setting.ts b/packages/schemas/src/db-entries/setting.ts index b1b4081eb..12f0952b9 100644 --- a/packages/schemas/src/db-entries/setting.ts +++ b/packages/schemas/src/db-entries/setting.ts @@ -11,19 +11,16 @@ import { export type CreateSetting = { id: string; - customDomain?: string | null; adminConsole: AdminConsoleConfig; }; export type Setting = { id: string; - customDomain: string | null; adminConsole: AdminConsoleConfig; }; const createGuard: Guard = z.object({ id: z.string(), - customDomain: z.string().nullable().optional(), adminConsole: adminConsoleConfigGuard, }); @@ -32,9 +29,8 @@ export const Settings: GeneratedSchema = Object.freeze({ tableSingular: 'setting', fields: { id: 'id', - customDomain: 'custom_domain', adminConsole: 'admin_console', }, - fieldKeys: ['id', 'customDomain', 'adminConsole'], + fieldKeys: ['id', 'adminConsole'], createGuard, }); diff --git a/packages/schemas/src/seeds/setting.ts b/packages/schemas/src/seeds/setting.ts index 430dfc5f0..02ab325d4 100644 --- a/packages/schemas/src/seeds/setting.ts +++ b/packages/schemas/src/seeds/setting.ts @@ -5,10 +5,9 @@ import { AppearanceMode } from '../foundations'; export const defaultSettingId = 'default'; -export const createDefaultSetting = (customDomain: string): Readonly => +export const createDefaultSetting = (): Readonly => Object.freeze({ id: defaultSettingId, - customDomain, adminConsole: { language: Language.English, appearanceMode: AppearanceMode.SyncWithSystem, diff --git a/packages/schemas/tables/settings.sql b/packages/schemas/tables/settings.sql index 58612bb8b..329956779 100644 --- a/packages/schemas/tables/settings.sql +++ b/packages/schemas/tables/settings.sql @@ -1,6 +1,5 @@ create table settings ( id varchar(21) not null, - custom_domain text, admin_console jsonb /* @use AdminConsoleConfig */ not null, primary key (id) );