mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor(console): rename the jwtClaims page
rename the jwtClaims page
This commit is contained in:
parent
8115944e1d
commit
e3e8b14569
27 changed files with 7 additions and 24 deletions
|
@ -1,10 +1,8 @@
|
|||
import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact';
|
||||
import { LogtoJwtTokenPath } from '@logto/schemas';
|
||||
import { type LogtoJwtTokenPath } from '@logto/schemas';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import CardTitle from '@/ds-components/CardTitle';
|
||||
import TabNav, { TabNavItem } from '@/ds-components/TabNav';
|
||||
|
||||
import { CodeEditorLoadingContext } from './CodeEditorLoadingContext';
|
||||
import Main from './Main';
|
||||
|
@ -12,20 +10,12 @@ import PageLoadingSkeleton from './PageLoadingSkeleton';
|
|||
import * as styles from './index.module.scss';
|
||||
import useJwtCustomizer from './use-jwt-customizer';
|
||||
|
||||
const tabPhrases = Object.freeze({
|
||||
[LogtoJwtTokenPath.AccessToken]: 'user_jwt.card_field',
|
||||
[LogtoJwtTokenPath.ClientCredentials]: 'machine_to_machine_jwt.card_field',
|
||||
});
|
||||
|
||||
const getPagePath = (tokenType: LogtoJwtTokenPath) => `/jwt-customizer/${tokenType}`;
|
||||
|
||||
type Props = {
|
||||
tab: LogtoJwtTokenPath;
|
||||
tokenType: LogtoJwtTokenPath;
|
||||
action: 'create' | 'edit';
|
||||
};
|
||||
|
||||
function JwtClaims({ tab }: Props) {
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
|
||||
function CustomizeJwtDetails({ tokenType }: Props) {
|
||||
const { isLoading, ...rest } = useJwtCustomizer();
|
||||
const [isMonacoLoaded, setIsMonacoLoaded] = useState(false);
|
||||
|
||||
|
@ -41,18 +31,11 @@ function JwtClaims({ tab }: Props) {
|
|||
subtitle="jwt_claims.description"
|
||||
className={styles.header}
|
||||
/>
|
||||
<TabNav className={styles.tabNav}>
|
||||
{Object.values(LogtoJwtTokenPath).map((tokenType) => (
|
||||
<TabNavItem key={tokenType} href={getPagePath(tokenType)} isActive={tokenType === tab}>
|
||||
{t(`jwt_claims.${tabPhrases[tokenType]}`)}
|
||||
</TabNavItem>
|
||||
))}
|
||||
</TabNav>
|
||||
{(isLoading || !isMonacoLoaded) && <PageLoadingSkeleton tokenType={tab} />}
|
||||
{(isLoading || !isMonacoLoaded) && <PageLoadingSkeleton tokenType={tokenType} />}
|
||||
|
||||
{!isLoading && (
|
||||
<CodeEditorLoadingContext.Provider value={codeEditorContextValue}>
|
||||
<Main tab={tab} {...rest} className={isMonacoLoaded ? undefined : styles.hidden} />
|
||||
<Main tab={tokenType} {...rest} className={isMonacoLoaded ? undefined : styles.hidden} />
|
||||
</CodeEditorLoadingContext.Provider>
|
||||
)}
|
||||
</div>
|
||||
|
@ -60,4 +43,4 @@ function JwtClaims({ tab }: Props) {
|
|||
}
|
||||
|
||||
// eslint-disable-next-line import/no-unused-modules -- will update this later
|
||||
export default withAppInsights(JwtClaims);
|
||||
export default withAppInsights(CustomizeJwtDetails);
|
Loading…
Reference in a new issue