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.
[ML] Converts Settings page to react (elastic#27144)
* Replace settings page with react directive * Adds test for Settings component * add calendar permission check * Update settings test * Remove outdated angular settings tests
- Loading branch information
1 parent
7379e1e
commit 681e7ae
Showing
9 changed files
with
275 additions
and
143 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
x-pack/plugins/ml/public/settings/__snapshots__/settings.test.js.snap
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,74 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Settings Renders settings page 1`] = ` | ||
<EuiPage | ||
className="mlSettingsPage" | ||
restrictWidth={false} | ||
> | ||
<EuiPageBody | ||
className="mlSettingsPage__body" | ||
restrictWidth={false} | ||
> | ||
<EuiPageContent | ||
className="mlSettingsPage__content" | ||
horizontalPosition="center" | ||
panelPaddingSize="l" | ||
> | ||
<EuiPageContentHeader | ||
responsive={true} | ||
> | ||
<EuiTitle | ||
size="m" | ||
textTransform="none" | ||
> | ||
<h2> | ||
Job Management | ||
</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeader> | ||
<EuiFlexGroup | ||
alignItems="stretch" | ||
component="div" | ||
direction="row" | ||
gutterSize="xl" | ||
justifyContent="flexStart" | ||
responsive={true} | ||
wrap={false} | ||
> | ||
<EuiFlexItem | ||
component="div" | ||
grow={false} | ||
> | ||
<EuiButtonEmpty | ||
color="primary" | ||
data-testid="ml_calendar_mng_button" | ||
href="undefined/app/ml#/settings/calendars_list" | ||
iconSide="left" | ||
isDisabled={false} | ||
size="l" | ||
type="button" | ||
> | ||
Calendar management | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
<EuiFlexItem | ||
component="div" | ||
grow={false} | ||
> | ||
<EuiButtonEmpty | ||
color="primary" | ||
data-testid="ml_filter_lists_button" | ||
href="undefined/app/ml#/settings/filter_lists" | ||
iconSide="left" | ||
isDisabled={false} | ||
size="l" | ||
type="button" | ||
> | ||
Filter Lists | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPageContent> | ||
</EuiPageBody> | ||
</EuiPage> | ||
`; |
29 changes: 0 additions & 29 deletions
29
x-pack/plugins/ml/public/settings/__tests__/settings_controller.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
.disabled { | ||
color: $euiColorMediumShade; | ||
cursor: pointer; | ||
} | ||
.mlSettingsPage { | ||
|
||
ml-settings { | ||
.mgtPanel { | ||
.mgtPanel__link { | ||
font-size: $euiFontSizeM; | ||
line-height: $euiSizeXL; | ||
margin-left: $euiSizeXS; | ||
} | ||
.mlSettingsPage__body { | ||
background: $euiColorLightestShade; | ||
min-height: 100vh; | ||
} | ||
|
||
.disabled { | ||
color: $euiColorMediumShade; | ||
} | ||
.mlSettingsPage__content { | ||
width: map-get($euiBreakpoints, 'xl'); | ||
margin-top: $euiSize; | ||
margin-bottom: $euiSize; | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
|
||
|
||
|
||
import './settings_controller'; | ||
import './settings_directive'; | ||
import './calendars'; | ||
import './filter_lists'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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 { PropTypes } from 'prop-types'; | ||
|
||
import { | ||
EuiButtonEmpty, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiPage, | ||
EuiPageContentHeader, | ||
EuiPageContent, | ||
EuiPageBody, | ||
EuiTitle | ||
} from '@elastic/eui'; | ||
|
||
import chrome from 'ui/chrome'; | ||
|
||
|
||
export function Settings({ canCreateFilter, canCreateCalendar }) { | ||
return ( | ||
<EuiPage className="mlSettingsPage"> | ||
<EuiPageBody className="mlSettingsPage__body"> | ||
<EuiPageContent | ||
className="mlSettingsPage__content" | ||
horizontalPosition="center" | ||
> | ||
<EuiPageContentHeader> | ||
<EuiTitle> | ||
<h2>Job Management</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeader> | ||
|
||
<EuiFlexGroup gutterSize="xl"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty | ||
data-testid="ml_calendar_mng_button" | ||
size="l" | ||
color="primary" | ||
href={`${chrome.getBasePath()}/app/ml#/settings/calendars_list`} | ||
isDisabled={canCreateCalendar === false} | ||
> | ||
Calendar management | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty | ||
data-testid="ml_filter_lists_button" | ||
size="l" | ||
color="primary" | ||
href={`${chrome.getBasePath()}/app/ml#/settings/filter_lists`} | ||
isDisabled={canCreateFilter === false} | ||
> | ||
Filter Lists | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
</EuiPageContent> | ||
</EuiPageBody> | ||
</EuiPage> | ||
); | ||
} | ||
|
||
Settings.propTypes = { | ||
canCreateFilter: PropTypes.bool.isRequired, | ||
canCreateCalendar: PropTypes.bool.isRequired, | ||
}; |
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,49 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
|
||
|
||
jest.mock('ui/chrome', () => ({ | ||
getBasePath: jest.fn() | ||
})); | ||
|
||
import { shallow, mount } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { Settings } from './settings'; | ||
|
||
|
||
describe('Settings', () => { | ||
|
||
test('Renders settings page', () => { | ||
const wrapper = shallow( | ||
<Settings canCreateFilter={true} canCreateCalendar={true}/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('Filter Lists button disabled if canCreateFilter is false', () => { | ||
const wrapper = mount( | ||
<Settings canCreateFilter={false} canCreateCalendar={true}/> | ||
); | ||
|
||
const button = wrapper.find('[data-testid="ml_filter_lists_button"]'); | ||
const filterButton = button.find('EuiButtonEmpty'); | ||
expect(filterButton.prop('isDisabled')).toBe(true); | ||
}); | ||
|
||
test('Calendar management button disabled if canCreateCalendar is false', () => { | ||
const wrapper = mount( | ||
<Settings canCreateFilter={true} canCreateCalendar={false} /> | ||
); | ||
|
||
const button = wrapper.find('[data-testid="ml_calendar_mng_button"]'); | ||
const calendarButton = button.find('EuiButtonEmpty'); | ||
expect(calendarButton.prop('isDisabled')).toBe(true); | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.