mirror of
https://github.com/logto-io/logto.git
synced 2025-02-10 21:58:23 -05:00
refactor(console): hide native preview when no social target supports native (#3626)
This commit is contained in:
parent
457116ee52
commit
9663852f1e
16 changed files with 53 additions and 12 deletions
|
@ -55,3 +55,6 @@ export const defaultEmailConnectorGroup: ConnectorGroup = {
|
||||||
logoDark: null,
|
logoDark: null,
|
||||||
target: '',
|
target: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Note: these connector targets will need a native connector to support the native platform
|
||||||
|
export const supportNativePlatformTargets = ['wechat', 'alipay'];
|
||||||
|
|
|
@ -2,6 +2,7 @@ import type { ConnectorResponse } from '@logto/schemas';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
|
import { supportNativePlatformTargets } from '@/consts';
|
||||||
import type { RequestError } from '@/hooks/use-api';
|
import type { RequestError } from '@/hooks/use-api';
|
||||||
import { getConnectorGroups } from '@/pages/Connectors/utils';
|
import { getConnectorGroups } from '@/pages/Connectors/utils';
|
||||||
|
|
||||||
|
@ -17,10 +18,16 @@ const useConnectorGroups = () => {
|
||||||
return getConnectorGroups(data);
|
return getConnectorGroups(data);
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
|
const hasSupportNativePlatformTarget = useMemo(
|
||||||
|
() => groups?.some(({ target }) => supportNativePlatformTargets.includes(target)) ?? false,
|
||||||
|
[groups]
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
data: groups,
|
data: groups,
|
||||||
connectors: data,
|
connectors: data,
|
||||||
|
hasSupportNativePlatformTarget,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import type { LanguageTag } from '@logto/language-kit';
|
import type { LanguageTag } from '@logto/language-kit';
|
||||||
import { languages as uiLanguageNameMapping } from '@logto/language-kit';
|
import { languages as uiLanguageNameMapping } from '@logto/language-kit';
|
||||||
import type { SignInExperience } from '@logto/schemas';
|
import { type SignInExperience, Theme } from '@logto/schemas';
|
||||||
import { Theme } from '@logto/schemas';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
@ -11,6 +10,7 @@ import Select from '@/components/Select';
|
||||||
import SignInExperiencePreview, { ToggleUiThemeButton } from '@/components/SignInExperiencePreview';
|
import SignInExperiencePreview, { ToggleUiThemeButton } from '@/components/SignInExperiencePreview';
|
||||||
import { PreviewPlatform } from '@/components/SignInExperiencePreview/types';
|
import { PreviewPlatform } from '@/components/SignInExperiencePreview/types';
|
||||||
import TabNav, { TabNavItem } from '@/components/TabNav';
|
import TabNav, { TabNavItem } from '@/components/TabNav';
|
||||||
|
import useConnectorGroups from '@/hooks/use-connector-groups';
|
||||||
import useUiLanguages from '@/hooks/use-ui-languages';
|
import useUiLanguages from '@/hooks/use-ui-languages';
|
||||||
|
|
||||||
import * as styles from './index.module.scss';
|
import * as styles from './index.module.scss';
|
||||||
|
@ -29,6 +29,7 @@ function Preview({
|
||||||
className,
|
className,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
|
const { hasSupportNativePlatformTarget: isNativeTabEnabled } = useConnectorGroups();
|
||||||
const [language, setLanguage] = useState<LanguageTag>('en');
|
const [language, setLanguage] = useState<LanguageTag>('en');
|
||||||
const [mode, setMode] = useState<Theme>(Theme.Light);
|
const [mode, setMode] = useState<Theme>(Theme.Light);
|
||||||
const [platform, setPlatform] = useState<PreviewPlatform>(PreviewPlatform.DesktopWeb);
|
const [platform, setPlatform] = useState<PreviewPlatform>(PreviewPlatform.DesktopWeb);
|
||||||
|
@ -95,7 +96,9 @@ function Preview({
|
||||||
setPlatform(PreviewPlatform.DesktopWeb);
|
setPlatform(PreviewPlatform.DesktopWeb);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('sign_in_exp.preview.desktop_web')}
|
{t(
|
||||||
|
isNativeTabEnabled ? 'sign_in_exp.preview.desktop_web' : 'sign_in_exp.preview.desktop'
|
||||||
|
)}
|
||||||
</TabNavItem>
|
</TabNavItem>
|
||||||
<TabNavItem
|
<TabNavItem
|
||||||
isActive={platform === PreviewPlatform.MobileWeb}
|
isActive={platform === PreviewPlatform.MobileWeb}
|
||||||
|
@ -103,8 +106,9 @@ function Preview({
|
||||||
setPlatform(PreviewPlatform.MobileWeb);
|
setPlatform(PreviewPlatform.MobileWeb);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('sign_in_exp.preview.mobile_web')}
|
{t(isNativeTabEnabled ? 'sign_in_exp.preview.mobile_web' : 'sign_in_exp.preview.mobile')}
|
||||||
</TabNavItem>
|
</TabNavItem>
|
||||||
|
{isNativeTabEnabled && (
|
||||||
<TabNavItem
|
<TabNavItem
|
||||||
isActive={platform === PreviewPlatform.Mobile}
|
isActive={platform === PreviewPlatform.Mobile}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -113,6 +117,7 @@ function Preview({
|
||||||
>
|
>
|
||||||
{t('sign_in_exp.preview.native')}
|
{t('sign_in_exp.preview.native')}
|
||||||
</TabNavItem>
|
</TabNavItem>
|
||||||
|
)}
|
||||||
</TabNav>
|
</TabNav>
|
||||||
<SignInExperiencePreview
|
<SignInExperiencePreview
|
||||||
platform={platform}
|
platform={platform}
|
||||||
|
|
|
@ -80,6 +80,8 @@ const sign_in_exp = {
|
||||||
native: 'Native',
|
native: 'Native',
|
||||||
desktop_web: 'Desktop-Web',
|
desktop_web: 'Desktop-Web',
|
||||||
mobile_web: 'Mobile-Web',
|
mobile_web: 'Mobile-Web',
|
||||||
|
desktop: 'Desktop',
|
||||||
|
mobile: 'Mobilgerät',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -79,6 +79,8 @@ const sign_in_exp = {
|
||||||
native: 'Native',
|
native: 'Native',
|
||||||
desktop_web: 'Desktop Web',
|
desktop_web: 'Desktop Web',
|
||||||
mobile_web: 'Mobile Web',
|
mobile_web: 'Mobile Web',
|
||||||
|
desktop: 'Desktop',
|
||||||
|
mobile: 'Mobile',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,8 @@ const sign_in_exp = {
|
||||||
native: 'Nativo',
|
native: 'Nativo',
|
||||||
desktop_web: 'Web de escritorio',
|
desktop_web: 'Web de escritorio',
|
||||||
mobile_web: 'Web móvil',
|
mobile_web: 'Web móvil',
|
||||||
|
desktop: 'Escritorio',
|
||||||
|
mobile: 'Móvil',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,8 @@ const sign_in_exp = {
|
||||||
native: 'Natif',
|
native: 'Natif',
|
||||||
desktop_web: 'Site web pour ordinateur de bureau',
|
desktop_web: 'Site web pour ordinateur de bureau',
|
||||||
mobile_web: 'Site web mobile',
|
mobile_web: 'Site web mobile',
|
||||||
|
desktop: 'Bureau',
|
||||||
|
mobile: 'Mobile',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -79,6 +79,8 @@ const sign_in_exp = {
|
||||||
native: 'ネイティブ',
|
native: 'ネイティブ',
|
||||||
desktop_web: 'デスクトップWeb',
|
desktop_web: 'デスクトップWeb',
|
||||||
mobile_web: 'モバイルWeb',
|
mobile_web: 'モバイルWeb',
|
||||||
|
desktop: 'デスクトップ',
|
||||||
|
mobile: 'モバイル',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,8 @@ const sign_in_exp = {
|
||||||
native: '네이티브',
|
native: '네이티브',
|
||||||
desktop_web: '데스크톱 웹',
|
desktop_web: '데스크톱 웹',
|
||||||
mobile_web: '모바일 웹',
|
mobile_web: '모바일 웹',
|
||||||
|
desktop: '데스크톱',
|
||||||
|
mobile: '모바일',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -78,6 +78,8 @@ const sign_in_exp = {
|
||||||
native: 'Nativo',
|
native: 'Nativo',
|
||||||
desktop_web: 'Web Desktop',
|
desktop_web: 'Web Desktop',
|
||||||
mobile_web: 'Web Mobile',
|
mobile_web: 'Web Mobile',
|
||||||
|
desktop: 'Área de trabalho',
|
||||||
|
mobile: 'Móvel',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -77,6 +77,8 @@ const sign_in_exp = {
|
||||||
native: 'App nativa',
|
native: 'App nativa',
|
||||||
desktop_web: 'Web no computador',
|
desktop_web: 'Web no computador',
|
||||||
mobile_web: 'Web no telemóvel',
|
mobile_web: 'Web no telemóvel',
|
||||||
|
desktop: 'Ambiente de trabalho',
|
||||||
|
mobile: 'Móvel',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -81,6 +81,8 @@ const sign_in_exp = {
|
||||||
native: 'Нативный',
|
native: 'Нативный',
|
||||||
desktop_web: 'Веб на рабочем столе',
|
desktop_web: 'Веб на рабочем столе',
|
||||||
mobile_web: 'Мобильный веб',
|
mobile_web: 'Мобильный веб',
|
||||||
|
desktop: 'Рабочий стол',
|
||||||
|
mobile: 'Мобильный',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@ const sign_in_exp = {
|
||||||
native: 'Doğal',
|
native: 'Doğal',
|
||||||
desktop_web: 'Masaüstü Web',
|
desktop_web: 'Masaüstü Web',
|
||||||
mobile_web: 'Mobil Web',
|
mobile_web: 'Mobil Web',
|
||||||
|
desktop: 'Masaüstü',
|
||||||
|
mobile: 'Mobil',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -74,6 +74,8 @@ const sign_in_exp = {
|
||||||
native: '移动原生',
|
native: '移动原生',
|
||||||
desktop_web: '桌面网页',
|
desktop_web: '桌面网页',
|
||||||
mobile_web: '移动网页',
|
mobile_web: '移动网页',
|
||||||
|
desktop: '桌面网页',
|
||||||
|
mobile: '移动设备',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -74,6 +74,8 @@ const sign_in_exp = {
|
||||||
native: '移動原生',
|
native: '移動原生',
|
||||||
desktop_web: '桌面網頁',
|
desktop_web: '桌面網頁',
|
||||||
mobile_web: '移動網頁',
|
mobile_web: '移動網頁',
|
||||||
|
desktop: '桌面網頁',
|
||||||
|
mobile: '移動設備',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
|
@ -74,6 +74,8 @@ const sign_in_exp = {
|
||||||
native: '移動原生',
|
native: '移動原生',
|
||||||
desktop_web: '桌面網頁',
|
desktop_web: '桌面網頁',
|
||||||
mobile_web: '移動網頁',
|
mobile_web: '移動網頁',
|
||||||
|
desktop: '桌面網頁',
|
||||||
|
mobile: '行動裝置',
|
||||||
},
|
},
|
||||||
others,
|
others,
|
||||||
sign_up_and_sign_in,
|
sign_up_and_sign_in,
|
||||||
|
|
Loading…
Add table
Reference in a new issue