From ff4e4a3f40b5ceed631a9bd1ebdc060853cf924a Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Thu, 19 Nov 2020 12:53:04 -0600 Subject: [PATCH] Various type fixes --- .../applications/workplace_search/types.ts | 24 ++++++++++++++++--- .../content_sources/components/overview.tsx | 5 ++-- .../components/source_content.tsx | 3 ++- .../components/source_settings.tsx | 6 ++--- .../views/content_sources/source_logic.ts | 14 +++++++---- 5 files changed, 39 insertions(+), 13 deletions(-) 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..73e7f7ed701d8 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 @@ -88,6 +88,12 @@ export interface ContentSource { name: string; } +export interface SourceContentItem { + id: string; + last_updated: string; + [key: string]: string; +} + export interface ContentSourceDetails extends ContentSource { status: string; statusMessage: string; @@ -105,11 +111,23 @@ interface DescriptionList { description: string; } +export interface DocumentSummaryItem { + count: number; + type: string; +} + +interface SourceActivity { + details: string[]; + event: string; + time: string; + status: string; +} + export interface ContentSourceFullData extends ContentSourceDetails { - activities: object[]; + activities: SourceActivity[]; details: DescriptionList[]; - summary: object[]; - groups: object[]; + summary: DocumentSummaryItem[]; + groups: Group[]; custom: boolean; accessToken: string; key: string; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.tsx index 2f9596589588c..8dbec9fa8b8fd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.tsx @@ -42,6 +42,7 @@ import { } from '../../../routes'; import { AppLogic } from '../../../app_logic'; +import { User } from '../../../types'; import { ComponentLoader } from '../../../components/shared/component_loader'; import { CredentialItem } from '../../../components/shared/credential_item'; @@ -221,7 +222,7 @@ export const Overview: React.FC = () => { }; const GroupsSummary = () => { - const GroupAvatars = ({ users }) => { + const GroupAvatars = ({ users }: { users: User[] }) => { const MAX_USERS = 4; return ( @@ -231,7 +232,7 @@ export const Overview: React.FC = () => { size="s" initials={user.initials} name={user.name || user.initials} - imageUrl={user.pictureUrl} + imageUrl={user.pictureUrl || ''} /> ))} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.tsx index ccef724500d94..3f289a6394131 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.tsx @@ -29,6 +29,7 @@ import { } from '@elastic/eui'; import { CUSTOM_SOURCE_DOCS_URL } from '../../../routes'; +import { SourceContentItem } from '../../../types'; import { TruncatedContent } from '../../../../shared/truncate'; @@ -115,7 +116,7 @@ export const SourceContent: React.FC = () => { ); - const contentItem = (item) => { + const contentItem = (item: SourceContentItem) => { const { id: itemId, last_updated: updated } = item; const url = item[urlField] || ''; const title = item[titleField] || ''; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.tsx index 25f8d04aa106e..1f756115e3ae4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, ChangeEvent, FormEvent } from 'react'; import { History } from 'history'; import { useActions, useValues } from 'kea'; @@ -70,9 +70,9 @@ export const SourceSettings: React.FC = () => { const { clientId, clientSecret, publicKey, consumerKey, baseUrl } = configuredFields || {}; - const handleNameChange = (e) => setValue(e.target.value); + const handleNameChange = (e: ChangeEvent) => setValue(e.target.value); - const submitNameChange = (e) => { + const submitNameChange = (e: FormEvent) => { e.preventDefault(); updateContentSource(id, { name: inputValue }); }; 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 889519b8a9985..0a11da02dc789 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 @@ -23,7 +23,13 @@ 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, + DocumentSummaryItem, + SourceContentItem, +} from '../../types'; export interface SourceActions { onInitializeSource(contentSource: ContentSourceFullData): ContentSourceFullData; @@ -32,7 +38,7 @@ export interface SourceActions { setSourceConnectData(sourceConnectData: SourceConnectData): SourceConnectData; setSearchResults(searchResultsResponse: SearchResultsResponse): SearchResultsResponse; initializeFederatedSummary(sourceId: string): { sourceId: string }; - onUpdateSummary(summary: object[]): object[]; + onUpdateSummary(summary: DocumentSummaryItem[]): DocumentSummaryItem[]; setContentFilterValue(contentFilterValue: string): string; setActivePage(activePage: number): number; setClientIdValue(clientIdValue: string): string; @@ -108,7 +114,7 @@ interface SourceValues { dataLoading: boolean; sectionLoading: boolean; buttonLoading: boolean; - contentItems: object[]; + contentItems: SourceContentItem[]; contentMeta: Meta; contentFilterValue: string; customSourceNameValue: string; @@ -129,7 +135,7 @@ interface SourceValues { } interface SearchResultsResponse { - results: object[]; + results: SourceContentItem[]; meta: Meta; }