mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-19 07:57:00 +00:00
Change back button to always appear in advanced web UI (#29669)
This commit is contained in:
parent
f4d753aedf
commit
be52633ee4
|
@ -13,7 +13,7 @@ import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react'
|
||||||
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
|
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
|
||||||
import SettingsIcon from '@/material-icons/400-24px/settings.svg?react';
|
import SettingsIcon from '@/material-icons/400-24px/settings.svg?react';
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import { ButtonInTabsBar, useColumnsContext } from 'mastodon/features/ui/util/columns_context';
|
import { ButtonInTabsBar } from 'mastodon/features/ui/util/columns_context';
|
||||||
import { WithRouterPropTypes } from 'mastodon/utils/react_router';
|
import { WithRouterPropTypes } from 'mastodon/utils/react_router';
|
||||||
|
|
||||||
import { useAppHistory } from './router';
|
import { useAppHistory } from './router';
|
||||||
|
@ -26,10 +26,9 @@ const messages = defineMessages({
|
||||||
back: { id: 'column_back_button.label', defaultMessage: 'Back' },
|
back: { id: 'column_back_button.label', defaultMessage: 'Back' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const BackButton = ({ pinned, show, onlyIcon }) => {
|
const BackButton = ({ onlyIcon }) => {
|
||||||
const history = useAppHistory();
|
const history = useAppHistory();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { multiColumn } = useColumnsContext();
|
|
||||||
|
|
||||||
const handleBackClick = useCallback(() => {
|
const handleBackClick = useCallback(() => {
|
||||||
if (history.location?.state?.fromMastodon) {
|
if (history.location?.state?.fromMastodon) {
|
||||||
|
@ -39,10 +38,6 @@ const BackButton = ({ pinned, show, onlyIcon }) => {
|
||||||
}
|
}
|
||||||
}, [history]);
|
}, [history]);
|
||||||
|
|
||||||
const showButton = history && !pinned && ((multiColumn && history.location?.state?.fromMastodon) || show);
|
|
||||||
|
|
||||||
if (!showButton) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button onClick={handleBackClick} className={classNames('column-header__back-button', { 'compact': onlyIcon })} aria-label={intl.formatMessage(messages.back)}>
|
<button onClick={handleBackClick} className={classNames('column-header__back-button', { 'compact': onlyIcon })} aria-label={intl.formatMessage(messages.back)}>
|
||||||
<Icon id='chevron-left' icon={ArrowBackIcon} className='column-back-button__icon' />
|
<Icon id='chevron-left' icon={ArrowBackIcon} className='column-back-button__icon' />
|
||||||
|
@ -52,8 +47,6 @@ const BackButton = ({ pinned, show, onlyIcon }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
BackButton.propTypes = {
|
BackButton.propTypes = {
|
||||||
pinned: PropTypes.bool,
|
|
||||||
show: PropTypes.bool,
|
|
||||||
onlyIcon: PropTypes.bool,
|
onlyIcon: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,7 +111,7 @@ class ColumnHeader extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { title, icon, iconComponent, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props;
|
const { title, icon, iconComponent, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues, history } = this.props;
|
||||||
const { collapsed, animating } = this.state;
|
const { collapsed, animating } = this.state;
|
||||||
|
|
||||||
const wrapperClassName = classNames('column-header__wrapper', {
|
const wrapperClassName = classNames('column-header__wrapper', {
|
||||||
|
@ -161,7 +154,9 @@ class ColumnHeader extends PureComponent {
|
||||||
pinButton = <button className='text-btn column-header__setting-btn' onClick={this.handlePin}><Icon id='plus' icon={AddIcon} /> <FormattedMessage id='column_header.pin' defaultMessage='Pin' /></button>;
|
pinButton = <button className='text-btn column-header__setting-btn' onClick={this.handlePin}><Icon id='plus' icon={AddIcon} /> <FormattedMessage id='column_header.pin' defaultMessage='Pin' /></button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
backButton = <BackButton pinned={pinned} show={showBackButton} onlyIcon={!!title} />;
|
if (history && !pinned && ((multiColumn && history.location?.state?.fromMastodon) || showBackButton)) {
|
||||||
|
backButton = <BackButton onlyIcon={!!title} />;
|
||||||
|
}
|
||||||
|
|
||||||
const collapsedContent = [
|
const collapsedContent = [
|
||||||
extraContent,
|
extraContent,
|
||||||
|
@ -199,16 +194,16 @@ class ColumnHeader extends PureComponent {
|
||||||
<h1 className={buttonClassName}>
|
<h1 className={buttonClassName}>
|
||||||
{hasTitle && (
|
{hasTitle && (
|
||||||
<>
|
<>
|
||||||
{showBackButton && backButton}
|
{backButton}
|
||||||
|
|
||||||
<button onClick={this.handleTitleClick} className='column-header__title'>
|
<button onClick={this.handleTitleClick} className='column-header__title'>
|
||||||
{!showBackButton && <Icon id={icon} icon={iconComponent} className='column-header__icon' />}
|
{!backButton && <Icon id={icon} icon={iconComponent} className='column-header__icon' />}
|
||||||
{title}
|
{title}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!hasTitle && showBackButton && backButton}
|
{!hasTitle && backButton}
|
||||||
|
|
||||||
<div className='column-header__buttons'>
|
<div className='column-header__buttons'>
|
||||||
{extraButton}
|
{extraButton}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class FollowRequests extends ImmutablePureComponent {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column bindToDocument={!multiColumn} icon='user-plus' iconComponent={PersonAddIcon} heading={intl.formatMessage(messages.heading)} alwaysShowBackButton>
|
<Column bindToDocument={!multiColumn} icon='user-plus' iconComponent={PersonAddIcon} heading={intl.formatMessage(messages.heading)}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
scrollKey='follow_requests'
|
scrollKey='follow_requests'
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
|
|
Loading…
Reference in a new issue