mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor: minor improvements
This commit is contained in:
parent
c68de569d5
commit
99c98b6654
4 changed files with 48 additions and 7 deletions
|
@ -20,9 +20,9 @@ export const getTranslationPromptMessages = ({
|
|||
}: GetTranslationPromptProperties) => [
|
||||
{
|
||||
role: 'assistant',
|
||||
content: `You are a translate assistant of a Typescript engenieer, when you receive a code snippet that contains an object, translate those values that are marked with comment "// UNTRANSLATED" into the language ${
|
||||
content: `You are a translate assistant of a Typescript engineer, when you receive a code snippet that contains an object, translate and ONLY translate those values that are marked with comment "// UNTRANSLATED" into the language ${
|
||||
languages[targetLanguage]
|
||||
}, keep all object keys original, output ts code only, the code format should be strictly consistent, and should not contain the given code snippet. ${conditionalString(
|
||||
}, remove the "// UNTRANSLATED" mark, keep all object keys original, output ts code only, the code format should be strictly consistent, and should not contain the given code snippet. ${conditionalString(
|
||||
extraPrompt
|
||||
)}
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { type Application, type SnakeCaseOidcConfig, ApplicationType } from '@logto/schemas';
|
||||
import {
|
||||
type Application,
|
||||
type SnakeCaseOidcConfig,
|
||||
ApplicationType,
|
||||
customClientMetadataGuard,
|
||||
} from '@logto/schemas';
|
||||
import { appendPath } from '@silverhand/essentials';
|
||||
import { useContext } from 'react';
|
||||
import { useFormContext } from 'react-hook-form';
|
||||
|
@ -27,6 +32,14 @@ function AdvancedSettings({ applicationType, oidcConfig }: Props) {
|
|||
formState: { errors },
|
||||
} = useFormContext<Application & { isAdmin?: boolean }>();
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
const { minValue, maxValue } =
|
||||
customClientMetadataGuard.shape.refreshTokenTtlInDays._def.innerType;
|
||||
const minTtl = minValue ?? Number.NEGATIVE_INFINITY;
|
||||
const maxTtl = maxValue ?? Number.POSITIVE_INFINITY;
|
||||
const ttlErrorMessage = t('errors.number_should_be_between_inclusive', {
|
||||
min: minTtl,
|
||||
max: maxTtl,
|
||||
});
|
||||
|
||||
return (
|
||||
<FormCard
|
||||
|
@ -93,7 +106,20 @@ function AdvancedSettings({ applicationType, oidcConfig }: Props) {
|
|||
<>
|
||||
<FormField title="application_details.rotate_refresh_token">
|
||||
<Switch
|
||||
label={t('application_details.rotate_refresh_token_label')}
|
||||
label={
|
||||
<Trans
|
||||
components={{
|
||||
a: (
|
||||
<TextLink
|
||||
href="https://docs.logto.io/docs/references/applications/#rotate-refresh-token"
|
||||
target="_blank"
|
||||
/>
|
||||
),
|
||||
}}
|
||||
>
|
||||
{t('application_details.rotate_refresh_token_label')}
|
||||
</Trans>
|
||||
}
|
||||
{...register('customClientMetadata.rotateRefreshToken')}
|
||||
/>
|
||||
</FormField>
|
||||
|
@ -103,9 +129,19 @@ function AdvancedSettings({ applicationType, oidcConfig }: Props) {
|
|||
>
|
||||
<TextInput
|
||||
{...register('customClientMetadata.refreshTokenTtlInDays', {
|
||||
min: 1,
|
||||
max: 90,
|
||||
min: {
|
||||
value: minTtl,
|
||||
message: ttlErrorMessage,
|
||||
},
|
||||
max: {
|
||||
value: maxTtl,
|
||||
message: ttlErrorMessage,
|
||||
},
|
||||
valueAsNumber: true,
|
||||
validate: (value) =>
|
||||
value === undefined ||
|
||||
Number.isInteger(value) ||
|
||||
t('errors.should_be_an_integer'),
|
||||
})}
|
||||
placeholder="14"
|
||||
// Confirm if we need a customized message here
|
||||
|
|
|
@ -38,12 +38,17 @@ describe('admin console application', () => {
|
|||
oidcClientMetadata: {
|
||||
redirectUris: newRedirectUris,
|
||||
},
|
||||
customClientMetadata: { rotateRefreshToken: true, refreshTokenTtlInDays: 10 },
|
||||
});
|
||||
|
||||
const updatedApplication = await getApplication(application.id);
|
||||
|
||||
expect(updatedApplication.description).toBe(newApplicationDescription);
|
||||
expect(updatedApplication.oidcClientMetadata.redirectUris).toEqual(newRedirectUris);
|
||||
expect(updatedApplication.customClientMetadata).toStrictEqual({
|
||||
rotateRefreshToken: true,
|
||||
refreshTokenTtlInDays: 10,
|
||||
});
|
||||
});
|
||||
|
||||
it('should update application "admin" successfully', async () => {
|
||||
|
|
|
@ -91,7 +91,7 @@ export const customClientMetadataGuard = z.object({
|
|||
[CustomClientMetadataKey.CorsAllowedOrigins]: z.string().url().array().optional(),
|
||||
[CustomClientMetadataKey.IdTokenTtl]: z.number().optional(),
|
||||
[CustomClientMetadataKey.RefreshTokenTtl]: z.number().optional(),
|
||||
[CustomClientMetadataKey.RefreshTokenTtlInDays]: z.number().optional(),
|
||||
[CustomClientMetadataKey.RefreshTokenTtlInDays]: z.number().int().min(1).max(90).optional(),
|
||||
[CustomClientMetadataKey.TenantId]: z.string().optional(),
|
||||
[CustomClientMetadataKey.AlwaysIssueRefreshToken]: z.boolean().optional(),
|
||||
[CustomClientMetadataKey.RotateRefreshToken]: z.boolean().optional(),
|
||||
|
|
Loading…
Reference in a new issue