[MM-56387] Replace missed usage of LocalizedIcon in 'search_results_header.tsx' with i/span tags (#25826)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
64232a106e
Коммит
47bf846731
@@ -23,11 +23,6 @@ const Icon = styled.i`
|
|||||||
font-size:12px;
|
font-size:12px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BackButton = styled.button`
|
|
||||||
border: 0px;
|
|
||||||
background: transparent;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderTitle = styled.span`
|
const HeaderTitle = styled.span`
|
||||||
line-height: 2.4rem;
|
line-height: 2.4rem;
|
||||||
`;
|
`;
|
||||||
@@ -46,19 +41,17 @@ const Header = ({channel, isArchived, isMobile, onClose}: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className='sidebar--right__header'>
|
<div className='sidebar--right__header'>
|
||||||
<span className='sidebar--right__title'>
|
<span className='sidebar--right__title'>
|
||||||
|
|
||||||
{isMobile && (
|
{isMobile && (
|
||||||
<BackButton
|
<button
|
||||||
className='sidebar--right__back'
|
className='sidebar--right__back btn btn-icon btn-sm'
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
|
aria-label={formatMessage({id: 'rhs_header.back.icon', defaultMessage: 'Back Icon'})}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className='icon icon-arrow-back-ios'
|
className='icon icon-arrow-back-ios'
|
||||||
aria-label='Back Icon'
|
|
||||||
/>
|
/>
|
||||||
</BackButton>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<HeaderTitle>
|
<HeaderTitle>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='channel_info_rhs.header.title'
|
id='channel_info_rhs.header.title'
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ interface Props {
|
|||||||
goBack: () => void;
|
goBack: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BackButton = styled.button`
|
|
||||||
border: 0;
|
|
||||||
background: transparent;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const HeaderTitle = styled.span`
|
const HeaderTitle = styled.span`
|
||||||
line-height: 2.4rem;
|
line-height: 2.4rem;
|
||||||
`;
|
`;
|
||||||
@@ -46,15 +41,15 @@ const Header = ({channel, canGoBack, onClose, goBack}: Props) => {
|
|||||||
<span className='sidebar--right__title'>
|
<span className='sidebar--right__title'>
|
||||||
|
|
||||||
{canGoBack && (
|
{canGoBack && (
|
||||||
<BackButton
|
<button
|
||||||
className='sidebar--right__back'
|
className='sidebar--right__back btn btn-icon btn-sm'
|
||||||
onClick={goBack}
|
onClick={goBack}
|
||||||
|
aria-label={formatMessage({id: 'rhs_header.back.icon', defaultMessage: 'Back Icon'})}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className='icon icon-arrow-back-ios'
|
className='icon icon-arrow-back-ios'
|
||||||
aria-label='Back Icon'
|
|
||||||
/>
|
/>
|
||||||
</BackButton>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<HeaderTitle>
|
<HeaderTitle>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class RhsCardHeader extends React.PureComponent<Props> {
|
class RhsCardHeader extends React.PureComponent<Props> {
|
||||||
handleBack = (e: React.MouseEvent<HTMLAnchorElement>): void => {
|
handleBack = (e: React.MouseEvent<HTMLButtonElement>): void => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
switch (this.props.previousRhsState) {
|
switch (this.props.previousRhsState) {
|
||||||
@@ -135,16 +135,15 @@ class RhsCardHeader extends React.PureComponent<Props> {
|
|||||||
placement='top'
|
placement='top'
|
||||||
overlay={backToResultsTooltip}
|
overlay={backToResultsTooltip}
|
||||||
>
|
>
|
||||||
<a
|
<button
|
||||||
href='#'
|
className='sidebar--right__back btn btn-icon btn-sm'
|
||||||
onClick={this.handleBack}
|
onClick={this.handleBack}
|
||||||
className='sidebar--right__back'
|
aria-label={this.props.intl.formatMessage({id: 'rhs_header.back.icon', defaultMessage: 'Back Icon'})}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className='icon icon-arrow-back-ios'
|
className='icon icon-arrow-back-ios'
|
||||||
aria-label={this.props.intl.formatMessage({id: 'generic_icons.back', defaultMessage: 'Back Icon'})}
|
|
||||||
/>
|
/>
|
||||||
</a>
|
</button>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,16 +160,15 @@ class RhsHeaderPost extends React.PureComponent<Props> {
|
|||||||
placement='top'
|
placement='top'
|
||||||
overlay={backToResultsTooltip}
|
overlay={backToResultsTooltip}
|
||||||
>
|
>
|
||||||
<a
|
<button
|
||||||
href='#'
|
className='sidebar--right__back btn btn-icon btn-sm'
|
||||||
onClick={this.handleBack}
|
onClick={this.handleBack}
|
||||||
className='sidebar--right__back'
|
aria-label={formatMessage({id: 'rhs_header.back.icon', defaultMessage: 'Back Icon'})}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className='icon icon-arrow-back-ios'
|
className='icon icon-arrow-back-ios'
|
||||||
aria-label={formatMessage({id: 'generic_icons.back', defaultMessage: 'Back Icon'})}
|
|
||||||
/>
|
/>
|
||||||
</a>
|
</button>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
import type {ConnectedProps} from 'react-redux';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import {bindActionCreators} from 'redux';
|
import {bindActionCreators} from 'redux';
|
||||||
import type {AnyAction, Dispatch} from 'redux';
|
import type {AnyAction, Dispatch} from 'redux';
|
||||||
@@ -45,4 +46,8 @@ function mapDispatchToProps(dispatch: Dispatch<AnyAction>) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(SearchResultsHeader);
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
||||||
|
|
||||||
|
export type PropsFromRedux = ConnectedProps<typeof connector>;
|
||||||
|
|
||||||
|
export default connector(SearchResultsHeader);
|
||||||
|
|||||||
@@ -8,15 +8,16 @@ import {RHSStates} from 'utils/constants';
|
|||||||
|
|
||||||
import type {RhsState} from 'types/store/rhs';
|
import type {RhsState} from 'types/store/rhs';
|
||||||
|
|
||||||
import Header from './search_results_header';
|
import SearchResultsHeader from './search_results_header';
|
||||||
|
|
||||||
describe('search_results_header', () => {
|
describe('search_results_header', () => {
|
||||||
test('should display back button when the parent is channel info', () => {
|
test('should display back button when the parent is channel info', () => {
|
||||||
renderWithContext(
|
renderWithContext(
|
||||||
<Header
|
<SearchResultsHeader
|
||||||
previousRhsState={RHSStates.CHANNEL_INFO as RhsState}
|
previousRhsState={RHSStates.CHANNEL_INFO as RhsState}
|
||||||
canGoBack={true}
|
canGoBack={true}
|
||||||
isExpanded={false}
|
isExpanded={false}
|
||||||
|
channelId='channel_id'
|
||||||
actions={{
|
actions={{
|
||||||
closeRightHandSide: jest.fn(),
|
closeRightHandSide: jest.fn(),
|
||||||
toggleRhsExpanded: jest.fn(),
|
toggleRhsExpanded: jest.fn(),
|
||||||
@@ -24,17 +25,18 @@ describe('search_results_header', () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{'Title'}
|
{'Title'}
|
||||||
</Header>,
|
</SearchResultsHeader>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByLabelText('Back Icon')).toBeInTheDocument();
|
expect(screen.getByLabelText('Back Icon')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
test('should NOT diplay expand when the parent is channel info', () => {
|
test('should NOT diplay expand when the parent is channel info', () => {
|
||||||
renderWithContext(
|
renderWithContext(
|
||||||
<Header
|
<SearchResultsHeader
|
||||||
previousRhsState={RHSStates.CHANNEL_INFO as RhsState}
|
previousRhsState={RHSStates.CHANNEL_INFO as RhsState}
|
||||||
canGoBack={true}
|
canGoBack={true}
|
||||||
isExpanded={false}
|
isExpanded={false}
|
||||||
|
channelId='channel_id'
|
||||||
actions={{
|
actions={{
|
||||||
closeRightHandSide: jest.fn(),
|
closeRightHandSide: jest.fn(),
|
||||||
toggleRhsExpanded: jest.fn(),
|
toggleRhsExpanded: jest.fn(),
|
||||||
@@ -42,17 +44,18 @@ describe('search_results_header', () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{'Title'}
|
{'Title'}
|
||||||
</Header>,
|
</SearchResultsHeader>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.queryByLabelText('Expand Sidebar Icon')).not.toBeInTheDocument();
|
expect(screen.queryByLabelText('Expand Sidebar Icon')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
test('should diplay expand when the parent is NOT channel info', () => {
|
test('should diplay expand when the parent is NOT channel info', () => {
|
||||||
renderWithContext(
|
renderWithContext(
|
||||||
<Header
|
<SearchResultsHeader
|
||||||
previousRhsState={RHSStates.FLAG as RhsState}
|
previousRhsState={RHSStates.FLAG as RhsState}
|
||||||
canGoBack={true}
|
canGoBack={true}
|
||||||
isExpanded={false}
|
isExpanded={false}
|
||||||
|
channelId='channel_id'
|
||||||
actions={{
|
actions={{
|
||||||
closeRightHandSide: jest.fn(),
|
closeRightHandSide: jest.fn(),
|
||||||
toggleRhsExpanded: jest.fn(),
|
toggleRhsExpanded: jest.fn(),
|
||||||
@@ -60,7 +63,7 @@ describe('search_results_header', () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{'Title'}
|
{'Title'}
|
||||||
</Header>,
|
</SearchResultsHeader>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByLabelText('Expand Sidebar Icon')).toBeInTheDocument();
|
expect(screen.getByLabelText('Expand Sidebar Icon')).toBeInTheDocument();
|
||||||
|
|||||||
@@ -2,47 +2,23 @@
|
|||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {FormattedMessage, type WrappedComponentProps, injectIntl} from 'react-intl';
|
import {FormattedMessage, useIntl} from 'react-intl';
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import KeyboardShortcutSequence, {
|
import KeyboardShortcutSequence, {KEYBOARD_SHORTCUTS} from 'components/keyboard_shortcuts/keyboard_shortcuts_sequence';
|
||||||
KEYBOARD_SHORTCUTS,
|
|
||||||
} from 'components/keyboard_shortcuts/keyboard_shortcuts_sequence';
|
|
||||||
import LocalizedIcon from 'components/localized_icon';
|
|
||||||
import OverlayTrigger from 'components/overlay_trigger';
|
import OverlayTrigger from 'components/overlay_trigger';
|
||||||
import Tooltip from 'components/tooltip';
|
import Tooltip from 'components/tooltip';
|
||||||
|
|
||||||
import Constants, {RHSStates} from 'utils/constants';
|
import Constants, {RHSStates} from 'utils/constants';
|
||||||
import {t} from 'utils/i18n';
|
|
||||||
|
|
||||||
import type {RhsState} from 'types/store/rhs';
|
import type {PropsFromRedux} from './index';
|
||||||
|
|
||||||
const BackButton = styled.button`
|
export interface Props extends PropsFromRedux {
|
||||||
border: 0px;
|
children: React.ReactNode;
|
||||||
background: transparent;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const BackButtonIcon = styled(LocalizedIcon)`
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 18px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
interface Props extends WrappedComponentProps {
|
|
||||||
isExpanded: boolean;
|
|
||||||
previousRhsState?: RhsState;
|
|
||||||
canGoBack: boolean;
|
|
||||||
children?: React.ReactNode;
|
|
||||||
actions: {
|
|
||||||
closeRightHandSide: () => void;
|
|
||||||
toggleRhsExpanded: () => void;
|
|
||||||
goBack: () => void;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchResultsHeader extends React.PureComponent<Props> {
|
function SearchResultsHeader(props: Props) {
|
||||||
render(): React.ReactNode {
|
const {formatMessage} = useIntl();
|
||||||
|
|
||||||
const closeSidebarTooltip = (
|
const closeSidebarTooltip = (
|
||||||
<Tooltip id='closeSidebarTooltip'>
|
<Tooltip id='closeSidebarTooltip'>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@@ -80,44 +56,41 @@ class SearchResultsHeader extends React.PureComponent<Props> {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|
||||||
const showExpand = this.props.previousRhsState !== RHSStates.CHANNEL_INFO;
|
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'>
|
||||||
{this.props.canGoBack && (
|
{props.canGoBack && (
|
||||||
<BackButton
|
<button
|
||||||
className='sidebar--right__back'
|
className='sidebar--right__back btn btn-icon btn-sm'
|
||||||
onClick={() => this.props.actions.goBack()}
|
onClick={props.actions.goBack}
|
||||||
|
aria-label={formatMessage({id: 'rhs_header.back.icon', defaultMessage: 'Back Icon'})}
|
||||||
>
|
>
|
||||||
<BackButtonIcon
|
<i className='icon icon-arrow-back-ios'/>
|
||||||
className='icon-arrow-back-ios'
|
</button>
|
||||||
ariaLabel={{id: t('rhs_header.back.icon'), defaultMessage: 'Back Icon'}}
|
|
||||||
/>
|
|
||||||
</BackButton>
|
|
||||||
)}
|
)}
|
||||||
{this.props.children}
|
{props.children}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div className='pull-right'>
|
<div className='pull-right'>
|
||||||
{showExpand && (
|
{showExpand && (
|
||||||
<OverlayTrigger
|
<OverlayTrigger
|
||||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
delayShow={Constants.OVERLAY_TIME_DELAY}
|
||||||
placement='bottom'
|
placement='bottom'
|
||||||
overlay={this.props.isExpanded ? shrinkSidebarTooltip : expandSidebarTooltip}
|
overlay={props.isExpanded ? shrinkSidebarTooltip : expandSidebarTooltip}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type='button'
|
type='button'
|
||||||
className='sidebar--right__expand btn btn-icon btn-sm'
|
className='sidebar--right__expand btn btn-icon btn-sm'
|
||||||
onClick={this.props.actions.toggleRhsExpanded}
|
onClick={props.actions.toggleRhsExpanded}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className='icon icon-arrow-expand'
|
className='icon icon-arrow-expand'
|
||||||
aria-label={this.props.intl.formatMessage({id: 'rhs_header.expandSidebarTooltip.icon', defaultMessage: 'Expand Sidebar Icon'})}
|
aria-label={formatMessage({id: 'rhs_header.expandSidebarTooltip.icon', defaultMessage: 'Expand Sidebar Icon'})}
|
||||||
/>
|
/>
|
||||||
<i
|
<i
|
||||||
className='icon icon-arrow-collapse'
|
className='icon icon-arrow-collapse'
|
||||||
aria-label={this.props.intl.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>
|
</OverlayTrigger>
|
||||||
@@ -132,11 +105,11 @@ class SearchResultsHeader extends React.PureComponent<Props> {
|
|||||||
type='button'
|
type='button'
|
||||||
className='sidebar--right__close btn btn-icon btn-sm'
|
className='sidebar--right__close btn btn-icon btn-sm'
|
||||||
aria-label='Close'
|
aria-label='Close'
|
||||||
onClick={this.props.actions.closeRightHandSide}
|
onClick={props.actions.closeRightHandSide}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className='icon icon-close'
|
className='icon icon-close'
|
||||||
aria-label={this.props.intl.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>
|
</OverlayTrigger>
|
||||||
@@ -144,6 +117,5 @@ class SearchResultsHeader extends React.PureComponent<Props> {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default injectIntl(SearchResultsHeader);
|
export default SearchResultsHeader;
|
||||||
|
|||||||
@@ -87,30 +87,6 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar--right__back {
|
|
||||||
display: flex;
|
|
||||||
width: 2.4rem;
|
|
||||||
height: 2.4rem;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-right: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
color: rgba(var(--center-channel-color-rgb), 0.56);
|
|
||||||
font-size: 12px;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: all 0.2s ease-in;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: rgba(var(--center-channel-color-rgb), 0.08);
|
|
||||||
color: rgba(var(--center-channel-color-rgb), 0.72);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: rgba(var(--button-bg-rgb), 0.08);
|
|
||||||
color: v(button-bg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-right__body {
|
.sidebar-right__body {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -237,6 +213,10 @@
|
|||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar--right__back {
|
||||||
|
margin-right: 4px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.controls {
|
.controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user