Skip to content

Commit

Permalink
[ML] Fix transform bulk actions. Fixes imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Aug 17, 2020
1 parent dc8b6e5 commit ab1de2e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiConfirmModal, EuiOverlayMask, EUI_MODAL_CONFIRM_BUTTON } from '@elastic/eui';

import { ForceStopAction } from './use_force_stop_action';
import { StopAction } from './use_stop_action';

export const StopButtonModal: FC<ForceStopAction> = ({
closeModal,
item,
forceStopAndCloseModal,
}) => {
export const StopButtonModal: FC<StopAction> = ({ closeModal, item, forceStopAndCloseModal }) => {
return (
<>
{item !== undefined && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { DeleteActionModal } from './delete_action_modal';
export { useDeleteAction } from './use_delete_action';
export { DeleteActionModal } from './delete_action_modal';
export { isDeleteActionDisabled, DeleteActionName } from './delete_action_name';
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export const useDeleteAction = (forceDisable: boolean) => {
<DeleteActionName
{...{
canDeleteTransform,
isBulkAction: false,
disabled: isDeleteActionDisabled([item], forceDisable),
isBulkAction: false,
}}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { StartActionModal } from './start_action_modal';
export { useStartAction } from './use_start_action';
export { StartActionModal } from './start_action_modal';
export { StartActionName } from './start_action_name';
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*/

export { useStopAction } from './use_stop_action';
export { StopActionName } from './stop_action_name';
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ import {
TRANSFORM_MODE,
TRANSFORM_LIST_COLUMN,
} from '../../../../common';
import { useStopTransforms } from '../../../../hooks';
import { AuthorizationContext } from '../../../../lib/authorization';

import { CreateTransformButton } from '../create_transform_button';
import { RefreshTransformListButton } from '../refresh_transform_list_button';
import { useDeleteAction, DeleteButton, DeleteButtonModal } from '../action_delete';
import { useStartAction, StartButton, StartButtonModal } from '../action_start';
import { StopButton } from '../action_stop';
import {
isDeleteActionDisabled,
useDeleteAction,
DeleteActionName,
DeleteActionModal,
} from '../action_delete';
import { useStartAction, StartActionName, StartActionModal } from '../action_start';
import { StopActionName } from '../action_stop';

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

const [transformSelection, setTransformSelection] = useState<TransformListRow[]>([]);
const [isActionsMenuOpen, setIsActionsMenuOpen] = useState(false);
const bulkStartAction = useStartAction();
const bulkDeleteAction = useDeleteAction();
const bulkStartAction = useStartAction(false);
const bulkDeleteAction = useDeleteAction(false);

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

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

const stopTransforms = useStopTransforms();

const { capabilities } = useContext(AuthorizationContext);
const disabled =
!capabilities.canCreateTransform ||
Expand Down Expand Up @@ -257,13 +265,23 @@ export const TransformList: FC<Props> = ({

const bulkActionMenuItems = [
<div key="startAction" className="transform__BulkActionItem">
<StartButton items={transformSelection} onClick={bulkStartAction.openModal} />
<EuiButtonEmpty onClick={() => bulkStartAction.openModal(transformSelection)}>
<StartActionName items={transformSelection} />
</EuiButtonEmpty>
</div>,
<div key="stopAction" className="transform__BulkActionItem">
<StopButton items={transformSelection} />
<EuiButtonEmpty onClick={() => stopTransforms(transformSelection)}>
<StopActionName items={transformSelection} />
</EuiButtonEmpty>
</div>,
<div key="deleteAction" className="transform__BulkActionItem">
<DeleteButton items={transformSelection} onClick={bulkDeleteAction.openModal} />
<EuiButtonEmpty onClick={() => bulkDeleteAction.openModal(transformSelection)}>
<DeleteActionName
canDeleteTransform={capabilities.canDeleteTransform}
disabled={isDeleteActionDisabled(transformSelection, false)}
isBulkAction={true}
/>
</EuiButtonEmpty>
</div>,
];

Expand Down Expand Up @@ -381,8 +399,8 @@ export const TransformList: FC<Props> = ({
return (
<div data-test-subj="transformListTableContainer">
{/* Bulk Action Modals */}
{bulkStartAction.isModalVisible && <StartButtonModal {...bulkStartAction} />}
{bulkDeleteAction.isModalVisible && <DeleteButtonModal {...bulkDeleteAction} />}
{bulkStartAction.isModalVisible && <StartActionModal {...bulkStartAction} />}
{bulkDeleteAction.isModalVisible && <DeleteActionModal {...bulkDeleteAction} />}

{/* Single Action Modals */}
{singleActionModals}
Expand Down

0 comments on commit ab1de2e

Please sign in to comment.