Controls Visualization - Dates shown in milliseconds AFTER dates selection#25654
Merged
nreese merged 5 commits intoelastic:masterfrom Nov 23, 2018
Merged
Controls Visualization - Dates shown in milliseconds AFTER dates selection#25654nreese merged 5 commits intoelastic:masterfrom
nreese merged 5 commits intoelastic:masterfrom
Conversation
Contributor
💔 Build Failed |
Contributor
💚 Build Succeeded |
Contributor
💔 Build Failed |
Contributor
Author
|
jenkins, test this |
Contributor
💚 Build Succeeded |
markov00
approved these changes
Nov 23, 2018
Contributor
markov00
left a comment
There was a problem hiding this comment.
Code LGTM. Tested on chrome/osx and this fix correctly the bug.
I've just added a minor comment on code readability.
| .sort((a, b) => { | ||
| return a.label.toLowerCase().localeCompare(b.label.toLowerCase()); | ||
| }) | ||
| } |
Contributor
There was a problem hiding this comment.
nit: Why you have moved this map in the JSX? Don't you think it loose a bit of readability if written here?
| label: this.props.formatOptionLabel(selectedOption).toString(), | ||
| value: selectedOption, | ||
| }; | ||
| })} |
Contributor
There was a problem hiding this comment.
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)
Contributor
💚 Build Succeeded |
nreese
added a commit
to nreese/kibana
that referenced
this pull request
Nov 23, 2018
…ction (elastic#25654) * use field format to create label * make sure labels are strings so sort does not throw exceptions * move map out of jsx block
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #25111
The problem was occurring because when the selected options where retrieved from the Kibana filter pill, the label was not formatted by the field formatter.
ListControlreact component expectedoptionsandselectedOptionsto contain already formatted labels. This made this bug easy to introduce since formatting needed to be applied in multiple locations.This PR resolves the issue by generating the labels (with the field formatter) in a single place. Instead of passing around
{ value: 'foo', label: 'formatted foo' }, the list control now just passes around['foo']and the label is created when needed by the UI.