0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

chore(console): attribute mapping 'id' field should not be editable (#5002)

This commit is contained in:
Darcy Ye 2023-11-30 10:37:25 +08:00 committed by GitHub
parent 3b9e078d04
commit 6c5213cb65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
import { socialUserInfoGuard } from '@logto/connector-kit';
import { type SsoConnectorWithProviderConfig } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
import { conditional, conditionalString } from '@silverhand/essentials';
import { useFormContext } from 'react-hook-form';
import { z } from 'zod';
@ -55,12 +55,24 @@ function SamlAttributeMapping({ providerConfig }: Props) {
<CopyToClipboard className={styles.copyToClipboard} variant="border" value={key} />
</td>
<td>
{/* Show default value of `id` field to show that Logto has handled the default value. */}
{/* Per SAML protocol, this field is not eligible to change in most cases. */}
{key === 'id' ? (
<CopyToClipboard
className={styles.copyToClipboard}
variant="border"
value={conditionalString(
result.success && result.data.defaultAttributeMapping[key]
)}
/>
) : (
<TextInput
{...register(`${primaryKey}.${key}`)}
placeholder={conditional(
result.success && result.data.defaultAttributeMapping[key]
)}
/>
)}
</td>
</tr>
);