Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
? {
Expand Down
8 changes: 7 additions & 1 deletion packages/console/src/utils/connector-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading