diff --git a/app/javascript/flavours/glitch/features/compose/components/options.jsx b/app/javascript/flavours/glitch/features/compose/components/options.jsx
deleted file mode 100644
index 5460960364..0000000000
--- a/app/javascript/flavours/glitch/features/compose/components/options.jsx
+++ /dev/null
@@ -1,330 +0,0 @@
-import PropTypes from 'prop-types';
-
-import { defineMessages, injectIntl } from 'react-intl';
-
-import ImmutablePropTypes from 'react-immutable-proptypes';
-import ImmutablePureComponent from 'react-immutable-pure-component';
-import { connect } from 'react-redux';
-
-import Toggle from 'react-toggle';
-
-import AttachFileIcon from '@/material-icons/400-24px/attach_file.svg?react';
-import BrushIcon from '@/material-icons/400-24px/brush.svg?react';
-import CodeIcon from '@/material-icons/400-24px/code.svg?react';
-import DescriptionIcon from '@/material-icons/400-24px/description.svg?react';
-import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
-import MarkdownIcon from '@/material-icons/400-24px/markdown.svg?react';
-import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
-import UploadFileIcon from '@/material-icons/400-24px/upload_file.svg?react';
-import { IconButton } from 'flavours/glitch/components/icon_button';
-import { pollLimits } from 'flavours/glitch/initial_state';
-
-
-import DropdownContainer from '../containers/dropdown_container';
-import LanguageDropdown from '../containers/language_dropdown_container';
-import PrivacyDropdownContainer from '../containers/privacy_dropdown_container';
-
-import TextIconButton from './text_icon_button';
-
-const messages = defineMessages({
- advanced_options_icon_title: {
- defaultMessage: 'Advanced options',
- id: 'advanced_options.icon_title',
- },
- attach: {
- defaultMessage: 'Attach...',
- id: 'compose.attach',
- },
- content_type: {
- defaultMessage: 'Content type',
- id: 'content-type.change',
- },
- doodle: {
- defaultMessage: 'Draw something',
- id: 'compose.attach.doodle',
- },
- html: {
- defaultMessage: 'HTML',
- id: 'compose.content-type.html',
- },
- local_only_long: {
- defaultMessage: 'Do not post to other instances',
- id: 'advanced_options.local-only.long',
- },
- local_only_short: {
- defaultMessage: 'Local-only',
- id: 'advanced_options.local-only.short',
- },
- markdown: {
- defaultMessage: 'Markdown',
- id: 'compose.content-type.markdown',
- },
- plain: {
- defaultMessage: 'Plain text',
- id: 'compose.content-type.plain',
- },
- spoiler: {
- defaultMessage: 'Hide text behind warning',
- id: 'compose_form.spoiler',
- },
- threaded_mode_long: {
- defaultMessage: 'Automatically opens a reply on posting',
- id: 'advanced_options.threaded_mode.long',
- },
- threaded_mode_short: {
- defaultMessage: 'Threaded mode',
- id: 'advanced_options.threaded_mode.short',
- },
- upload: {
- defaultMessage: 'Upload a file',
- id: 'compose.attach.upload',
- },
- add_poll: {
- defaultMessage: 'Add a poll',
- id: 'poll_button.add_poll',
- },
- remove_poll: {
- defaultMessage: 'Remove poll',
- id: 'poll_button.remove_poll',
- },
-});
-
-const mapStateToProps = (state, { name }) => ({
- checked: state.getIn(['compose', 'advanced_options', name]),
-});
-
-class ToggleOptionImpl extends ImmutablePureComponent {
-
- static propTypes = {
- name: PropTypes.string.isRequired,
- checked: PropTypes.bool,
- onChangeAdvancedOption: PropTypes.func.isRequired,
- };
-
- handleChange = () => {
- this.props.onChangeAdvancedOption(this.props.name);
- };
-
- render() {
- const { meta, text, checked } = this.props;
-
- return (
- <>
-
-
-
-
-
- {text}
- {meta}
-
- >
- );
- }
-
-}
-
-const ToggleOption = connect(mapStateToProps)(ToggleOptionImpl);
-
-class ComposerOptions extends ImmutablePureComponent {
-
- static propTypes = {
- acceptContentTypes: PropTypes.string,
- advancedOptions: ImmutablePropTypes.map,
- disabled: PropTypes.bool,
- allowMedia: PropTypes.bool,
- allowPoll: PropTypes.bool,
- hasPoll: PropTypes.bool,
- intl: PropTypes.object.isRequired,
- onChangeAdvancedOption: PropTypes.func.isRequired,
- onChangeContentType: PropTypes.func.isRequired,
- onTogglePoll: PropTypes.func.isRequired,
- onDoodleOpen: PropTypes.func.isRequired,
- onToggleSpoiler: PropTypes.func,
- onUpload: PropTypes.func.isRequired,
- contentType: PropTypes.string,
- resetFileKey: PropTypes.number,
- spoiler: PropTypes.bool,
- showContentTypeChoice: PropTypes.bool,
- isEditing: PropTypes.bool,
- };
-
- handleChangeFiles = ({ target: { files } }) => {
- const { onUpload } = this.props;
- if (files.length) {
- onUpload(files);
- }
- };
-
- handleClickAttach = (name) => {
- const { fileElement } = this;
- const { onDoodleOpen } = this.props;
-
- switch (name) {
- case 'upload':
- if (fileElement) {
- fileElement.click();
- }
- return;
- case 'doodle':
- onDoodleOpen();
- return;
- }
- };
-
- handleRefFileElement = (fileElement) => {
- this.fileElement = fileElement;
- };
-
- renderToggleItemContents = (item) => {
- const { onChangeAdvancedOption } = this.props;
- const { name, meta, text } = item;
-
- return
;
- };
-
- render () {
- const {
- acceptContentTypes,
- advancedOptions,
- contentType,
- disabled,
- allowMedia,
- allowPoll,
- hasPoll,
- onChangeAdvancedOption,
- onChangeContentType,
- onTogglePoll,
- onToggleSpoiler,
- resetFileKey,
- spoiler,
- showContentTypeChoice,
- isEditing,
- intl: { formatMessage },
- } = this.props;
-
- const contentTypeItems = {
- plain: {
- icon: 'file-text',
- iconComponent: DescriptionIcon,
- name: 'text/plain',
- text: formatMessage(messages.plain),
- },
- html: {
- icon: 'code',
- iconComponent: CodeIcon,
- name: 'text/html',
- text: formatMessage(messages.html),
- },
- markdown: {
- icon: 'arrow-circle-down',
- iconComponent: MarkdownIcon,
- name: 'text/markdown',
- text: formatMessage(messages.markdown),
- },
- };
-
- // The result.
- return (
-
-
-
- {!!pollLimits && (
-
- )}
-
- {showContentTypeChoice && (
-
- )}
- {onToggleSpoiler && (
-
- )}
-
-
-
- );
- }
-
-}
-
-export default injectIntl(ComposerOptions);
diff --git a/app/javascript/flavours/glitch/features/compose/components/poll_button.jsx b/app/javascript/flavours/glitch/features/compose/components/poll_button.jsx
new file mode 100644
index 0000000000..4900d38119
--- /dev/null
+++ b/app/javascript/flavours/glitch/features/compose/components/poll_button.jsx
@@ -0,0 +1,61 @@
+import PropTypes from 'prop-types';
+import { PureComponent } from 'react';
+
+import { defineMessages, injectIntl } from 'react-intl';
+
+import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
+
+import { IconButton } from '../../../components/icon_button';
+
+
+const messages = defineMessages({
+ add_poll: { id: 'poll_button.add_poll', defaultMessage: 'Add a poll' },
+ remove_poll: { id: 'poll_button.remove_poll', defaultMessage: 'Remove poll' },
+});
+
+const iconStyle = {
+ height: null,
+ lineHeight: '27px',
+};
+
+class PollButton extends PureComponent {
+
+ static propTypes = {
+ disabled: PropTypes.bool,
+ unavailable: PropTypes.bool,
+ active: PropTypes.bool,
+ onClick: PropTypes.func.isRequired,
+ intl: PropTypes.object.isRequired,
+ };
+
+ handleClick = () => {
+ this.props.onClick();
+ };
+
+ render () {
+ const { intl, active, unavailable, disabled } = this.props;
+
+ if (unavailable) {
+ return null;
+ }
+
+ return (
+
+
+
+ );
+ }
+
+}
+
+export default injectIntl(PollButton);
diff --git a/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx b/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx
index 053b02673d..1ee0a06c62 100644
--- a/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx
+++ b/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx
@@ -8,21 +8,19 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
-
import AddIcon from '@/material-icons/400-24px/add.svg?react';
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
import AutosuggestInput from 'flavours/glitch/components/autosuggest_input';
import { Icon } from 'flavours/glitch/components/icon';
import { IconButton } from 'flavours/glitch/components/icon_button';
-import { pollLimits } from 'flavours/glitch/initial_state';
const messages = defineMessages({
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
add_option: { id: 'compose_form.poll.add_option', defaultMessage: 'Add a choice' },
remove_option: { id: 'compose_form.poll.remove_option', defaultMessage: 'Remove this choice' },
poll_duration: { id: 'compose_form.poll.duration', defaultMessage: 'Poll duration' },
- single_choice: { id: 'compose_form.poll.single_choice', defaultMessage: 'Allow one choice' },
- multiple_choices: { id: 'compose_form.poll.multiple_choices', defaultMessage: 'Allow multiple choices' },
+ switchToMultiple: { id: 'compose_form.poll.switch_to_multiple', defaultMessage: 'Change poll to allow multiple choices' },
+ switchToSingle: { id: 'compose_form.poll.switch_to_single', defaultMessage: 'Change poll to allow for a single choice' },
minutes: { id: 'intervals.full.minutes', defaultMessage: '{number, plural, one {# minute} other {# minutes}}' },
hours: { id: 'intervals.full.hours', defaultMessage: '{number, plural, one {# hour} other {# hours}}' },
days: { id: 'intervals.full.days', defaultMessage: '{number, plural, one {# day} other {# days}}' },
@@ -38,6 +36,7 @@ class OptionIntl extends PureComponent {
autoFocus: PropTypes.bool,
onChange: PropTypes.func.isRequired,
onRemove: PropTypes.func.isRequired,
+ onToggleMultiple: PropTypes.func.isRequired,
suggestions: ImmutablePropTypes.list,
onClearSuggestions: PropTypes.func.isRequired,
onFetchSuggestions: PropTypes.func.isRequired,
@@ -53,6 +52,19 @@ class OptionIntl extends PureComponent {
this.props.onRemove(this.props.index);
};
+
+ handleToggleMultiple = e => {
+ this.props.onToggleMultiple();
+ e.preventDefault();
+ e.stopPropagation();
+ };
+
+ handleCheckboxKeypress = e => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ this.handleToggleMultiple(e);
+ }
+ };
+
onSuggestionsClearRequested = () => {
this.props.onClearSuggestions();
};
@@ -71,11 +83,19 @@ class OptionIntl extends PureComponent {
return (