Skip to content

Commit

Permalink
[Fleet] Handle errors happenning during Fleet setup in the UI (#87185) (
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Jan 5, 2021
1 parent 5bb0186 commit 7877aaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface FleetStatusState {
enabled: boolean;
isLoading: boolean;
isReady: boolean;
error?: Error;
missingRequirements?: GetFleetStatusResponse['missing_requirements'];
}

Expand Down Expand Up @@ -44,7 +45,7 @@ export const FleetStatusProvider: React.FC = ({ children }) => {
missingRequirements: res.data?.missing_requirements,
}));
} catch (error) {
setState((s) => ({ ...s, isLoading: true }));
setState((s) => ({ ...s, isLoading: false, error }));
}
}
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { PAGE_ROUTING_PATHS } from '../../constants';
import { Loading } from '../../components';
import { Loading, Error } from '../../components';
import { useConfig, useFleetStatus, useBreadcrumbs, useCapabilities } from '../../hooks';
import { AgentListPage } from './agent_list_page';
import { SetupPage } from './setup_page';
import { AgentDetailsPage } from './agent_details_page';
import { NoAccessPage } from './error_pages/no_access';
import { EnrollmentTokenListPage } from './enrollment_token_list_page';
import { ListLayout } from './components/list_layout';
import { WithoutHeaderLayout } from '../../layouts';

export const FleetApp: React.FunctionComponent = () => {
useBreadcrumbs('fleet');
Expand All @@ -27,6 +29,22 @@ export const FleetApp: React.FunctionComponent = () => {
return <Loading />;
}

if (fleetStatus.error) {
return (
<WithoutHeaderLayout>
<Error
title={
<FormattedMessage
id="xpack.fleet.agentsInitializationErrorMessageTitle"
defaultMessage="Unable to initialize central management for Elastic Agents"
/>
}
error={fleetStatus.error}
/>
</WithoutHeaderLayout>
);
}

if (fleetStatus.isReady === false) {
return (
<SetupPage
Expand Down

0 comments on commit 7877aaf

Please sign in to comment.