diff --git a/.eslintrc.json b/.eslintrc.json index 035a86189..d99b2254b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,6 +21,8 @@ "no-eval": [2], "no-global-assign": [2], "no-implied-eval": [2], + "lines-around-comment": ["warn", {"beforeLineComment": true}], + "spaced-comment": ["warn", "always", { "line": { "exceptions": ["-", "="] } }], "no-script-url": [2], "no-throw-literal": [2], "yoda": [1], diff --git a/app.js b/app.js index 739c735b2..c3fa5d8d6 100644 --- a/app.js +++ b/app.js @@ -23,6 +23,7 @@ if (app.get('env') !== 'test') { //============================================================================== app.set('trust proxy', 1); + // We disable frameward on helmet to allow crossdomain injection of the embed app.use(helmet({ frameguard: false diff --git a/bin/cli-serve b/bin/cli-serve index c22920eaa..5478b7c1e 100755 --- a/bin/cli-serve +++ b/bin/cli-serve @@ -60,11 +60,13 @@ function normalizePort(val) { let port = parseInt(val, 10); if (isNaN(port)) { + // named pipe return val; } if (port >= 0) { + // port number return port; } diff --git a/client/coral-admin/src/components/BanUserDialog.js b/client/coral-admin/src/components/BanUserDialog.js index 1867b9ac2..1b4af6eb1 100644 --- a/client/coral-admin/src/components/BanUserDialog.js +++ b/client/coral-admin/src/components/BanUserDialog.js @@ -14,7 +14,7 @@ const BanUserDialog = ({open, handleClose, onClickBanUser, user = {}}) => { return ( handleClose()} onCancel={() => handleClose()} title={lang.t('bandialog.ban_user')}> - handleClose()}>× + handleClose()}>×

diff --git a/client/coral-admin/src/components/CommentList.js b/client/coral-admin/src/components/CommentList.js index 8c6655bb5..597ea62a6 100644 --- a/client/coral-admin/src/components/CommentList.js +++ b/client/coral-admin/src/components/CommentList.js @@ -31,6 +31,7 @@ export default class CommentList extends React.Component { // add key handlers and gestures componentDidMount () { this.bindKeyHandlers(); + // this.bindGestures() // need to check whether we're on a mobile device or this throws an Error } @@ -80,6 +81,7 @@ export default class CommentList extends React.Component { const {commentIds} = this.props; const {active} = this.state; + // check boundaries if (active === null || !commentIds.length) { this.setState({active: commentIds[0]}); @@ -102,6 +104,7 @@ export default class CommentList extends React.Component { // TODO: In the future this can be improved and look at the actual state to // resolve since the content of the list could change externally. For now it works as expected onClickAction (action, id, author_id) { + // activate the next comment if (id === this.state.active) { const {commentIds} = this.props; diff --git a/client/coral-admin/src/containers/Configure/CommentSettings.js b/client/coral-admin/src/containers/Configure/CommentSettings.js index 5819076c6..050432743 100644 --- a/client/coral-admin/src/containers/Configure/CommentSettings.js +++ b/client/coral-admin/src/containers/Configure/CommentSettings.js @@ -69,11 +69,17 @@ const updateClosedTimeout = (updateSettings, ts, isMeasure) => (event) => { } }; -const CommentSettings = ({updateSettings, settingsError, settings, errors}) => +const CommentSettings = ({fetchingSettings, updateSettings, settingsError, settings, errors}) => { + if (fetchingSettings) { + /* maybe a spinner here at some point */ + return

Loading settings...

; + } + + return @@ -86,7 +92,7 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => < @@ -113,7 +119,7 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => < @@ -144,7 +150,9 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => < value={getTimeoutAmount(settings.closedTimeout)} label={lang.t('configure.closed-comments-label')} />
- @@ -164,6 +172,7 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => < ; +}; export default CommentSettings; diff --git a/client/coral-admin/src/containers/Configure/Configure.js b/client/coral-admin/src/containers/Configure/Configure.js index 8dd106cd0..ed8ba9b26 100644 --- a/client/coral-admin/src/containers/Configure/Configure.js +++ b/client/coral-admin/src/containers/Configure/Configure.js @@ -78,6 +78,7 @@ class Configure extends React.Component { switch(section){ case 'comments': return { + this.setState({modalOpen: true}); + } + onTabClick (activeTab) { this.setState({activeTab}); } @@ -93,6 +100,11 @@ class ModerationQueue extends React.Component { className={`mdl-tabs__tab ${styles.tab}`}>{lang.t('modqueue.rejected')} this.onTabClick('flagged')} className={`mdl-tabs__tab ${styles.tab}`}>{lang.t('modqueue.flagged')} + + + {lang.t('modqueue.showshortcuts')} +
{ + /* Combine seperate calls into a single object */ let all = {}; all.comments = pending.comments @@ -55,6 +56,7 @@ Promise.all([ return all; }) .then(all => { + /* Post comments and users to redux store. Actions will be posted when they are needed. */ store.dispatch({type: 'USERS_MODERATION_QUEUE_FETCH_SUCCESS', users: all.users}); @@ -62,6 +64,7 @@ Promise.all([ comments: all.comments}); }); + // .catch(error => store.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH_FAILED', error})); // Update a comment. Now to update a comment we need to send back the whole object diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index ef00f1cf8..6f8e76c4b 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -28,7 +28,8 @@ "nextcomment": "Go to the next comment", "prevcomment": "Go to the previous comment", "singleview": "Toggle single comment edit view", - "thismenu": "Open this menu" + "thismenu": "Open this menu", + "showshortcuts": "Show Shortcuts" }, "comment": { "flagged": "flagged", @@ -95,7 +96,8 @@ "rejected": "rechazado", "flagged": "marcado", "shortcuts": "Atajos de teclado", - "close": "Cerrar" + "close": "Cerrar", + "showshortcuts": "Mostrar atajos" }, "comment": { "flagged": "marcado", diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js index cb8bf0012..71da184ab 100644 --- a/client/coral-configure/containers/ConfigureStreamContainer.js +++ b/client/coral-configure/containers/ConfigureStreamContainer.js @@ -51,8 +51,8 @@ class ConfigureStreamContainer extends Component { } getClosedIn () { - const {config} = this.props; - const {created_at, closedTimeout} = config; + const {closedTimeout} = this.props.config; + const {created_at} = this.props.asset; return lang.timeago(new Date(created_at).getTime() + (1000 * closedTimeout)); } @@ -80,7 +80,11 @@ class ConfigureStreamContainer extends Component { } const mapStateToProps = (state) => ({ - config: state.config.toJS() + config: state.config.toJS(), + asset: state.items + .get('assets') + .first() + .toJS() }); const mapDispatchToProps = dispatch => ({ diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index e6cc8fbbc..7d1e6c612 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -58,6 +58,7 @@ class CommentStream extends Component { } componentDidMount () { + // Set up messaging between embedded Iframe an parent component this.pym = new Pym.Child({polling: 100}); diff --git a/client/coral-framework/actions/items.js b/client/coral-framework/actions/items.js index cd798c6b9..160dcb24c 100644 --- a/client/coral-framework/actions/items.js +++ b/client/coral-framework/actions/items.js @@ -118,6 +118,7 @@ export function getStream (assetUrl) { /* Sort comments by date*/ json.comments.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()); const rels = json.comments.reduce((h, item) => { + /* Check for root and child comments. */ if ( item.asset_id === assetId && diff --git a/client/coral-framework/modules/i18n/i18n.js b/client/coral-framework/modules/i18n/i18n.js index 1d81e885c..d4ed36b09 100644 --- a/client/coral-framework/modules/i18n/i18n.js +++ b/client/coral-framework/modules/i18n/i18n.js @@ -9,6 +9,7 @@ import get from 'lodash/get'; class i18n { constructor (translations) { + /** * Register locales */ @@ -16,6 +17,7 @@ class i18n { this.locales = {'en': 'en', 'es': 'es'}; timeago.register('es_ES', esTA); this.timeagoInstance = new timeago(); + /** * Load translations */ @@ -55,6 +57,7 @@ class i18n { this.t = (key, ...replacements) => { if (has(this.translations, key)) { let translation = get(this.translations, key); + // replace any {n} with the arguments passed to this method replacements.forEach((str, i) => { translation = translation.replace(new RegExp(`\\{${i}\\}`, 'g'), str); diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index 086a0cf36..fe67b22e0 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -103,7 +103,7 @@ class CommentBox extends Component {
{ author && (