import React, { type FC, useCallback } from 'react' import { RiHistoryLine } from '@remixicon/react' import { useTranslation } from 'react-i18next' import { useKeyPress } from 'ahooks' import Button from '../../base/button' import Tooltip from '../../base/tooltip' import { getKeyboardKeyCodeBySystem } from '../utils' type VersionHistoryButtonProps = { onClick: () => Promise | unknown } const VERSION_HISTORY_SHORTCUT = ['⌘', '⇧', 'H'] const PopupContent = React.memo(() => { const { t } = useTranslation() return (
{t('workflow.common.versionHistory')}
{VERSION_HISTORY_SHORTCUT.map(key => ( {key} ))}
) }) PopupContent.displayName = 'PopupContent' const VersionHistoryButton: FC = ({ onClick, }) => { const handleViewVersionHistory = useCallback(async () => { await onClick?.() }, [onClick]) useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.shift.h`, (e) => { e.preventDefault() handleViewVersionHistory() } , { exactMatch: true, useCapture: true }) return } noDecoration popupClassName='rounded-lg border-[0.5px] border-components-panel-border bg-components-tooltip-bg shadow-lg shadow-shadow-shadow-5 backdrop-blur-[5px] p-1.5' > } export default VersionHistoryButton