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(editor): Fix type errors in the SettingsLdapView.vue (no-changelog) #9308

Merged
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
1 change: 1 addition & 0 deletions packages/design-system/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type IFormInput = {
disabled?: boolean;
labelSize?: 'small' | 'medium' | 'large';
labelAlignment?: 'left' | 'right' | 'center';
tooltipText?: string;
};
shouldDisplay?: (values: { [key: string]: unknown }) => boolean;
};
Expand Down
16 changes: 16 additions & 0 deletions packages/editor-ui/src/v3-infinite-loading.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
declare module 'v3-infinite-loading' {
import { Plugin, DefineComponent } from 'vue';

interface InfiniteLoadingProps {
target: string;
}

export interface Events {
infinite: (state: { loaded: () => void; complete: () => void }) => void;
}

const InfiniteLoading: DefineComponent<InfiniteLoadingProps, {}, {}, {}, {}, {}, {}, Events> &
Plugin;

export default InfiniteLoading;
}
55 changes: 44 additions & 11 deletions packages/editor-ui/src/views/SettingsLdapView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
</template>

<script lang="ts">
import type { CSSProperties } from 'vue';
import { defineComponent } from 'vue';
import { capitalizeFirstLetter } from '@/utils/htmlUtils';
import { convertToDisplayDate } from '@/utils/typesUtils';
Expand All @@ -155,16 +156,14 @@ import { MODAL_CONFIRM } from '@/constants';

import humanizeDuration from 'humanize-duration';
import { ElTable, ElTableColumn } from 'element-plus';
import type { Events } from 'v3-infinite-loading';
import InfiniteLoading from 'v3-infinite-loading';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store';
import { useSettingsStore } from '@/stores/settings.store';
import { useUIStore } from '@/stores/ui.store';
import { createEventBus } from 'n8n-design-system/utils';
import type { N8nFormInputs } from 'n8n-design-system';
import type { CellStyle } from 'element-plus';

type N8nFormInputsRef = InstanceType<typeof N8nFormInputs>;
import type { TableColumnCtx } from 'element-plus';

type TableRow = {
status: string;
Expand All @@ -174,6 +173,38 @@ type TableRow = {
runMode: string;
};

type LDAPConfigForm = {
loginEnabled: boolean;
loginLabel: string;
serverAddress: string;
allowUnauthorizedCerts: boolean;
port: number;
connectionSecurity: string;
baseDn: string;
bindingType: 'admin' | 'anonymous';
adminDn: string;
adminPassword: string;
email: string;
firstName: string;
lastName: string;
loginId: string;
ldapId: string;
userFilter: string;
synchronizationEnabled: boolean;
synchronizationInterval: string;
pageSize: string;
searchTimeout: string;
};

type CellClassStyleMethodParams<T> = {
data: {
row: T;
rowIndex: number;
column: TableColumnCtx<T>;
columnIndex: number;
};
};

export default defineComponent({
name: 'SettingsLdapView',
components: {
Expand Down Expand Up @@ -205,10 +236,6 @@ export default defineComponent({
syncEnabled: false,
};
},
async mounted() {
if (!this.isLDAPFeatureEnabled) return;
await this.getLdapConfig();
},
computed: {
...mapStores(useUsersStore, useSettingsStore, useUIStore),
currentUser(): null | IUser {
Expand All @@ -218,11 +245,16 @@ export default defineComponent({
return this.settingsStore.settings.enterprise.ldap;
},
},
async mounted() {
if (!this.isLDAPFeatureEnabled) return;
await this.getLdapConfig();
},
methods: {
goToUpgrade() {
void this.uiStore.goToUpgrade('ldap', 'upgrade-ldap');
},
cellClassStyle({ row, column }: CellStyle<TableRow>) {
cellClassStyle({ data }: CellClassStyleMethodParams<TableRow>): CSSProperties {
const { row, column } = data;
if (column.property === 'status') {
if (row.status === 'Success') {
return { color: 'green' };
Expand Down Expand Up @@ -270,7 +302,8 @@ export default defineComponent({
async onSubmit(): Promise<void> {
// 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
const formInputsRef = this.$refs.ldapConfigForm as N8nFormInputsRef | undefined;
const formInputsRef = this.$refs.ldapConfigForm as { values: LDAPConfigForm };

if (!this.hasAnyChanges || !formInputsRef) {
return;
}
Expand Down Expand Up @@ -681,7 +714,7 @@ export default defineComponent({
this.showError(error, this.$locale.baseText('settings.ldap.configurationError'));
}
},
async getLdapSynchronizations(state: { loaded: () => void; complete: () => void }) {
async getLdapSynchronizations(state: Parameters<Events['infinite']>[0]) {
try {
this.loadingTable = true;
const data = await this.settingsStore.getLdapSynchronizations({
Expand Down
Loading