Skip to content

Commit e7ff3a6

Browse files
[Workplace Search] Migrate SourceLogic from ent-search (#83593)
* 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
1 parent b63830f commit e7ff3a6

File tree

4 files changed

+696
-2
lines changed

4 files changed

+696
-2
lines changed

x-pack/plugins/enterprise_search/public/applications/workplace_search/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { CURRENT_MAJOR_VERSION } from '../../../common/version';
1010

1111
export const SETUP_GUIDE_PATH = '/setup_guide';
1212

13+
export const NOT_FOUND_PATH = '/404';
14+
1315
export const LEAVE_FEEDBACK_EMAIL = '[email protected]';
1416
export const LEAVE_FEEDBACK_URL = `mailto:${LEAVE_FEEDBACK_EMAIL}?Subject=Elastic%20Workplace%20Search%20Feedback`;
1517

x-pack/plugins/enterprise_search/public/applications/workplace_search/types.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ export * from '../../../common/types/workplace_search';
88

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

11+
export interface MetaPage {
12+
current: number;
13+
size: number;
14+
total_pages: number;
15+
total_results: number;
16+
}
17+
18+
export interface Meta {
19+
page: MetaPage;
20+
}
21+
1122
export interface Group {
1223
id: string;
1324
name: string;
@@ -89,6 +100,30 @@ export interface ContentSourceDetails extends ContentSource {
89100
boost: number;
90101
}
91102

103+
interface DescriptionList {
104+
title: string;
105+
description: string;
106+
}
107+
108+
export interface ContentSourceFullData extends ContentSourceDetails {
109+
activities: object[];
110+
details: DescriptionList[];
111+
summary: object[];
112+
groups: object[];
113+
custom: boolean;
114+
accessToken: string;
115+
key: string;
116+
urlField: string;
117+
titleField: string;
118+
licenseSupportsPermissions: boolean;
119+
serviceTypeSupportsPermissions: boolean;
120+
indexPermissions: boolean;
121+
hasPermissions: boolean;
122+
urlFieldIsLinkable: boolean;
123+
createdAt: string;
124+
serviceName: string;
125+
}
126+
92127
export interface ContentSourceStatus {
93128
id: string;
94129
name: string;
@@ -121,3 +156,10 @@ export enum FeatureIds {
121156
GlobalAccessPermissions = 'GlobalAccessPermissions',
122157
DocumentLevelPermissions = 'DocumentLevelPermissions',
123158
}
159+
160+
export interface CustomSource {
161+
accessToken: string;
162+
key: string;
163+
name: string;
164+
id: string;
165+
}

0 commit comments

Comments
 (0)