kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
TimelineQueueButtonHeader: Make more i18n friendly
rodzic
61c34b93e7
commit
81fa77b8a5
|
@ -1,6 +1,6 @@
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage, defineMessages } from 'react-intl';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusContainer from '../containers/status_container';
|
import StatusContainer from '../containers/status_container';
|
||||||
|
@ -9,6 +9,10 @@ import LoadGap from './load_gap';
|
||||||
import ScrollableList from './scrollable_list';
|
import ScrollableList from './scrollable_list';
|
||||||
import TimelineQueueButtonHeader from './timeline_queue_button_header';
|
import TimelineQueueButtonHeader from './timeline_queue_button_header';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
queue: { id: 'status_list.queue_label', defaultMessage: 'Click to see {count} new {count, plural, one {post} other {posts}}' },
|
||||||
|
});
|
||||||
|
|
||||||
export default class StatusList extends ImmutablePureComponent {
|
export default class StatusList extends ImmutablePureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -138,7 +142,12 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<TimelineQueueButtonHeader key='timeline-queue-button-header' onClick={this.handleDequeueTimeline} count={totalQueuedItemsCount} itemType='post' />,
|
<TimelineQueueButtonHeader
|
||||||
|
key='timeline-queue-button-header'
|
||||||
|
onClick={this.handleDequeueTimeline}
|
||||||
|
count={totalQueuedItemsCount}
|
||||||
|
message={messages.queue}
|
||||||
|
/>,
|
||||||
<ScrollableList key='scrollable-list' {...other} isLoading={isLoading} showLoading={isLoading && statusIds.size === 0} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}>
|
<ScrollableList key='scrollable-list' {...other} isLoading={isLoading} showLoading={isLoading && statusIds.size === 0} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}>
|
||||||
{scrollableContent}
|
{scrollableContent}
|
||||||
</ScrollableList>,
|
</ScrollableList>,
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
import { shortNumberFormat } from '../utils/numbers';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
export default class TimelineQueueButtonHeader extends React.PureComponent {
|
export default @injectIntl
|
||||||
|
class TimelineQueueButtonHeader extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
count: PropTypes.number,
|
count: PropTypes.number,
|
||||||
itemType: PropTypes.string,
|
message: PropTypes.object.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
count: 0,
|
count: 0,
|
||||||
itemType: 'item',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { count, itemType, onClick } = this.props;
|
const { count, message, onClick, intl } = this.props;
|
||||||
|
|
||||||
const classes = classNames('timeline-queue-header', {
|
const classes = classNames('timeline-queue-header', {
|
||||||
'hidden': (count <= 0),
|
'hidden': (count <= 0),
|
||||||
|
@ -27,14 +27,7 @@ export default class TimelineQueueButtonHeader extends React.PureComponent {
|
||||||
return (
|
return (
|
||||||
<div className={classes}>
|
<div className={classes}>
|
||||||
<a className='timeline-queue-header__btn' onClick={onClick}>
|
<a className='timeline-queue-header__btn' onClick={onClick}>
|
||||||
{(count > 0) && <FormattedMessage
|
{(count > 0) && intl.formatMessage(message, { count })}
|
||||||
id='timeline_queue.label'
|
|
||||||
defaultMessage='Click to see {count} new {type}'
|
|
||||||
values={{
|
|
||||||
count: shortNumberFormat(count),
|
|
||||||
type: count === 1 ? itemType : `${itemType}s`,
|
|
||||||
}}
|
|
||||||
/>}
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { getSettings } from 'soapbox/actions/settings';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
|
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
|
||||||
|
queue: { id: 'notifications.queue_label', defaultMessage: 'Click to see {count} new {count, plural, one {notification} other {notifications}}' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const getNotifications = createSelector([
|
const getNotifications = createSelector([
|
||||||
|
@ -182,7 +183,11 @@ class Notifications extends React.PureComponent {
|
||||||
<ColumnSettingsContainer />
|
<ColumnSettingsContainer />
|
||||||
</ColumnHeader>
|
</ColumnHeader>
|
||||||
{filterBarContainer}
|
{filterBarContainer}
|
||||||
<TimelineQueueButtonHeader onClick={this.handleDequeueNotifications} count={totalQueuedNotificationsCount} itemType='notification' />
|
<TimelineQueueButtonHeader
|
||||||
|
onClick={this.handleDequeueNotifications}
|
||||||
|
count={totalQueuedNotificationsCount}
|
||||||
|
message={messages.queue}
|
||||||
|
/>
|
||||||
{scrollContainer}
|
{scrollContainer}
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
Ładowanie…
Reference in New Issue