fix(editor): Fix saving and connecting on LDAP setup form (#10163)

Co-authored-by: Ricardo Espinoza <ricardo@n8n.io>
This commit is contained in:
Iván Ovejero 2024-07-24 09:37:34 +02:00 committed by GitHub
parent e46341ac46
commit 30784fb76c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 40 deletions

View file

@ -64,6 +64,12 @@ function onValidate(name: string, isValid: boolean) {
}; };
} }
function getValues() {
return { ...values };
}
defineExpose({ getValues });
function onSubmit() { function onSubmit() {
showValidationWarnings.value = true; showValidationWarnings.value = true;

View file

@ -84,28 +84,23 @@
<ElTableColumn <ElTableColumn
prop="status" prop="status"
:label="$locale.baseText('settings.ldap.synchronizationTable.column.status')" :label="$locale.baseText('settings.ldap.synchronizationTable.column.status')"
> />
</ElTableColumn>
<ElTableColumn <ElTableColumn
prop="endedAt" prop="endedAt"
:label="$locale.baseText('settings.ldap.synchronizationTable.column.endedAt')" :label="$locale.baseText('settings.ldap.synchronizationTable.column.endedAt')"
> />
</ElTableColumn>
<ElTableColumn <ElTableColumn
prop="runMode" prop="runMode"
:label="$locale.baseText('settings.ldap.synchronizationTable.column.runMode')" :label="$locale.baseText('settings.ldap.synchronizationTable.column.runMode')"
> />
</ElTableColumn>
<ElTableColumn <ElTableColumn
prop="runTime" prop="runTime"
:label="$locale.baseText('settings.ldap.synchronizationTable.column.runTime')" :label="$locale.baseText('settings.ldap.synchronizationTable.column.runTime')"
> />
</ElTableColumn>
<ElTableColumn <ElTableColumn
prop="details" prop="details"
:label="$locale.baseText('settings.ldap.synchronizationTable.column.details')" :label="$locale.baseText('settings.ldap.synchronizationTable.column.details')"
> />
</ElTableColumn>
<template #empty>{{ <template #empty>{{
$locale.baseText('settings.ldap.synchronizationTable.empty.message') $locale.baseText('settings.ldap.synchronizationTable.empty.message')
}}</template> }}</template>
@ -197,12 +192,10 @@ type LDAPConfigForm = {
}; };
type CellClassStyleMethodParams<T> = { type CellClassStyleMethodParams<T> = {
data: { row: T;
row: T; rowIndex: number;
rowIndex: number; column: TableColumnCtx<T>;
column: TableColumnCtx<T>; columnIndex: number;
columnIndex: number;
};
}; };
export default defineComponent({ export default defineComponent({
@ -253,8 +246,7 @@ export default defineComponent({
goToUpgrade() { goToUpgrade() {
void this.uiStore.goToUpgrade('ldap', 'upgrade-ldap'); void this.uiStore.goToUpgrade('ldap', 'upgrade-ldap');
}, },
cellClassStyle({ data }: CellClassStyleMethodParams<TableRow>): CSSProperties { cellClassStyle({ row, column }: CellClassStyleMethodParams<TableRow>): CSSProperties {
const { row, column } = data;
if (column.property === 'status') { if (column.property === 'status') {
if (row.status === 'Success') { if (row.status === 'Success') {
return { color: 'green' }; return { color: 'green' };
@ -302,34 +294,33 @@ export default defineComponent({
async onSubmit(): Promise<void> { async onSubmit(): Promise<void> {
// We want to save all form values (incl. the hidden onces), so we are using // We want to save all form values (incl. the hidden onces), so we are using
// `values` data prop of the `FormInputs` child component since they are all preserved there // `values` data prop of the `FormInputs` child component since they are all preserved there
const formInputsRef = this.$refs.ldapConfigForm as { values: LDAPConfigForm }; const formInputsRef = this.$refs.ldapConfigForm as { getValues: () => LDAPConfigForm };
const formValues = formInputsRef.getValues();
if (!this.hasAnyChanges || !formInputsRef) { if (!this.hasAnyChanges || !formInputsRef) {
return; return;
} }
const newConfiguration: ILdapConfig = { const newConfiguration: ILdapConfig = {
loginEnabled: formInputsRef.values.loginEnabled, loginEnabled: formValues.loginEnabled,
loginLabel: formInputsRef.values.loginLabel, loginLabel: formValues.loginLabel,
connectionUrl: formInputsRef.values.serverAddress, connectionUrl: formValues.serverAddress,
allowUnauthorizedCerts: formInputsRef.values.allowUnauthorizedCerts, allowUnauthorizedCerts: formValues.allowUnauthorizedCerts,
connectionPort: +formInputsRef.values.port, connectionPort: +formValues.port,
connectionSecurity: formInputsRef.values.connectionSecurity, connectionSecurity: formValues.connectionSecurity,
baseDn: formInputsRef.values.baseDn, baseDn: formValues.baseDn,
bindingAdminDn: bindingAdminDn: formValues.bindingType === 'admin' ? formValues.adminDn : '',
formInputsRef.values.bindingType === 'admin' ? formInputsRef.values.adminDn : '', bindingAdminPassword: formValues.bindingType === 'admin' ? formValues.adminPassword : '',
bindingAdminPassword: emailAttribute: formValues.email,
formInputsRef.values.bindingType === 'admin' ? formInputsRef.values.adminPassword : '', firstNameAttribute: formValues.firstName,
emailAttribute: formInputsRef.values.email, lastNameAttribute: formValues.lastName,
firstNameAttribute: formInputsRef.values.firstName, loginIdAttribute: formValues.loginId,
lastNameAttribute: formInputsRef.values.lastName, ldapIdAttribute: formValues.ldapId,
loginIdAttribute: formInputsRef.values.loginId, userFilter: formValues.userFilter,
ldapIdAttribute: formInputsRef.values.ldapId, synchronizationEnabled: formValues.synchronizationEnabled,
userFilter: formInputsRef.values.userFilter, synchronizationInterval: +formValues.synchronizationInterval,
synchronizationEnabled: formInputsRef.values.synchronizationEnabled, searchPageSize: +formValues.pageSize,
synchronizationInterval: +formInputsRef.values.synchronizationInterval, searchTimeout: +formValues.searchTimeout,
searchPageSize: +formInputsRef.values.pageSize,
searchTimeout: +formInputsRef.values.searchTimeout,
}; };
let saveForm = true; let saveForm = true;