forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Set up Workplace Search header action menu, creat…
…e reusable renderHeaderActions (elastic#78050) (elastic#78099) * Create reusable renderHeaderActions - I put it in the same file as renderApp, since both functions behave similarly (one renders in the main Kibana app/body, the other renders in Kibana's header) - slightly opinionated: renamed renderActionMenu to renderHeaderActions from Kibana's examples * Add example renderHeaderActions usage * Add example WorkplaceSearchHeaderActions component - not sure if this should be where it lives or is exported from, feel free to change @scottybollinger * Update WorkplaceSearchHeaderActions with realistic functionality - pass required externalUrl helper as arg/prop - TODO: Consider refactoring KibanaContext to a Kea store so that we can share it across our renderApp and renderHeaderActions * Fix type errors
- Loading branch information
Constance
authored
Sep 22, 2020
1 parent
be7ae56
commit c95956f
Showing
6 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...rch/public/applications/workplace_search/components/layout/kibana_header_actions.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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 { EuiButtonEmpty } from '@elastic/eui'; | ||
import { ExternalUrl } from '../../../shared/enterprise_search_url'; | ||
|
||
import { WorkplaceSearchHeaderActions } from './'; | ||
|
||
describe('WorkplaceSearchHeaderActions', () => { | ||
const externalUrl = new ExternalUrl('http://localhost:3002'); | ||
|
||
it('renders a link to the search application', () => { | ||
const wrapper = shallow(<WorkplaceSearchHeaderActions externalUrl={externalUrl} />); | ||
|
||
expect(wrapper.find(EuiButtonEmpty).prop('href')).toEqual('http://localhost:3002/ws/search'); | ||
}); | ||
|
||
it('does not render without an Enterprise Search host URL set', () => { | ||
const wrapper = shallow(<WorkplaceSearchHeaderActions externalUrl={{} as any} />); | ||
|
||
expect(wrapper.isEmptyRender()).toBe(true); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
...e_search/public/applications/workplace_search/components/layout/kibana_header_actions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { EuiButtonEmpty } from '@elastic/eui'; | ||
|
||
import { IExternalUrl } from '../../../shared/enterprise_search_url'; | ||
|
||
interface IProps { | ||
externalUrl: IExternalUrl; | ||
} | ||
|
||
export const WorkplaceSearchHeaderActions: React.FC<IProps> = ({ externalUrl }) => { | ||
const { enterpriseSearchUrl, getWorkplaceSearchUrl } = externalUrl; | ||
if (!enterpriseSearchUrl) return null; | ||
|
||
return ( | ||
<EuiButtonEmpty href={getWorkplaceSearchUrl('/search')} target="_blank" iconType="search"> | ||
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.headerActions.searchApplication', { | ||
defaultMessage: 'Go to search application', | ||
})} | ||
</EuiButtonEmpty> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters