Merge branch 'features/polls-behind-cws' into 'develop'

Put poll options behind content warnings

See merge request soapbox-pub/soapbox-fe!653
groups
Alex Gleason 2021-08-02 16:01:44 +00:00
commit 836feb603d
6 zmienionych plików z 71 dodań i 15 usunięć

Wyświetl plik

@ -16,7 +16,6 @@ import { MediaGallery, Video, Audio } from '../features/ui/util/async-components
import { HotKeys } from 'react-hotkeys';
import classNames from 'classnames';
import Icon from 'soapbox/components/icon';
import PollContainer from 'soapbox/containers/poll_container';
import { Link, NavLink } from 'react-router-dom';
import { getDomain } from 'soapbox/utils/accounts';
import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper';
@ -361,10 +360,6 @@ class Status extends ImmutablePureComponent {
status = status.get('reblog');
}
if (status.get('poll')) {
poll = <PollContainer pollId={status.get('poll')} />;
}
const size = status.get('media_attachments').size;
if (size > 0) {

Wyświetl plik

@ -6,6 +6,7 @@ import { isRtl } from '../rtl';
import { FormattedMessage } from 'react-intl';
import Permalink from './permalink';
import classnames from 'classnames';
import PollContainer from 'soapbox/containers/poll_container';
import Icon from 'soapbox/components/icon';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
import { addGreentext } from 'soapbox/utils/greentext';
@ -240,6 +241,8 @@ class StatusContent extends React.PureComponent {
{mentionsPlaceholder}
<div tabIndex={!hidden ? 0 : null} className={`status__content__text ${!hidden ? 'status__content__text--visible' : ''}`} style={directionStyle} dangerouslySetInnerHTML={content} lang={status.get('language')} />
{!hidden && !!status.get('poll') && <PollContainer pollId={status.get('poll')} />}
</div>
);
} else if (this.props.onClick) {
@ -261,9 +264,13 @@ class StatusContent extends React.PureComponent {
output.push(readMoreButton);
}
if (status.get('poll')) {
output.push(<PollContainer pollId={status.get('poll')} />);
}
return output;
} else {
return (
const output = [
<div
tabIndex='0'
ref={this.setRef}
@ -273,8 +280,14 @@ class StatusContent extends React.PureComponent {
style={directionStyle}
dangerouslySetInnerHTML={content}
lang={status.get('language')}
/>
);
/>,
];
if (status.get('poll')) {
output.push(<PollContainer pollId={status.get('poll')} />);
}
return output;
}
}

Wyświetl plik

@ -0,0 +1,50 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import classNames from 'classnames';
export default class PollPreview extends ImmutablePureComponent {
static propTypes = {
poll: ImmutablePropTypes.map,
};
renderOption(option) {
const { poll } = this.props;
const showResults = poll.get('voted') || poll.get('expired');
return (
<li key={option}>
<label className={classNames('poll__text', { selectable: !showResults })}>
<input
name='vote-options'
type={poll.get('multiple') ? 'checkbox' : 'radio'}
onChange={this.handleOptionChange}
disabled
/>
<span className={classNames('poll__input', { checkbox: poll.get('multiple') })} />
<span dangerouslySetInnerHTML={{ __html: option }} />
</label>
</li>
);
}
render() {
const { poll } = this.props;
if (!poll) {
return null;
}
return (
<div className='poll'>
<ul>
{poll.get('options').map((option, i) => this.renderOption(option, i))}
</ul>
</div>
);
}
}

Wyświetl plik

@ -11,7 +11,7 @@ import { getDomain } from 'soapbox/utils/accounts';
import Avatar from 'soapbox/components/avatar';
import DisplayName from 'soapbox/components/display_name';
import AttachmentList from 'soapbox/components/attachment_list';
import PollContainer from 'soapbox/containers/poll_container';
import PollPreview from './poll_preview';
import ScheduledStatusActionBar from './scheduled_status_action_bar';
const mapStateToProps = (state, props) => {
@ -72,7 +72,7 @@ class ScheduledStatus extends ImmutablePureComponent {
media={status.get('media_attachments')}
/>
{status.get('poll') && <PollContainer pollId={status.get('poll')} />}
{status.get('poll') && <PollPreview poll={status.get('poll')} />}
{showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && (
<button className='status__content__read-more-button' onClick={this.handleClick}>

Wyświetl plik

@ -14,7 +14,6 @@ import Audio from '../../audio';
import scheduleIdleTask from '../../ui/util/schedule_idle_task';
import classNames from 'classnames';
import Icon from 'soapbox/components/icon';
import PollContainer from 'soapbox/containers/poll_container';
import StatusInteractionBar from './status_interaction_bar';
import { getDomain } from 'soapbox/utils/accounts';
import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper';
@ -103,9 +102,6 @@ export default class DetailedStatus extends ImmutablePureComponent {
outerStyle.height = `${this.state.height}px`;
}
if (status.get('poll')) {
poll = <PollContainer pollId={status.get('poll')} />;
}
if (size > 0) {
if (size === 1 && status.getIn(['media_attachments', 0, 'type']) === 'video') {
const video = status.getIn(['media_attachments', 0]);

Wyświetl plik

@ -210,6 +210,8 @@
"compose_form.publish": "Wyślij",
"compose_form.publish_loud": "{publish}!",
"compose_form.schedule": "Zaplanuj",
"compose_form.scheduled_statuses.click_here": "Naciśnij tutaj",
"compose_form.scheduled_statuses.message": "Masz zaplanowane wpisy. {click_here}, aby je zobaczyć.",
"compose_form.sensitive.hide": "Oznacz multimedia jako wrażliwe",
"compose_form.sensitive.marked": "Zawartość multimedia jest oznaczona jako wrażliwa",
"compose_form.sensitive.unmarked": "Zawartość multimedialna nie jest oznaczona jako wrażliwa",
@ -222,7 +224,7 @@
"confirmations.admin.delete_local_user.checkbox": "Wiem, że właśnie usuwam lokalnego użytkownika.",
"confirmations.admin.delete_status.confirm": "Usuń wpis",
"confirmations.admin.delete_status.message": "Zamierzasz usunąć wpis użytkownika @{acct}. To działanie nie może zostać cofnięte.",
"confirmations.admin.delete_user.confirm": "@Usuń {name}",
"confirmations.admin.delete_user.confirm": "Usuń @{name}",
"confirmations.admin.delete_user.message": "Zamierzasz usunąć @{acct}. TO DZIAŁANIE NIE MOŻE ZOSTAĆ COFNIĘTE.",
"confirmations.admin.mark_status_not_sensitive.confirm": "Oznacz wpis jako niewrażliwy",
"confirmations.admin.mark_status_not_sensitive.message": "Zamierzasz oznaczyć wpis {acct} jako niewrażliwy.",