Use server-provided poll limits instead of hardcoded ones
Also does not enable polls if no limits are provided by the serverpull/944/head
parent
3b1390dc78
commit
235be596bc
|
@ -19,6 +19,7 @@ import {
|
||||||
assignHandlers,
|
assignHandlers,
|
||||||
hiddenComponent,
|
hiddenComponent,
|
||||||
} from 'flavours/glitch/util/react_helpers';
|
} from 'flavours/glitch/util/react_helpers';
|
||||||
|
import { pollLimits } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
// Messages.
|
// Messages.
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -248,19 +249,21 @@ export default class ComposerOptions extends React.PureComponent {
|
||||||
onModalOpen={onModalOpen}
|
onModalOpen={onModalOpen}
|
||||||
title={intl.formatMessage(messages.attach)}
|
title={intl.formatMessage(messages.attach)}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
{!!pollLimits && (
|
||||||
active={hasPoll}
|
<IconButton
|
||||||
disabled={disabled || !allowPoll}
|
active={hasPoll}
|
||||||
icon='tasks'
|
disabled={disabled || !allowPoll}
|
||||||
inverted
|
icon='tasks'
|
||||||
onClick={onTogglePoll}
|
inverted
|
||||||
size={18}
|
onClick={onTogglePoll}
|
||||||
style={{
|
size={18}
|
||||||
height: null,
|
style={{
|
||||||
lineHeight: null,
|
height: null,
|
||||||
}}
|
lineHeight: null,
|
||||||
title={intl.formatMessage(hasPoll ? messages.remove_poll : messages.add_poll)}
|
}}
|
||||||
/>
|
title={intl.formatMessage(hasPoll ? messages.remove_poll : messages.add_poll)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Motion
|
<Motion
|
||||||
defaultStyle={{ scale: 0.87 }}
|
defaultStyle={{ scale: 0.87 }}
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
import IconButton from 'flavours/glitch/components/icon_button';
|
||||||
import Icon from 'flavours/glitch/components/icon';
|
import Icon from 'flavours/glitch/components/icon';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { pollLimits } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
|
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
|
||||||
|
@ -48,7 +49,7 @@ class Option extends React.PureComponent {
|
||||||
<input
|
<input
|
||||||
type='text'
|
type='text'
|
||||||
placeholder={intl.formatMessage(messages.option_placeholder, { number: index + 1 })}
|
placeholder={intl.formatMessage(messages.option_placeholder, { number: index + 1 })}
|
||||||
maxlength={25}
|
maxlength={pollLimits.max_option_chars}
|
||||||
value={title}
|
value={title}
|
||||||
onChange={this.handleOptionTitleChange}
|
onChange={this.handleOptionTitleChange}
|
||||||
/>
|
/>
|
||||||
|
@ -100,7 +101,7 @@ class PollForm extends ImmutablePureComponent {
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div className='poll__footer'>
|
<div className='poll__footer'>
|
||||||
{options.size < 4 && (
|
{options.size < pollLimits.max_options && (
|
||||||
<button className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>
|
<button className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ export const deleteModal = getMeta('delete_modal');
|
||||||
export const me = getMeta('me');
|
export const me = getMeta('me');
|
||||||
export const searchEnabled = getMeta('search_enabled');
|
export const searchEnabled = getMeta('search_enabled');
|
||||||
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
|
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
|
||||||
|
export const pollLimits = (initialState && initialState.poll_limits);
|
||||||
export const invitesEnabled = getMeta('invites_enabled');
|
export const invitesEnabled = getMeta('invites_enabled');
|
||||||
export const version = getMeta('version');
|
export const version = getMeta('version');
|
||||||
export const mascot = getMeta('mascot');
|
export const mascot = getMeta('mascot');
|
||||||
|
|
Loading…
Reference in New Issue