-
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] Add ML saved objects to Kibana saved objects management page #205177
Open
qn895
wants to merge
23
commits into
elastic:main
Choose a base branch
from
qn895:ml-kbn-saved-objs-in-management
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+317
−108
Open
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
85b1e57
Add ML saved objects to management page
qn895 349b842
Update UI
qn895 31c5c56
Remove console
qn895 bc3c7b4
Merge remote-tracking branch 'upstream/main' into ml-kbn-saved-objs-i…
qn895 1450c34
Add capabilities check within allowed_types
qn895 ffc1890
Add capabilities check
qn895 d78992f
Update types
qn895 80ca324
Update translation
qn895 25964a4
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine 63044c1
Merge remote-tracking branch 'upstream/main' into ml-kbn-saved-objs-i…
qn895 6a83915
Disable flyout
qn895 5c911c6
Update atexts
qn895 0211426
Fix display name
qn895 a0377ac
Merge remote-tracking branch 'upstream/main' into ml-kbn-saved-objs-i…
qn895 4b00d37
Update paths, disable export if has ML saved objects
qn895 51be700
Update tests
qn895 602c73f
Fix test & update text
qn895 c9c404d
Update texts for deleting and exporting
qn895 63a7536
Update tests
qn895 c8ca28a
Fix export all
qn895 ab6f7fd
Update delete texts for deletion
qn895 e40c0ec
Merge remote-tracking branch 'upstream/main' into ml-kbn-saved-objs-i…
qn895 885662f
Update tests
qn895 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...latform/plugins/shared/saved_objects_management/common/constants/ml_saved_object_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
export const ML_SAVED_OBJECT_TYPES = new Set(['ml-job', 'ml-trained-model']); | ||
65 changes: 9 additions & 56 deletions
65
...t/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 20 additions & 10 deletions
30
...ment/public/management_section/objects_table/components/__snapshots__/table.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import { | |
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage, FormattedRelative } from '@kbn/i18n-react'; | ||
import { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public'; | ||
import { ML_SAVED_OBJECT_TYPES } from '../../../../common/constants/ml_saved_object_types'; | ||
import type { SavedObjectManagementTypeInfo } from '../../../../common/types'; | ||
import { getDefaultTitle, getSavedObjectLabel } from '../../../lib'; | ||
import { SavedObjectWithMetadata } from '../../../types'; | ||
|
@@ -328,6 +329,9 @@ export class Table extends PureComponent<TableProps, TableState> { | |
icon: 'kqlSelector', | ||
onClick: (object) => onShowRelationships(object), | ||
'data-test-subj': 'savedObjectsTableAction-relationships', | ||
available: (object) => { | ||
return object ? !object.type?.startsWith('ml') : true; | ||
}, | ||
}, | ||
...actionRegistry.getAll().map((action) => { | ||
action.setActionContext({ capabilities }); | ||
|
@@ -369,26 +373,64 @@ export class Table extends PureComponent<TableProps, TableState> { | |
); | ||
} | ||
|
||
const button = ( | ||
<EuiButton | ||
iconType="arrowDown" | ||
iconSide="right" | ||
onClick={this.toggleExportPopoverVisibility} | ||
isDisabled={selectedSavedObjects.length === 0} | ||
> | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.exportPopoverButtonLabel" | ||
defaultMessage="Export" | ||
/> | ||
</EuiButton> | ||
); | ||
|
||
const activeActionContents = this.state.activeAction?.render() ?? null; | ||
const exceededResultCount = totalItemCount > MAX_PAGINATED_ITEM; | ||
|
||
const hasMlObjects = selectedSavedObjects.some(({ type }) => ML_SAVED_OBJECT_TYPES.has(type)); | ||
|
||
const anySelected = selectedSavedObjects.length > 0; | ||
const allHidden = | ||
anySelected && selectedSavedObjects.every(({ meta: { hiddenType } }) => hiddenType); | ||
|
||
const deleteTooltip = () => { | ||
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. |
||
if (hasMlObjects) { | ||
return ( | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.hasMlObjects.deleteDisabledTooltip" | ||
defaultMessage="Navigate to the Machine Learning management page to delete machine learning objects." | ||
/> | ||
); | ||
} | ||
if (allHidden) { | ||
return ( | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.deleteDisabledTooltip" | ||
defaultMessage="Selected objects can’t be deleted because they are hidden objects." | ||
/> | ||
); | ||
} | ||
}; | ||
const disabledExportTooltip = () => { | ||
if (hasMlObjects) { | ||
return ( | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.hasMlObjects.exportDisabledTooltip" | ||
defaultMessage="Navigate to the Machine Learning management page to export machine learning objects." | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
); | ||
} | ||
}; | ||
const button = ( | ||
<EuiToolTip | ||
data-test-subj="exportSOToolTip" | ||
key="exportSOToolTip" | ||
content={disabledExportTooltip()} | ||
> | ||
<EuiButton | ||
iconType="arrowDown" | ||
iconSide="right" | ||
onClick={this.toggleExportPopoverVisibility} | ||
isDisabled={selectedSavedObjects.length === 0} | ||
disabled={hasMlObjects} | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.exportPopoverButtonLabel" | ||
defaultMessage="Export" | ||
/> | ||
</EuiButton> | ||
</EuiToolTip> | ||
); | ||
|
||
return ( | ||
<Fragment> | ||
{activeActionContents} | ||
|
@@ -406,22 +448,18 @@ export class Table extends PureComponent<TableProps, TableState> { | |
<EuiToolTip | ||
data-test-subj="deleteSOToolTip" | ||
key="deleteSOToolTip" | ||
content={ | ||
allHidden ? ( | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.deleteDisabledTooltip" | ||
defaultMessage="Selected objects can’t be deleted because they are hidden objects." | ||
/> | ||
) : undefined | ||
} | ||
content={deleteTooltip()} | ||
> | ||
<EuiButton | ||
key="deleteSO" | ||
iconType="trash" | ||
color="danger" | ||
onClick={onDelete} | ||
isDisabled={ | ||
!anySelected || allHidden || !capabilities.savedObjectsManagement.delete | ||
hasMlObjects || | ||
!anySelected || | ||
allHidden || | ||
!capabilities.savedObjectsManagement.delete | ||
} | ||
title={ | ||
capabilities.savedObjectsManagement.delete | ||
|
@@ -468,7 +506,13 @@ export class Table extends PureComponent<TableProps, TableState> { | |
/> | ||
</EuiFormRow> | ||
<EuiFormRow> | ||
<EuiButton key="exportSO" iconType="exportAction" onClick={this.onExportClick} fill> | ||
<EuiButton | ||
key="exportSO" | ||
iconType="exportAction" | ||
onClick={this.onExportClick} | ||
fill | ||
disabled={hasMlObjects} | ||
> | ||
<FormattedMessage | ||
id="savedObjectsManagement.objectsTable.table.exportButtonLabel" | ||
defaultMessage="Export" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if we should move the constants declared here to a package and also include this Set.
In this PR
ml-job
andml-trained-model
are used a few times and it would be safer if they all came from the same place.