Skip to content

Commit

Permalink
RESET ME
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Sep 11, 2020
1 parent 2b949c5 commit 0638823
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, { useContext } from 'react';
import { EuiPageContent, EuiEmptyPrompt, EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

import { FlashMessages } from '../../../../shared/flash_messages';
import { sendTelemetry } from '../../../../shared/telemetry';
import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { KibanaContext, IKibanaContext } from '../../../../index';
Expand Down Expand Up @@ -40,6 +41,7 @@ export const EmptyState: React.FC = () => {
<SetPageChrome isRoot />
<EngineOverviewHeader />
<EuiPageContent className="emptyState">
<FlashMessages />
<EuiEmptyPrompt
className="emptyState__prompt"
iconType="eyeClosed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from 'react';
import { EuiPageContent, EuiSpacer, EuiLoadingContent } from '@elastic/eui';

import { FlashMessages } from '../../../../shared/flash_messages';
import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { EngineOverviewHeader } from './header';

Expand All @@ -16,6 +17,7 @@ export const LoadingState: React.FC = () => {
<SetPageChrome isRoot />
<EngineOverviewHeader />
<EuiPageContent paddingSize="l">
<FlashMessages />
<EuiLoadingContent lines={5} />
<EuiSpacer size="xxl" />
<EuiLoadingContent lines={4} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { FormattedMessage } from '@kbn/i18n/react';

import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendAppSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { FlashMessages } from '../../../shared/flash_messages';
import { FlashMessages, handleAPIError } from '../../../shared/flash_messages';
import { LicenseContext, ILicenseContext, hasPlatinumLicense } from '../../../shared/licensing';
import { KibanaContext, IKibanaContext } from '../../../index';

Expand Down Expand Up @@ -50,9 +50,14 @@ export const EngineOverview: React.FC = () => {
const [metaEnginesTotal, setMetaEnginesTotal] = useState(0);

const getEnginesData = async ({ type, pageIndex }: IGetEnginesParams) => {
return await http.get('/api/app_search/engines', {
query: { type, pageIndex },
});
try {
return await http.get('/api/app_search/engines', {
query: { type, pageIndex },
});
} catch (e) {
setIsLoading(false);
handleAPIError(e);
}
};
const setEnginesData = async (params: IGetEnginesParams, callbacks: ISetEnginesCallbacks) => {
const response = await getEnginesData(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export {
IFlashMessagesActions,
} from './flash_messages_logic';
export { FlashMessagesProvider } from './flash_messages_provider';
export { handleAPIError } from './handle_api_errors';
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useActions, useValues } from 'kea';

import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { FlashMessages } from '../../../shared/flash_messages';

import { OverviewLogic } from './overview_logic';

Expand Down Expand Up @@ -58,7 +59,7 @@ export const Overview: React.FC = () => {
initializeOverview();
}, [initializeOverview]);

if (dataLoading) return <Loading />;
// if (dataLoading) return <Loading />;

const hideOnboarding = hasUsers && hasOrgSources && isOldAccount && orgName !== defaultOrgName;

Expand All @@ -76,6 +77,7 @@ export const Overview: React.FC = () => {
description={headerDescription}
action={<ProductButton />}
/>
<FlashMessages />
{!hideOnboarding && <OnboardingSteps />}
<EuiSpacer size="xl" />
<OrganizationStats />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { kea, MakeLogicType } from 'kea';
import { HttpLogic } from '../../../shared/http';
import { handleAPIError } from '../../../shared/flash_messages';

import { IAccount, IOrganization } from '../../types';

Expand Down Expand Up @@ -129,8 +130,12 @@ export const OverviewLogic = kea<MakeLogicType<IOverviewValues, IOverviewActions
},
listeners: ({ actions }) => ({
initializeOverview: async () => {
const response = await HttpLogic.values.http.get('/api/workplace_search/overview');
actions.setServerData(response);
try {
const response = await HttpLogic.values.http.get('/api/workplace_search/overview');
actions.setServerData(response);
} catch (e) {
handleAPIError(e);
}
},
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export function registerEnginesRoute({
const { type, pageIndex } = request.query;

return enterpriseSearchRequestHandler.createRequest({
path: '/as/engines/collection',
// path: '/as/engines/collection',
// path: '/as/engines/wtf/details', // 404 w no message
path: '/as/engines/test/curations/cur-doesntexist.json', // 404 w error message
// path: '/as/engines/test/synonyms/collection', // 500
params: {
type,
'page[current]': pageIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function registerWSOverviewRoute({
validate: false,
},
enterpriseSearchRequestHandler.createRequest({
path: '/ws/org',
path: '/as/engines/test/curations/cur-doesntexist.json',
hasValidData: (body: { accountsCount: number }) => typeof body?.accountsCount === 'number',
})
);
Expand Down

0 comments on commit 0638823

Please sign in to comment.