0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -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;
}
const payload = {
config: result.data,
syncProfile: syncProfile === SyncProfileMode.EachSignIn,
};
const payload =
connectorData.type === ConnectorType.Social
? {
config: result.data,
syncProfile: syncProfile === SyncProfileMode.EachSignIn,
}
: { config: result.data };
const standardConnectorPayload = {
...payload,
metadata: { ...metadata, name: { en: metadata.name } },

View file

@ -1,4 +1,5 @@
import type { ConnectorFactoryResponse } from '@logto/schemas';
import { ConnectorType } from '@logto/schemas';
import { useState } from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
@ -102,16 +103,18 @@ const ConnectorForm = ({ connector, isAllowEditTarget }: Props) => {
)}
/>
</FormField>
<FormField title="connectors.guide.sync_profile">
<Controller
name="syncProfile"
control={control}
rules={{ required: true }}
render={({ field: { onChange, value } }) => (
<Select options={syncProfileOptions} value={value} onChange={onChange} />
)}
/>
</FormField>
{connector.type === ConnectorType.Social && (
<FormField title="connectors.guide.sync_profile">
<Controller
name="syncProfile"
control={control}
rules={{ required: true }}
render={({ field: { onChange, value } }) => (
<Select options={syncProfileOptions} value={value} onChange={onChange} />
)}
/>
</FormField>
)}
</div>
);
};

View file

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