-
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][Fleet] Link to ML assets from Integration > Assets tab #189767
Changes from 8 commits
796a79d
454e274
9c7e66a
70338f4
dd8e5b7
791863a
c024c1d
ca89c98
3e81b35
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 |
---|---|---|
|
@@ -33,11 +33,9 @@ const getKibanaLinkForESAsset = (type: ElasticsearchAssetType, id: string): stri | |
case 'data_stream_ilm_policy': | ||
return `/app/management/data/index_lifecycle_management/policies/edit/${id}`; | ||
case 'transform': | ||
// TODO: Confirm link for transforms | ||
return ''; | ||
return `/app/management/data/transform?_a=(transform:(queryText:${id}))`; | ||
case 'ml_model': | ||
// TODO: Confirm link for ml models | ||
return ''; | ||
return `/app/ml/trained_models?_a=(trained_models:(queryText:'model_id:(${id})'))`; | ||
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. Same for models - would be nice to add the description, if it exists. 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. ❓ is it possible to utilize our ML locator to retrieve these URLs? It'd make it easier to maintain 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. I was directed to keep it consistent in that file, for now. If maintainability becomes an issue then we can bring it up. |
||
default: | ||
return ''; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { useState } from 'react'; | ||
import { useCallback } from 'react'; | ||
import type { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; | ||
import type { ListingPageUrlState } from '../../transform_management_section'; | ||
|
||
const PAGE_SIZE = 10; | ||
const PAGE_SIZE_OPTIONS = [10, 25, 50]; | ||
|
||
// Copying from EUI EuiBasicTable types as type is not correctly picked up for table's onChange | ||
|
@@ -30,15 +30,6 @@ export interface CriteriaWithPagination<T extends object> extends Criteria<T> { | |
}; | ||
} | ||
|
||
interface AnalyticsBasicTableSettings<T extends object> { | ||
pageIndex: number; | ||
pageSize: number; | ||
totalItemCount: number; | ||
showPerPageOptions: boolean; | ||
sortField: keyof T; | ||
sortDirection: Direction; | ||
} | ||
|
||
interface UseTableSettingsReturnValue<T extends object> { | ||
onTableChange: EuiBasicTableProps<T>['onChange']; | ||
pagination: Pagination; | ||
|
@@ -47,34 +38,29 @@ interface UseTableSettingsReturnValue<T extends object> { | |
|
||
export function useTableSettings<TypeOfItem extends object>( | ||
sortByField: keyof TypeOfItem, | ||
items: TypeOfItem[] | ||
items: TypeOfItem[], | ||
pageState: ListingPageUrlState, | ||
updatePageState: (update: Partial<ListingPageUrlState>) => void | ||
): UseTableSettingsReturnValue<TypeOfItem> { | ||
const [tableSettings, setTableSettings] = useState<AnalyticsBasicTableSettings<TypeOfItem>>({ | ||
pageIndex: 0, | ||
pageSize: PAGE_SIZE, | ||
totalItemCount: 0, | ||
showPerPageOptions: true, | ||
sortField: sortByField, | ||
sortDirection: 'asc', | ||
}); | ||
const { pageIndex, pageSize, sortField, sortDirection } = pageState; | ||
|
||
const onTableChange: EuiBasicTableProps<TypeOfItem>['onChange'] = ({ | ||
page = { index: 0, size: PAGE_SIZE }, | ||
sort = { field: sortByField, direction: 'asc' }, | ||
}: CriteriaWithPagination<TypeOfItem>) => { | ||
const { index, size } = page; | ||
const { field, direction } = sort; | ||
const onTableChange: EuiBasicTableProps<TypeOfItem>['onChange'] = useCallback( | ||
({ page, sort }: CriteriaWithPagination<TypeOfItem>) => { | ||
let resultSortField = sort?.field; | ||
if (typeof resultSortField !== 'string') { | ||
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. what other types can it be? 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. 🤔 I think this is holdover defensive code from the example code I was using from https://github.com/elastic/kibana/pull/140613/files in |
||
resultSortField = pageState.sortField as keyof TypeOfItem; | ||
} | ||
|
||
setTableSettings({ | ||
...tableSettings, | ||
pageIndex: index, | ||
pageSize: size, | ||
sortField: field, | ||
sortDirection: direction, | ||
}); | ||
}; | ||
|
||
const { pageIndex, pageSize, sortField, sortDirection } = tableSettings; | ||
const result = { | ||
pageIndex: page?.index ?? pageState.pageIndex, | ||
pageSize: page?.size ?? pageState.pageSize, | ||
sortField: resultSortField as string, | ||
sortDirection: sort?.direction ?? pageState.sortDirection, | ||
}; | ||
updatePageState(result); | ||
}, | ||
[pageState, updatePageState] | ||
); | ||
|
||
const pagination = { | ||
pageIndex, | ||
|
@@ -85,8 +71,8 @@ export function useTableSettings<TypeOfItem extends object>( | |
|
||
const sorting = { | ||
sort: { | ||
field: sortField as string, | ||
direction: sortDirection, | ||
field: sortField, | ||
direction: sortDirection as Direction, | ||
}, | ||
}; | ||
return { onTableChange, pagination, sorting }; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Might not be possible, but adding the description of the transform, if set, would be nice here, as happens for dashboard assets:
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.
Currently for ES assets that isn't possible but I can create a follow up issue to allow it for ES assets.