Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enterprise Search] Share Loading component #83246

Merged
merged 5 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jest.mock('../../../shared/flash_messages', () => ({
}));
import { setQueuedErrorMessage } from '../../../shared/flash_messages';

import { Loading } from '../loading';

import { EngineRouter } from './';

describe('EngineRouter', () => {
Expand Down Expand Up @@ -59,10 +61,10 @@ describe('EngineRouter', () => {
);
});

it('does not render if async data is still loading', () => {
it('renders a loading component if async data is still loading', () => {
setMockValues({ ...values, dataLoading: true });
const wrapper = shallow(<EngineRouter />);
expect(wrapper.isEmptyRender()).toBe(true);
expect(wrapper.find(Loading)).toHaveLength(1);
});

it('renders a default engine overview', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import {
// API_LOGS_TITLE,
} from './constants';

import { Loading } from '../loading';

import { EngineLogic } from './';

export const EngineRouter: React.FC = () => {
Expand Down Expand Up @@ -86,7 +88,9 @@ export const EngineRouter: React.FC = () => {
return <Redirect to={ENGINES_PATH} />;
}

if (dataLoading) return null;
if (dataLoading) {
return <Loading />;
}
cee-chen marked this conversation as resolved.
Show resolved Hide resolved

return (
<Switch>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { Loading } from './loading';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

.enterpriseSearchLoading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';

import { EuiLoadingSpinner } from '@elastic/eui';

import { Loading } from './';

describe('Loading', () => {
it('renders', () => {
const wrapper = shallow(<Loading />);
expect(wrapper.find(EuiLoadingSpinner)).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { EuiLoadingSpinner } from '@elastic/eui';

import './loading.scss';

export const Loading: React.FC = () => (
<div className="enterpriseSearchLoading">
<EuiLoadingSpinner size="xl" />
</div>
);