0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-24 22:05:56 -05:00

Merge pull request #1364 from logto-io/charles-log-3329-improve-get-started-task-db-values

refactor: get-started task corresponding keys in DB
This commit is contained in:
Charles Zhao 2022-07-02 09:58:58 +08:00 committed by GitHub
commit 99e3f49226
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 39 additions and 39 deletions

View file

@ -43,7 +43,7 @@ export const useSidebarMenuItems = (): {
firstItem: Optional<SidebarItem>;
} => {
const {
data: { hideGetStarted },
data: { getStartedHidden },
} = useUserPreferences();
const sections: SidebarSection[] = [
@ -53,7 +53,7 @@ export const useSidebarMenuItems = (): {
{
Icon: Bolt,
title: 'get_started',
isHidden: hideGetStarted,
isHidden: getStartedHidden,
},
{
Icon: BarGraph,

View file

@ -14,7 +14,7 @@ const userPreferencesGuard = z.object({
language: z.nativeEnum(Language),
appearanceMode: z.nativeEnum(AppearanceMode),
experienceNoticeConfirmed: z.boolean().optional(),
hideGetStarted: z.boolean().optional(),
getStartedHidden: z.boolean().optional(),
});
export type UserPreferences = z.infer<typeof userPreferencesGuard>;

View file

@ -57,7 +57,7 @@ const CreateForm = ({ onClose }: Props) => {
const createdApp = await api.post('/api/applications', { json: data }).json<Application>();
setCreatedApp(createdApp);
setIsGetStartedModalOpen(true);
void updateSettings({ createApplication: true });
void updateSettings({ applicationCreated: true });
});
return (

View file

@ -64,8 +64,8 @@ const Guide = ({ connector, onClose }: Props) => {
.json<ConnectorDTO>();
await updateSettings({
...conditional(!isSocialConnector && { configurePasswordless: true }),
...conditional(isSocialConnector && { configureSocialSignIn: true }),
...conditional(!isSocialConnector && { passwordlessConfigured: true }),
...conditional(isSocialConnector && { socialSignInConfigured: true }),
});
onClose();

View file

@ -16,7 +16,7 @@ import * as styles from './index.module.scss';
const GetStartedProgress = () => {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const {
data: { hideGetStarted },
data: { getStartedHidden },
} = useUserPreferences();
const theme = useTheme();
const Icon = theme === AppearanceMode.LightMode ? Tada : TadaDark;
@ -24,7 +24,7 @@ const GetStartedProgress = () => {
const [showDropDown, setShowDropdown] = useState(false);
const { data, completedCount, totalCount } = useGetStartedMetadata({ checkDemoAppExists: false });
if (hideGetStarted) {
if (getStartedHidden) {
return null;
}

View file

@ -61,10 +61,10 @@ const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
subtitle: 'get_started.card1_subtitle',
icon: isLightMode ? CheckDemo : CheckDemoDark,
buttonText: 'admin_console.general.check_out',
isComplete: settings?.checkDemo,
isComplete: settings?.demoChecked,
isHidden: hideDemo,
onClick: async () => {
void updateSettings({ checkDemo: true });
void updateSettings({ demoChecked: true });
window.open('/demo-app', '_blank');
},
},
@ -74,7 +74,7 @@ const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
subtitle: 'get_started.card2_subtitle',
icon: isLightMode ? CreateApp : CreateAppDark,
buttonText: 'admin_console.general.create',
isComplete: settings?.createApplication,
isComplete: settings?.applicationCreated,
onClick: () => {
navigate('/applications/create');
},
@ -85,7 +85,7 @@ const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
subtitle: 'get_started.card3_subtitle',
icon: isLightMode ? Customize : CustomizeDark,
buttonText: 'admin_console.general.customize',
isComplete: settings?.customizeSignInExperience,
isComplete: settings?.signInExperienceCustomized,
onClick: () => {
navigate('/sign-in-experience');
},
@ -96,7 +96,7 @@ const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
subtitle: 'get_started.card4_subtitle',
icon: isLightMode ? Passwordless : PasswordlessDark,
buttonText: 'admin_console.general.enable',
isComplete: settings?.configurePasswordless,
isComplete: settings?.passwordlessConfigured,
onClick: () => {
navigate('/connectors');
},
@ -107,7 +107,7 @@ const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
subtitle: 'get_started.card5_subtitle',
icon: isLightMode ? OneClick : OneClickDark,
buttonText: 'admin_console.general.set_up',
isComplete: settings?.configureSocialSignIn,
isComplete: settings?.socialSignInConfigured,
onClick: () => {
navigate('/connectors/social');
},
@ -118,9 +118,9 @@ const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
subtitle: 'get_started.card6_subtitle',
icon: isLightMode ? FurtherReadings : FurtherReadingsDark,
buttonText: 'admin_console.general.check_out',
isComplete: settings?.checkFurtherReadings,
isComplete: settings?.furtherReadingsChecked,
onClick: () => {
void updateSettings({ checkFurtherReadings: true });
void updateSettings({ furtherReadingsChecked: true });
window.open('https://docs.logto.io/', '_blank');
},
},

View file

@ -21,7 +21,7 @@ const GetStarted = () => {
const [showConfirmModal, setShowConfirmModal] = useState(false);
const hideGetStarted = () => {
void update({ hideGetStarted: true });
void update({ getStartedHidden: true });
// Navigate to next menu item
navigate('/dashboard');
};

View file

@ -68,7 +68,7 @@ const GuideModal = ({ isOpen, onClose }: Props) => {
api.patch('/api/sign-in-exp', {
json: signInExperienceParser.toRemoteModel(formData),
}),
updateSettings({ customizeSignInExperience: true }),
updateSettings({ signInExperienceCustomized: true }),
]);
onClose();
@ -76,7 +76,7 @@ const GuideModal = ({ isOpen, onClose }: Props) => {
const onSkip = async () => {
setIsLoading(true);
await updateSettings({ customizeSignInExperience: true });
await updateSettings({ signInExperienceCustomized: true });
setIsLoading(false);
onClose();
};

View file

@ -62,7 +62,7 @@ const SignInExperience = () => {
})
.json<SignInExperienceType>();
void mutate(updatedData);
await updateSettings({ customizeSignInExperience: true });
await updateSettings({ signInExperienceCustomized: true });
toast.success(t('general.saved'));
};
@ -91,7 +91,7 @@ const SignInExperience = () => {
return <div>{settingsError.body?.message ?? settingsError.message}</div>;
}
if (!settings?.customizeSignInExperience) {
if (!settings?.signInExperienceCustomized) {
return <Welcome mutate={mutateSettings} />;
}

View file

@ -44,12 +44,12 @@ export const mockRole: Role = {
export const mockSetting: Setting = {
id: 'foo setting',
adminConsole: {
checkDemo: false,
createApplication: false,
configurePasswordless: false,
configureSocialSignIn: false,
customizeSignInExperience: false,
checkFurtherReadings: false,
demoChecked: false,
applicationCreated: false,
signInExperienceCustomized: false,
passwordlessConfigured: false,
socialSignInConfigured: false,
furtherReadingsChecked: false,
},
};

View file

@ -147,12 +147,12 @@ export enum AppearanceMode {
export const adminConsoleConfigGuard = z.object({
// Get started challenges
checkDemo: z.boolean(),
createApplication: z.boolean(),
configurePasswordless: z.boolean(),
configureSocialSignIn: z.boolean(),
customizeSignInExperience: z.boolean(),
checkFurtherReadings: z.boolean(),
demoChecked: z.boolean(),
applicationCreated: z.boolean(),
signInExperienceCustomized: z.boolean(),
passwordlessConfigured: z.boolean(),
socialSignInConfigured: z.boolean(),
furtherReadingsChecked: z.boolean(),
});
export type AdminConsoleConfig = z.infer<typeof adminConsoleConfigGuard>;

View file

@ -11,11 +11,11 @@ export const createDefaultSetting = (): Readonly<CreateSetting> =>
adminConsole: {
language: Language.English,
appearanceMode: AppearanceMode.SyncWithSystem,
checkDemo: false,
createApplication: false,
configurePasswordless: false,
configureSocialSignIn: false,
customizeSignInExperience: false,
checkFurtherReadings: false,
demoChecked: false,
applicationCreated: false,
signInExperienceCustomized: false,
passwordlessConfigured: false,
socialSignInConfigured: false,
furtherReadingsChecked: false,
},
});