mirror of
https://github.com/wassname/talk.git
synced 2026-08-03 13:20:59 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {OFFTOPIC_TOGGLE_CHECKBOX} from './constants';
|
||||
import { OFFTOPIC_TOGGLE_CHECKBOX } from './constants';
|
||||
|
||||
export const toggleCheckbox = () => ({
|
||||
type: OFFTOPIC_TOGGLE_CHECKBOX
|
||||
type: OFFTOPIC_TOGGLE_CHECKBOX,
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import React from 'react';
|
||||
import styles from './OffTopicCheckbox.css';
|
||||
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
|
||||
export default class OffTopicCheckbox extends React.Component {
|
||||
|
||||
label = 'OFF_TOPIC';
|
||||
|
||||
componentDidMount() {
|
||||
@@ -18,28 +17,30 @@ export default class OffTopicCheckbox extends React.Component {
|
||||
this.props.unregisterHook(this.clearTagsHook);
|
||||
}
|
||||
|
||||
handleChange = (e) => {
|
||||
const {addTag, removeTag} = this.props;
|
||||
handleChange = e => {
|
||||
const { addTag, removeTag } = this.props;
|
||||
if (e.target.checked) {
|
||||
addTag(this.label);
|
||||
} else {
|
||||
const idx = this.props.tags.indexOf(this.label);
|
||||
removeTag(idx);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const checked = this.props.tags.indexOf(this.label) >= 0;
|
||||
return (
|
||||
<div className={styles.offTopic}>
|
||||
{
|
||||
!this.props.isReply ? (
|
||||
<label className={styles.offTopicLabel}>
|
||||
<input type="checkbox" onChange={this.handleChange} checked={checked}/>
|
||||
{t('off_topic')}
|
||||
</label>
|
||||
) : null
|
||||
}
|
||||
{!this.props.isReply ? (
|
||||
<label className={styles.offTopicLabel}>
|
||||
<input
|
||||
type="checkbox"
|
||||
onChange={this.handleChange}
|
||||
checked={checked}
|
||||
/>
|
||||
{t('off_topic')}
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import React from 'react';
|
||||
import styles from './OffTopicFilter.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
|
||||
export default class OffTopicFilter extends React.Component {
|
||||
|
||||
tag = 'OFF_TOPIC';
|
||||
className = 'talk-plugin-off-topic-comment';
|
||||
cn = {[this.className] : {tags: [this.tag]}};
|
||||
cn = { [this.className]: { tags: [this.tag] } };
|
||||
|
||||
handleChange = (e) => {
|
||||
handleChange = e => {
|
||||
if (e.target.checked) {
|
||||
this.props.addCommentClassName(this.cn);
|
||||
this.props.toggleCheckbox();
|
||||
} else {
|
||||
const idx = this.props.commentClassNames.findIndex((i) => i[this.className]);
|
||||
const idx = this.props.commentClassNames.findIndex(
|
||||
i => i[this.className]
|
||||
);
|
||||
this.props.removeCommentClassName(idx);
|
||||
this.props.toggleCheckbox();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import React from 'react';
|
||||
import styles from './OffTopicTag.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {isTagged} from 'plugin-api/beta/client/utils';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
import { isTagged } from 'plugin-api/beta/client/utils';
|
||||
import cn from 'classnames';
|
||||
|
||||
export default (props) => (
|
||||
export default props => (
|
||||
<span>
|
||||
{
|
||||
isTagged(props.comment.tags, 'OFF_TOPIC') && props.depth === 0 ? (
|
||||
<span className={cn(styles.tag, 'talk-stream-comment-offtopic-tag-label')}>
|
||||
{t('off_topic')}
|
||||
</span>
|
||||
) : null
|
||||
}
|
||||
{isTagged(props.comment.tags, 'OFF_TOPIC') && props.depth === 0 ? (
|
||||
<span
|
||||
className={cn(styles.tag, 'talk-stream-comment-offtopic-tag-label')}
|
||||
>
|
||||
{t('off_topic')}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {addTag, removeTag} from 'plugin-api/alpha/client/actions';
|
||||
import {commentBoxTagsSelector} from 'plugin-api/alpha/client/selectors';
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { addTag, removeTag } from 'plugin-api/alpha/client/actions';
|
||||
import { commentBoxTagsSelector } from 'plugin-api/alpha/client/selectors';
|
||||
import { connect } from 'plugin-api/beta/client/hocs';
|
||||
import OffTopicCheckbox from '../components/OffTopicCheckbox';
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
tags: commentBoxTagsSelector(state)
|
||||
const mapStateToProps = state => ({
|
||||
tags: commentBoxTagsSelector(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({addTag, removeTag}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ addTag, removeTag }, dispatch);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(OffTopicCheckbox);
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {toggleCheckbox} from '../actions';
|
||||
import {commentClassNamesSelector} from 'plugin-api/alpha/client/selectors';
|
||||
import { connect } from 'plugin-api/beta/client/hocs';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { toggleCheckbox } from '../actions';
|
||||
import { commentClassNamesSelector } from 'plugin-api/alpha/client/selectors';
|
||||
import OffTopicFilter from '../components/OffTopicFilter';
|
||||
import {
|
||||
addCommentClassName,
|
||||
removeCommentClassName
|
||||
removeCommentClassName,
|
||||
} from 'plugin-api/alpha/client/actions';
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
const mapStateToProps = state => ({
|
||||
commentClassNames: commentClassNamesSelector(state),
|
||||
checked: state.talkPluginOfftopic.checked
|
||||
checked: state.talkPluginOfftopic.checked,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
toggleCheckbox,
|
||||
addCommentClassName,
|
||||
removeCommentClassName
|
||||
removeCommentClassName,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {gql} from 'react-apollo';
|
||||
import { gql } from 'react-apollo';
|
||||
import OffTopicTag from '../components/OffTopicTag';
|
||||
import {withFragments} from 'plugin-api/beta/client/hocs';
|
||||
import { withFragments } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
export default withFragments({
|
||||
comment: gql`
|
||||
@@ -11,5 +11,5 @@ export default withFragments({
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
`,
|
||||
})(OffTopicTag);
|
||||
|
||||
@@ -15,6 +15,6 @@ export default {
|
||||
slots: {
|
||||
commentInputDetailArea: [OffTopicCheckbox],
|
||||
commentInfoBar: [OffTopicTag],
|
||||
viewingOptionsFilter: [OffTopicFilter]
|
||||
}
|
||||
viewingOptionsFilter: [OffTopicFilter],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import {OFFTOPIC_TOGGLE_CHECKBOX} from './constants';
|
||||
import { OFFTOPIC_TOGGLE_CHECKBOX } from './constants';
|
||||
|
||||
const initialState = {
|
||||
checked: false
|
||||
checked: false,
|
||||
};
|
||||
|
||||
export default function offTopic (state = initialState, action) {
|
||||
export default function offTopic(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case OFFTOPIC_TOGGLE_CHECKBOX: {
|
||||
return {
|
||||
...state,
|
||||
checked: !state.checked
|
||||
};
|
||||
}
|
||||
default :
|
||||
return state;
|
||||
case OFFTOPIC_TOGGLE_CHECKBOX: {
|
||||
return {
|
||||
...state,
|
||||
checked: !state.checked,
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user