From a02ad695683bcde2c4b78b4a9f3d9935be975f57 Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 3 Jan 2017 09:36:20 -0300 Subject: [PATCH 1/3] Adds specific fields to the metadata in the action when flagging because suspect word. --- routes/api/comments/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index 39b4b02bc..21426d217 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -137,7 +137,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => { .then((comment) => { if (req.wordlist.suspect) { return Comment - .addAction(comment.id, null, 'flag', 'body', 'Matched suspect word filters.') + .addAction(comment.id, null, 'flag', {field: 'body', details: 'Matched suspect word filters.'}) .then(() => comment); } From 5c6df6d48145dabd040d06e2d2b0ebc87a7e9289 Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 3 Jan 2017 09:37:02 -0300 Subject: [PATCH 2/3] Fix tests when flagging because suspect word. --- tests/routes/api/comments/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index 1c782e405..3af37cada 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -225,8 +225,9 @@ describe('/api/v1/comments', () => { let action = actions[0]; expect(action).to.have.property('item_id', comment.id); - expect(action).to.have.property('field', 'body'); - expect(action).to.have.property('detail', 'Matched suspect word filters.'); + expect(action).to.have.property('metadata'); + expect(action.metadata).to.have.property('field', 'body'); + expect(action.metadata).to.have.property('details', 'Matched suspect word filters.'); }); }); From 759e74a88d26c5212fd354e0c8f9d7be3c6d47a3 Mon Sep 17 00:00:00 2001 From: Dan Zajdband Date: Tue, 3 Jan 2017 10:46:55 -0300 Subject: [PATCH 3/3] coral-admin: Fixed check for component unmount removing a listener when there is no object --- client/coral-admin/src/components/CommentList.js | 4 +--- client/coral-ui/components/Dialog.js | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/coral-admin/src/components/CommentList.js b/client/coral-admin/src/components/CommentList.js index 326d63cf1..a1a990490 100644 --- a/client/coral-admin/src/components/CommentList.js +++ b/client/coral-admin/src/components/CommentList.js @@ -25,9 +25,7 @@ export default class CommentList extends React.Component { loading: PropTypes.bool, // list of actions (flags, etc) associated with the comments - actions: PropTypes.shape({ - ids: PropTypes.arrayOf(PropTypes.string) - }), + actions: PropTypes.arrayOf(PropTypes.string), suspectWords: PropTypes.arrayOf(PropTypes.string) } diff --git a/client/coral-ui/components/Dialog.js b/client/coral-ui/components/Dialog.js index 9af9be6dd..17cb78d28 100644 --- a/client/coral-ui/components/Dialog.js +++ b/client/coral-ui/components/Dialog.js @@ -42,7 +42,9 @@ export default class Dialog extends Component { componentWillUnmount() { const dialog = this.dialog; - dialog.removeEventListener('cancel', this.props.onCancel); + if (dialog) { + dialog.removeEventListener('cancel', this.props.onCancel); + } } render() {