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