mirror of
https://github.com/wassname/talk.git
synced 2026-08-02 13:10:23 +08:00
Merge branch 'master' into map-dispatch-mod-queue
This commit is contained in:
@@ -4,6 +4,7 @@ import {Router, Route, IndexRoute, browserHistory} from 'react-router';
|
||||
import ModerationQueue from 'containers/ModerationQueue/ModerationQueue';
|
||||
import CommentStream from 'containers/CommentStream/CommentStream';
|
||||
import Configure from 'containers/Configure/Configure';
|
||||
import Streams from 'containers/Streams/Streams';
|
||||
import CommunityContainer from 'containers/Community/CommunityContainer';
|
||||
import LayoutContainer from 'containers/LayoutContainer';
|
||||
|
||||
@@ -13,6 +14,7 @@ const routes = (
|
||||
<Route path='embed' component={CommentStream} />
|
||||
<Route path='community' component={CommunityContainer} />
|
||||
<Route path='configure' component={Configure} />
|
||||
<Route path='streams' component={Streams} />
|
||||
</Route>
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
FETCH_ASSETS_REQUEST,
|
||||
FETCH_ASSETS_SUCCESS,
|
||||
FETCH_ASSETS_FAILURE,
|
||||
UPDATE_ASSET_STATE_REQUEST,
|
||||
UPDATE_ASSET_STATE_SUCCESS,
|
||||
UPDATE_ASSET_STATE_FAILURE
|
||||
} from '../constants/assets';
|
||||
import coralApi from '../../../coral-framework/helpers/response';
|
||||
|
||||
/**
|
||||
* Action disptacher related to assets
|
||||
*/
|
||||
|
||||
// Fetch a page of assets
|
||||
// Get comments to fill each of the three lists on the mod queue
|
||||
export const fetchAssets = (skip = '', limit = '', search = '', sort = '', filter = '') => (dispatch) => {
|
||||
dispatch({type: FETCH_ASSETS_REQUEST});
|
||||
return coralApi(`/assets?skip=${skip}&limit=${limit}&sort=${sort}&search=${search}&filter=${filter}`)
|
||||
.then(({result, count}) =>
|
||||
dispatch({type: FETCH_ASSETS_SUCCESS,
|
||||
assets: result,
|
||||
count
|
||||
}))
|
||||
.catch(error => dispatch({type: FETCH_ASSETS_FAILURE, error}));
|
||||
};
|
||||
|
||||
// Update an asset state
|
||||
// Get comments to fill each of the three lists on the mod queue
|
||||
export const updateAssetState = (id, closedAt) => (dispatch) => {
|
||||
dispatch({type: UPDATE_ASSET_STATE_REQUEST});
|
||||
return coralApi(`/assets/${id}/status`, {method: 'PUT', body: {closedAt}})
|
||||
.then(() =>
|
||||
dispatch({type: UPDATE_ASSET_STATE_SUCCESS}))
|
||||
.catch(error => dispatch({type: UPDATE_ASSET_STATE_FAILURE, error}));
|
||||
};
|
||||
@@ -16,6 +16,8 @@ export default ({handleLogout}) => (
|
||||
activeClassName={styles.active}>{lang.t('configure.community')}</Link>
|
||||
<Link className={styles.navLink} to="/admin/configure"
|
||||
activeClassName={styles.active}>{lang.t('configure.configure')}</Link>
|
||||
<Link className={styles.navLink} to="/admin/streams"
|
||||
activeClassName={styles.active}>{lang.t('configure.streams')}</Link>
|
||||
</Navigation>
|
||||
<div className={styles.rightPanel}>
|
||||
<ul>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export const FETCH_ASSETS_REQUEST = 'FETCH_ASSETS_REQUEST';
|
||||
export const FETCH_ASSETS_SUCCESS = 'FETCH_ASSETS_SUCCESS';
|
||||
export const FETCH_ASSETS_FAILURE = 'FETCH_ASSETS_FAILURE';
|
||||
export const UPDATE_ASSET_STATE_REQUEST = 'UPDATE_ASSET_STATE_REQUEST';
|
||||
export const UPDATE_ASSET_STATE_SUCCESS = 'UPDATE_ASSET_STATE_SUCCESS';
|
||||
export const UPDATE_ASSET_STATE_FAILURE = 'UPDATE_ASSET_STATE_FAILURE';
|
||||
@@ -1,6 +1,5 @@
|
||||
export const SHOW_BANUSER_DIALOG = 'SHOW_BANUSER_DIALOG';
|
||||
export const HIDE_BANUSER_DIALOG = 'HIDE_BANUSER_DIALOG';
|
||||
export const USER_BAN_SUCESS = 'USER_BAN_SUCESS';
|
||||
export const USERS_MODERATION_QUEUE_FETCH_SUCCESS = 'USERS_MODERATION_QUEUE_FETCH_SUCCESS';
|
||||
export const COMMENTS_MODERATION_QUEUE_FETCH = 'COMMENTS_MODERATION_QUEUE_FETCH';
|
||||
export const COMMENTS_MODERATION_QUEUE_FETCH_SUCCESS = 'COMMENTS_MODERATION_QUEUE_FETCH_SUCCESS';
|
||||
|
||||
@@ -7,7 +7,7 @@ import styles from './Community.css';
|
||||
import Table from './Table';
|
||||
import Loading from './Loading';
|
||||
import NoResults from './NoResults';
|
||||
import Pager from './Pager';
|
||||
import Pager from 'coral-ui/components/Pager';
|
||||
|
||||
const lang = new I18n(translations);
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
.container {
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.leftColumn {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.mainContent {
|
||||
width: calc(90% - 200px);
|
||||
}
|
||||
|
||||
.searchIcon {
|
||||
vertical-align: middle;
|
||||
font-size: 18px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.searchBox {
|
||||
padding: 3px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 3px;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.searchBoxInput {
|
||||
border: none;
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.searchBoxInput:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.optionHeader {
|
||||
font-size: 16px;
|
||||
font-weight: 900;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.optionDetail {
|
||||
font-size: 16px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.streamsTable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.radio {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.statusMenu {
|
||||
border-radius: 3px;
|
||||
width: 10em;
|
||||
text-align: center;
|
||||
float: right;
|
||||
border: 1px solid #ccc;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.statusMenuOpen {
|
||||
padding: 10px;
|
||||
background-color: #4caf50;
|
||||
}
|
||||
|
||||
.statusMenuIcon {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.statusMenuClosed {
|
||||
padding: 10px;
|
||||
background-color: #000;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import React, {Component} from 'react';
|
||||
import styles from './Streams.css';
|
||||
import {connect} from 'react-redux';
|
||||
import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import {fetchAssets, updateAssetState} from '../../actions/assets';
|
||||
import translations from '../../translations.json';
|
||||
import {
|
||||
RadioGroup,
|
||||
Radio,
|
||||
Icon,
|
||||
DataTable,
|
||||
TableHeader
|
||||
} from 'react-mdl';
|
||||
import Pager from 'coral-ui/components/Pager';
|
||||
|
||||
const limit = 25;
|
||||
|
||||
class Streams extends Component {
|
||||
|
||||
state = {
|
||||
search: '',
|
||||
sort: 'desc',
|
||||
filter: 'all',
|
||||
statusMenus: {},
|
||||
timer: null,
|
||||
page: 0
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
this.props.fetchAssets(0, limit, '', this.state.sortBy);
|
||||
}
|
||||
|
||||
onSettingChange = (setting) => (e) => {
|
||||
let options = this.state;
|
||||
this.setState({[setting]: e.target.value});
|
||||
options[setting] = e.target.value;
|
||||
this.props.fetchAssets(0, limit, options.search, options.sort, options.filter);
|
||||
}
|
||||
|
||||
onSearchChange = (e) => {
|
||||
this.setState((prevState) => {
|
||||
prevState.search = e.target.value;
|
||||
clearTimeout(prevState.timer);
|
||||
const fetchAssets = this.props.fetchAssets;
|
||||
prevState.timer = setTimeout(() => {
|
||||
fetchAssets(0, limit, e.target.value, this.state.sort, this.state.filter);
|
||||
}, 350);
|
||||
return prevState;
|
||||
});
|
||||
}
|
||||
|
||||
renderDate = (date) => {
|
||||
const d = new Date(date);
|
||||
return `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;
|
||||
}
|
||||
|
||||
onStatusClick = (closeStream, id, statusMenuOpen) => () => {
|
||||
if (statusMenuOpen) {
|
||||
this.setState(prev => {
|
||||
prev.statusMenus[id] = false;
|
||||
return prev;
|
||||
});
|
||||
this.props.updateAssetState(id, closeStream ? Date.now() : null)
|
||||
.then(() => {
|
||||
const {search, sort, filter, page} = this.state;
|
||||
this.props.fetchAssets(page, limit, search, sort, filter);
|
||||
});
|
||||
} else {
|
||||
this.setState(prev => {
|
||||
prev.statusMenus[id] = true;
|
||||
return prev;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
renderStatus = (closedAt, {id}) => {
|
||||
const closed = closedAt && new Date(closedAt).getTime() < Date.now();
|
||||
const statusMenuOpen = this.state.statusMenus[id];
|
||||
return <div className={styles.statusMenu}>
|
||||
<div
|
||||
className={closed ? styles.statusMenuClosed : styles.statusMenuOpen}
|
||||
onClick={this.onStatusClick(closed, id, statusMenuOpen)}>
|
||||
{closed ? lang.t('streams.closed') : lang.t('streams.open')}
|
||||
{!statusMenuOpen && <Icon className={styles.statusMenuIcon} name='keyboard_arrow_down'/>}
|
||||
</div>
|
||||
{
|
||||
statusMenuOpen &&
|
||||
<div
|
||||
className={!closed ? styles.statusMenuClosed : styles.statusMenuOpen}
|
||||
onClick={this.onStatusClick(!closed, id, statusMenuOpen)}>
|
||||
{!closed ? lang.t('streams.closed') : lang.t('streams.open')}
|
||||
</div>
|
||||
}
|
||||
</div>;
|
||||
}
|
||||
|
||||
onPageClick = (page) => {
|
||||
this.setState({page});
|
||||
const {search, sort, filter} = this.state;
|
||||
this.props.fetchAssets((page - 1) * limit, limit, search, sort, filter);
|
||||
}
|
||||
|
||||
render () {
|
||||
const {search, sort, filter} = this.state;
|
||||
const {assets} = this.props;
|
||||
|
||||
return <div className={styles.container}>
|
||||
<div className={styles.leftColumn}>
|
||||
|
||||
<div className={styles.searchBox}>
|
||||
<Icon name='search' className={styles.searchIcon}/>
|
||||
<input
|
||||
type='text'
|
||||
value={search}
|
||||
className={styles.searchBoxInput}
|
||||
onChange={this.onSearchChange}
|
||||
placeholder={lang.t('streams.search')}/>
|
||||
</div>
|
||||
|
||||
<div className={styles.optionHeader}>{lang.t('streams.filter-streams')}</div>
|
||||
<div className={styles.optionDetail}>{lang.t('streams.stream-status')}</div>
|
||||
<RadioGroup
|
||||
name='status filter'
|
||||
value={filter}
|
||||
childContainer='div'
|
||||
onChange={this.onSettingChange('filter')}>
|
||||
<Radio value='all'>{lang.t('streams.all')}</Radio>
|
||||
<Radio value='open'>{lang.t('streams.open')}</Radio>
|
||||
<Radio value='closed'>{lang.t('streams.closed')}</Radio>
|
||||
</RadioGroup>
|
||||
<div className={styles.optionHeader}>{lang.t('streams.sort-by')}</div>
|
||||
<RadioGroup
|
||||
name='sort by'
|
||||
value={sort}
|
||||
childContainer='div'
|
||||
onChange={this.onSettingChange('sort')}>
|
||||
<Radio value='desc'>{lang.t('streams.newest')}</Radio>
|
||||
<Radio value='asc'>{lang.t('streams.oldest')}</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
<div className={styles.mainContent}>
|
||||
<DataTable
|
||||
className={styles.streamsTable}
|
||||
rows={assets.ids.map((id) => assets.byId[id])}>
|
||||
<TableHeader name="title">{lang.t('streams.article')}</TableHeader>
|
||||
<TableHeader numeric name="publication_date" cellFormatter={this.renderDate}>
|
||||
{lang.t('streams.pubdate')}
|
||||
</TableHeader>
|
||||
<TableHeader numeric name="closedAt" cellFormatter={this.renderStatus}>
|
||||
{lang.t('streams.status')}
|
||||
</TableHeader>
|
||||
</DataTable>
|
||||
<Pager
|
||||
totalPages={Math.ceil((assets.count || 0) / limit)}
|
||||
page={this.state.page}
|
||||
onNewPageHandler={this.onPageClick}
|
||||
/>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({assets}) => {
|
||||
return {
|
||||
assets: assets.toJS()
|
||||
};
|
||||
};
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
fetchAssets: (...args) => {
|
||||
dispatch(fetchAssets.apply(this, args));
|
||||
},
|
||||
updateAssetState: (...args) => dispatch(updateAssetState.apply(this, args))
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Streams);
|
||||
|
||||
const lang = new I18n(translations);
|
||||
@@ -0,0 +1,24 @@
|
||||
import {Map, List, fromJS} from 'immutable';
|
||||
import {FETCH_ASSETS_SUCCESS, UPDATE_ASSET_STATE_REQUEST} from '../constants/assets';
|
||||
|
||||
const initialState = Map({
|
||||
byId: Map(),
|
||||
ids: List()
|
||||
});
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_ASSETS_SUCCESS:
|
||||
return replaceAssets(action, state);
|
||||
case UPDATE_ASSET_STATE_REQUEST:
|
||||
return state.setIn(['byId', action.id, 'closedAt'], action.closedAt);
|
||||
default: return state;
|
||||
}
|
||||
};
|
||||
|
||||
const replaceAssets = (action, state) => {
|
||||
const assets = fromJS(action.assets.reduce((prev, curr) => { prev[curr.id] = curr; return prev; }, {}));
|
||||
return state.set('byId', assets)
|
||||
.set('count', action.count)
|
||||
.set('ids', List(assets.keys()));
|
||||
};
|
||||
@@ -33,6 +33,7 @@ export default (state = initialState, action) => {
|
||||
case actions.COMMENT_STREAM_FETCH_SUCCESS: return replaceComments(action, state);
|
||||
case actions.SHOW_BANUSER_DIALOG: return setBanUser(state, true, action);
|
||||
case actions.HIDE_BANUSER_DIALOG: return setBanUser(state, false, action);
|
||||
case actions.USER_BAN_SUCCESS: return setBanUser(state, false, action);
|
||||
case userActions.UPDATE_STATUS_SUCCESS: return setBanUser(state, false, action);
|
||||
default: return state;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import settings from 'reducers/settings';
|
||||
import community from 'reducers/community';
|
||||
import users from 'reducers/users';
|
||||
import auth from 'reducers/auth';
|
||||
import assets from 'reducers/assets';
|
||||
|
||||
// Combine all reducers into a main one
|
||||
export default combineReducers({
|
||||
@@ -11,5 +12,6 @@ export default combineReducers({
|
||||
comments,
|
||||
community,
|
||||
auth,
|
||||
users
|
||||
users,
|
||||
assets
|
||||
});
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"moderate": "Moderate",
|
||||
"configure": "Configure",
|
||||
"community": "Community",
|
||||
"streams": "Streams",
|
||||
"closed-comments-desc": "Write a message for closed threads",
|
||||
"closed-comments-label": "Write a message...",
|
||||
"hours": "Hours",
|
||||
@@ -73,6 +74,22 @@
|
||||
"note": "Note: Banning this user will also place this comment in the Rejected queue.",
|
||||
"cancel": "Cancel",
|
||||
"yes_ban_user": "Yes, Ban User"
|
||||
},
|
||||
"streams": {
|
||||
"search": "Search",
|
||||
"filter-streams": "Filter Streams",
|
||||
"stream-status": "Stream Status",
|
||||
"all": "All",
|
||||
"open": "Open",
|
||||
"closed": "Closed",
|
||||
"newest": "Newest",
|
||||
"oldest": "Oldest",
|
||||
"sort-by": "Sort By",
|
||||
"open": "Open",
|
||||
"closed": "Closed",
|
||||
"article": "Article",
|
||||
"pubdate": "Publication Date",
|
||||
"status": "Status"
|
||||
}
|
||||
},
|
||||
"es": {
|
||||
@@ -139,6 +156,22 @@
|
||||
"note": "Nota: Suspender este usuario también va a colocar este comentario en la cola de Rechazados.",
|
||||
"cancel": "Cancelar",
|
||||
"yes_ban_user": "Si, Suspendan el usuario"
|
||||
},
|
||||
"streams": {
|
||||
"search": "",
|
||||
"filter-streams": "",
|
||||
"stream-status": "",
|
||||
"all": "",
|
||||
"open": "",
|
||||
"closed": "",
|
||||
"newest": "",
|
||||
"oldest": "",
|
||||
"sort-by": "",
|
||||
"open": "",
|
||||
"closed": "",
|
||||
"article": "",
|
||||
"pubdate": "",
|
||||
"status": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ hr {
|
||||
.coral-plugin-commentbox-char-count {
|
||||
color: #ccc;
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.coral-plugin-commentbox-char-max {
|
||||
@@ -230,7 +229,7 @@ hr {
|
||||
|
||||
.coral-plugin-flags-popup-header {
|
||||
font-weight: bolder;
|
||||
font-size: 16px;
|
||||
font-size: 1.33rem;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@@ -240,7 +239,8 @@ hr {
|
||||
|
||||
.coral-plugin-flags-popup-radio-label {
|
||||
margin:5px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
font-size: .9rem;
|
||||
}
|
||||
|
||||
.coral-plugin-flags-popup-counter {
|
||||
@@ -254,8 +254,9 @@ hr {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.coral-plugin-flags-other-text {
|
||||
.coral-plugin-flags-reason-text {
|
||||
margin-left: 20px;
|
||||
margin-top: 5px;
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
@@ -290,7 +291,7 @@ hr {
|
||||
.close-comments-alert {
|
||||
background-color: #d65344;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
font-size: 1.33rem;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,9 @@ export function postItem (item, type, id) {
|
||||
*
|
||||
* @params
|
||||
* id - the id of the item on which the action is taking place
|
||||
* action - the name of the action
|
||||
* action - the action object.
|
||||
* Must include an 'action_type' string.
|
||||
* May optionally include a `metadata` object with arbitrary action data.
|
||||
* user - the user performing the action
|
||||
* host - the coral host
|
||||
*
|
||||
|
||||
@@ -18,7 +18,7 @@ const getPopupMenu = [
|
||||
{val: 'other', text: lang.t('other')}
|
||||
],
|
||||
button: lang.t('continue'),
|
||||
sets: 'detail'
|
||||
sets: 'reason'
|
||||
};
|
||||
},
|
||||
() => {
|
||||
|
||||
@@ -10,10 +10,9 @@ class FlagButton extends Component {
|
||||
|
||||
state = {
|
||||
showMenu: false,
|
||||
showOther: false,
|
||||
itemType: '',
|
||||
detail: '',
|
||||
otherText: '',
|
||||
reason: '',
|
||||
note: '',
|
||||
step: 0,
|
||||
posted: false
|
||||
}
|
||||
@@ -30,7 +29,7 @@ class FlagButton extends Component {
|
||||
|
||||
onPopupContinue = () => {
|
||||
const {postAction, addItem, updateItem, flag, id, author_id} = this.props;
|
||||
const {itemType, field, detail, step, otherText, posted} = this.state;
|
||||
const {itemType, field, reason, step, note, posted} = this.state;
|
||||
|
||||
// Proceed to the next step or close the menu if we've reached the end
|
||||
if (step + 1 >= this.props.getPopupMenu.length) {
|
||||
@@ -39,11 +38,10 @@ class FlagButton extends Component {
|
||||
this.setState({step: step + 1});
|
||||
}
|
||||
|
||||
// If itemType and detail are both set, post the action
|
||||
if (itemType && detail && !posted) {
|
||||
// If itemType and reason are both set, post the action
|
||||
if (itemType && reason && !posted) {
|
||||
|
||||
// Set the text from the "other" field if it exists.
|
||||
const updatedDetail = otherText || detail;
|
||||
let item_id;
|
||||
switch(itemType) {
|
||||
case 'comments':
|
||||
@@ -55,8 +53,11 @@ class FlagButton extends Component {
|
||||
}
|
||||
const action = {
|
||||
action_type: 'flag',
|
||||
field,
|
||||
detail: updatedDetail
|
||||
metadata: {
|
||||
field,
|
||||
reason,
|
||||
note
|
||||
}
|
||||
};
|
||||
postAction(item_id, itemType, action)
|
||||
.then((action) => {
|
||||
@@ -70,11 +71,6 @@ class FlagButton extends Component {
|
||||
|
||||
onPopupOptionClick = (sets) => (e) => {
|
||||
|
||||
// If the "other" option is clicked, show the other textbox
|
||||
if(sets === 'detail' && e.target.value === 'other') {
|
||||
this.setState({showOther: true});
|
||||
}
|
||||
|
||||
// If flagging a user, indicate that this is referencing the username rather than the bio
|
||||
if(sets === 'itemType' && e.target.value === 'user') {
|
||||
this.setState({field: 'username'});
|
||||
@@ -92,8 +88,8 @@ class FlagButton extends Component {
|
||||
this.setState({[sets]: e.target.value});
|
||||
}
|
||||
|
||||
onOtherTextChange = (e) => {
|
||||
this.setState({otherText: e.target.value});
|
||||
onNoteTextChange = (e) => {
|
||||
this.setState({note: e.target.value});
|
||||
}
|
||||
|
||||
handleClickOutside () {
|
||||
@@ -142,16 +138,16 @@ class FlagButton extends Component {
|
||||
)
|
||||
}
|
||||
{
|
||||
this.state.showOther && <div>
|
||||
<input
|
||||
className={`${name}-other-text`}
|
||||
type="text"
|
||||
id="otherText"
|
||||
onChange={this.onOtherTextChange}
|
||||
value={this.state.otherText}/>
|
||||
<label htmlFor={'otherText'} className={`${name}-popup-radio-label screen-reader-text`}>
|
||||
lang.t('flag-reason')
|
||||
</label><br/>
|
||||
this.state.reason && <div>
|
||||
<label htmlFor={'note'} className={`${name}-popup-radio-label`}>
|
||||
{lang.t('flag-reason')}
|
||||
</label><br/>
|
||||
<textarea
|
||||
className={`${name}-reason-text`}
|
||||
id="note"
|
||||
rows={4}
|
||||
onChange={this.onNoteTextChange}
|
||||
value={this.state.note}/>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
|
||||
@@ -22,12 +22,13 @@ const getPopupMenu = [
|
||||
[
|
||||
{val: 'I don\'t agree with this comment', text: lang.t('no-agree-comment')},
|
||||
{val: 'This comment is offensive', text: lang.t('comment-offensive')},
|
||||
{val: 'This comment reveals personally identifiable infomration', text: lang.t('personal-info')},
|
||||
{val: 'This looks like an ad/marketing', text: lang.t('marketing')},
|
||||
{val: 'other', text: lang.t('other')}
|
||||
]
|
||||
: [
|
||||
{val: 'This username is offensive', text: lang.t('username-offensive')},
|
||||
{val: 'I don\'t like this username', text: lang.t('no-like-username')},
|
||||
{val: 'This user is impersonating', text: lang.t('user-impersonating')},
|
||||
{val: 'This looks like an ad/marketing', text: lang.t('marketing')},
|
||||
{val: 'other', text: lang.t('other')}
|
||||
];
|
||||
@@ -35,7 +36,7 @@ const getPopupMenu = [
|
||||
header: lang.t('step-2-header'),
|
||||
options,
|
||||
button: lang.t('continue'),
|
||||
sets: 'detail'
|
||||
sets: 'reason'
|
||||
};
|
||||
},
|
||||
() => {
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
"bio-offensive": "This bio is offensive",
|
||||
"no-like-bio": "I don't like this bio",
|
||||
"marketing": "This looks like an ad/marketing",
|
||||
"user-impersonating": "This user is impersonating",
|
||||
"thank-you": "We value your safety and feedback. A moderator will review your flag.",
|
||||
"flag-reason": "Reason for flag",
|
||||
"flag-reason": "Reason for flag (Optional)",
|
||||
"other": "Other"
|
||||
},
|
||||
"es": {
|
||||
@@ -42,9 +43,10 @@
|
||||
"no-like-username": "No me gusta ese nombre de usuario",
|
||||
"bio-offensive": "Esta bio es ofensiva",
|
||||
"no-like-bio": "No me gusta esta bio",
|
||||
"user-impersonating": "Este usario suplanta a alguien",
|
||||
"marketing": "Esto parece una publicidad/marketing",
|
||||
"thank-you": "Nos interesa tu protección y comentarios. Un moderador va a mirar tu marca.",
|
||||
"flag-reason": "Razón por la que marcar",
|
||||
"flag-reason": "Razón por la que marcar (Opcional)",
|
||||
"other": "Otro"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -12,7 +12,7 @@ const Pager = ({totalPages, page, onNewPageHandler}) => (
|
||||
<div className="pager">
|
||||
<ul>
|
||||
{
|
||||
(totalPages > page) ?
|
||||
(totalPages > page && totalPages > 1) ?
|
||||
<li
|
||||
className={`mdl-button mdl-js-button ${styles.li}`}
|
||||
onClick={() => onNewPageHandler(page - 1)}>
|
||||
@@ -23,7 +23,7 @@ const Pager = ({totalPages, page, onNewPageHandler}) => (
|
||||
}
|
||||
{Rows(page, totalPages, onNewPageHandler)}
|
||||
{
|
||||
(page < totalPages) ?
|
||||
(page < totalPages && totalPages > 1) ?
|
||||
<li
|
||||
className={`mdl-button mdl-js-button ${styles.li}`}
|
||||
onClick={() => onNewPageHandler(page + 1)}>
|
||||
@@ -42,4 +42,3 @@ Pager.propTypes = {
|
||||
};
|
||||
|
||||
export default Pager;
|
||||
|
||||
+498
-37
@@ -18,12 +18,6 @@ paths:
|
||||
tags:
|
||||
- Comments
|
||||
parameters:
|
||||
- name: status
|
||||
in: query
|
||||
description: Performs a search based on the comment's status.
|
||||
type: string
|
||||
enum:
|
||||
- flag
|
||||
- name: action_type
|
||||
in: query
|
||||
description: Performs a search based on the actions that have been added to it.
|
||||
@@ -38,7 +32,7 @@ paths:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
- $ref: '#/definitions/Comment'
|
||||
$ref: '#/definitions/Comment'
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
@@ -49,9 +43,19 @@ paths:
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
description: The comment to create.
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/Comment'
|
||||
type: object
|
||||
properties:
|
||||
body:
|
||||
type: string
|
||||
description: The text of the comment to create.
|
||||
asset_id:
|
||||
type: string
|
||||
description: The parent asset of this comment.
|
||||
parent_id:
|
||||
type: string
|
||||
description: The parent comment of this comment (null if the comment is not a reply.)
|
||||
responses:
|
||||
201:
|
||||
description: The comment that was created.
|
||||
@@ -61,6 +65,7 @@ paths:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
/comments/{comment_id}:
|
||||
get:
|
||||
tags:
|
||||
@@ -98,6 +103,7 @@ paths:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
/comments/{comment_id}/status:
|
||||
put:
|
||||
tags:
|
||||
@@ -108,6 +114,7 @@ paths:
|
||||
in: path
|
||||
description: The id of the comment to retrieve.
|
||||
type: string
|
||||
format: uuid
|
||||
required: true
|
||||
- name: body
|
||||
in: body
|
||||
@@ -119,6 +126,11 @@ paths:
|
||||
status:
|
||||
type: string
|
||||
description: The status to update to.
|
||||
enum:
|
||||
- new
|
||||
- flagged
|
||||
- accepted
|
||||
- rejected
|
||||
responses:
|
||||
204:
|
||||
description: The comment status was updated.
|
||||
@@ -126,15 +138,15 @@ paths:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/comments/{comment_id}/actions:
|
||||
/comments/{item_id}/actions:
|
||||
post:
|
||||
tags:
|
||||
- Comments
|
||||
- Actions
|
||||
parameters:
|
||||
- name: comment_id
|
||||
- name: item_id
|
||||
in: path
|
||||
description: The id of the comment to retrieve.
|
||||
description: The id of the item which is the target of the action.
|
||||
type: string
|
||||
required: true
|
||||
- name: body
|
||||
@@ -146,7 +158,13 @@ paths:
|
||||
properties:
|
||||
action_type:
|
||||
type: string
|
||||
description: The action to add
|
||||
description: The type of action to add
|
||||
enum:
|
||||
- like
|
||||
- flag
|
||||
metadata:
|
||||
type: object
|
||||
description: An arbitrary object describing the action, should be consistent per action type.
|
||||
responses:
|
||||
201:
|
||||
description: The action created.
|
||||
@@ -240,6 +258,19 @@ paths:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/auth/facebook/callback:
|
||||
get:
|
||||
tags:
|
||||
- Auth
|
||||
responses:
|
||||
200:
|
||||
description: Logs in the user after FB Auth.
|
||||
schema:
|
||||
$ref: '#/definitions/User'
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/queue/comments/pending:
|
||||
get:
|
||||
tags:
|
||||
@@ -249,9 +280,23 @@ paths:
|
||||
200:
|
||||
description: The comments that are not moderated.
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
- $ref: '#/definitions/Comment'
|
||||
type: object
|
||||
properties:
|
||||
comments:
|
||||
type: array
|
||||
description: The comments that have yet to be moderated.
|
||||
items:
|
||||
$ref: '#/definitions/Comment'
|
||||
users:
|
||||
type: array
|
||||
description: The users authoring these comments.
|
||||
items:
|
||||
$ref: '#/definitions/User'
|
||||
actions:
|
||||
type: array
|
||||
description: The actions which have taken place on these comments.
|
||||
items:
|
||||
$ref: '#/definitions/Actions'
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
@@ -280,6 +325,17 @@ paths:
|
||||
in: query
|
||||
type: string
|
||||
description: Field to sort by.
|
||||
- name: filter
|
||||
in: query
|
||||
type: string
|
||||
enum:
|
||||
- open
|
||||
- closed
|
||||
description: Comment status to filter by.
|
||||
- name: search
|
||||
in: query
|
||||
type: string
|
||||
description: String to search by.
|
||||
responses:
|
||||
200:
|
||||
description: Assets listed.
|
||||
@@ -358,6 +414,34 @@ paths:
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
/assets/{asset_id}/status:
|
||||
put:
|
||||
parameters:
|
||||
- name: asset_id
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
format: uuid
|
||||
description: The id of the asset to be updated
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
closedAt:
|
||||
type: number
|
||||
description: The Unix timestamp when the stream will be or was previously closed.
|
||||
closedMessage:
|
||||
type: string
|
||||
description: The message to display to users when the stream is closed.
|
||||
responses:
|
||||
204:
|
||||
description: Status update successful.
|
||||
500:
|
||||
description: An error has occurred.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/stream:
|
||||
get:
|
||||
tags:
|
||||
@@ -368,7 +452,7 @@ paths:
|
||||
parameters:
|
||||
- name: asset_url
|
||||
in: query
|
||||
description: The asset url to get the comment stream from.
|
||||
description: The url of the asset for which to get the comment stream.
|
||||
type: string
|
||||
format: url
|
||||
responses:
|
||||
@@ -377,22 +461,23 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
assets:
|
||||
type: array
|
||||
items:
|
||||
- $ref: '#/definitions/Asset'
|
||||
asset:
|
||||
$ref: '#/definitions/Asset'
|
||||
comments:
|
||||
type: array
|
||||
description: All comments for this asset.
|
||||
items:
|
||||
- $ref: '#/definitions/Comment'
|
||||
$ref: '#/definitions/Comment'
|
||||
users:
|
||||
type: array
|
||||
description: All authors of comments on this asset.
|
||||
items:
|
||||
- $ref: '#/definitions/User'
|
||||
$ref: '#/definitions/User'
|
||||
actions:
|
||||
type: array
|
||||
description: All actions on comments on this asset and their authors.
|
||||
items:
|
||||
- $ref: '#/definitions/Actions'
|
||||
$ref: '#/definitions/Actions'
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
@@ -401,7 +486,7 @@ paths:
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
description: The settings.
|
||||
description: All global settings.
|
||||
schema:
|
||||
$ref: '#/definitions/Settings'
|
||||
500:
|
||||
@@ -409,6 +494,14 @@ paths:
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
put:
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
description: Settings to be updated.
|
||||
schema:
|
||||
type: object
|
||||
description: Any allowed setting and value.
|
||||
responses:
|
||||
204:
|
||||
description: The settings were updated.
|
||||
@@ -416,6 +509,241 @@ paths:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/users:
|
||||
get:
|
||||
parameters:
|
||||
- name: value
|
||||
in: query
|
||||
type: string
|
||||
description: A term to search users' displayNames and email addresses.
|
||||
- name: sort
|
||||
in: query
|
||||
type: string
|
||||
enum:
|
||||
- asc
|
||||
- desc
|
||||
description: Determines whether users sorted in are ascending or descending order.
|
||||
- name: field
|
||||
in: query
|
||||
type: string
|
||||
description: The field used to sort.
|
||||
- name: page
|
||||
in: query
|
||||
type: number
|
||||
description: The page of search results to return.
|
||||
- name: limit
|
||||
in: query
|
||||
type: number
|
||||
description: The number of search restults per page.
|
||||
responses:
|
||||
200:
|
||||
description: A paginated array of users matching search terms.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
result:
|
||||
type: array
|
||||
description: Users matching search criteria.
|
||||
items:
|
||||
$ref: '#/definitions/User'
|
||||
limit:
|
||||
type: number
|
||||
description: Results per page.
|
||||
count:
|
||||
type: number
|
||||
description: Total number of results.
|
||||
page:
|
||||
type: number
|
||||
description: The current page.
|
||||
totalPages:
|
||||
type: number
|
||||
description: The total number of pages.
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
post:
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
description: User to be created.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
password:
|
||||
type: string
|
||||
displayName:
|
||||
type: string
|
||||
responses:
|
||||
201:
|
||||
description: The user that has been created.
|
||||
schema:
|
||||
$ref: '#/definitions/User'
|
||||
/users/update-password:
|
||||
post:
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: The token that was in the url of the email link.
|
||||
password:
|
||||
type: string
|
||||
description: The new password.
|
||||
responses:
|
||||
204:
|
||||
description: Password update successful.
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/request-password-reset:
|
||||
post:
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
description: The email address of the user whos password is being reset.
|
||||
responses:
|
||||
204:
|
||||
description: Returned regardless of whether the user was found in the DB.
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/users/{user_id}/role:
|
||||
post:
|
||||
parameters:
|
||||
- name: user_id
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
format: uuid
|
||||
description: ID of the user to be updated.
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
role:
|
||||
type: string
|
||||
description: Role to be added to the user.
|
||||
enum:
|
||||
- admin
|
||||
- moderator
|
||||
responses:
|
||||
204:
|
||||
description: Role update successful.
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/users/{user_id}/status:
|
||||
post:
|
||||
parameters:
|
||||
- name: user_id
|
||||
in: path
|
||||
type: string
|
||||
format: uuid
|
||||
required: true
|
||||
description: ID of the user to be updated.
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status for the user to be set to.
|
||||
enum:
|
||||
- active
|
||||
- banned
|
||||
comment_id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: The id of the comment which triggered this status change.
|
||||
responses:
|
||||
200:
|
||||
description: Status update successful.
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/users/{user_id}/bio:
|
||||
put:
|
||||
parameters:
|
||||
- name: user_id
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
format: uuid
|
||||
description: The id of the user being updated.
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
bio:
|
||||
type: string
|
||||
description: The bio that should be set for this user.
|
||||
responses:
|
||||
200:
|
||||
description: Status update successful.
|
||||
schema:
|
||||
$ref: '#/definitions/User'
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/{user_id}/actions:
|
||||
post:
|
||||
parameters:
|
||||
- name: user_id
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
format: uuid
|
||||
description: The user on which this action is being taken.
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
action_type:
|
||||
description: The type of action being taken on this user.
|
||||
type: string
|
||||
enum:
|
||||
- flag
|
||||
metadata:
|
||||
type: object
|
||||
description: Arbitrary data to be included with the action.
|
||||
responses:
|
||||
200:
|
||||
description: The newly created action.
|
||||
schema:
|
||||
$ref: '#/definitions/Action'
|
||||
500:
|
||||
description: An error occured.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
definitions:
|
||||
Error:
|
||||
type: object
|
||||
@@ -423,10 +751,6 @@ definitions:
|
||||
message:
|
||||
type: string
|
||||
description: The error that occured.
|
||||
Item:
|
||||
type: object
|
||||
ModerationAction:
|
||||
type: string
|
||||
Comment:
|
||||
type: object
|
||||
properties:
|
||||
@@ -453,31 +777,66 @@ definitions:
|
||||
asset_id:
|
||||
type: string
|
||||
description: Display name of comment
|
||||
status_history:
|
||||
type: array
|
||||
description: A history of status changes for this comment.
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum:
|
||||
- accepted
|
||||
- rejected
|
||||
- premod
|
||||
assigned_by:
|
||||
type: string
|
||||
description: ID of the user who assigned this status.
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Date when status was assigned.
|
||||
|
||||
Actions:
|
||||
type: object
|
||||
description: A summary of actions taken on a particular item which is with the comment stream.
|
||||
properties:
|
||||
item_id:
|
||||
type: string
|
||||
description: The ID of the item which these actions target
|
||||
item_type:
|
||||
type: string # comment, user...
|
||||
type: string
|
||||
description: The type of item which these actions target (comment, user, etc.)
|
||||
type:
|
||||
type: string # flagged, likes, upvotes...
|
||||
type: string
|
||||
description: The type of action (like, flag, etc.)
|
||||
count:
|
||||
type: integer
|
||||
description: The number of this type of actions performed on this item.
|
||||
metadata:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
description: Metadata from the actions performed on this item. This metadata can be defined differently for each action type.
|
||||
current_user:
|
||||
type: boolean
|
||||
type: object
|
||||
description: Will include the action performed by the currently logged in user if that user has taken an action on this item. Otherwise will return null.
|
||||
Action:
|
||||
type: object
|
||||
description: A single action taken by a user.
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: The uuid.v4 id of the action.
|
||||
type:
|
||||
type: string
|
||||
description: The type of action being taken (like, flag, etc.)
|
||||
user_id:
|
||||
type: string
|
||||
moderation:
|
||||
type: string
|
||||
enum:
|
||||
- pre
|
||||
- post
|
||||
description: The ID of the user taking this action.
|
||||
metadata:
|
||||
type: object
|
||||
description: An object which contains arbitrary metadata about the action. Should be consistent for each action_type.
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
@@ -518,10 +877,112 @@ definitions:
|
||||
type: string
|
||||
format: datetime
|
||||
description: When this asset was published.
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Creation Date-Time
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Updated Date-Time
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: The uuid.v4 id of the user.
|
||||
displayName:
|
||||
type: string
|
||||
description: The name appearing next to the user's comments.
|
||||
disabled:
|
||||
type: boolean
|
||||
description: Indicates whether the user's account has been disabled (ie if the user is banned).
|
||||
password:
|
||||
type: string
|
||||
description: This provides a source of identity proof for users who login using the local provider. A local provider will be assumed for users who do not have any social profiles.
|
||||
profiles:
|
||||
type: array
|
||||
description: The array of identities for a given user. Any one user can have multiple profiles associated with them (eg facebook, google, etc.)
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: A unique identifier for the profile.
|
||||
provider:
|
||||
type: string
|
||||
description: The ame of the identity provider being used (e.g. 'facebook', 'twitter', etc.)
|
||||
roles:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: Roles occupied by the user (e.g. 'admin', 'moderator', etc.)
|
||||
status:
|
||||
type: string
|
||||
description: The current status of the user in the system.
|
||||
enum:
|
||||
- active
|
||||
- banned
|
||||
settings:
|
||||
type: object
|
||||
description: User-specific settings
|
||||
properties:
|
||||
bio:
|
||||
type: string
|
||||
description: A bio visible to other users.
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Creation Date-Time
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Updated Date-Time
|
||||
Settings:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: The id of the settings object. Defaults to 1 for global settings.
|
||||
moderation:
|
||||
type: string
|
||||
enum:
|
||||
- pre
|
||||
- post
|
||||
description: Indicates whether moderation occurs before or after a comment is made publicly visible.
|
||||
infoBoxEnable:
|
||||
type: boolean
|
||||
description: Indicates whether an informational box will be shown above the comment input box.
|
||||
infoBoxContent:
|
||||
type: string
|
||||
description: The text to appear in the informational box.
|
||||
closedTimeout:
|
||||
type: number
|
||||
format: int32
|
||||
description: The time after which streams will be automatically closed in seconds. Null will keep streams open forever.
|
||||
closedMessage:
|
||||
type: string
|
||||
description: The message displayed when a stream is closed.
|
||||
wordlist:
|
||||
type: array
|
||||
description: A list of banned word which will cause a comment to be automatically rejected.
|
||||
items:
|
||||
type: string
|
||||
charCount:
|
||||
type: number
|
||||
format: int32
|
||||
description: The maximum number of characters allowed in a comment.
|
||||
charCountEnable:
|
||||
type: boolean
|
||||
description: Indicates whether a maximum character count should be enabled for comments.
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Creation Date-Time
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Updated Date-Time
|
||||
Job:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
+1
-2
@@ -13,8 +13,7 @@ const ActionSchema = new Schema({
|
||||
item_type: String,
|
||||
item_id: String,
|
||||
user_id: String,
|
||||
field: String, // Used when an action references a particular field of an object. (e.g. a flag on a username or bio)
|
||||
detail: String, // Describes the reason for an action (e.g. 'Username is offensive')
|
||||
metadata: Object, //Holds arbitrary metadata about the action.
|
||||
}, {
|
||||
timestamps: {
|
||||
createdAt: 'created_at',
|
||||
|
||||
+2
-3
@@ -287,13 +287,12 @@ CommentSchema.statics.pushStatus = (id, status, assigned_by = null) => Comment.u
|
||||
* @param {String} action the new action to the comment
|
||||
* @return {Promise}
|
||||
*/
|
||||
CommentSchema.statics.addAction = (item_id, user_id, action_type, field, detail) => Action.insertUserAction({
|
||||
CommentSchema.statics.addAction = (item_id, user_id, action_type, metadata) => Action.insertUserAction({
|
||||
item_id,
|
||||
item_type: 'comments',
|
||||
user_id,
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
metadata
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+2
-3
@@ -614,11 +614,10 @@ UserService.addBio = (id, bio) => (
|
||||
* @param {String} action the new action to the user
|
||||
* @return {Promise}
|
||||
*/
|
||||
UserService.addAction = (item_id, user_id, action_type, field, detail) => Action.insertUserAction({
|
||||
UserService.addAction = (item_id, user_id, action_type, metadata) => Action.insertUserAction({
|
||||
item_id,
|
||||
item_type: 'users',
|
||||
user_id,
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
metadata
|
||||
});
|
||||
|
||||
@@ -12,18 +12,47 @@ router.get('/', (req, res, next) => {
|
||||
skip = 0,
|
||||
sort = 'asc',
|
||||
field = 'created_at',
|
||||
filter = 'all',
|
||||
search = ''
|
||||
} = req.query;
|
||||
|
||||
const FilterOpenAssets = (query, filter) => {
|
||||
switch(filter) {
|
||||
case 'open':
|
||||
return query.merge({
|
||||
$or: [
|
||||
{
|
||||
closedAt: null
|
||||
},
|
||||
{
|
||||
closedAt: {
|
||||
$gt: Date.now()
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
case 'closed':
|
||||
return query.merge({
|
||||
closedAt: {
|
||||
$lt: Date.now()
|
||||
}
|
||||
});
|
||||
default:
|
||||
return query;
|
||||
}
|
||||
};
|
||||
|
||||
// Find all the assets.
|
||||
Promise.all([
|
||||
Asset
|
||||
.search(search)
|
||||
|
||||
// Find the actuall assets.
|
||||
FilterOpenAssets(Asset.search(search), filter)
|
||||
.sort({[field]: (sort === 'asc') ? 1 : -1})
|
||||
.skip(skip)
|
||||
.limit(limit),
|
||||
Asset
|
||||
.search(search)
|
||||
.skip(parseInt(skip))
|
||||
.limit(parseInt(limit)),
|
||||
|
||||
// Get the count of actual assets.
|
||||
FilterOpenAssets(Asset.search(search), filter)
|
||||
.count()
|
||||
])
|
||||
.then(([result, count]) => {
|
||||
@@ -107,7 +136,6 @@ router.put('/:asset_id/status', (req, res, next) => {
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
res.status(204).json();
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -190,12 +190,11 @@ router.post('/:comment_id/actions', (req, res, next) => {
|
||||
|
||||
const {
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
metadata
|
||||
} = req.body;
|
||||
|
||||
Comment
|
||||
.addAction(req.params.comment_id, req.user.id, action_type, field, detail)
|
||||
.addAction(req.params.comment_id, req.user.id, action_type, metadata)
|
||||
.then((action) => {
|
||||
res.status(201).json(action);
|
||||
})
|
||||
|
||||
@@ -162,12 +162,11 @@ router.put('/:user_id/bio', (req, res, next) => {
|
||||
router.post('/:user_id/actions', authorization.needed(), (req, res, next) => {
|
||||
const {
|
||||
action_type,
|
||||
field,
|
||||
detail
|
||||
metadata
|
||||
} = req.body;
|
||||
|
||||
User
|
||||
.addAction(req.params.user_id, req.user.id, action_type, field, detail)
|
||||
.addAction(req.params.user_id, req.user.id, action_type, metadata)
|
||||
.then((action) => {
|
||||
res.status(201).json(action);
|
||||
})
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import 'react';
|
||||
import 'redux';
|
||||
import {expect} from 'chai';
|
||||
import fetchMock from 'fetch-mock';
|
||||
import * as actions from '../../../../client/coral-admin/src/actions/assets';
|
||||
import {Map} from 'immutable';
|
||||
|
||||
import configureStore from 'redux-mock-store';
|
||||
|
||||
const mockStore = configureStore();
|
||||
|
||||
describe('Asset actions', () => {
|
||||
let store;
|
||||
|
||||
const assets = [
|
||||
{
|
||||
url: 'http://test.com',
|
||||
id: '123',
|
||||
status: 'closed'
|
||||
},
|
||||
{
|
||||
url: 'http://test.org',
|
||||
id: '456',
|
||||
status: 'open'
|
||||
}
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
store = mockStore(new Map({}));
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
describe('FETCH_ASSETS_REQUEST', () => {
|
||||
|
||||
it('should fetch a list of assets', () => {
|
||||
|
||||
fetchMock.get('*', JSON.stringify({
|
||||
result: assets,
|
||||
count: 2
|
||||
}));
|
||||
|
||||
return actions.fetchAssets(2, 20)(store.dispatch)
|
||||
.then(() => {
|
||||
expect(store.getActions()[0]).to.have.property('type', 'FETCH_ASSETS_REQUEST');
|
||||
expect(store.getActions()[1]).to.have.property('type', 'FETCH_ASSETS_SUCCESS');
|
||||
expect(store.getActions()[1]).to.have.property('count', 2);
|
||||
expect(store.getActions()[1]).to.have.property('assets').
|
||||
and.to.deep.equal(assets);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error appropriatly', () => {
|
||||
|
||||
fetchMock.get('*', 404);
|
||||
|
||||
return actions.fetchAssets(2, 20)(store.dispatch)
|
||||
.then(() => {
|
||||
expect(store.getActions()[0]).to.have.property('type', 'FETCH_ASSETS_REQUEST');
|
||||
expect(store.getActions()[1]).to.have.property('type', 'FETCH_ASSETS_FAILURE');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('UPDATE_ASSET_STATE_REQUEST', () => {
|
||||
|
||||
it('should update an asset', () => {
|
||||
|
||||
fetchMock.put('*', JSON.stringify(assets[0]));
|
||||
|
||||
return actions.updateAssetState('123', 'status', 'open')(store.dispatch)
|
||||
.then(() => {
|
||||
expect(store.getActions()[0]).to.have.property('type', 'UPDATE_ASSET_STATE_REQUEST');
|
||||
expect(store.getActions()[1]).to.have.property('type', 'UPDATE_ASSET_STATE_SUCCESS');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should return an error appropriately', () => {
|
||||
|
||||
fetchMock.put('*', 404);
|
||||
|
||||
return actions.updateAssetState('123', 'status', 'open')(store.dispatch)
|
||||
.then(() => {
|
||||
expect(store.getActions()[0]).to.have.property('type', 'UPDATE_ASSET_STATE_REQUEST');
|
||||
expect(store.getActions()[1]).to.have.property('type', 'UPDATE_ASSET_STATE_FAILURE');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
import {Map, fromJS} from 'immutable';
|
||||
import {expect} from 'chai';
|
||||
import assetsReducer from '../../../../client/coral-admin/src/reducers/assets';
|
||||
|
||||
describe ('assetsReducer', () => {
|
||||
describe('FETCH_ASSETS_SUCCESS', () => {
|
||||
it('should replace the existing assets', () => {
|
||||
const action = {
|
||||
type: 'FETCH_ASSETS_SUCCESS',
|
||||
count: 200,
|
||||
assets: [
|
||||
{
|
||||
id: '123',
|
||||
url: 'http://test.com',
|
||||
closedAt: 'tomorrow'
|
||||
},
|
||||
{
|
||||
id: '456',
|
||||
url: 'http://test2.com',
|
||||
closedAt: 'thursday'
|
||||
},
|
||||
]
|
||||
};
|
||||
const store = new Map({});
|
||||
const result = assetsReducer(store, action);
|
||||
expect(result.getIn(['byId', '123']).toJS()).to.deep.equal({
|
||||
url: 'http://test.com',
|
||||
closedAt: 'tomorrow',
|
||||
id: '123'
|
||||
});
|
||||
expect(result.getIn(['ids']).toJS()).to.deep.equal([
|
||||
'123',
|
||||
'456'
|
||||
]);
|
||||
expect(result.getIn(['count'])).to.equal(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe('UPDATE_ASSET_STATE_REQUEST', () => {
|
||||
it('should update the state of a particular asset', () => {
|
||||
const action = {
|
||||
type: 'UPDATE_ASSET_STATE_REQUEST',
|
||||
id: '123',
|
||||
closedAt: null
|
||||
};
|
||||
const store = new fromJS({
|
||||
byId: {
|
||||
'123': {
|
||||
id: '123',
|
||||
url: 'http://test.com',
|
||||
closedAt: Date.now()
|
||||
},
|
||||
'456': {
|
||||
id: '456',
|
||||
url: 'http://test2.com',
|
||||
closedAt: 'thursday'
|
||||
}
|
||||
}
|
||||
});
|
||||
const result = assetsReducer(store, action);
|
||||
expect(result.getIn(['byId', '123', 'closedAt'])).to.equal.null;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -18,12 +18,13 @@ describe('/api/v1/assets', () => {
|
||||
url: 'https://coralproject.net/news/asset1',
|
||||
title: 'Asset 1',
|
||||
description: 'term1',
|
||||
id: '1'
|
||||
closedAt: Date.now()
|
||||
},
|
||||
{
|
||||
url: 'https://coralproject.net/news/asset2',
|
||||
title: 'Asset 2',
|
||||
description: 'term2'
|
||||
description: 'term2',
|
||||
closedAt: null
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -81,6 +82,38 @@ describe('/api/v1/assets', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return only closed assets', () => {
|
||||
return chai.request(app)
|
||||
.get('/api/v1/assets?filter=closed')
|
||||
.set(passport.inject({roles: ['admin']}))
|
||||
.then((res) => {
|
||||
const body = res.body;
|
||||
|
||||
expect(body).to.have.property('count', 1);
|
||||
expect(body).to.have.property('result');
|
||||
|
||||
const assets = body.result;
|
||||
|
||||
expect(assets[0]).to.have.property('title', 'Asset 1');
|
||||
});
|
||||
});
|
||||
|
||||
it('should return only opened assets', () => {
|
||||
return chai.request(app)
|
||||
.get('/api/v1/assets?filter=open')
|
||||
.set(passport.inject({roles: ['admin']}))
|
||||
.then((res) => {
|
||||
const body = res.body;
|
||||
|
||||
expect(body).to.have.property('count', 1);
|
||||
expect(body).to.have.property('result');
|
||||
|
||||
const assets = body.result;
|
||||
|
||||
expect(assets[0]).to.have.property('title', 'Asset 2');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#put', () => {
|
||||
|
||||
@@ -440,12 +440,13 @@ describe('/api/v1/comments/:comment_id/actions', () => {
|
||||
return chai.request(app)
|
||||
.post('/api/v1/comments/abc/actions')
|
||||
.set(passport.inject({id: '456', roles: ['admin']}))
|
||||
.send({'action_type': 'flag', 'detail': 'Comment is too awesome.'})
|
||||
.send({'action_type': 'flag', 'metadata': {'reason': 'Comment is too awesome.'}})
|
||||
.then((res) => {
|
||||
expect(res).to.have.status(201);
|
||||
expect(res).to.have.body;
|
||||
expect(res.body).to.have.property('action_type', 'flag');
|
||||
expect(res.body).to.have.property('detail', 'Comment is too awesome.');
|
||||
expect(res.body).to.have.property('metadata')
|
||||
.and.to.deep.equal({'reason': 'Comment is too awesome.'});
|
||||
expect(res.body).to.have.property('item_id', 'abc');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,14 +31,16 @@ describe('/api/v1/users/:user_id/actions', () => {
|
||||
return chai.request(app)
|
||||
.post('/api/v1/users/abc/actions')
|
||||
.set(passport.inject({id: '456', roles: ['admin']}))
|
||||
.send({'action_type': 'flag', 'detail': 'Bio is too awesome.'})
|
||||
.send({'action_type': 'flag', 'metadata': {'reason': 'Bio is too awesome.'}})
|
||||
.then((res) => {
|
||||
expect(res).to.have.status(201);
|
||||
expect(res).to.have.body;
|
||||
expect(res.body).to.have.property('action_type', 'flag');
|
||||
expect(res.body).to.have.property('detail', 'Bio is too awesome.');
|
||||
expect(res.body).to.have.property('metadata')
|
||||
.and.to.deep.equal({'reason': 'Bio is too awesome.'});
|
||||
expect(res.body).to.have.property('item_id', 'abc');
|
||||
});
|
||||
})
|
||||
.catch(err => console.error(err.message));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user