migrate tooltips of file_preview_modal_main_actions.tsx to WithTooltip (#27243)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1505c37977
Коммит
633b565192
@@ -12,10 +12,9 @@ import {getFilePublicLink as selectFilePublicLink} from 'mattermost-redux/select
|
||||
|
||||
import CopyButton from 'components/copy_button';
|
||||
import ExternalLink from 'components/external_link';
|
||||
import OverlayTrigger from 'components/overlay_trigger';
|
||||
import Tooltip from 'components/tooltip';
|
||||
import WithTooltip from 'components/with_tooltip';
|
||||
|
||||
import Constants, {FileTypes} from 'utils/constants';
|
||||
import {FileTypes} from 'utils/constants';
|
||||
import {copyToClipboard, getFileType} from 'utils/utils';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
@@ -63,15 +62,11 @@ const FilePreviewModalMainActions: React.FC<Props> = (props: Props) => {
|
||||
defaultMessage: 'Close',
|
||||
});
|
||||
const closeButton = (
|
||||
<OverlayTrigger
|
||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
||||
key='publicLink'
|
||||
<WithTooltip
|
||||
id='close-icon-tooltip'
|
||||
title={closeMessage}
|
||||
placement={tooltipPlacement}
|
||||
overlay={
|
||||
<Tooltip id='close-icon-tooltip'>
|
||||
{closeMessage}
|
||||
</Tooltip>
|
||||
}
|
||||
key='publicLink'
|
||||
>
|
||||
<button
|
||||
className='file-preview-modal-main-actions__action-item'
|
||||
@@ -80,7 +75,7 @@ const FilePreviewModalMainActions: React.FC<Props> = (props: Props) => {
|
||||
>
|
||||
<i className='icon icon-close'/>
|
||||
</button>
|
||||
</OverlayTrigger>
|
||||
</WithTooltip>
|
||||
);
|
||||
|
||||
let publicTooltipMessage;
|
||||
@@ -96,17 +91,13 @@ const FilePreviewModalMainActions: React.FC<Props> = (props: Props) => {
|
||||
});
|
||||
}
|
||||
const publicLink = (
|
||||
<OverlayTrigger
|
||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
||||
<WithTooltip
|
||||
id='link-variant-icon-tooltip.text'
|
||||
key='filePreviewPublicLink'
|
||||
placement={tooltipPlacement}
|
||||
title={publicTooltipMessage}
|
||||
shouldUpdatePosition={true}
|
||||
onExit={() => setPublicLinkCopied(false)}
|
||||
overlay={
|
||||
<Tooltip id='link-variant-icon-tooltip'>
|
||||
{publicTooltipMessage}
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
<a
|
||||
href='#'
|
||||
@@ -116,7 +107,7 @@ const FilePreviewModalMainActions: React.FC<Props> = (props: Props) => {
|
||||
>
|
||||
<i className='icon icon-link-variant'/>
|
||||
</a>
|
||||
</OverlayTrigger>
|
||||
</WithTooltip>
|
||||
);
|
||||
|
||||
const downloadMessage = intl.formatMessage({
|
||||
@@ -124,15 +115,11 @@ const FilePreviewModalMainActions: React.FC<Props> = (props: Props) => {
|
||||
defaultMessage: 'Download',
|
||||
});
|
||||
const download = (
|
||||
<OverlayTrigger
|
||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
||||
<WithTooltip
|
||||
id='download-icon-tooltip.text'
|
||||
key='download'
|
||||
placement={tooltipPlacement}
|
||||
overlay={
|
||||
<Tooltip id='download-icon-tooltip'>
|
||||
{downloadMessage}
|
||||
</Tooltip>
|
||||
}
|
||||
title={downloadMessage}
|
||||
>
|
||||
<ExternalLink
|
||||
href={props.fileURL}
|
||||
@@ -143,7 +130,7 @@ const FilePreviewModalMainActions: React.FC<Props> = (props: Props) => {
|
||||
>
|
||||
<i className='icon icon-download-outline'/>
|
||||
</ExternalLink>
|
||||
</OverlayTrigger>
|
||||
</WithTooltip>
|
||||
);
|
||||
|
||||
const copy = (
|
||||
|
||||
@@ -20,6 +20,7 @@ export type CommonTooltipProps = {
|
||||
shortcut?: ShortcutDefinition;
|
||||
emoji?: string;
|
||||
emojiStyle?: EmojiStyle;
|
||||
shouldUpdatePosition?: boolean;
|
||||
}
|
||||
|
||||
export function createTooltip(commonTooltipProps: CommonTooltipProps) {
|
||||
|
||||
@@ -17,6 +17,7 @@ type WithTooltipProps = {
|
||||
children: OverlayTriggerProps['children'];
|
||||
placement: OverlayTriggerProps['placement'];
|
||||
onShow?: () => void;
|
||||
onExit?: () => void;
|
||||
} & CommonTooltipProps;
|
||||
const WithTooltip = ({
|
||||
id,
|
||||
@@ -28,6 +29,8 @@ const WithTooltip = ({
|
||||
placement,
|
||||
onShow,
|
||||
children,
|
||||
onExit,
|
||||
shouldUpdatePosition,
|
||||
}: WithTooltipProps) => {
|
||||
const ThisTooltip = useMemo(() => createTooltip({
|
||||
id,
|
||||
@@ -44,6 +47,8 @@ const WithTooltip = ({
|
||||
overlay={<ThisTooltip/>}
|
||||
placement={placement}
|
||||
onEnter={onShow}
|
||||
onExit={onExit}
|
||||
shouldUpdatePosition={shouldUpdatePosition}
|
||||
>
|
||||
{children}
|
||||
</OverlayTrigger>
|
||||
|
||||
Ссылка в новой задаче
Block a user