Skip to content

Commit

Permalink
[Workplace Search] Migrate SourceLogic from ent-search (#83593)
Browse files Browse the repository at this point in the history
* Initial copy/paste of source logic

Only changed lodash imports and import order for linting

* Add types and route

* Update paths and typings

Renamed IMeta -> Meta
Used object instead of IObject

* Remove internal flash messages in favor of globals

- All instances of flashAPIErrors(e) are only placeholders until the later commit removing axios.

- buttonLoading was set to false when the error flash messages were set. For now I added a `setButtonNotLoading` action to do this manually in a finally block. This will be refactored once axios is removed.

- SourcesLogic is no longer needed because we set a queued flash message instead of trying to set it in SourcesLogic, which no longer has local flash messages

* Add return types to callback definitions

* Update routes

According to the API info getSourceReConnectData is supposed to send the source ID and not the service type. In the template, we are actually sending the ID but the logic file parameterizes it as serviceType. This is fixed here.

Usage: https://github.com/elastic/ent-search/blob/master/app/javascript/workplace_search/ContentSources/components/AddSource/ReAuthenticate.tsx#L38

* Replace axios with HttpLogic

Also removes using history in favor of KibanaLogic’s navigateToUrl

* Fix incorrect type

This selector is actually an array of strings

* Create GenericObject to satisfy TypeScript

Previously in `ent-search`, we had a generic `IObject` interface that we could use on keyed objects. It was not migrated over since it uses `any` and Kibana has a generic `object` type we can use in most situations. However, when we are checking for keys in our code, `object` does not work. This commit is an attempt at making a generic interface we can use.

* More strict object typing

Removes GenericObject from last commit and adds stricter local typing

* Add i18n

Also added for already-merged SourcesLogic

* Move button loading action to finally block

* Move route strings to inline
  • Loading branch information
scottybollinger authored Nov 18, 2020
1 parent b63830f commit e7ff3a6
Show file tree
Hide file tree
Showing 4 changed files with 696 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { CURRENT_MAJOR_VERSION } from '../../../common/version';

export const SETUP_GUIDE_PATH = '/setup_guide';

export const NOT_FOUND_PATH = '/404';

export const LEAVE_FEEDBACK_EMAIL = '[email protected]';
export const LEAVE_FEEDBACK_URL = `mailto:${LEAVE_FEEDBACK_EMAIL}?Subject=Elastic%20Workplace%20Search%20Feedback`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ export * from '../../../common/types/workplace_search';

export type SpacerSizeTypes = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';

export interface MetaPage {
current: number;
size: number;
total_pages: number;
total_results: number;
}

export interface Meta {
page: MetaPage;
}

export interface Group {
id: string;
name: string;
Expand Down Expand Up @@ -89,6 +100,30 @@ export interface ContentSourceDetails extends ContentSource {
boost: number;
}

interface DescriptionList {
title: string;
description: string;
}

export interface ContentSourceFullData extends ContentSourceDetails {
activities: object[];
details: DescriptionList[];
summary: object[];
groups: object[];
custom: boolean;
accessToken: string;
key: string;
urlField: string;
titleField: string;
licenseSupportsPermissions: boolean;
serviceTypeSupportsPermissions: boolean;
indexPermissions: boolean;
hasPermissions: boolean;
urlFieldIsLinkable: boolean;
createdAt: string;
serviceName: string;
}

export interface ContentSourceStatus {
id: string;
name: string;
Expand Down Expand Up @@ -121,3 +156,10 @@ export enum FeatureIds {
GlobalAccessPermissions = 'GlobalAccessPermissions',
DocumentLevelPermissions = 'DocumentLevelPermissions',
}

export interface CustomSource {
accessToken: string;
key: string;
name: string;
id: string;
}
Loading

0 comments on commit e7ff3a6

Please sign in to comment.