mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(editor): Fix type errors in the SettingsLdapView.vue
(no-changelog) (#9308)
This commit is contained in:
parent
22b6f90950
commit
552cf8f3db
|
@ -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;
|
||||
};
|
||||
|
|
16
packages/editor-ui/src/v3-infinite-loading.d.ts
vendored
Normal file
16
packages/editor-ui/src/v3-infinite-loading.d.ts
vendored
Normal file
|
@ -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;
|
||||
}
|
|
@ -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';
|
||||
|
@ -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;
|
||||
|
@ -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: {
|
||||
|
@ -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 {
|
||||
|
@ -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' };
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue