mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
fix(console): nonstandard social connector detail page target fail to display (#3443)
This commit is contained in:
parent
72c7cba40e
commit
63be7d04a5
1 changed files with 13 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
import type { ConnectorResponse } from '@logto/schemas';
|
import type { ConnectorResponse } from '@logto/schemas';
|
||||||
import { ConnectorType } from '@logto/schemas';
|
import { ConnectorType } from '@logto/schemas';
|
||||||
|
import type { Optional } from '@silverhand/essentials';
|
||||||
import { conditional } from '@silverhand/essentials';
|
import { conditional } from '@silverhand/essentials';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { FormProvider, useForm } from 'react-hook-form';
|
import { FormProvider, useForm } from 'react-hook-form';
|
||||||
|
@ -27,6 +28,14 @@ type Props = {
|
||||||
onConnectorUpdated: (connector: ConnectorResponse) => void;
|
onConnectorUpdated: (connector: ConnectorResponse) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getConnectorTarget = (connectorData: ConnectorResponse): Optional<string> => {
|
||||||
|
return conditional(
|
||||||
|
connectorData.type === ConnectorType.Social &&
|
||||||
|
!connectorData.isStandard &&
|
||||||
|
(connectorData.metadata.target ?? connectorData.target)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Props) => {
|
const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Props) => {
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
const { getDocumentationUrl } = useDocumentationUrl();
|
const { getDocumentationUrl } = useDocumentationUrl();
|
||||||
|
@ -36,6 +45,7 @@ const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Prop
|
||||||
reValidateMode: 'onBlur',
|
reValidateMode: 'onBlur',
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
syncProfile: SyncProfileMode.OnlyAtRegister,
|
syncProfile: SyncProfileMode.OnlyAtRegister,
|
||||||
|
target: getConnectorTarget(connectorData),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const {
|
const {
|
||||||
|
@ -52,7 +62,7 @@ const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Prop
|
||||||
|
|
||||||
reset({
|
reset({
|
||||||
...(formItems ? initFormData(formItems, config) : {}),
|
...(formItems ? initFormData(formItems, config) : {}),
|
||||||
target,
|
target: getConnectorTarget(connectorData) ?? target,
|
||||||
logo,
|
logo,
|
||||||
logoDark: logoDark ?? '',
|
logoDark: logoDark ?? '',
|
||||||
name: name?.en,
|
name: name?.en,
|
||||||
|
@ -76,7 +86,8 @@ const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Prop
|
||||||
...payload,
|
...payload,
|
||||||
metadata: { name: { en: name }, logo, logoDark, target },
|
metadata: { name: { en: name }, logo, logoDark, target },
|
||||||
};
|
};
|
||||||
const body = isStandard ? standardConnectorPayload : payload;
|
// Should not update `target` for neither passwordless connectors nor non-standard social connectors.
|
||||||
|
const body = isStandard ? standardConnectorPayload : { ...payload, target: undefined };
|
||||||
|
|
||||||
const updatedConnector = await api
|
const updatedConnector = await api
|
||||||
.patch(`api/connectors/${id}`, {
|
.patch(`api/connectors/${id}`, {
|
||||||
|
|
Loading…
Add table
Reference in a new issue