-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Migrate bucket span estimator button to EUI/React. #19045
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f3e6ed8
[ML] Migrate bucket span estimator button to React.
walterra 2b3a06b
[ML] Migrate the button itself to EUI.
walterra 302e2e0
[ML] Move import of component to line where angular template was impo…
walterra ea5e2c5
[ML] Added jest tests for the BucketSpanEstimator component.
walterra ec2b87e
[ML] Review feedback: Align function format. Remove unnecessary watch…
walterra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
49 changes: 49 additions & 0 deletions
49
...le/components/bucket_span_estimator/__snapshots__/bucket_span_estimator_view.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,49 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BucketSpanEstimator renders the button 1`] = ` | ||
<div | ||
className="bucket-span-estimator" | ||
> | ||
<EuiToolTip | ||
content="Experimental feature for estimating bucket span." | ||
position="bottom" | ||
> | ||
<EuiButton | ||
color="primary" | ||
disabled={true} | ||
fill={true} | ||
iconSide="right" | ||
isLoading={true} | ||
onClick={[Function]} | ||
size="s" | ||
type="button" | ||
> | ||
Estimating bucket span | ||
</EuiButton> | ||
</EuiToolTip> | ||
</div> | ||
`; | ||
|
||
exports[`BucketSpanEstimator renders the loading button 1`] = ` | ||
<div | ||
className="bucket-span-estimator" | ||
> | ||
<EuiToolTip | ||
content="Experimental feature for estimating bucket span." | ||
position="bottom" | ||
> | ||
<EuiButton | ||
color="primary" | ||
disabled={true} | ||
fill={true} | ||
iconSide="right" | ||
isLoading={true} | ||
onClick={[Function]} | ||
size="s" | ||
type="button" | ||
> | ||
Estimating bucket span | ||
</EuiButton> | ||
</EuiToolTip> | ||
</div> | ||
`; |
13 changes: 0 additions & 13 deletions
13
...ml/public/jobs/new_job/simple/components/bucket_span_estimator/bucket_span_estimator.html
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
42 changes: 42 additions & 0 deletions
42
...public/jobs/new_job/simple/components/bucket_span_estimator/bucket_span_estimator_view.js
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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import { | ||
EuiButton, | ||
EuiToolTip | ||
} from '@elastic/eui'; | ||
|
||
export function BucketSpanEstimator({ buttonDisabled, buttonText, estimatorRunning, guessBucketSpan }) { | ||
return ( | ||
<div className="bucket-span-estimator"> | ||
<EuiToolTip | ||
content="Experimental feature for estimating bucket span." | ||
position="bottom" | ||
> | ||
<EuiButton | ||
disabled={buttonDisabled} | ||
fill | ||
iconSide="right" | ||
isLoading={estimatorRunning} | ||
onClick={guessBucketSpan} | ||
size="s" | ||
> | ||
{buttonText} | ||
</EuiButton> | ||
</EuiToolTip> | ||
</div> | ||
); | ||
} | ||
BucketSpanEstimator.propTypes = { | ||
buttonDisabled: PropTypes.bool.isRequired, | ||
buttonText: PropTypes.string.isRequired, | ||
estimatorRunning: PropTypes.bool.isRequired, | ||
guessBucketSpan: PropTypes.func.isRequired | ||
}; | ||
|
38 changes: 38 additions & 0 deletions
38
...c/jobs/new_job/simple/components/bucket_span_estimator/bucket_span_estimator_view.test.js
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,38 @@ | ||
/* | ||
* 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 { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { BucketSpanEstimator } from './bucket_span_estimator_view'; | ||
|
||
describe('BucketSpanEstimator', () => { | ||
const props = { | ||
buttonDisabled: false, | ||
estimatorRunning: false, | ||
guessBucketSpan: () => {}, | ||
buttonText: 'Estimate bucket span' | ||
}; | ||
|
||
const component = ( | ||
<BucketSpanEstimator {...props} /> | ||
); | ||
|
||
const wrapper = shallow(component); | ||
|
||
test('renders the button', () => { | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
props.buttonDisabled = true; | ||
props.estimatorRunning = true; | ||
props.buttonText = 'Estimating bucket span'; | ||
wrapper.setProps(props); | ||
|
||
test('renders the loading button', () => { | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
19 changes: 9 additions & 10 deletions
19
...k/plugins/ml/public/jobs/new_job/simple/components/bucket_span_estimator/styles/main.less
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,15 +1,14 @@ | ||
.bucket-span-estimator { | ||
float: right; | ||
margin-right: 5px; | ||
margin-top: -27px; | ||
|
||
button { | ||
float: right; | ||
margin-right: 5px; | ||
margin-top: -27px; | ||
} | ||
button:disabled { | ||
background-color: #D9D9D9; | ||
} | ||
button.running { | ||
color: #2D2D2D; | ||
button.euiButton.euiButton--small { | ||
font-size: 12px; | ||
height: 22px; | ||
|
||
.euiButton__content { | ||
padding: 2px 8px 3px; | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this warning about it being an experimental feature is still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are adding in k-api tests shortly. I'm not sure how far we'll get in terms of depth of coverage in this release, so let's keep as experimental till we have a stronger set of data scenario tests.