mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Timepicker step forward/backward should not overlap (#11131)
* Timepicker step forward/backward should not overlap This PR fixes the step forward/backward buttons in the timepicker so that the ranges do not overlap. Prior to this PR, if you stepped forward/backward, the new range would include one millisecond of time in both ranges, which could result in documents being visible in both time ranges. * Add unit for add/subtract methods
This commit is contained in:
parent
2fed5d3f22
commit
6752dfe168
2 changed files with 12 additions and 12 deletions
|
@ -14,15 +14,15 @@ describe('timeNavigation', () => {
|
||||||
|
|
||||||
it('should step forward by the amount of the duration', () => {
|
it('should step forward by the amount of the duration', () => {
|
||||||
const { from, to, mode } = timeNavigation.stepForward(bounds);
|
const { from, to, mode } = timeNavigation.stepForward(bounds);
|
||||||
expect(from).to.be('2016-01-01T00:15:00.000Z');
|
expect(from).to.be('2016-01-01T00:15:00.001Z');
|
||||||
expect(to).to.be('2016-01-01T00:30:00.000Z');
|
expect(to).to.be('2016-01-01T00:30:00.001Z');
|
||||||
expect(mode).to.be('absolute');
|
expect(mode).to.be('absolute');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should step backward by the amount of the duration', () => {
|
it('should step backward by the amount of the duration', () => {
|
||||||
const { from, to, mode } = timeNavigation.stepBackward(bounds);
|
const { from, to, mode } = timeNavigation.stepBackward(bounds);
|
||||||
expect(from).to.be('2015-12-31T23:45:00.000Z');
|
expect(from).to.be('2015-12-31T23:44:59.999Z');
|
||||||
expect(to).to.be('2016-01-01T00:00:00.000Z');
|
expect(to).to.be('2015-12-31T23:59:59.999Z');
|
||||||
expect(mode).to.be('absolute');
|
expect(mode).to.be('absolute');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ export default {
|
||||||
stepForward({ min, max }) {
|
stepForward({ min, max }) {
|
||||||
const diff = max.diff(min);
|
const diff = max.diff(min);
|
||||||
return {
|
return {
|
||||||
from: max.toISOString(),
|
from: moment(max).add(1, 'ms').toISOString(),
|
||||||
to: moment(max).add(diff).toISOString(),
|
to: moment(max).add(diff + 1, 'ms').toISOString(),
|
||||||
mode: 'absolute'
|
mode: 'absolute'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -15,8 +15,8 @@ export default {
|
||||||
stepBackward({ min, max }) {
|
stepBackward({ min, max }) {
|
||||||
const diff = max.diff(min);
|
const diff = max.diff(min);
|
||||||
return {
|
return {
|
||||||
from: moment(min).subtract(diff).toISOString(),
|
from: moment(min).subtract(diff + 1, 'ms').toISOString(),
|
||||||
to: min.toISOString(),
|
to: moment(min).subtract(1, 'ms').toISOString(),
|
||||||
mode: 'absolute'
|
mode: 'absolute'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -25,8 +25,8 @@ export default {
|
||||||
zoomOut({ min, max }) {
|
zoomOut({ min, max }) {
|
||||||
const diff = max.diff(min);
|
const diff = max.diff(min);
|
||||||
return {
|
return {
|
||||||
from: moment(min).subtract(diff / 2).toISOString(),
|
from: moment(min).subtract(diff / 2, 'ms').toISOString(),
|
||||||
to: moment(max).add(diff / 2).toISOString(),
|
to: moment(max).add(diff / 2, 'ms').toISOString(),
|
||||||
mode: 'absolute'
|
mode: 'absolute'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -35,8 +35,8 @@ export default {
|
||||||
zoomIn({ min, max }) {
|
zoomIn({ min, max }) {
|
||||||
const diff = max.diff(min);
|
const diff = max.diff(min);
|
||||||
return {
|
return {
|
||||||
from: moment(min).add(diff / 4).toISOString(),
|
from: moment(min).add(diff / 4, 'ms').toISOString(),
|
||||||
to: moment(max).subtract(diff / 4).toISOString(),
|
to: moment(max).subtract(diff / 4, 'ms').toISOString(),
|
||||||
mode: 'absolute'
|
mode: 'absolute'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue