-
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
De-angularize and EUI-ficate Discover Context control elements #44474
Merged
kertal
merged 37 commits into
elastic:master
from
kertal:kertal-pr-convert-context-size-picker-to-react
Sep 10, 2019
+382
−401
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
031fcd5
Convert context loading button to react
kertal 45cf0e8
Use react component, remove angular code
kertal 1017a98
Create SizePicker react component
kertal 44ace83
Add more Eui components
kertal c2b535c
Merge branch 'kertal-pr-convert-context-loading-button-to-react' into…
kertal b12b5c2
Merge LoadingButton and SizePicker to ActionBar
kertal 2b9a38f
Merge remote-tracking branch 'upstream/master' into kertal-pr-convert…
kertal db36c16
Merge remote-tracking branch 'upstream/master' into kertal-pr-convert…
kertal 6e7c45d
Rename scss + fix unused path
kertal 923c481
Fix wrong scss import
kertal e8235b8
Adapt notes
kertal 0996392
Adapt warning messages
kertal 14ad456
Adapt older documents warning
kertal 2db71e7
Add jest tests
kertal affb021
Merge remote-tracking branch 'upstream/master' into kertal-pr-convert…
kertal 5ecc2c3
Visual and Textual changes
kertal 283dced
Adapt Load button
kertal 354b29a
vertical alignment and copy changes
ryankeairns 5bbad0d
Merge pull request #1 from ryankeairns/kertal-pr-convert-context-size…
kertal 7d1bc5f
Extract warnings to component
kertal 766acec
Merge branch 'kertal-pr-convert-context-size-picker-to-react' of gith…
kertal 582cf91
Fix invalid warningDocCount assignment
kertal ca2f0f7
Fix translations, add comments
kertal 919a616
Switch older / younger warnings
kertal ce441dd
Remove step size of input and defaultStepSize
kertal b1c38ae
Merge remote-tracking branch 'upstream/master' into kertal-pr-convert…
kertal 9534a11
Replace ActionBarType with SurrDocType + depended adaptions
kertal b130215
Use valueAsNumber instead of Number(value)
kertal 9be7528
Add comment about CSS number input
kertal 42c0ae5
Fix types in app.html
kertal 0e3a0b5
Debounce input
kertal 1f71e88
Migrate constants + state to typescript
kertal 59ecff6
Merge remote-tracking branch 'upstream/master' into kertal-pr-convert…
kertal b72f197
Implement original behavior of input
kertal 81aeb3b
Remove unused increaseCount functions + tests
kertal 4070444
Improve check of valid inputs in the range of (MIN|MAX)_CONTEXT_SIZE
kertal 3e2facb
Improve tests
kertal 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
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
10 changes: 10 additions & 0 deletions
10
src/legacy/core_plugins/kibana/public/context/components/action_bar/_action_bar.scss
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,10 @@ | ||
.cxtSizePicker { | ||
text-align: center; | ||
width: $euiSize * 5; | ||
|
||
&::-webkit-outer-spin-button, | ||
&::-webkit-inner-spin-button { | ||
appearance: none; // Hide increment and decrement buttons for type="number" input. | ||
margin: 0; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/legacy/core_plugins/kibana/public/context/components/action_bar/_index.scss
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 @@ | ||
@import './action_bar'; |
94 changes: 94 additions & 0 deletions
94
src/legacy/core_plugins/kibana/public/context/components/action_bar/action_bar.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,94 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { ActionBar, ActionBarProps } from './action_bar'; | ||
// @ts-ignore | ||
import { findTestSubject } from '@elastic/eui/lib/test'; | ||
import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../query_parameters/constants'; | ||
|
||
describe('Test Discover Context ActionBar for successor | predecessor records', () => { | ||
['successors', 'predecessors'].forEach(type => { | ||
const onChangeCount = jest.fn(); | ||
const props = { | ||
defaultStepSize: 5, | ||
docCount: 20, | ||
docCountAvailable: 0, | ||
isDisabled: false, | ||
isLoading: false, | ||
onChangeCount, | ||
type, | ||
} as ActionBarProps; | ||
const wrapper = mountWithIntl(<ActionBar {...props} />); | ||
|
||
const input = findTestSubject(wrapper, `${type}CountPicker`); | ||
const btn = findTestSubject(wrapper, `${type}LoadMoreButton`); | ||
|
||
test(`${type}: Load button click`, () => { | ||
btn.simulate('click'); | ||
expect(onChangeCount).toHaveBeenCalledWith(25); | ||
}); | ||
|
||
test(`${type}: Load button click doesnt submit when MAX_CONTEXT_SIZE was reached`, () => { | ||
onChangeCount.mockClear(); | ||
input.simulate('change', { target: { valueAsNumber: MAX_CONTEXT_SIZE } }); | ||
btn.simulate('click'); | ||
expect(onChangeCount).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
test(`${type}: Count input change submits on blur`, () => { | ||
input.simulate('change', { target: { valueAsNumber: 123 } }); | ||
input.simulate('blur'); | ||
expect(onChangeCount).toHaveBeenCalledWith(123); | ||
}); | ||
|
||
test(`${type}: Count input change submits on return`, () => { | ||
input.simulate('change', { target: { valueAsNumber: 124 } }); | ||
input.simulate('submit'); | ||
expect(onChangeCount).toHaveBeenCalledWith(124); | ||
}); | ||
|
||
test(`${type}: Count input doesnt submits values higher than MAX_CONTEXT_SIZE `, () => { | ||
onChangeCount.mockClear(); | ||
input.simulate('change', { target: { valueAsNumber: MAX_CONTEXT_SIZE + 1 } }); | ||
input.simulate('submit'); | ||
expect(onChangeCount).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
test(`${type}: Count input doesnt submits values lower than MIN_CONTEXT_SIZE `, () => { | ||
onChangeCount.mockClear(); | ||
input.simulate('change', { target: { valueAsNumber: MIN_CONTEXT_SIZE - 1 } }); | ||
input.simulate('submit'); | ||
expect(onChangeCount).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
test(`${type}: Warning about limitation of additional records`, () => { | ||
if (type === 'predecessors') { | ||
expect(findTestSubject(wrapper, 'predecessorsWarningMsg').text()).toBe( | ||
'No documents newer than the anchor could be found.' | ||
); | ||
} else { | ||
expect(findTestSubject(wrapper, 'successorsWarningMsg').text()).toBe( | ||
'No documents older than the anchor could be found.' | ||
); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
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.
Not super important and I might be wrong about that, but isn't
predecessors
andsuccessors
used the wrong way? A predecessor isa thing that has been followed or replaced by another.
, so this should be the older documents, right? But here it is fetching the newer ones.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.
exactly, here predecessor are the docs that are displayed before the anchor, but I also do agree. I'd go with e.g.
newer
,older
, I think then there are no more questions open. However, there's much more to refactor in this case, functions etc.that's why I kept this heritage for now (but I'd like to change it in a future refactoring)