mirror of
https://github.com/wassname/talk.git
synced 2026-07-10 17:48:01 +08:00
Moves settings into the state for the stream. Adds premodlinks to the query.
This commit is contained in:
@@ -7,7 +7,7 @@ import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import translations from '../translations.json';
|
||||
const lang = new I18n(translations);
|
||||
|
||||
export default ({handleChange, handleApply, changed, updateQuestionBoxContent, ...props}) => (
|
||||
export default ({handleChange, handleApply, changed, ...props}) => (
|
||||
<form onSubmit={handleApply}>
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.container}>
|
||||
@@ -38,9 +38,9 @@ export default ({handleChange, handleApply, changed, updateQuestionBoxContent, .
|
||||
<Checkbox
|
||||
className={styles.checkbox}
|
||||
cStyle={changed ? 'green' : 'darkGrey'}
|
||||
name="premodLinks"
|
||||
name="plinksenable"
|
||||
onChange={handleChange}
|
||||
defaultChecked={props.premodLinks}
|
||||
defaultChecked={props.premodLinksEnable}
|
||||
info={{
|
||||
title: lang.t('configureCommentStream.enablePremodLinks'),
|
||||
description: lang.t('configureCommentStream.enablePremodLinksDescription')
|
||||
@@ -57,11 +57,10 @@ export default ({handleChange, handleApply, changed, updateQuestionBoxContent, .
|
||||
title: lang.t('configureCommentStream.enableQuestionBox'),
|
||||
description: lang.t('configureCommentStream.enableQuestionBoxDescription')
|
||||
}} />
|
||||
|
||||
<div className={`${props.questionBoxEnable ? null : styles.hidden}`} >
|
||||
<TextField
|
||||
id="qboxcontent"
|
||||
onChange={updateQuestionBoxContent}
|
||||
onChange={handleChange}
|
||||
rows={3}
|
||||
value={props.questionBoxContent}
|
||||
label={lang.t('configureCommentStream.includeQuestionHere')}
|
||||
|
||||
@@ -15,13 +15,13 @@ class ConfigureStreamContainer extends Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
changed: false
|
||||
changed: false,
|
||||
settings: props.asset.settings
|
||||
};
|
||||
|
||||
this.toggleStatus = this.toggleStatus.bind(this);
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleApply = this.handleApply.bind(this);
|
||||
this.updateQuestionBoxContent = this.updateQuestionBoxContent.bind(this);
|
||||
}
|
||||
|
||||
handleApply (e) {
|
||||
@@ -31,7 +31,7 @@ class ConfigureStreamContainer extends Component {
|
||||
const questionBoxEnable = elements.qboxenable.checked;
|
||||
const questionBoxContent = elements.qboxcontent.value;
|
||||
|
||||
const premodLinksEnable = elements.premodLinks.checked;
|
||||
const premodLinksEnable = elements.plinksenable.checked;
|
||||
const {changed} = this.state;
|
||||
|
||||
const newConfig = {
|
||||
@@ -53,18 +53,20 @@ class ConfigureStreamContainer extends Component {
|
||||
|
||||
handleChange (e) {
|
||||
if (e.target && e.target.id === 'qboxenable') {
|
||||
this.props.asset.settings.questionBoxEnable = e.target.checked;
|
||||
this.state.settings.questionBoxEnable = e.target.checked;
|
||||
}
|
||||
if (e.target && e.target.id === 'qboxcontent') {
|
||||
this.state.settings.questionBoxContent = e.target.value;
|
||||
}
|
||||
if (e.target && e.target.id === 'qboxcontent') {
|
||||
this.state.settings.premodLinksEnable = e.target.value;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
changed: true
|
||||
});
|
||||
}
|
||||
|
||||
updateQuestionBoxContent(e) {
|
||||
this.props.asset.settings.questionBoxContent = e.target.value;
|
||||
this.handleChange(e);
|
||||
}
|
||||
|
||||
toggleStatus () {
|
||||
this.props.updateStatus(
|
||||
this.props.asset.closedAt === null ? 'closed' : 'open'
|
||||
@@ -78,7 +80,8 @@ class ConfigureStreamContainer extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const {settings, closedAt} = this.props.asset;
|
||||
const {closedAt} = this.props.asset;
|
||||
const {settings} = this.state;
|
||||
const status = closedAt === null ? 'open' : 'closed';
|
||||
const premod = settings.moderation === 'PRE';
|
||||
|
||||
@@ -88,9 +91,8 @@ class ConfigureStreamContainer extends Component {
|
||||
handleChange={this.handleChange}
|
||||
handleApply={this.handleApply}
|
||||
changed={this.state.changed}
|
||||
premodLinks={settings.premodLinks}
|
||||
premodLinksEnable={settings.premodLinksEnable}
|
||||
premod={premod}
|
||||
updateQuestionBoxContent={this.updateQuestionBoxContent}
|
||||
questionBoxEnable={settings.questionBoxEnable}
|
||||
questionBoxContent={settings.questionBoxContent}
|
||||
/>
|
||||
|
||||
@@ -28,6 +28,7 @@ query AssetQuery($asset_id: ID, $asset_url: String, $comment_id: ID!, $has_comme
|
||||
moderation
|
||||
infoBoxEnable
|
||||
infoBoxContent
|
||||
premodLinksEnable
|
||||
questionBoxEnable
|
||||
questionBoxContent
|
||||
closeTimeout
|
||||
|
||||
Reference in New Issue
Block a user