forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] clear selection action (elastic#79834)
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/ml/public/ui_actions/clear_selection_action.tsx
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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { ActionContextMapping, createAction } from '../../../../../src/plugins/ui_actions/public'; | ||
import { MlCoreSetup } from '../plugin'; | ||
|
||
export const CLEAR_SELECTION_ACTION = 'clearSelectionAction'; | ||
|
||
export interface ClearSelectionContext { | ||
updateCallback: () => void; | ||
} | ||
|
||
export function createClearSelectionAction(getStartServices: MlCoreSetup['getStartServices']) { | ||
return createAction<typeof CLEAR_SELECTION_ACTION>({ | ||
id: 'clear-selection-action', | ||
type: CLEAR_SELECTION_ACTION, | ||
getIconType(context: ActionContextMapping[typeof CLEAR_SELECTION_ACTION]): string { | ||
return 'cross'; | ||
}, | ||
getDisplayName: () => | ||
i18n.translate('xpack.ml.actions.clearSelectionTitle', { | ||
defaultMessage: 'Clear selection', | ||
}), | ||
shouldAutoExecute: () => Promise.resolve(false), | ||
async execute({ updateCallback }: ClearSelectionContext) { | ||
updateCallback(); | ||
}, | ||
async isCompatible({ updateCallback }: ClearSelectionContext) { | ||
return typeof updateCallback === 'function'; | ||
}, | ||
}); | ||
} |
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