Skip to content

Commit

Permalink
Rename management button to "delete"
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Feb 2, 2021
1 parent 2a4d39a commit 3b233f9
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ import { SearchSessionsMgmtAPI } from '../../lib/api';
import { TableText } from '../';
import { OnActionComplete } from './types';

interface CancelButtonProps {
interface DeleteButtonProps {
id: string;
name: string;
api: SearchSessionsMgmtAPI;
onActionComplete: OnActionComplete;
}

const CancelConfirm = ({
onConfirmDismiss,
const DeleteConfirm = ({
onConfirmCancel,
...props
}: CancelButtonProps & { onConfirmDismiss: () => void }) => {
}: DeleteButtonProps & { onConfirmCancel: () => void }) => {
const { id, name, api, onActionComplete } = props;
const [isLoading, setIsLoading] = useState(false);

const title = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.title', {
defaultMessage: 'Cancel search session',
defaultMessage: 'Delete search session',
});
const confirm = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.cancelButton', {
defaultMessage: 'Cancel',
const confirm = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.deleteButton', {
defaultMessage: 'Delete',
});
const cancel = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.dontCancelButton', {
defaultMessage: 'Dismiss',
const cancel = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.cancelButton', {
defaultMessage: 'Cancel',
});
const message = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.message', {
defaultMessage: `Canceling the search session \'{name}\' will expire any cached results, so that quick restore will no longer be available. You will still be able to re-run it, using the reload action.`,
defaultMessage: `Deleting the search session \'{name}\' will expire any cached results.`,
values: {
name,
},
Expand All @@ -46,7 +46,7 @@ const CancelConfirm = ({
<EuiOverlayMask>
<EuiConfirmModal
title={title}
onCancel={onConfirmDismiss}
onCancel={onConfirmCancel}
onConfirm={async () => {
setIsLoading(true);
await api.sendCancel(id);
Expand All @@ -64,26 +64,26 @@ const CancelConfirm = ({
);
};

export const CancelButton = (props: CancelButtonProps) => {
export const DeleteButton = (props: DeleteButtonProps) => {
const [showConfirm, setShowConfirm] = useState(false);

const onClick = () => {
setShowConfirm(true);
};

const onConfirmDismiss = () => {
const onConfirmCancel = () => {
setShowConfirm(false);
};

return (
<>
<TableText onClick={onClick}>
<FormattedMessage
id="xpack.data.mgmt.searchSessions.actionCancel"
defaultMessage="Cancel"
id="xpack.data.mgmt.searchSessions.actionDelete"
defaultMessage="Delete"
/>
</TableText>
{showConfirm ? <CancelConfirm {...props} onConfirmDismiss={onConfirmDismiss} /> : null}
{showConfirm ? <DeleteConfirm {...props} onConfirmCancel={onConfirmCancel} /> : null}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IClickActionDescriptor } from '../';
import extendSessionIcon from '../../icons/extend_session.svg';
import { SearchSessionsMgmtAPI } from '../../lib/api';
import { UISession } from '../../types';
import { CancelButton } from './cancel_button';
import { DeleteButton } from './delete_button';
import { ExtendButton } from './extend_button';
import { ReloadButton } from './reload_button';
import { ACTION, OnActionComplete } from './types';
Expand All @@ -21,11 +21,11 @@ export const getAction = (
onActionComplete: OnActionComplete
): IClickActionDescriptor | null => {
switch (actionType) {
case ACTION.CANCEL:
case ACTION.DELETE:
return {
iconType: 'crossInACircleFilled',
textColor: 'default',
label: <CancelButton api={api} id={id} name={name} onActionComplete={onActionComplete} />,
label: <DeleteButton api={api} id={id} name={name} onActionComplete={onActionComplete} />,
};

case ACTION.RELOAD:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const PopoverActionsMenu = ({ api, onActionComplete, session }: PopoverAc

// add a line above the delete action (when there are multiple)
// NOTE: Delete action MUST be the final action[] item
if (actions.length > 1 && actionType === ACTION.CANCEL) {
if (actions.length > 1 && actionType === ACTION.DELETE) {
itemSet.push({ isSeparator: true, key: 'separadorable' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export type OnActionComplete = () => void;

export enum ACTION {
EXTEND = 'extend',
CANCEL = 'cancel',
DELETE = 'delete',
RELOAD = 'reload',
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getActions(status: SearchSessionStatus) {
actions.push(ACTION.RELOAD);
if (status === SearchSessionStatus.IN_PROGRESS || status === SearchSessionStatus.COMPLETE) {
actions.push(ACTION.EXTEND);
actions.push(ACTION.CANCEL);
actions.push(ACTION.DELETE);
}
return actions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
'[data-test-subj="sessionManagementPopoverAction-reload"]'
);
},
cancel: async () => {
delete: async () => {
await actionsCell.click();
await find.clickByCssSelector(
'[data-test-subj="sessionManagementPopoverAction-cancel"]'
'[data-test-subj="sessionManagementPopoverAction-delete"]'
);
await PageObjects.common.clickConfirmOnModal();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await searchSessions.expectState('completed');
});

it('Cancels a session from management', async () => {
it('Deletes a session from management', async () => {
await PageObjects.searchSessionsManagement.goTo();

const searchSessionList = await PageObjects.searchSessionsManagement.getList();

expect(searchSessionList.length).to.be(1);
await searchSessionList[0].cancel();
await searchSessionList[0].delete();

// TODO: update this once canceling doesn't delete the object!
await retry.waitFor(`wait for list to be empty`, async function () {
const s = await PageObjects.searchSessionsManagement.getList();

Expand Down

0 comments on commit 3b233f9

Please sign in to comment.