-
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
[ML] New Platform server shim: update calendar routes to use new platform router #56264
[ML] New Platform server shim: update calendar routes to use new platform router #56264
Conversation
Pinging @elastic/ml-ui (:ml) |
|
||
constructor(isLegacy: boolean, client: any) { | ||
this.isLegacy = isLegacy; | ||
this.client = client; |
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.
it might be worth making the isLegacy
check once here in the constructor and setting this.client
as either client
or client.ml!.mlClient.callAsCurrentUser
Or even making the check outside of this class and only passing in the correct client
when instantiating the class
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.
Good call- much better. Added the legacy check in the constructor here: e4c0e64639120c16c78f85258334091d4ec0c6ea
try { | ||
const resp = await this.callWithRequest('ml.calendars', { calendarId }); | ||
let resp; | ||
if (this.isLegacy === true) { |
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.
as per the previous comment, having these checks inside the class seems unnecessary and means we'll have to change them again at some point in the future.
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've just seen the comment on this PR referring to the need for compatibility with the still legacy job service, so please ignore the suggestion of moving these checks out side of the class.
I still think the check could be moved to the constructor, so it's only happening once also isLegacy
wouldn't need to be stored.
try { | ||
const calendarIds = request.params.calendarIds.split(','); | ||
|
||
if (calendarIds.length === 1) { |
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.
nit, this could be a ternary
this.callWithRequest = callWithRequest; | ||
this.eventManager = new EventManager(callWithRequest); | ||
private isLegacy: boolean; | ||
private client: any; |
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.
for recent classes that i've written i've started all private class members with an underscore.
I don't know if this is something we want to try to do everywhere. I quite like the naming convention as it makes it easy to spot private and public members.
Other parts of Kibana have adopted this pattern but it seems to depend on the developer.
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.
Updated naming these with the underscore - e4c0e64639120c16c78f85258334091d4ec0c6ea
@@ -6,17 +6,46 @@ | |||
|
|||
import _ from 'lodash'; |
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.
it looks like only difference
is used from lodash
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.
Updated to only pull in difference
e4c0e64639120c16c78f85258334091d4ec0c6ea
@@ -0,0 +1,94 @@ | |||
/* |
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.
it's strange that calenadar_manager
has been marked as a js -> ts rename by git, but this file hasn't.
it would be useful to try to retain the git history
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.
yeah, I'm not sure why that's the case. I'll look into it.
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.
it looks ok now. it shows it as a moved file. one of your subsequent comments must have made the difference.
probably removing the churn by removing all the isLegacy
checks
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.
LGTM.
Just one question - I guess the ts-ignore
can be removed from the routes that have been converted to TS. This calendars
one, plus the one for data_frame_analytics
which has already been done?
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.
LGTM
95785c2
to
9908a66
Compare
Functional test failures were being caused by a missing definition in the schema (in the route validation) for Will address removing use of both |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
Tested and calendar editing issue is fixed. LGTM |
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.
Latest edit LGTM
…form router (elastic#56264) * migrate calendar routes to NP * add proper types for calendars and events * set actual client in constructor so isLegacy is not stored * remove unnecessary comments * fix calendar schema for missing calendar_id and event_id properties
Summary
Related meta issue: #49743
Updates all calendar routes to use new platform router.
Adds an
isLegacy
parameter to theCalendarManager
so that it's still compatible with other route creators usingcallWithRequest
.I've left the type of client passed in as
any
for now, as job routes will be updated very soon and we'll be able to remove that legacy parameter and remove the need to have both types inCalendarManager
.Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorials- [ ] Unit or functional tests were updated or added to match the most common scenarios- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
- [ ] This was checked for breaking API changes and was labeled appropriately- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately