@@ -17,10 +17,11 @@ import TranslateIcon from "media/icons/globe-02.svg";
1717
1818import Search from "components/Search" ;
1919
20- import { Locale , BuildType } from "shared/interface" ;
20+ import { Locale , BuildType , PathConfig } from "shared/interface" ;
2121import { ActionButton } from "components/Card/FeedbackSection/components" ;
2222import { Link } from "gatsby" ;
2323import { useIsAutoTranslation } from "shared/useIsAutoTranslation" ;
24+ import { useCloudMode } from "shared/useCloudMode" ;
2425
2526const useTiDBAIStatus = ( ) => {
2627 const [ showTiDBAIButton , setShowTiDBAIButton ] = React . useState ( true ) ;
@@ -62,8 +63,9 @@ export default function HeaderAction(props: {
6263 docInfo ?: { type : string ; version : string } ;
6364 buildType ?: BuildType ;
6465 pageUrl ?: string ;
66+ pathConfig ?: PathConfig ;
6567} ) {
66- const { supportedLocales, docInfo, buildType, pageUrl } = props ;
68+ const { supportedLocales, docInfo, buildType, pageUrl, pathConfig } = props ;
6769 const { language, t } = useI18next ( ) ;
6870 const { showTiDBAIButton, initializingTiDBAI } = useTiDBAIStatus ( ) ;
6971 const isAutoTranslation = useIsAutoTranslation ( pageUrl || "" ) ;
@@ -78,7 +80,10 @@ export default function HeaderAction(props: {
7880 sx = { { marginLeft : "auto" , alignItems : "center" } }
7981 >
8082 { supportedLocales . length > 0 && (
81- < LangSwitch supportedLocales = { supportedLocales } />
83+ < LangSwitch
84+ supportedLocales = { supportedLocales }
85+ pathConfig = { pathConfig }
86+ />
8287 ) }
8388 { docInfo && ! isAutoTranslation && buildType !== "archive" && (
8489 < >
@@ -121,13 +126,15 @@ const LangSwitch = (props: {
121126 language ?: string ;
122127 changeLanguage ?: ( ) => void ;
123128 supportedLocales : Locale [ ] ;
129+ pathConfig ?: PathConfig ;
124130} ) => {
125- const { supportedLocales } = props ;
131+ const { supportedLocales, pathConfig } = props ;
126132
127133 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
128134
129135 const theme = useTheme ( ) ;
130136 const { language, changeLanguage } = useI18next ( ) ;
137+ const { isClassic } = useCloudMode ( pathConfig ! . repo ) ;
131138
132139 const open = Boolean ( anchorEl ) ;
133140 const handleClick = ( event : React . MouseEvent < HTMLElement > ) => {
@@ -213,7 +220,7 @@ const LangSwitch = (props: {
213220 onClick = { toggleLanguage ( Locale . zh ) }
214221 disableRipple
215222 selected = { language === Locale . zh }
216- disabled = { ! supportedLocales . includes ( Locale . zh ) }
223+ disabled = { ! supportedLocales . includes ( Locale . zh ) || ! isClassic }
217224 >
218225 < Typography component = "span" color = { theme . palette . carbon [ 900 ] } >
219226 < Trans i18nKey = "lang.zh" />
@@ -223,7 +230,7 @@ const LangSwitch = (props: {
223230 onClick = { toggleLanguage ( Locale . ja ) }
224231 disableRipple
225232 selected = { language === Locale . ja }
226- disabled = { ! supportedLocales . includes ( Locale . ja ) }
233+ disabled = { ! supportedLocales . includes ( Locale . ja ) || ! isClassic }
227234 >
228235 < Typography component = "span" color = { theme . palette . carbon [ 900 ] } >
229236 < Trans i18nKey = "lang.ja" />
0 commit comments