0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

fix(console): remove sync profile field for non-social connector (#2637)

This commit is contained in:
wangsijie 2022-12-13 13:07:11 +08:00 committed by GitHub
parent 9e08808569
commit 83cb2ec37f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 25 deletions

View file

@ -67,10 +67,13 @@ const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Prop
return; return;
} }
const payload = { const payload =
connectorData.type === ConnectorType.Social
? {
config: result.data, config: result.data,
syncProfile: syncProfile === SyncProfileMode.EachSignIn, syncProfile: syncProfile === SyncProfileMode.EachSignIn,
}; }
: { config: result.data };
const standardConnectorPayload = { const standardConnectorPayload = {
...payload, ...payload,
metadata: { ...metadata, name: { en: metadata.name } }, metadata: { ...metadata, name: { en: metadata.name } },

View file

@ -1,4 +1,5 @@
import type { ConnectorFactoryResponse } from '@logto/schemas'; import type { ConnectorFactoryResponse } from '@logto/schemas';
import { ConnectorType } from '@logto/schemas';
import { useState } from 'react'; import { useState } from 'react';
import { Controller, useFormContext } from 'react-hook-form'; import { Controller, useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -102,6 +103,7 @@ const ConnectorForm = ({ connector, isAllowEditTarget }: Props) => {
)} )}
/> />
</FormField> </FormField>
{connector.type === ConnectorType.Social && (
<FormField title="connectors.guide.sync_profile"> <FormField title="connectors.guide.sync_profile">
<Controller <Controller
name="syncProfile" name="syncProfile"
@ -112,6 +114,7 @@ const ConnectorForm = ({ connector, isAllowEditTarget }: Props) => {
)} )}
/> />
</FormField> </FormField>
)}
</div> </div>
); );
}; };

View file

@ -67,19 +67,24 @@ const Guide = ({ connector, onClose }: Props) => {
const { id: connectorId } = connector; const { id: connectorId } = connector;
const createdConnector = await api const basePayload = {
.post('/api/connectors', {
json: {
config: result.data, config: result.data,
connectorId, connectorId,
syncProfile: syncProfile === SyncProfileMode.EachSignIn,
metadata: conditional( metadata: conditional(
isStandard && { isStandard && {
...otherData, ...otherData,
name: { en: name }, name: { en: name },
} }
), ),
}, };
const payload = isSocialConnector
? { ...basePayload, syncProfile: syncProfile === SyncProfileMode.EachSignIn }
: basePayload;
const createdConnector = await api
.post('/api/connectors', {
json: payload,
}) })
.json<ConnectorResponse>(); .json<ConnectorResponse>();