Skip to content

Commit

Permalink
Various type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scottybollinger committed Nov 19, 2020
1 parent e473203 commit ff4e4a3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -221,7 +222,7 @@ export const Overview: React.FC = () => {
};

const GroupsSummary = () => {
const GroupAvatars = ({ users }) => {
const GroupAvatars = ({ users }: { users: User[] }) => {
const MAX_USERS = 4;
return (
<EuiFlexGroup gutterSize="xs" alignItems="center">
Expand All @@ -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 || ''}
/>
</EuiFlexItem>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from '@elastic/eui';

import { CUSTOM_SOURCE_DOCS_URL } from '../../../routes';
import { SourceContentItem } from '../../../types';

import { TruncatedContent } from '../../../../shared/truncate';

Expand Down Expand Up @@ -115,7 +116,7 @@ export const SourceContent: React.FC = () => {
</EuiPanel>
);

const contentItem = (item) => {
const contentItem = (item: SourceContentItem) => {
const { id: itemId, last_updated: updated } = item;
const url = item[urlField] || '';
const title = item[titleField] || '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<HTMLInputElement>) => setValue(e.target.value);

const submitNameChange = (e) => {
const submitNameChange = (e: FormEvent) => {
e.preventDefault();
updateContentSource(id, { name: inputValue });
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -108,7 +114,7 @@ interface SourceValues {
dataLoading: boolean;
sectionLoading: boolean;
buttonLoading: boolean;
contentItems: object[];
contentItems: SourceContentItem[];
contentMeta: Meta;
contentFilterValue: string;
customSourceNameValue: string;
Expand All @@ -129,7 +135,7 @@ interface SourceValues {
}

interface SearchResultsResponse {
results: object[];
results: SourceContentItem[];
meta: Meta;
}

Expand Down

0 comments on commit ff4e4a3

Please sign in to comment.