-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Controls Visualization - Dates shown in milliseconds AFTER dates selection #25654
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
24407f0
use field format to create label
nreese 03086f4
Merge branch 'master' of github.com:elastic/kibana into issue-25111
nreese ca49927
make sure labels are strings so sort does not throw exceptions
nreese 90c2518
Merge branch 'master' of github.com:elastic/kibana into issue-25111
nreese 1c2ffc2
move map out of jsx block
nreese 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -43,7 +43,10 @@ class ListControlUi extends Component { | |
| } | ||
|
|
||
| handleOnChange = (selectedOptions) => { | ||
| this.props.stageFilter(this.props.controlIndex, selectedOptions); | ||
| const selectedValues = selectedOptions.map(({ value }) => { | ||
| return value; | ||
| }); | ||
| this.props.stageFilter(this.props.controlIndex, selectedValues); | ||
| } | ||
|
|
||
| debouncedFetch = _.debounce(async (searchValue) => { | ||
|
|
@@ -77,25 +80,32 @@ class ListControlUi extends Component { | |
| ); | ||
| } | ||
|
|
||
| const options = this.props.options.map(option => { | ||
| return { | ||
| label: option.label, | ||
| value: option.value, | ||
| ['data-test-subj']: `option_${option.value.replace(' ', '_')}` | ||
| }; | ||
| }); | ||
|
|
||
| return ( | ||
| <EuiComboBox | ||
| placeholder={intl.formatMessage({ | ||
| id: 'inputControl.vis.listControl.selectPlaceholder', | ||
| defaultMessage: 'Select...' | ||
| })} | ||
| options={options} | ||
| options={this.props.options.map(option => { | ||
| return { | ||
| label: this.props.formatOptionLabel(option).toString(), | ||
| value: option, | ||
| ['data-test-subj']: `option_${option.toString().replace(' ', '_')}` | ||
| }; | ||
| }) | ||
| .sort((a, b) => { | ||
| return a.label.toLowerCase().localeCompare(b.label.toLowerCase()); | ||
| }) | ||
| } | ||
| isLoading={this.state.isLoading} | ||
| async={this.props.dynamicOptions} | ||
| onSearchChange={this.props.dynamicOptions ? this.onSearchChange : undefined} | ||
| selectedOptions={this.props.selectedOptions} | ||
| selectedOptions={this.props.selectedOptions.map(selectedOption => { | ||
| return { | ||
| label: this.props.formatOptionLabel(selectedOption).toString(), | ||
| value: selectedOption, | ||
| }; | ||
| })} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same as the comment above. You an also write an helper function like: function formatOptions(optionList, formatter, dataTestSubjPrefix, sorted) {
const formattedOptionList = optionList.map(value => {
const formattedOption = {
label: formatter(value).toString(),
value,
};
if (dataTestSubjPrefix ) {
formattedOption['data-test-subj'] = `${dataTestSubjPrefix}_${value.toString().replace(' ', '_')}`;
}
return formattedOption;
});
if (sorted) {
return formattedOptionList.sort((a, b) => {
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
})
}
return formattedOptionList;
}
const options = formatOptions(this.props.options, this.props.formatOptionLabel, 'option', true)
const selectedOptions = formatOptions(this.props.selectedOptions, this.props.formatOptionLabel) |
||
| onChange={this.handleOnChange} | ||
| singleSelection={!this.props.multiselect} | ||
| data-test-subj={`listControlSelect${this.props.controlIndex}`} | ||
|
|
@@ -117,16 +127,12 @@ class ListControlUi extends Component { | |
| } | ||
| } | ||
|
|
||
| const comboBoxOptionShape = PropTypes.shape({ | ||
| label: PropTypes.string.isRequired, | ||
| value: PropTypes.string.isRequired, | ||
| }); | ||
|
|
||
| ListControlUi.propTypes = { | ||
| id: PropTypes.string.isRequired, | ||
| label: PropTypes.string.isRequired, | ||
| selectedOptions: PropTypes.arrayOf(comboBoxOptionShape).isRequired, | ||
| options: PropTypes.arrayOf(comboBoxOptionShape), | ||
| selectedOptions: PropTypes.array.isRequired, | ||
| options: PropTypes.array, | ||
| formatOptionLabel: PropTypes.func.isRequired, | ||
| disableMsg: PropTypes.string, | ||
| multiselect: PropTypes.bool, | ||
| dynamicOptions: PropTypes.bool, | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
nit: Why you have moved this map in the JSX? Don't you think it loose a bit of readability if written here?