Skip to content

Commit ab1de2e

Browse files
committed
[ML] Fix transform bulk actions. Fixes imports.
1 parent dc8b6e5 commit ab1de2e

File tree

6 files changed

+36
-19
lines changed

6 files changed

+36
-19
lines changed

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_stop/stop_button_modal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ import { i18n } from '@kbn/i18n';
99
import { FormattedMessage } from '@kbn/i18n/react';
1010
import { EuiConfirmModal, EuiOverlayMask, EUI_MODAL_CONFIRM_BUTTON } from '@elastic/eui';
1111

12-
import { ForceStopAction } from './use_force_stop_action';
12+
import { StopAction } from './use_stop_action';
1313

14-
export const StopButtonModal: FC<ForceStopAction> = ({
15-
closeModal,
16-
item,
17-
forceStopAndCloseModal,
18-
}) => {
14+
export const StopButtonModal: FC<StopAction> = ({ closeModal, item, forceStopAndCloseModal }) => {
1915
return (
2016
<>
2117
{item !== undefined && (

x-pack/plugins/transform/public/app/sections/transform_management/components/action_delete/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export { DeleteActionModal } from './delete_action_modal';
87
export { useDeleteAction } from './use_delete_action';
8+
export { DeleteActionModal } from './delete_action_modal';
9+
export { isDeleteActionDisabled, DeleteActionName } from './delete_action_name';

x-pack/plugins/transform/public/app/sections/transform_management/components/action_delete/use_delete_action.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export const useDeleteAction = (forceDisable: boolean) => {
7373
<DeleteActionName
7474
{...{
7575
canDeleteTransform,
76-
isBulkAction: false,
7776
disabled: isDeleteActionDisabled([item], forceDisable),
77+
isBulkAction: false,
7878
}}
7979
/>
8080
),

x-pack/plugins/transform/public/app/sections/transform_management/components/action_start/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export { StartActionModal } from './start_action_modal';
87
export { useStartAction } from './use_start_action';
8+
export { StartActionModal } from './start_action_modal';
9+
export { StartActionName } from './start_action_name';

x-pack/plugins/transform/public/app/sections/transform_management/components/action_stop/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*/
66

77
export { useStopAction } from './use_stop_action';
8+
export { StopActionName } from './stop_action_name';

x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ import {
3131
TRANSFORM_MODE,
3232
TRANSFORM_LIST_COLUMN,
3333
} from '../../../../common';
34+
import { useStopTransforms } from '../../../../hooks';
3435
import { AuthorizationContext } from '../../../../lib/authorization';
3536

3637
import { CreateTransformButton } from '../create_transform_button';
3738
import { RefreshTransformListButton } from '../refresh_transform_list_button';
38-
import { useDeleteAction, DeleteButton, DeleteButtonModal } from '../action_delete';
39-
import { useStartAction, StartButton, StartButtonModal } from '../action_start';
40-
import { StopButton } from '../action_stop';
39+
import {
40+
isDeleteActionDisabled,
41+
useDeleteAction,
42+
DeleteActionName,
43+
DeleteActionModal,
44+
} from '../action_delete';
45+
import { useStartAction, StartActionName, StartActionModal } from '../action_start';
46+
import { StopActionName } from '../action_stop';
4147

4248
import { ItemIdToExpandedRowMap, Clause, TermClause, FieldClause, Value } from './common';
4349
import { getTaskStateBadge, useColumns } from './use_columns';
@@ -89,8 +95,8 @@ export const TransformList: FC<Props> = ({
8995

9096
const [transformSelection, setTransformSelection] = useState<TransformListRow[]>([]);
9197
const [isActionsMenuOpen, setIsActionsMenuOpen] = useState(false);
92-
const bulkStartAction = useStartAction();
93-
const bulkDeleteAction = useDeleteAction();
98+
const bulkStartAction = useStartAction(false);
99+
const bulkDeleteAction = useDeleteAction(false);
94100

95101
const [searchError, setSearchError] = useState<any>(undefined);
96102

@@ -100,6 +106,8 @@ export const TransformList: FC<Props> = ({
100106
const [sortField, setSortField] = useState<string>(TRANSFORM_LIST_COLUMN.ID);
101107
const [sortDirection, setSortDirection] = useState<Direction>('asc');
102108

109+
const stopTransforms = useStopTransforms();
110+
103111
const { capabilities } = useContext(AuthorizationContext);
104112
const disabled =
105113
!capabilities.canCreateTransform ||
@@ -257,13 +265,23 @@ export const TransformList: FC<Props> = ({
257265

258266
const bulkActionMenuItems = [
259267
<div key="startAction" className="transform__BulkActionItem">
260-
<StartButton items={transformSelection} onClick={bulkStartAction.openModal} />
268+
<EuiButtonEmpty onClick={() => bulkStartAction.openModal(transformSelection)}>
269+
<StartActionName items={transformSelection} />
270+
</EuiButtonEmpty>
261271
</div>,
262272
<div key="stopAction" className="transform__BulkActionItem">
263-
<StopButton items={transformSelection} />
273+
<EuiButtonEmpty onClick={() => stopTransforms(transformSelection)}>
274+
<StopActionName items={transformSelection} />
275+
</EuiButtonEmpty>
264276
</div>,
265277
<div key="deleteAction" className="transform__BulkActionItem">
266-
<DeleteButton items={transformSelection} onClick={bulkDeleteAction.openModal} />
278+
<EuiButtonEmpty onClick={() => bulkDeleteAction.openModal(transformSelection)}>
279+
<DeleteActionName
280+
canDeleteTransform={capabilities.canDeleteTransform}
281+
disabled={isDeleteActionDisabled(transformSelection, false)}
282+
isBulkAction={true}
283+
/>
284+
</EuiButtonEmpty>
267285
</div>,
268286
];
269287

@@ -381,8 +399,8 @@ export const TransformList: FC<Props> = ({
381399
return (
382400
<div data-test-subj="transformListTableContainer">
383401
{/* Bulk Action Modals */}
384-
{bulkStartAction.isModalVisible && <StartButtonModal {...bulkStartAction} />}
385-
{bulkDeleteAction.isModalVisible && <DeleteButtonModal {...bulkDeleteAction} />}
402+
{bulkStartAction.isModalVisible && <StartActionModal {...bulkStartAction} />}
403+
{bulkDeleteAction.isModalVisible && <DeleteActionModal {...bulkDeleteAction} />}
386404

387405
{/* Single Action Modals */}
388406
{singleActionModals}

0 commit comments

Comments
 (0)