diff --git a/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionDropDown.tsx b/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionDropDown.tsx index 8440a06f..7ab422fb 100644 --- a/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionDropDown.tsx +++ b/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionDropDown.tsx @@ -6,7 +6,7 @@ import { TerminalStateProps } from '@/components/PlaybookExecutionModal'; import PlaybookSelectionModal from '@/components/PlaybookSelection/PlaybookSelectionModal'; import { DownOutlined } from '@ant-design/icons'; import { history } from '@umijs/max'; -import { Dropdown, MenuProps, Space } from 'antd'; +import { Dropdown, MenuProps, Popconfirm, Space } from 'antd'; import { ItemType } from 'rc-menu/es/interface'; import React, { Dispatch, ReactNode, SetStateAction } from 'react'; import { API, SsmAnsible } from 'ssm-shared-lib'; @@ -22,6 +22,10 @@ export type QuickActionProps = { const DeviceQuickActionDropDown: React.FC = (props) => { const [playbookSelectionModalIsOpened, setPlaybookSelectionModalIsOpened] = React.useState(false); + const [showConfirmation, setShowConfirmation] = React.useState({ + visible: false, + onConfirm: () => {}, + }); const onClick: MenuProps['onClick'] = ({ key }) => { const idx = parseInt(key); @@ -30,6 +34,7 @@ const DeviceQuickActionDropDown: React.FC = (props) => { alert('Internal Error'); return; } + if (DeviceQuickActionReference[idx].action === Actions.CONNECT) { history.push({ pathname: `/manage/devices/ssh/${props.target?.uuid}`, @@ -37,6 +42,19 @@ const DeviceQuickActionDropDown: React.FC = (props) => { return; } if (DeviceQuickActionReference[idx].type === Types.PLAYBOOK) { + if (DeviceQuickActionReference[idx].needConfirmation) { + setShowConfirmation({ + visible: true, + onConfirm: () => { + props.setTerminal({ + isOpen: true, + quickRef: DeviceQuickActionReference[idx].playbookQuickRef, + target: props.target ? [props.target] : undefined, + }); + }, + }); + return; + } props.setTerminal({ isOpen: true, quickRef: DeviceQuickActionReference[idx].playbookQuickRef, @@ -104,6 +122,19 @@ const DeviceQuickActionDropDown: React.FC = (props) => { itemSelected={props.target ? [props.target] : undefined} callback={onSelectPlaybook} /> + { + showConfirmation.onConfirm(); + setShowConfirmation({ visible: false, onConfirm: () => {} }); + }} + onCancel={() => + setShowConfirmation({ visible: false, onConfirm: () => {} }) + } + okText="Yes" + cancelText="No" + /> e.preventDefault()}> {props.children ? props.children : } diff --git a/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionReference.tsx b/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionReference.tsx index c585eebc..aa633133 100644 --- a/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionReference.tsx +++ b/client/src/components/DeviceComponents/DeviceQuickAction/DeviceQuickActionReference.tsx @@ -27,6 +27,7 @@ export type QuickActionReferenceType = { onAdvancedMenu: boolean; children?: QuickActionReferenceType[]; icon?: React.ReactNode; + needConfirmation?: boolean; }; export enum Actions { @@ -47,6 +48,7 @@ const DeviceQuickActionReference: QuickActionReferenceType[] = [ icon: , label: 'Reboot', onAdvancedMenu: false, + needConfirmation: true, }, { type: Types.ACTION,