[MM-60158] Migrate tooltips of "components/search_results_header/search_results_header.tsx" to WithTooltip (#28005)
Этот коммит содержится в:
@@ -5,10 +5,9 @@ import React from 'react';
|
|||||||
import {FormattedMessage, useIntl} from 'react-intl';
|
import {FormattedMessage, useIntl} from 'react-intl';
|
||||||
|
|
||||||
import KeyboardShortcutSequence, {KEYBOARD_SHORTCUTS} from 'components/keyboard_shortcuts/keyboard_shortcuts_sequence';
|
import KeyboardShortcutSequence, {KEYBOARD_SHORTCUTS} from 'components/keyboard_shortcuts/keyboard_shortcuts_sequence';
|
||||||
import OverlayTrigger from 'components/overlay_trigger';
|
import WithTooltip from 'components/with_tooltip';
|
||||||
import Tooltip from 'components/tooltip';
|
|
||||||
|
|
||||||
import Constants, {RHSStates} from 'utils/constants';
|
import {RHSStates} from 'utils/constants';
|
||||||
|
|
||||||
import type {PropsFromRedux} from './index';
|
import type {PropsFromRedux} from './index';
|
||||||
|
|
||||||
@@ -19,31 +18,12 @@ export interface Props extends PropsFromRedux {
|
|||||||
function SearchResultsHeader(props: Props) {
|
function SearchResultsHeader(props: Props) {
|
||||||
const {formatMessage} = useIntl();
|
const {formatMessage} = useIntl();
|
||||||
|
|
||||||
const closeSidebarTooltip = (
|
const showExpand = props.previousRhsState !== RHSStates.CHANNEL_INFO;
|
||||||
<Tooltip id='closeSidebarTooltip'>
|
|
||||||
<FormattedMessage
|
|
||||||
id='rhs_header.closeSidebarTooltip'
|
|
||||||
defaultMessage='Close'
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
|
|
||||||
const expandSidebarTooltip = (
|
// sidebarTooltipContent contains tooltips content for expand or shrink sidebarTooltip.
|
||||||
<Tooltip id='expandSidebarTooltip'>
|
// if props.isExpanded is true, defaultMessage would feed from 'shrinkTooltip', else 'expandTooltip'
|
||||||
<FormattedMessage
|
const sidebarTooltipContent = props.isExpanded ? (
|
||||||
id='rhs_header.expandSidebarTooltip'
|
<>
|
||||||
defaultMessage='Expand the right sidebar'
|
|
||||||
/>
|
|
||||||
<KeyboardShortcutSequence
|
|
||||||
shortcut={KEYBOARD_SHORTCUTS.navExpandSidebar}
|
|
||||||
hideDescription={true}
|
|
||||||
isInsideTooltip={true}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
|
|
||||||
const shrinkSidebarTooltip = (
|
|
||||||
<Tooltip id='shrinkSidebarTooltip'>
|
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='rhs_header.collapseSidebarTooltip'
|
id='rhs_header.collapseSidebarTooltip'
|
||||||
defaultMessage='Collapse the right sidebar'
|
defaultMessage='Collapse the right sidebar'
|
||||||
@@ -53,11 +33,21 @@ function SearchResultsHeader(props: Props) {
|
|||||||
hideDescription={true}
|
hideDescription={true}
|
||||||
isInsideTooltip={true}
|
isInsideTooltip={true}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<FormattedMessage
|
||||||
|
id='rhs_header.expandSidebarTooltip'
|
||||||
|
defaultMessage='Expand the right sidebar'
|
||||||
|
/>
|
||||||
|
<KeyboardShortcutSequence
|
||||||
|
shortcut={KEYBOARD_SHORTCUTS.navExpandSidebar}
|
||||||
|
hideDescription={true}
|
||||||
|
isInsideTooltip={true}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const showExpand = props.previousRhsState !== RHSStates.CHANNEL_INFO;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='sidebar--right__header'>
|
<div className='sidebar--right__header'>
|
||||||
<span className='sidebar--right__title'>
|
<span className='sidebar--right__title'>
|
||||||
@@ -74,10 +64,10 @@ function SearchResultsHeader(props: Props) {
|
|||||||
</span>
|
</span>
|
||||||
<div className='pull-right'>
|
<div className='pull-right'>
|
||||||
{showExpand && (
|
{showExpand && (
|
||||||
<OverlayTrigger
|
<WithTooltip
|
||||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
|
||||||
placement='bottom'
|
placement='bottom'
|
||||||
overlay={props.isExpanded ? shrinkSidebarTooltip : expandSidebarTooltip}
|
id={props.isExpanded ? 'shrinkSidebarTooltip' : 'expandSidebarTooltip'}
|
||||||
|
title={sidebarTooltipContent}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type='button'
|
type='button'
|
||||||
@@ -93,12 +83,17 @@ function SearchResultsHeader(props: Props) {
|
|||||||
aria-label={formatMessage({id: 'rhs_header.collapseSidebarTooltip.icon', defaultMessage: 'Collapse Sidebar Icon'})}
|
aria-label={formatMessage({id: 'rhs_header.collapseSidebarTooltip.icon', defaultMessage: 'Collapse Sidebar Icon'})}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</OverlayTrigger>
|
</WithTooltip>
|
||||||
)}
|
)}
|
||||||
<OverlayTrigger
|
<WithTooltip
|
||||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
|
||||||
placement='top'
|
placement='top'
|
||||||
overlay={closeSidebarTooltip}
|
id='closeSidebarTooltip'
|
||||||
|
title={
|
||||||
|
<FormattedMessage
|
||||||
|
id='rhs_header.closeSidebarTooltip'
|
||||||
|
defaultMessage='Close'
|
||||||
|
/>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
id='searchResultsCloseButton'
|
id='searchResultsCloseButton'
|
||||||
@@ -112,7 +107,7 @@ function SearchResultsHeader(props: Props) {
|
|||||||
aria-label={formatMessage({id: 'rhs_header.closeTooltip.icon', defaultMessage: 'Close Sidebar Icon'})}
|
aria-label={formatMessage({id: 'rhs_header.closeTooltip.icon', defaultMessage: 'Close Sidebar Icon'})}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</OverlayTrigger>
|
</WithTooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user