-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Lens] Custom labels for ranges #79628
Changes from all commits
f35b205
a8505b3
0407327
41cbf19
0f24e71
26a4334
1e3b9a3
2a4d8f0
7b2769b
9d1dfe6
4a51b81
5ca9b6f
051b93f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [Range](./kibana-plugin-plugins-expressions-public.range.md) > [label](./kibana-plugin-plugins-expressions-public.range.label.md) | ||
|
||
## Range.label property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
label?: string; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [Range](./kibana-plugin-plugins-expressions-server.range.md) > [label](./kibana-plugin-plugins-expressions-server.range.label.md) | ||
|
||
## Range.label property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
label?: string; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,12 @@ import { keys } from '@elastic/eui'; | |
import { IFieldFormat } from '../../../../../../../../src/plugins/data/common'; | ||
import { RangeTypeLens, isValidRange, isValidNumber } from './ranges'; | ||
import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; | ||
import { NewBucketButton, DragDropBuckets, DraggableBucketContainer } from '../shared_components'; | ||
import { | ||
NewBucketButton, | ||
DragDropBuckets, | ||
DraggableBucketContainer, | ||
LabelInput, | ||
} from '../shared_components'; | ||
|
||
const generateId = htmlIdGenerator(); | ||
|
||
|
@@ -63,7 +68,7 @@ export const RangePopover = ({ | |
// send the range back to the main state | ||
setRange(newRange); | ||
}; | ||
const { from, to } = tempRange; | ||
const { from, to, label } = tempRange; | ||
|
||
const lteAppendLabel = i18n.translate('xpack.lens.indexPattern.ranges.lessThanOrEqualAppend', { | ||
defaultMessage: '\u2264', | ||
|
@@ -159,6 +164,25 @@ export const RangePopover = ({ | |
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFormRow> | ||
<EuiFormRow> | ||
<LabelInput | ||
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. Hey @flash1293, I saw this one got merged already, but you make this input |
||
value={label || ''} | ||
onChange={(newLabel) => { | ||
const newRange = { | ||
...tempRange, | ||
label: newLabel, | ||
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. So this resets to the empty string to indicate that it's empty, is that going to cause problems with equality? Imagine the steps 1. Create custom label 2. Delete custom label 3. Formats correctly? 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. Tested, this doesn't cause any issues |
||
}; | ||
setTempRange(newRange); | ||
saveRangeAndReset(newRange); | ||
}} | ||
placeholder={i18n.translate( | ||
'xpack.lens.indexPattern.ranges.customRangeLabelPlaceholder', | ||
{ defaultMessage: 'Custom label' } | ||
)} | ||
onSubmit={onSubmit} | ||
dataTestSubj="indexPattern-ranges-label" | ||
/> | ||
</EuiFormRow> | ||
</EuiPopover> | ||
); | ||
}; | ||
|
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.
Could you add a test for handling multiple overlapping ranges?
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.
What kind of test are you expecting? The formatter only ever gets a single value passed in. Do you want to cover the behavior of the built-in cache?
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 think I left this in the wrong place- I was worried about the duplicate label case, but this is the wrong place to test it.