-
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] Injectables refactor #50512
[ML] Injectables refactor #50512
Conversation
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
e22c589
to
15db3f7
Compare
💚 Build Succeeded
|
Pinging @elastic/ml-ui (:ml) |
💚 Build Succeeded
|
💚 Build Succeeded
|
💚 Build Succeeded
|
💚 Build Succeeded
|
resolve(this.formatsByJob); | ||
}) | ||
.catch(err => { | ||
// console.log('fieldFormatService error populating formats:', err); |
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.
Can this be removed?
x-pack/legacy/plugins/ml/public/settings/filter_lists/edit/directive.tsx
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/public/settings/filter_lists/list/directive.tsx
Show resolved
Hide resolved
@@ -62,7 +46,7 @@ export function getIndexPatternIdFromName(name: string) { | |||
return indexPatternCache[j].id; | |||
} | |||
} | |||
return name; | |||
return null; |
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.
Just to clarify, this is changing the default return type to null
rather than returning the name
for cases where no matching index pattern could be found. Probably makes more sense, but just want to make sure!
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 checked the places where this is called and returning null
makes more sense.
After this refactor, there are no places where returning the originally supplied index name is expected.
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.
Tested this out, including where the field format service is using, and all looks good.
Other than the minor comments added above, LGTM
import { VALIDATION_STATUS } from '../constants/validation'; | ||
|
||
// get the most severe status level from a list of messages | ||
const contains = (arr: string[], str: string) => arr.findIndex(v => v === str) >= 0; |
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.
just migration to TS, but for an array of primitives it's easier to use arr.indexOf(str)
indexPattern: any, | ||
savedSearch: 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.
we have interfaces for those two 🙂
import React from 'react'; | ||
// @ts-ignore No declaration file for module | ||
import { banners } from 'ui/notify'; | ||
// import chrome from 'ui/chrome'; |
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.
commented import
let licenseType = null; | ||
let expiredLicenseBannerId; | ||
let licenseType: LICENSE_TYPE | null = null; | ||
let expiredLicenseBannerId: 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.
is it possible to provide a type?
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.
Adding type of string
but it's worth noting that it's a guess because banners
is js.
It's also worth noting that the value expiredLicenseBannerId
is never really used, it's only checked to see if it has been set.
this.indexPatternIdsByJob = {}; | ||
this.formatsByJob = {}; | ||
} | ||
indexPatternIdsByJob: 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.
Record?
const formatsByDetector = {}; | ||
const formatsByDetector: 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.
object replaced with an array 🤔
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.
yes, it looks like it was incorrect being an object.
formatsByDetector
is indexed using detector_index
from each detector which is an incrementing integer.
return { | ||
restrict: 'E', | ||
replace: false, | ||
scope: {}, | ||
link: function (scope, element) { | ||
link(scope: any, element: ng.IAugmentedJQuery) { |
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.
ng.IScope
?
return { | ||
restrict: 'E', | ||
replace: false, | ||
scope: {}, | ||
link: function (scope, element) { | ||
link(scope: any, element: ng.IAugmentedJQuery) { |
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.
ng.IScope
?
return { | ||
restrict: 'E', | ||
replace: false, | ||
scope: {}, | ||
link: function (scope, element) { | ||
link(scope: any, element: ng.IAugmentedJQuery) { |
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.
ng.IScope
?
return name; | ||
return null; |
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.
is it correct?
c787b6e
to
f1caf40
Compare
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 👍
💚 Build Succeeded
|
@elasticmachine merge upstream |
merge conflict between base and head |
f1caf40
to
e4726c8
Compare
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 added some minor comments.
import expect from '@kbn/expect'; | ||
import { parseInterval } from '../parse_interval'; | ||
|
||
describe('ML parse interval util', function() { |
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.
We also need to migrate away from mocha
. Since these tests don't include anything angular related, they could be moved to .../util/parse_interval.test.ts
and migrated to jest
.
@@ -4,14 +4,11 @@ | |||
* you may not use this file except in compliance with the Elastic License. | |||
*/ | |||
|
|||
|
|||
|
|||
import expect from '@kbn/expect'; | |||
import { renderTemplate } from '../string_utils'; | |||
|
|||
describe('ML - string utils', () => { |
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 be moved to .../util/string_utils.test.ts
and migrated to jest
.
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, makes sense to move it over
import dateMath from '@elastic/datemath'; | ||
|
||
type SupportedUnits = unitOfTime.Base; |
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.
Just wondering if this should be singular SupportedUnit
since later on it's used as an array like SupportedUnits[]
.
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.
unitOfTime.Base
is a list of string literal types, something like ms | s | m | h |....
so from a language point of view i thought the plural made sense.
but i guess it's a union so it'll only have one value.
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
* [ML] Injectables refactor * removing unrelated files * additional typescript conversion * more typescript conversion * adding some return types * fixing eui errors * typescripting license checks * updated based on review * fixing merge conflict error * converting tests to jest * fixing types
* [ML] Injectables refactor * removing unrelated files * additional typescript conversion * more typescript conversion * adding some return types * fixing eui errors * typescripting license checks * updated based on review * fixing merge conflict error * converting tests to jest * fixing types
New platform related refactor PR.
Removes the use of soon to be obsolete injectables.
Removed:
Private
kbnBaseUrl
kbnUrl
reactDirective
some uses of
$scope
Removes the use of
$route
bySearchItemsProvider
and so removes the need of a provider wrapper entirely.Also typescriptifies and refactors some simple util files and directives.
@peteharverson special care is needed when reviewing the changes made to
field_format_service
. From my tests everything appears to be correct, but there may be edge cases i've missed.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- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately