mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(console): fix passwordless connector tester send failed bug (#6268)
This commit is contained in:
parent
ca73d3142f
commit
6963192ac5
3 changed files with 18 additions and 4 deletions
|
@ -31,9 +31,13 @@ const useJsonStringConfigParser = () => {
|
||||||
export const useConnectorFormConfigParser = () => {
|
export const useConnectorFormConfigParser = () => {
|
||||||
const parseJsonConfig = useJsonStringConfigParser();
|
const parseJsonConfig = useJsonStringConfigParser();
|
||||||
|
|
||||||
return (data: ConnectorFormType, formItems: ConnectorResponse['formItems']) => {
|
return (
|
||||||
|
data: ConnectorFormType,
|
||||||
|
formItems: ConnectorResponse['formItems'],
|
||||||
|
skipFalsyValuesRemoval = false
|
||||||
|
) => {
|
||||||
return formItems
|
return formItems
|
||||||
? parseFormConfig(data.formConfig, formItems)
|
? parseFormConfig(data.formConfig, formItems, skipFalsyValuesRemoval)
|
||||||
: parseJsonConfig(data.jsonConfig);
|
: parseJsonConfig(data.jsonConfig);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,7 +68,11 @@ 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.
|
||||||
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
|
const payload = isSocialConnector
|
||||||
? {
|
? {
|
||||||
|
|
|
@ -22,11 +22,17 @@ 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) {
|
||||||
|
|
Loading…
Reference in a new issue