-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Use forceNow
query parameter when parsing timefilter
#16236
Changes from 2 commits
28fe61b
fb39267
15decc0
554fc7d
1ecb16d
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import moment from 'moment'; | ||
import expect from 'expect.js'; | ||
import ngMock from 'ng_mock'; | ||
import $ from 'jquery'; | ||
|
@@ -24,28 +25,60 @@ describe('kbnGlobalTimepicker', function () { | |
expect($el.attr('data-test-subj')).to.be('globalTimepicker'); | ||
}); | ||
|
||
it('sets data-shared-timefilter to true when auto-refresh selector is enabled', function () { | ||
it('sets data-shared-timefilter-* using the timefilter when auto-refresh selector is enabled', function () { | ||
const minString = '2000-01-01T00:00:00Z'; | ||
const maxString = '2001-01-01T00:00:00Z'; | ||
const bounds = { | ||
min: moment(minString), | ||
max: moment(maxString), | ||
}; | ||
scope.timefilter = { | ||
isAutoRefreshSelectorEnabled: true, | ||
isTimeRangeSelectorEnabled: false | ||
isTimeRangeSelectorEnabled: false, | ||
getBounds: () => bounds | ||
}; | ||
|
||
const $el = compile(); | ||
expect($el.attr('data-shared-timefilter')).to.eql('true'); | ||
|
||
expect($el.attr('data-shared-timefilter-from')).to.eql(minString); | ||
expect($el.attr('data-shared-timefilter-to')).to.eql(maxString); | ||
}); | ||
it('sets data-shared-timefilter to true when time range selector is enabled', function () { | ||
|
||
it('sets data-shared-timefilter-* using the timefilter when time range selector is enabled', function () { | ||
const minString = '2000-01-01T00:00:00Z'; | ||
const maxString = '2001-01-01T00:00:00Z'; | ||
const bounds = { | ||
min: moment(minString), | ||
max: moment(maxString), | ||
}; | ||
scope.timefilter = { | ||
isAutoRefreshSelectorEnabled: false, | ||
isTimeRangeSelectorEnabled: true | ||
isTimeRangeSelectorEnabled: true, | ||
getBounds: () => bounds | ||
}; | ||
|
||
const $el = compile(); | ||
expect($el.attr('data-shared-timefilter')).to.eql('true'); | ||
|
||
expect($el.attr('data-shared-timefilter-from')).to.eql(minString); | ||
expect($el.attr('data-shared-timefilter-to')).to.eql(maxString); | ||
}); | ||
it(`sets data-shared-timefilter to false when auto-refresh and time range selectors are both disabled`, function () { | ||
|
||
it(`sets data-shared-timefilter-* to null when auto-refresh and time range selectors are both disabled`, function () { | ||
const minString = '2000-01-01T00:00:00Z'; | ||
const maxString = '2001-01-01T00:00:00Z'; | ||
const bounds = { | ||
min: moment(minString), | ||
max: moment(maxString), | ||
}; | ||
scope.timefilter = { | ||
isAutoRefreshSelectorEnabled: false, | ||
isTimeRangeSelectorEnabled: false | ||
isTimeRangeSelectorEnabled: false, | ||
getBounds: () => bounds | ||
}; | ||
|
||
const $el = compile(); | ||
expect($el.attr('data-shared-timefilter')).to.eql('false'); | ||
|
||
expect($el.attr('data-shared-timefilter-from')).to.eql(''); | ||
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. Contrary to the test description, this isn't testing for 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. 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 value is fine, but the test says "sets data-shared-timefilter-* to null", but it's not null, and it's not testing for null. My only beef here is the description of what is being tested. 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. Does 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. That's fine. My only issue was the mention of |
||
expect($el.attr('data-shared-timefilter-to')).to.eql(''); | ||
}); | ||
}); |
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.
Being Angular code and all, should this use $location.search() instead? And actually, isn't that required since we're using hash routing?
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 want this to be a normal querystring parameter outside of the AngularJS based hash routing, because I assumed that Canvas itself might not be using the hash based routing.
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.
Ah, fair enough. We are using hash routing though, and actually I think everything would need to. Though, I suppose an app could use search param routing...
So your intention is that you'd have something like
http://localhost:5601/acd/app/canvas?forceNow=2001-01-01T00:00:00Z#/workpad/workpad-1ba0f600-47f0-4306-a587-17cc95a74281
?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.
Yup, that's the intent right now.
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 happens if an app needs the
forceNow
parameter to be part of the hash route?I think that's actually going to be the case for Canvas. Our router is going to assume that the entirety of the parameters it should be looking at come after the hash. I can work around it, but I wonder if the location of this setting can be left up to the app creating the URL somehow.
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.
Allowing the application to decide where to look for the parameter in the URL is going against the intent of this change entirely. The goal is to make the applications abide by a standard "interface" and then they'll work with Reporting, changing where the
forceNow
is for different applications is the exact thing that we're trying to avoid by introducing application specific logic.With that being said, if we want to move the
forceNow
to the hash parameters, we can, as we can support this within Kibana. There's been discussion about moving to non hash-based routing, but we can readdress this when this happensThere 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.
Fair enough. I'll add an issue in Canvas to address search params that could be in the URL already and we can push forward that way.