From 596c214f1ce924c1d6b7b08c94b7c1038a68fa79 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 31 Jan 2018 13:41:07 -0700 Subject: [PATCH 1/8] allowed moderators to configure asset --- client/coral-embed-stream/src/components/Embed.js | 2 +- client/coral-framework/services/perms.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/components/Embed.js b/client/coral-embed-stream/src/components/Embed.js index 980e5745e..0fd257ef2 100644 --- a/client/coral-embed-stream/src/components/Embed.js +++ b/client/coral-embed-stream/src/components/Embed.js @@ -43,7 +43,7 @@ export default class Embed extends React.Component { {t('framework.my_profile')} , ]; - if (can(user, 'UPDATE_CONFIG')) { + if (can(user, 'UPDATE_ASSET_CONFIG')) { tabs.push( Date: Thu, 1 Feb 2018 12:13:33 +0100 Subject: [PATCH 2/8] Clearly remove auth data from storage --- client/coral-admin/src/actions/auth.js | 3 +++ client/coral-embed-stream/src/actions/auth.js | 3 +++ plugins/talk-plugin-auth/client/components/SignInContainer.js | 1 + 3 files changed, 7 insertions(+) diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js index 332d756c0..6892080cd 100644 --- a/client/coral-admin/src/actions/auth.js +++ b/client/coral-admin/src/actions/auth.js @@ -33,6 +33,7 @@ export const handleLogin = (email, password, recaptchaResponse) => ( if (!user) { if (!bowser.safari && !bowser.ios && storage) { storage.removeItem('token'); + storage.removeItem('exp'); } return dispatch(checkLoginFailure('not logged in')); } @@ -128,6 +129,7 @@ export const checkLogin = () => (dispatch, _, { rest, client, storage }) => { if (!user) { if (!bowser.safari && !bowser.ios && storage) { storage.removeItem('token'); + storage.removeItem('exp'); } return dispatch(checkLoginFailure('not logged in')); } @@ -152,6 +154,7 @@ export const logout = () => (dispatch, _, { rest, client, storage }) => { return rest('/auth', { method: 'DELETE' }).then(() => { if (storage) { storage.removeItem('token'); + storage.removeItem('exp'); } // Reset the websocket. diff --git a/client/coral-embed-stream/src/actions/auth.js b/client/coral-embed-stream/src/actions/auth.js index e74265026..4406c744c 100644 --- a/client/coral-embed-stream/src/actions/auth.js +++ b/client/coral-embed-stream/src/actions/auth.js @@ -266,6 +266,7 @@ export const logout = () => async ( if (storage) { storage.removeItem('token'); + storage.removeItem('exp'); } // Reset the websocket. @@ -304,6 +305,7 @@ export const checkLogin = () => ( if (!result.user) { if (storage) { storage.removeItem('token'); + storage.removeItem('exp'); } throw ErrNotLoggedIn; } @@ -329,6 +331,7 @@ export const checkLogin = () => ( if (error.status && error.status === 401 && storage) { // Unauthorized. storage.removeItem('token'); + storage.removeItem('exp'); } const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) diff --git a/plugins/talk-plugin-auth/client/components/SignInContainer.js b/plugins/talk-plugin-auth/client/components/SignInContainer.js index a4dec87e5..4dc072feb 100644 --- a/plugins/talk-plugin-auth/client/components/SignInContainer.js +++ b/plugins/talk-plugin-auth/client/components/SignInContainer.js @@ -60,6 +60,7 @@ class SignInContainer extends React.Component { if (e.key === 'auth') { const { err, data } = JSON.parse(e.newValue); authCallback(err, data); + localStorage.removeItem('auth'); } }; From c4b6cb54e60893bafceef07ea44d1904eb100ab2 Mon Sep 17 00:00:00 2001 From: Leandro Date: Thu, 1 Feb 2018 13:27:17 +0100 Subject: [PATCH 3/8] Insert BASE_PATH on public assets --- views/admin/confirm-email.ejs | 2 +- views/admin/password-reset.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/views/admin/confirm-email.ejs b/views/admin/confirm-email.ejs index f8f6c62f2..8c0d85e01 100644 --- a/views/admin/confirm-email.ejs +++ b/views/admin/confirm-email.ejs @@ -6,7 +6,7 @@ Email Verification - + <%_ if (locals.customCssUrl) { _%> <%_ } _%> diff --git a/views/admin/password-reset.ejs b/views/admin/password-reset.ejs index c5bb4ef90..ae06b5179 100644 --- a/views/admin/password-reset.ejs +++ b/views/admin/password-reset.ejs @@ -6,7 +6,7 @@ Password Reset - + <%_ if (locals.customCssUrl) { _%> <%_ } _%> From 6afb300d86df88768f88597b894a73737c8cd06c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 1 Feb 2018 17:55:53 +0100 Subject: [PATCH 4/8] Unlisten --- .../client/components/SignInContainer.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/talk-plugin-auth/client/components/SignInContainer.js b/plugins/talk-plugin-auth/client/components/SignInContainer.js index 4dc072feb..6f99f9ce6 100644 --- a/plugins/talk-plugin-auth/client/components/SignInContainer.js +++ b/plugins/talk-plugin-auth/client/components/SignInContainer.js @@ -38,8 +38,7 @@ class SignInContainer extends React.Component { } componentDidMount() { - window.addEventListener('storage', this.handleAuth); - + this.listenToStorageChanges(); const { formData } = this.state; const errors = Object.keys(formData).reduce((map, prop) => { map[prop] = t('sign_in.required_field'); @@ -49,6 +48,14 @@ class SignInContainer extends React.Component { } componentWillUnmount() { + this.unlisten(); + } + + listenToStorageChanges() { + window.addEventListener('storage', this.handleAuth); + } + + unlisten() { window.removeEventListener('storage', this.handleAuth); } @@ -60,6 +67,7 @@ class SignInContainer extends React.Component { if (e.key === 'auth') { const { err, data } = JSON.parse(e.newValue); authCallback(err, data); + this.unlisten(); localStorage.removeItem('auth'); } }; From 219fcdddea9f87d6315c67437caf3f2d1a321d6a Mon Sep 17 00:00:00 2001 From: Nat Welch Date: Thu, 1 Feb 2018 13:26:34 -0500 Subject: [PATCH 5/8] Change text wrapping of Stories table --- client/coral-admin/src/routes/Stories/components/Stories.css | 1 + 1 file changed, 1 insertion(+) diff --git a/client/coral-admin/src/routes/Stories/components/Stories.css b/client/coral-admin/src/routes/Stories/components/Stories.css index e8e2b8474..63a05ab6a 100644 --- a/client/coral-admin/src/routes/Stories/components/Stories.css +++ b/client/coral-admin/src/routes/Stories/components/Stories.css @@ -56,6 +56,7 @@ width: 100%; border-left: none; border-right: none; + white-space: pre-wrap; a { color: rgb(44, 44, 44); From edac21a4f47f8c8c3a866c761b8e1ecf6adf1451 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 2 Feb 2018 11:52:42 +0100 Subject: [PATCH 6/8] Fix Flag Menu not working --- .../src/tabs/stream/components/FlagButton.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js b/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js index bc673ba28..b1974db36 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js +++ b/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js @@ -8,6 +8,7 @@ import ClickOutside from 'coral-framework/components/ClickOutside'; import cn from 'classnames'; import styles from './FlagButton.css'; import * as REASONS from 'coral-framework/graphql/flagReasons'; +import PropTypes from 'prop-types'; import { getErrorMessages, forEachError } from 'coral-framework/utils'; @@ -77,9 +78,8 @@ export default class FlagButton extends Component { return; } break; - case this.props.getPopupMenu.length: - this.closeMenu(); - return; + default: + throw new Error(`Unexpected step ${step}`); } // If itemType and reason are both set, post the action @@ -92,6 +92,8 @@ export default class FlagButton extends Component { case 'USERS': item_id = author_id; break; + default: + throw new Error(`Unexpected itemType ${itemType}`); } let action = { @@ -132,6 +134,10 @@ export default class FlagButton extends Component { } if (!failed) { + if (step === this.props.getPopupMenu.length - 1) { + this.closeMenu(); + return; + } this.setState({ step: step + 1 }); } }; @@ -272,3 +278,12 @@ export default class FlagButton extends Component { ); } } + +FlagButton.propTypes = { + currentUser: PropTypes.object, + showSignInDialog: PropTypes.func, + notify: PropTypes.func, + getPopupMenu: PropTypes.array, + flaggedByCurrentUser: PropTypes.bool, + banned: PropTypes.bool, +}; From ac67b0484b283cc7a1c06316130ff6ec66e6f348 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 2 Feb 2018 12:12:58 +0100 Subject: [PATCH 7/8] Better fix --- .../src/tabs/stream/components/FlagButton.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js b/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js index b1974db36..002297415 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js +++ b/client/coral-embed-stream/src/tabs/stream/components/FlagButton.js @@ -78,6 +78,8 @@ export default class FlagButton extends Component { return; } break; + case 2: + return this.closeMenu(); default: throw new Error(`Unexpected step ${step}`); } @@ -134,10 +136,6 @@ export default class FlagButton extends Component { } if (!failed) { - if (step === this.props.getPopupMenu.length - 1) { - this.closeMenu(); - return; - } this.setState({ step: step + 1 }); } }; From aec0251c4fb8e1f8e604e7b7ebb6964bd8633741 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 2 Feb 2018 15:50:43 +0100 Subject: [PATCH 8/8] Fix zen mode --- .../src/routes/Moderation/components/ModerationQueue.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js index ce957b82d..93786013f 100644 --- a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js +++ b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js @@ -397,6 +397,13 @@ class ModerationQueue extends React.Component { const index = comments.findIndex( comment => comment.id === selectedCommentId ); + + // This can happen temporarily when we call redux to change the selected comment + // but it didn't fully take effect yet. + if (index === -1) { + return null; + } + const comment = comments[index]; return (