-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial example: Convert RoleMappings views to new page template
- Refactor RoleMappingsHeadings to a fn that returns a pageHeader obj to match new page template + remove unnecessary type union + fix un-i18n'ed product names + simplify returned JSX
- Loading branch information
Showing
13 changed files
with
143 additions
and
162 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
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
41 changes: 41 additions & 0 deletions
41
...s/enterprise_search/public/applications/shared/role_mapping/role_mappings_header.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,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { EuiLink, EuiButton } from '@elastic/eui'; | ||
|
||
import { getRoleMappingsHeader } from './role_mappings_header'; | ||
|
||
describe('getRoleMappingsHeader', () => { | ||
const onClick = jest.fn(); | ||
const pageHeader = getRoleMappingsHeader({ productName: 'Workplace Search', onClick }); | ||
|
||
it('returns an EuiPageHeader object', () => { | ||
expect(pageHeader.pageTitle).toEqual('Role mappings'); | ||
}); | ||
|
||
it('renders the passed productName in the description', () => { | ||
const Description = () => <>{pageHeader.description}</>; | ||
const wrapper = shallow(<Description />); | ||
|
||
expect(wrapper.text()).toEqual( | ||
expect.stringContaining('role attributes with Workplace Search permissions') | ||
); | ||
expect(wrapper.find(EuiLink)).toHaveLength(1); | ||
}); | ||
|
||
it('renders an action button with a passed onClick', () => { | ||
const Button = () => <>{pageHeader.rightSideItems[0]}</>; | ||
const wrapper = shallow(<Button />); | ||
|
||
wrapper.find(EuiButton).simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...lugins/enterprise_search/public/applications/shared/role_mapping/role_mappings_header.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,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiButton, EuiLink } from '@elastic/eui'; | ||
|
||
import { | ||
ROLE_MAPPINGS_HEADING_TITLE, | ||
ROLE_MAPPINGS_HEADING_DESCRIPTION, | ||
ROLE_MAPPINGS_HEADING_DOCS_LINK, | ||
ROLE_MAPPINGS_HEADING_BUTTON, | ||
} from './constants'; | ||
|
||
interface Props { | ||
productName: string; | ||
onClick(): void; | ||
} | ||
|
||
// TODO: Replace EuiLink href with actual docs link when available | ||
const ROLE_MAPPINGS_DOCS_HREF = '#TODO'; | ||
|
||
export const getRoleMappingsHeader = ({ productName, onClick }: Props) => ({ | ||
pageTitle: ROLE_MAPPINGS_HEADING_TITLE, | ||
description: ( | ||
<> | ||
{ROLE_MAPPINGS_HEADING_DESCRIPTION(productName)}{' '} | ||
<EuiLink external href={ROLE_MAPPINGS_DOCS_HREF} target="_blank"> | ||
{ROLE_MAPPINGS_HEADING_DOCS_LINK} | ||
</EuiLink> | ||
</> | ||
), | ||
rightSideItems: [ | ||
<EuiButton fill onClick={onClick}> | ||
{ROLE_MAPPINGS_HEADING_BUTTON} | ||
</EuiButton>, | ||
], | ||
}); |
25 changes: 0 additions & 25 deletions
25
.../enterprise_search/public/applications/shared/role_mapping/role_mappings_heading.test.tsx
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
...ugins/enterprise_search/public/applications/shared/role_mapping/role_mappings_heading.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.