0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor: update initial data (#3534)

This commit is contained in:
Gao Sun 2023-03-20 16:08:44 +08:00 committed by GitHub
parent 497f244858
commit c2e4226292
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 13 deletions

View file

@ -25,7 +25,7 @@ export const seedByPool = async (pool: DatabasePool, cloud = false) => {
text: 'Create tables', text: 'Create tables',
prefixText: chalk.blue('[info]'), prefixText: chalk.blue('[info]'),
}); });
await seedTables(connection, latestTimestamp); await seedTables(connection, latestTimestamp, cloud);
if (cloud) { if (cloud) {
await seedCloud(connection); await seedCloud(connection);

View file

@ -117,7 +117,8 @@ export const createTables = async (connection: DatabaseTransactionConnection) =>
export const seedTables = async ( export const seedTables = async (
connection: DatabaseTransactionConnection, connection: DatabaseTransactionConnection,
latestTimestamp: number latestTimestamp: number,
isCloud: boolean
) => { ) => {
await createTenant(connection, defaultTenantId); await createTenant(connection, defaultTenantId);
await seedOidcConfigs(connection, defaultTenantId); await seedOidcConfigs(connection, defaultTenantId);
@ -164,7 +165,7 @@ export const seedTables = async (
await Promise.all([ await Promise.all([
connection.query(insertInto(createDefaultAdminConsoleConfig(defaultTenantId), 'logto_configs')), connection.query(insertInto(createDefaultAdminConsoleConfig(defaultTenantId), 'logto_configs')),
connection.query( connection.query(
insertInto(createDefaultSignInExperience(defaultTenantId), 'sign_in_experiences') insertInto(createDefaultSignInExperience(defaultTenantId, isCloud), 'sign_in_experiences')
), ),
connection.query(insertInto(createDefaultAdminConsoleConfig(adminTenantId), 'logto_configs')), connection.query(insertInto(createDefaultAdminConsoleConfig(adminTenantId), 'logto_configs')),
connection.query(insertInto(createAdminTenantSignInExperience(), 'sign_in_experiences')), connection.query(insertInto(createAdminTenantSignInExperience(), 'sign_in_experiences')),

View file

@ -113,7 +113,7 @@ export class TenantsLibrary {
), ),
transaction.query(insertInto(createDefaultAdminConsoleConfig(tenantId), LogtoConfigs.table)), transaction.query(insertInto(createDefaultAdminConsoleConfig(tenantId), LogtoConfigs.table)),
transaction.query( transaction.query(
insertInto(createDefaultSignInExperience(tenantId), SignInExperiences.table) insertInto(createDefaultSignInExperience(tenantId, true), SignInExperiences.table)
), ),
]); ]);

View file

@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import TextLink from '@/components/TextLink'; import TextLink from '@/components/TextLink';
import { logtoBlogLink } from '@/onboarding/constants'; import { aboutCloudPreviewLink } from '@/onboarding/constants';
import * as styles from './index.module.scss'; import * as styles from './index.module.scss';
@ -11,7 +11,7 @@ const Broadcast = () => {
return ( return (
<div className={styles.broadcast}> <div className={styles.broadcast}>
<span>{t('cloud.broadcast')}</span> <span>{t('cloud.broadcast')}</span>
<TextLink href={logtoBlogLink} target="_blank" className={styles.link}> <TextLink href={aboutCloudPreviewLink} target="_blank" className={styles.link}>
{t('general.learn_more')} {t('general.learn_more')}
</TextLink> </TextLink>
</div> </div>

View file

@ -1,2 +1,3 @@
export const reservationLink = 'https://calendly.com/logto/30min'; export const reservationLink = 'https://calendly.com/logto/30min';
export const logtoBlogLink = 'https://docs.logto.io/blog?utm_source=console'; export const logtoBlogLink = 'https://docs.logto.io/blog?utm_source=console';
export const aboutCloudPreviewLink = 'https://docs.logto.io/about/cloud-preview?utm_source=console';

View file

@ -7,7 +7,10 @@ import { adminTenantId, defaultTenantId } from './tenant.js';
const defaultPrimaryColor = '#6139F6'; const defaultPrimaryColor = '#6139F6';
export const createDefaultSignInExperience = (forTenantId: string): Readonly<SignInExperience> => export const createDefaultSignInExperience = (
forTenantId: string,
isCloud: boolean
): Readonly<SignInExperience> =>
Object.freeze({ Object.freeze({
tenantId: forTenantId, tenantId: forTenantId,
id: 'default', id: 'default',
@ -17,8 +20,8 @@ export const createDefaultSignInExperience = (forTenantId: string): Readonly<Sig
darkPrimaryColor: generateDarkColor(defaultPrimaryColor), darkPrimaryColor: generateDarkColor(defaultPrimaryColor),
}, },
branding: { branding: {
logoUrl: 'https://logto.io/logo.svg', logoUrl: isCloud ? '' : 'https://logto.io/logo.svg',
darkLogoUrl: 'https://logto.io/logo-dark.svg', darkLogoUrl: isCloud ? '' : 'https://logto.io/logo-dark.svg',
}, },
languageInfo: { languageInfo: {
autoDetect: true, autoDetect: true,
@ -27,14 +30,14 @@ export const createDefaultSignInExperience = (forTenantId: string): Readonly<Sig
termsOfUseUrl: null, termsOfUseUrl: null,
privacyPolicyUrl: null, privacyPolicyUrl: null,
signUp: { signUp: {
identifiers: [SignInIdentifier.Username], identifiers: [isCloud ? SignInIdentifier.Email : SignInIdentifier.Username],
password: true, password: true,
verify: false, verify: isCloud,
}, },
signIn: { signIn: {
methods: [ methods: [
{ {
identifier: SignInIdentifier.Username, identifier: isCloud ? SignInIdentifier.Email : SignInIdentifier.Username,
password: true, password: true,
verificationCode: false, verificationCode: false,
isPasswordPrimary: true, isPasswordPrimary: true,
@ -48,7 +51,7 @@ export const createDefaultSignInExperience = (forTenantId: string): Readonly<Sig
}); });
/** @deprecated Use `createDefaultSignInExperience()` instead. */ /** @deprecated Use `createDefaultSignInExperience()` instead. */
export const defaultSignInExperience = createDefaultSignInExperience(defaultTenantId); export const defaultSignInExperience = createDefaultSignInExperience(defaultTenantId, false);
export const createAdminTenantSignInExperience = (): Readonly<SignInExperience> => export const createAdminTenantSignInExperience = (): Readonly<SignInExperience> =>
Object.freeze({ Object.freeze({