Skip to content

Commit

Permalink
Rename engine_overview folder to engines
Browse files Browse the repository at this point in the history
- To better match ent-search folder structure
- Also rename/clarify pluralization of "Engines" where possible, to distinguish between individual Engine Overview pages
  • Loading branch information
cee-chen committed Nov 5, 2020
1 parent 074ef6f commit 69dd473
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getAppSearchUrl } from '../../../../shared/enterprise_search_url';
import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { CREATE_ENGINES_PATH } from '../../../routes';

import { EngineOverviewHeader } from './header';
import { EnginesOverviewHeader } from './header';

import './empty_state.scss';

Expand All @@ -34,7 +34,7 @@ export const EmptyState: React.FC = () => {
return (
<>
<SetPageChrome />
<EngineOverviewHeader />
<EnginesOverviewHeader />
<EuiPageContent className="emptyState">
<EuiEmptyPrompt
className="emptyState__prompt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import { mockTelemetryActions } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';

import { EngineOverviewHeader } from './';
import { EnginesOverviewHeader } from './';

describe('EngineOverviewHeader', () => {
describe('EnginesOverviewHeader', () => {
it('renders', () => {
const wrapper = shallow(<EngineOverviewHeader />);
const wrapper = shallow(<EnginesOverviewHeader />);
expect(wrapper.find('h1')).toHaveLength(1);
});

it('renders a launch app search button that sends telemetry on click', () => {
const wrapper = shallow(<EngineOverviewHeader />);
const wrapper = shallow(<EnginesOverviewHeader />);
const button = wrapper.find('[data-test-subj="launchButton"]');

expect(button.prop('href')).toBe('http://localhost:3002/as');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { TelemetryLogic } from '../../../../shared/telemetry';
import { getAppSearchUrl } from '../../../../shared/enterprise_search_url';

export const EngineOverviewHeader: React.FC = () => {
export const EnginesOverviewHeader: React.FC = () => {
const { sendAppSearchTelemetry } = useActions(TelemetryLogic);

const buttonProps = {
Expand All @@ -42,7 +42,7 @@ export const EngineOverviewHeader: React.FC = () => {
<h1>
<FormattedMessage
id="xpack.enterpriseSearch.appSearch.enginesOverview.title"
defaultMessage="Engine Overview"
defaultMessage="Engines Overview"
/>
</h1>
</EuiTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { EngineOverviewHeader } from './header';
export { EnginesOverviewHeader } from './header';
export { LoadingState } from './loading_state';
export { EmptyState } from './empty_state';
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import React from 'react';
import { EuiPageContent, EuiSpacer, EuiLoadingContent } from '@elastic/eui';

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

export const LoadingState: React.FC = () => {
return (
<>
<SetPageChrome />
<EngineOverviewHeader />
<EnginesOverviewHeader />
<EuiPageContent paddingSize="l">
<EuiLoadingContent lines={5} />
<EuiSpacer size="xxl" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

.engineOverview {
.enginesOverview {
padding: $euiSize;

@include euiBreakpoint('m', 'l', 'xl') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { shallow, ReactWrapper } from 'enzyme';
import { mountAsync, mockHttpValues, setMockValues } from '../../../__mocks__';

import { LoadingState, EmptyState } from './components';
import { EngineTable } from './engine_table';
import { EnginesTable } from './engines_table';

import { EngineOverview } from './';
import { EnginesOverview } from './';

describe('EngineOverview', () => {
describe('EnginesOverview', () => {
describe('non-happy-path states', () => {
it('isLoading', () => {
const wrapper = shallow(<EngineOverview />);
const wrapper = shallow(<EnginesOverview />);

expect(wrapper.find(LoadingState)).toHaveLength(1);
});
Expand All @@ -36,7 +36,7 @@ describe('EngineOverview', () => {
}),
},
});
const wrapper = await mountAsync(<EngineOverview />, { i18n: true });
const wrapper = await mountAsync(<EnginesOverview />, { i18n: true });

expect(wrapper.find(EmptyState)).toHaveLength(1);
});
Expand Down Expand Up @@ -69,9 +69,9 @@ describe('EngineOverview', () => {
});

it('renders and calls the engines API', async () => {
const wrapper = await mountAsync(<EngineOverview />, { i18n: true });
const wrapper = await mountAsync(<EnginesOverview />, { i18n: true });

expect(wrapper.find(EngineTable)).toHaveLength(1);
expect(wrapper.find(EnginesTable)).toHaveLength(1);
expect(mockApi).toHaveBeenNthCalledWith(1, '/api/app_search/engines', {
query: {
type: 'indexed',
Expand All @@ -86,9 +86,9 @@ describe('EngineOverview', () => {
hasPlatinumLicense: true,
http: { ...mockHttpValues.http, get: mockApi },
});
const wrapper = await mountAsync(<EngineOverview />, { i18n: true });
const wrapper = await mountAsync(<EnginesOverview />, { i18n: true });

expect(wrapper.find(EngineTable)).toHaveLength(2);
expect(wrapper.find(EnginesTable)).toHaveLength(2);
expect(mockApi).toHaveBeenNthCalledWith(2, '/api/app_search/engines', {
query: {
type: 'meta',
Expand All @@ -100,18 +100,18 @@ describe('EngineOverview', () => {

describe('pagination', () => {
const getTablePagination = (wrapper: ReactWrapper) =>
wrapper.find(EngineTable).prop('pagination');
wrapper.find(EnginesTable).prop('pagination');

it('passes down page data from the API', async () => {
const wrapper = await mountAsync(<EngineOverview />, { i18n: true });
const wrapper = await mountAsync(<EnginesOverview />, { i18n: true });
const pagination = getTablePagination(wrapper);

expect(pagination.totalEngines).toEqual(100);
expect(pagination.pageIndex).toEqual(0);
});

it('re-polls the API on page change', async () => {
const wrapper = await mountAsync(<EngineOverview />, { i18n: true });
const wrapper = await mountAsync(<EnginesOverview />, { i18n: true });
await act(async () => getTablePagination(wrapper).onPaginate(5));
wrapper.update();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import { LicensingLogic } from '../../../shared/licensing';
import { EngineIcon } from './assets/engine_icon';
import { MetaEngineIcon } from './assets/meta_engine_icon';

import { EngineOverviewHeader, LoadingState, EmptyState } from './components';
import { EngineTable } from './engine_table';
import { EnginesOverviewHeader, LoadingState, EmptyState } from './components';
import { EnginesTable } from './engines_table';

import './engine_overview.scss';
import './engines_overview.scss';

interface IGetEnginesParams {
type: string;
Expand All @@ -38,7 +38,7 @@ interface ISetEnginesCallbacks {
setResultsTotal: React.Dispatch<React.SetStateAction<number>>;
}

export const EngineOverview: React.FC = () => {
export const EnginesOverview: React.FC = () => {
const { http } = useValues(HttpLogic);
const { hasPlatinumLicense } = useValues(LicensingLogic);

Expand Down Expand Up @@ -88,8 +88,8 @@ export const EngineOverview: React.FC = () => {
<SetPageChrome />
<SendTelemetry action="viewed" metric="engines_overview" />

<EngineOverviewHeader />
<EuiPageContent panelPaddingSize="s" className="engineOverview">
<EnginesOverviewHeader />
<EuiPageContent panelPaddingSize="s" className="enginesOverview">
<FlashMessages />
<EuiPageContentHeader>
<EuiTitle size="s">
Expand All @@ -102,7 +102,7 @@ export const EngineOverview: React.FC = () => {
</EuiTitle>
</EuiPageContentHeader>
<EuiPageContentBody data-test-subj="appSearchEngines">
<EngineTable
<EnginesTable
data={engines}
pagination={{
totalEngines: enginesTotal,
Expand All @@ -126,7 +126,7 @@ export const EngineOverview: React.FC = () => {
</EuiTitle>
</EuiPageContentHeader>
<EuiPageContentBody data-test-subj="appSearchMetaEngines">
<EngineTable
<EnginesTable
data={metaEngines}
pagination={{
totalEngines: metaEnginesTotal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import React from 'react';
import { EuiBasicTable, EuiPagination, EuiButtonEmpty } from '@elastic/eui';
import { EuiLink } from '../../../shared/react_router_helpers';

import { EngineTable } from './engine_table';
import { EnginesTable } from './engines_table';

describe('EngineTable', () => {
describe('EnginesTable', () => {
const onPaginate = jest.fn(); // onPaginate updates the engines API call upstream

const wrapper = mountWithIntl(
<EngineTable
<EnginesTable
data={[
{
name: 'test-engine',
Expand Down Expand Up @@ -71,7 +71,10 @@ describe('EngineTable', () => {

it('handles empty data', () => {
const emptyWrapper = mountWithIntl(
<EngineTable data={[]} pagination={{ totalEngines: 0, pageIndex: 0, onPaginate: () => {} }} />
<EnginesTable
data={[]}
pagination={{ totalEngines: 0, pageIndex: 0, onPaginate: () => {} }}
/>
);
const emptyTable = emptyWrapper.find(EuiBasicTable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ import { getEngineRoute } from '../../routes';

import { ENGINES_PAGE_SIZE } from '../../../../../common/constants';

export interface IEngineTableData {
interface IEnginesTableData {
name: string;
created_at: string;
document_count: number;
field_count: number;
}
export interface IEngineTablePagination {
interface IEnginesTablePagination {
totalEngines: number;
pageIndex: number;
onPaginate(pageIndex: number): void;
}
export interface IEngineTableProps {
data: IEngineTableData[];
pagination: IEngineTablePagination;
interface IEnginesTableProps {
data: IEnginesTableData[];
pagination: IEnginesTablePagination;
}
export interface IOnChange {
interface IOnChange {
page: {
index: number;
};
}

export const EngineTable: React.FC<IEngineTableProps> = ({
export const EnginesTable: React.FC<IEnginesTableProps> = ({
data,
pagination: { totalEngines, pageIndex, onPaginate },
}) => {
Expand All @@ -52,7 +52,7 @@ export const EngineTable: React.FC<IEngineTableProps> = ({
}),
});

const columns: Array<EuiBasicTableColumn<IEngineTableData>> = [
const columns: Array<EuiBasicTableColumn<IEnginesTableData>> = [
{
field: 'name',
name: i18n.translate('xpack.enterpriseSearch.appSearch.enginesOverview.table.column.name', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { EngineOverview } from './engine_overview';
export { EnginesOverview } from './engines_overview';
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { shallow } from 'enzyme';
import { Layout, SideNav, SideNavLink } from '../shared/layout';
import { SetupGuide } from './components/setup_guide';
import { ErrorConnecting } from './components/error_connecting';
import { EngineOverview } from './components/engine_overview';
import { EnginesOverview } from './components/engines';
import { EngineRouter } from './components/engine';
import { AppSearch, AppSearchUnconfigured, AppSearchConfigured, AppSearchNav } from './';

Expand Down Expand Up @@ -57,7 +57,7 @@ describe('AppSearchConfigured', () => {

expect(wrapper.find(Layout)).toHaveLength(2);
expect(wrapper.find(Layout).last().prop('readOnlyMode')).toBeFalsy();
expect(wrapper.find(EngineOverview)).toHaveLength(1);
expect(wrapper.find(EnginesOverview)).toHaveLength(1);
expect(wrapper.find(EngineRouter)).toHaveLength(1);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import { SetupGuide } from './components/setup_guide';
import { ErrorConnecting } from './components/error_connecting';
import { NotFound } from '../shared/not_found';
import { EngineOverview } from './components/engine_overview';
import { EnginesOverview } from './components/engines';
import { Settings } from './components/settings';
import { Credentials } from './components/credentials';

Expand Down Expand Up @@ -82,7 +82,7 @@ export const AppSearchConfigured: React.FC<IInitialAppData> = (props) => {
<Redirect to={ENGINES_PATH} />
</Route>
<Route exact path={ENGINES_PATH}>
<EngineOverview />
<EnginesOverview />
</Route>
<Route exact path={SETTINGS_PATH}>
<Settings />
Expand Down

0 comments on commit 69dd473

Please sign in to comment.