Skip to content

Commit 11fa3c7

Browse files
committed
review comments
1 parent 5b7bd8a commit 11fa3c7

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

  • x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/date_histogram.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export const dateHistogramOperation: OperationDefinition<
248248
const definedOption = options.find((o) => o.key === intervalInput);
249249
const selectedOptions = definedOption
250250
? [definedOption]
251-
: [{ label: intervalInput, key: 'custom' }];
251+
: [{ label: intervalInput, key: intervalInput }];
252252

253253
useEffect(() => {
254254
if (isValid && intervalInput !== currentColumn.params.interval) {
@@ -293,6 +293,14 @@ export const dateHistogramOperation: OperationDefinition<
293293
defaultMessage:
294294
'Select an option or create a custom value. Examples: 30s, 20m, 24h, 2d, 1w, 1M',
295295
})}
296+
isInvalid={!isValid}
297+
error={
298+
!isValid &&
299+
i18n.translate('xpack.lens.indexPattern.dateHistogram.invalidInterval', {
300+
defaultMessage:
301+
"Please pick a valid interval. It's not possible to use multiple weeks, months or years as interval.",
302+
})
303+
}
296304
>
297305
{intervalIsRestricted ? (
298306
<FormattedMessage
@@ -309,25 +317,22 @@ export const dateHistogramOperation: OperationDefinition<
309317
data-test-subj="lensDateHistogramInterval"
310318
isInvalid={!isValid}
311319
onChange={(opts) => {
312-
if (opts.length) {
313-
const newValue = opts[0].key!;
314-
setIntervalInput(newValue);
315-
if (newValue === autoInterval && currentColumn.params.ignoreTimeRange) {
316-
updateLayer(
317-
updateColumnParam({
318-
layer,
319-
columnId,
320-
paramName: 'ignoreTimeRange',
321-
value: false,
322-
})
323-
);
324-
}
320+
const newValue = opts.length ? opts[0].key! : '';
321+
setIntervalInput(newValue);
322+
if (newValue === autoInterval && currentColumn.params.ignoreTimeRange) {
323+
updateLayer(
324+
updateColumnParam({
325+
layer,
326+
columnId,
327+
paramName: 'ignoreTimeRange',
328+
value: false,
329+
})
330+
);
325331
}
326332
}}
327333
onCreateOption={(customValue: string) => setIntervalInput(customValue.trim())}
328334
options={options}
329335
selectedOptions={selectedOptions}
330-
isClearable={false}
331336
singleSelection={{ asPlainText: true }}
332337
placeholder={i18n.translate(
333338
'xpack.lens.indexPattern.dateHistogram.selectIntervalPlaceholder',

0 commit comments

Comments
 (0)