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

fix(console): fix empty string update of connector config form (#6626)

Revert "fix(console): fix passwordless connector tester send failed bug (#6268)"

This reverts commit 6963192ac5.
This commit is contained in:
wangsijie 2024-09-24 13:48:35 +08:00 committed by GitHub
parent b73728bbe5
commit f8fd52b2f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 18 deletions

View file

@ -31,13 +31,9 @@ const useJsonStringConfigParser = () => {
export const useConnectorFormConfigParser = () => { export const useConnectorFormConfigParser = () => {
const parseJsonConfig = useJsonStringConfigParser(); const parseJsonConfig = useJsonStringConfigParser();
return ( return (data: ConnectorFormType, formItems: ConnectorResponse['formItems']) => {
data: ConnectorFormType,
formItems: ConnectorResponse['formItems'],
skipFalsyValuesRemoval = false
) => {
return formItems return formItems
? parseFormConfig(data.formConfig, formItems, skipFalsyValuesRemoval) ? parseFormConfig(data.formConfig, formItems)
: parseJsonConfig(data.jsonConfig); : parseJsonConfig(data.jsonConfig);
}; };
}; };

View file

@ -68,11 +68,7 @@ function ConnectorContent({ isDeleted, connectorData, onConnectorUpdated }: Prop
const { syncProfile, name, logo, logoDark, target, rawConfig } = data; const { syncProfile, name, logo, logoDark, target, rawConfig } = data;
// Apply the raw config first to avoid losing data updated from other forms that are not // Apply the raw config first to avoid losing data updated from other forms that are not
// included in the form items. // included in the form items.
// Explicitly SKIP falsy values removal logic (the last argument of `configParser()` method) for social connectors. const config = removeFalsyValues({ ...rawConfig, ...configParser(data, formItems) });
const config = removeFalsyValues({
...rawConfig,
...configParser(data, formItems, isSocialConnector),
});
const payload = isSocialConnector const payload = isSocialConnector
? { ? {

View file

@ -22,17 +22,11 @@ const initFormData = (formItems: ConnectorConfigFormItem[], config?: Record<stri
export const parseFormConfig = ( export const parseFormConfig = (
config: Record<string, unknown>, config: Record<string, unknown>,
formItems: ConnectorConfigFormItem[], formItems: ConnectorConfigFormItem[]
skipFalsyValuesRemoval = false
) => { ) => {
return Object.fromEntries( return Object.fromEntries(
Object.entries(config) Object.entries(config)
.map(([key, value]) => { .map(([key, value]) => {
// Filter out empty input
if (!skipFalsyValuesRemoval && value === '') {
return null;
}
const formItem = formItems.find((item) => item.key === key); const formItem = formItems.find((item) => item.key === key);
if (!formItem) { if (!formItem) {