Skip to content

Commit

Permalink
Rename kibana_breadcrumbs to kibana_chrome
Browse files Browse the repository at this point in the history
- in anticipation of upcoming refactor where SetPageChrome now handles document title as well as Kibana breadcrumbs
+ cleanup exports
  • Loading branch information
cee-chen committed Aug 5, 2020
1 parent 47b9aba commit 818f30e
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiPage, EuiPageBody, EuiPageContent, EuiEmptyPrompt, EuiButton } from
import { FormattedMessage } from '@kbn/i18n/react';

import { sendTelemetry } from '../../../shared/telemetry';
import { SetAppSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { KibanaContext, IKibanaContext } from '../../../index';

import { EngineOverviewHeader } from '../engine_overview_header';
Expand All @@ -33,7 +33,7 @@ export const EmptyState: React.FC = () => {

return (
<EuiPage restrictWidth>
<SetBreadcrumbs isRoot />
<SetPageChrome isRoot />

<EuiPageBody>
<EngineOverviewHeader />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import { EuiPage, EuiPageBody, EuiPageContent } from '@elastic/eui';

import { ErrorStatePrompt } from '../../../shared/error_state';
import { SetAppSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendAppSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { EngineOverviewHeader } from '../engine_overview_header';

Expand All @@ -17,7 +17,7 @@ import './empty_states.scss';
export const ErrorState: React.FC = () => {
return (
<EuiPage restrictWidth>
<SetBreadcrumbs isRoot />
<SetPageChrome isRoot />
<SendTelemetry action="error" metric="cannot_connect" />

<EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import React from 'react';
import { EuiPage, EuiPageBody, EuiPageContent, EuiSpacer, EuiLoadingContent } from '@elastic/eui';

import { SetAppSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { EngineOverviewHeader } from '../engine_overview_header';

import './empty_states.scss';

export const LoadingState: React.FC = () => {
return (
<EuiPage restrictWidth>
<SetBreadcrumbs isRoot />
<SetPageChrome isRoot />

<EuiPageBody>
<EngineOverviewHeader />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

import { SetAppSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendAppSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { LicenseContext, ILicenseContext, hasPlatinumLicense } from '../../../shared/licensing';
import { KibanaContext, IKibanaContext } from '../../../index';
Expand Down Expand Up @@ -93,7 +93,7 @@ export const EngineOverview: React.FC = () => {

return (
<EuiPage restrictWidth className="engineOverview">
<SetBreadcrumbs isRoot />
<SetPageChrome isRoot />
<SendTelemetry action="viewed" metric="engines_overview" />

<EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import { SetAppSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SetupGuide as SetupGuideLayout } from '../../../shared/setup_guide';
import { SetupGuide } from './';

Expand All @@ -16,6 +16,6 @@ describe('SetupGuide', () => {
const wrapper = shallow(<SetupGuide />);

expect(wrapper.find(SetupGuideLayout)).toHaveLength(1);
expect(wrapper.find(SetBreadcrumbs)).toHaveLength(1);
expect(wrapper.find(SetPageChrome)).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';

import { APP_SEARCH_PLUGIN } from '../../../../../common/constants';
import { SetupGuide as SetupGuideLayout } from '../../../shared/setup_guide';
import { SetAppSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendAppSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import GettingStarted from '../../assets/getting_started.png';

Expand All @@ -22,7 +22,7 @@ export const SetupGuide: React.FC = () => (
standardAuthLink="https://swiftype.com/documentation/app-search/self-managed/security#standard"
elasticsearchNativeAuthLink="https://swiftype.com/documentation/app-search/self-managed/security#elasticsearch-native-realm"
>
<SetBreadcrumbs
<SetPageChrome
text={i18n.translate('xpack.enterpriseSearch.setupGuide.title', {
defaultMessage: 'Setup Guide',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { generateBreadcrumb } from './generate_breadcrumbs';
import { appSearchBreadcrumbs, enterpriseSearchBreadcrumbs, workplaceSearchBreadcrumbs } from './';
import {
generateBreadcrumb,
appSearchBreadcrumbs,
enterpriseSearchBreadcrumbs,
workplaceSearchBreadcrumbs,
} from './generate_breadcrumbs';

import { mockHistory as mockHistoryUntyped } from '../../__mocks__';
const mockHistory = mockHistoryUntyped as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export {
enterpriseSearchBreadcrumbs,
appSearchBreadcrumbs,
workplaceSearchBreadcrumbs,
} from './generate_breadcrumbs';
export { SetAppSearchBreadcrumbs, SetWorkplaceSearchBreadcrumbs } from './set_breadcrumbs';
export { SetAppSearchChrome, SetWorkplaceSearchChrome } from './set_chrome';
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import '../../__mocks__/react_router_history.mock';
import { mountWithKibanaContext } from '../../__mocks__';

jest.mock('./generate_breadcrumbs', () => ({ appSearchBreadcrumbs: jest.fn() }));
import { appSearchBreadcrumbs, SetAppSearchBreadcrumbs } from './';
import { appSearchBreadcrumbs } from './generate_breadcrumbs';
import { SetAppSearchChrome } from './';

describe('SetAppSearchBreadcrumbs', () => {
describe('SetAppSearchChrome', () => {
const setBreadcrumbs = jest.fn();
const builtBreadcrumbs = [] as any;
const appSearchBreadCrumbsInnerCall = jest.fn().mockReturnValue(builtBreadcrumbs);
Expand All @@ -23,16 +24,16 @@ describe('SetAppSearchBreadcrumbs', () => {
jest.clearAllMocks();
});

const mountSetAppSearchBreadcrumbs = (props: any) => {
return mountWithKibanaContext(<SetAppSearchBreadcrumbs {...props} />, {
const mountSetAppSearchChrome = (props: any) => {
return mountWithKibanaContext(<SetAppSearchChrome {...props} />, {
http: {},
enterpriseSearchUrl: 'http://localhost:3002',
setBreadcrumbs,
});
};

describe('when isRoot is false', () => {
const subject = () => mountSetAppSearchBreadcrumbs({ text: 'Page 1', isRoot: false });
const subject = () => mountSetAppSearchChrome({ text: 'Page 1', isRoot: false });

it('calls appSearchBreadcrumbs to build breadcrumbs, then registers them with Kibana', () => {
subject();
Expand All @@ -48,7 +49,7 @@ describe('SetAppSearchBreadcrumbs', () => {
});

describe('when isRoot is true', () => {
const subject = () => mountSetAppSearchBreadcrumbs({ text: 'Page 1', isRoot: true });
const subject = () => mountSetAppSearchChrome({ text: 'Page 1', isRoot: true });

it('calls appSearchBreadcrumbs to build breadcrumbs with an empty breadcrumb, then registers them with Kibana', () => {
subject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from './generate_breadcrumbs';

/**
* Small on-mount helper for setting Kibana's chrome breadcrumbs on any App Search view
* Helpers for setting Kibana chrome (breadcrumbs, doc titles) on React view mount
* @see https://github.com/elastic/kibana/blob/master/src/core/public/chrome/chrome_service.tsx
*/

Expand All @@ -31,7 +31,7 @@ interface IRootBreadcrumbsProps {
}
type TBreadcrumbsProps = IBreadcrumbsProps | IRootBreadcrumbsProps;

export const SetAppSearchBreadcrumbs: React.FC<TBreadcrumbsProps> = ({ text, isRoot }) => {
export const SetAppSearchChrome: React.FC<TBreadcrumbsProps> = ({ text, isRoot }) => {
const history = useHistory();
const { setBreadcrumbs } = useContext(KibanaContext) as IKibanaContext;

Expand All @@ -44,7 +44,7 @@ export const SetAppSearchBreadcrumbs: React.FC<TBreadcrumbsProps> = ({ text, isR
return null;
};

export const SetWorkplaceSearchBreadcrumbs: React.FC<TBreadcrumbsProps> = ({ text, isRoot }) => {
export const SetWorkplaceSearchChrome: React.FC<TBreadcrumbsProps> = ({ text, isRoot }) => {
const history = useHistory();
const { setBreadcrumbs } = useContext(KibanaContext) as IKibanaContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { EuiPage, EuiPageBody, EuiPageContent } from '@elastic/eui';

import { WORKPLACE_SEARCH_PLUGIN } from '../../../../../common/constants';
import { ErrorStatePrompt } from '../../../shared/error_state';
import { SetWorkplaceSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { ViewContentHeader } from '../shared/view_content_header';

export const ErrorState: React.FC = () => {
return (
<EuiPage restrictWidth>
<SetBreadcrumbs isRoot />
<SetPageChrome isRoot />
<SendTelemetry action="error" metric="cannot_connect" />

<EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiPage, EuiPageBody, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useActions, useValues } from 'kea';

import { SetWorkplaceSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { KibanaContext, IKibanaContext } from '../../../index';

Expand Down Expand Up @@ -72,7 +72,7 @@ export const Overview: React.FC = () => {

return (
<EuiPage restrictWidth>
<SetBreadcrumbs isRoot />
<SetPageChrome isRoot />
<SendTelemetry action="viewed" metric="overview" />

<EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import { SetWorkplaceSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SetupGuide as SetupGuideLayout } from '../../../shared/setup_guide';
import { SetupGuide } from './';

Expand All @@ -16,6 +16,6 @@ describe('SetupGuide', () => {
const wrapper = shallow(<SetupGuide />);

expect(wrapper.find(SetupGuideLayout)).toHaveLength(1);
expect(wrapper.find(SetBreadcrumbs)).toHaveLength(1);
expect(wrapper.find(SetPageChrome)).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';

import { WORKPLACE_SEARCH_PLUGIN } from '../../../../../common/constants';
import { SetupGuide as SetupGuideLayout } from '../../../shared/setup_guide';
import { SetWorkplaceSearchBreadcrumbs as SetBreadcrumbs } from '../../../shared/kibana_breadcrumbs';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import GettingStarted from '../../assets/getting_started.png';

Expand All @@ -26,7 +26,7 @@ export const SetupGuide: React.FC = () => {
standardAuthLink="https://www.elastic.co/guide/en/workplace-search/current/workplace-search-security.html#standard"
elasticsearchNativeAuthLink="https://www.elastic.co/guide/en/workplace-search/current/workplace-search-security.html#elasticsearch-native-realm"
>
<SetBreadcrumbs
<SetPageChrome
text={i18n.translate('xpack.enterpriseSearch.setupGuide.title', {
defaultMessage: 'Setup Guide',
})}
Expand Down

0 comments on commit 818f30e

Please sign in to comment.