mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
Revert "fix(console): fix empty string update of connector config for… (#6627)
Revert "fix(console): fix empty string update of connector config form (#6626)"
This reverts commit f8fd52b2f8
.
This commit is contained in:
parent
1b001f8fe8
commit
b3cac2edb1
3 changed files with 18 additions and 4 deletions
|
@ -31,9 +31,13 @@ const useJsonStringConfigParser = () => {
|
|||
export const useConnectorFormConfigParser = () => {
|
||||
const parseJsonConfig = useJsonStringConfigParser();
|
||||
|
||||
return (data: ConnectorFormType, formItems: ConnectorResponse['formItems']) => {
|
||||
return (
|
||||
data: ConnectorFormType,
|
||||
formItems: ConnectorResponse['formItems'],
|
||||
skipFalsyValuesRemoval = false
|
||||
) => {
|
||||
return formItems
|
||||
? parseFormConfig(data.formConfig, formItems)
|
||||
? parseFormConfig(data.formConfig, formItems, skipFalsyValuesRemoval)
|
||||
: parseJsonConfig(data.jsonConfig);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -68,7 +68,11 @@ function ConnectorContent({ isDeleted, connectorData, onConnectorUpdated }: Prop
|
|||
const { syncProfile, name, logo, logoDark, target, rawConfig } = data;
|
||||
// Apply the raw config first to avoid losing data updated from other forms that are not
|
||||
// included in the form items.
|
||||
const config = removeFalsyValues({ ...rawConfig, ...configParser(data, formItems) });
|
||||
// Explicitly SKIP falsy values removal logic (the last argument of `configParser()` method) for social connectors.
|
||||
const config = removeFalsyValues({
|
||||
...rawConfig,
|
||||
...configParser(data, formItems, isSocialConnector),
|
||||
});
|
||||
|
||||
const payload = isSocialConnector
|
||||
? {
|
||||
|
|
|
@ -22,11 +22,17 @@ const initFormData = (formItems: ConnectorConfigFormItem[], config?: Record<stri
|
|||
|
||||
export const parseFormConfig = (
|
||||
config: Record<string, unknown>,
|
||||
formItems: ConnectorConfigFormItem[]
|
||||
formItems: ConnectorConfigFormItem[],
|
||||
skipFalsyValuesRemoval = false
|
||||
) => {
|
||||
return Object.fromEntries(
|
||||
Object.entries(config)
|
||||
.map(([key, value]) => {
|
||||
// Filter out empty input
|
||||
if (!skipFalsyValuesRemoval && value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const formItem = formItems.find((item) => item.key === key);
|
||||
|
||||
if (!formItem) {
|
||||
|
|
Loading…
Reference in a new issue