[MM-58856] Migrate tooltips of "components/copy_button.tsx" to WithTooltip (#27433)

Этот коммит содержится в:
Ningthoujam Swamikumar Singh
2024-07-08 22:20:55 +05:30
коммит произвёл GitHub
родитель e0688e237b
Коммит d939c1bd46

Просмотреть файл

@@ -3,14 +3,12 @@
import classNames from 'classnames'; import classNames from 'classnames';
import React, {useRef, useState} from 'react'; import React, {useRef, useState} from 'react';
import {Tooltip} from 'react-bootstrap';
import {FormattedMessage, defineMessages, useIntl} from 'react-intl'; import {FormattedMessage, defineMessages, useIntl} from 'react-intl';
import OverlayTrigger from 'components/overlay_trigger';
import Constants from 'utils/constants';
import {copyToClipboard} from 'utils/utils'; import {copyToClipboard} from 'utils/utils';
import WithTooltip from './with_tooltip';
type Props = { type Props = {
content: string; content: string;
isForText?: boolean; isForText?: boolean;
@@ -48,20 +46,17 @@ const CopyButton: React.FC<Props> = (props: Props) => {
tooltipMessage = messages.copyCode; tooltipMessage = messages.copyCode;
} }
const tooltip = ( const tooltipText = (
<Tooltip id='copyButton'>
<FormattedMessage {...tooltipMessage}/> <FormattedMessage {...tooltipMessage}/>
</Tooltip>
); );
const spanClassName = classNames('post-code__clipboard', props.className); const spanClassName = classNames('post-code__clipboard', props.className);
return ( return (
<OverlayTrigger <WithTooltip
shouldUpdatePosition={true} id='copyButton.text'
delayShow={Constants.OVERLAY_TIME_DELAY}
placement={props.placement ?? 'top'} placement={props.placement ?? 'top'}
overlay={tooltip} title={tooltipText}
> >
<span <span
className={spanClassName} className={spanClassName}
@@ -80,7 +75,7 @@ const CopyButton: React.FC<Props> = (props: Props) => {
/> />
} }
</span> </span>
</OverlayTrigger> </WithTooltip>
); );
}; };