diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/types.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/types.ts index 1bd3cabb0227d..8b51a64006a2a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/types.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/types.ts @@ -163,3 +163,9 @@ export interface CustomSource { name: string; id: string; } + +export type AnyType = string | number | boolean | object | undefined | null; + +export interface GenericObject { + [key: string]: AnyType | AnyType[]; +} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.ts index e1b7a649bc45a..26876bd8c99c6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.ts @@ -21,7 +21,7 @@ import { import { DEFAULT_META } from '../../../shared/constants'; import { AppLogic } from '../../app_logic'; import { NOT_FOUND_PATH } from '../../routes'; -import { ContentSourceFullData, CustomSource, Meta } from '../../types'; +import { ContentSourceFullData, CustomSource, Meta, GenericObject } from '../../types'; export interface SourceActions { onInitializeSource(contentSource: ContentSourceFullData): ContentSourceFullData; @@ -118,8 +118,7 @@ interface SourceValues { newCustomSource: CustomSource; currentServiceType: string; githubOrganizations: string[]; - selectedGithubOrganizationsMap: object; - selectedGithubOrganizations: object; + selectedGithubOrganizationsMap: GenericObject; selectedGithubOrganizations: string[]; } @@ -345,13 +344,13 @@ export const SourceLogic = kea>({ }, ], selectedGithubOrganizationsMap: [ - {}, + {} as GenericObject, { - setSelectedGithubOrganizations: (state, option) => ({ + setSelectedGithubOrganizations: (state: GenericObject, option) => ({ ...state, ...{ [option]: !state[option] }, }), - resetSourceState: () => [], + resetSourceState: () => ({}), }, ], }, @@ -562,7 +561,7 @@ export const SourceLogic = kea>({ password: passwordValue || undefined, organizations: githubOrganizations.length > 0 ? githubOrganizations : undefined, indexPermissions: indexPermissionsValue || undefined, - }; + } as GenericObject; // Remove undefined values from params Object.keys(params).forEach((key) => params[key] === undefined && delete params[key]);