From e256b0da8a61b0111d69fd6641f3b7bbc8033324 Mon Sep 17 00:00:00 2001 From: okbel Date: Fri, 12 Jan 2018 15:47:09 -0300 Subject: [PATCH 1/8] Adding format to admin comment - CommentFormatter --- ...BodyHighlighter.js => CommentFormatter.js} | 50 +++++++++++++++---- .../routes/Moderation/components/Comment.js | 13 +++-- 2 files changed, 47 insertions(+), 16 deletions(-) rename client/coral-admin/src/components/{CommentBodyHighlighter.js => CommentFormatter.js} (63%) diff --git a/client/coral-admin/src/components/CommentBodyHighlighter.js b/client/coral-admin/src/components/CommentFormatter.js similarity index 63% rename from client/coral-admin/src/components/CommentBodyHighlighter.js rename to client/coral-admin/src/components/CommentFormatter.js index 9e381bf0b..6c086b6aa 100644 --- a/client/coral-admin/src/components/CommentBodyHighlighter.js +++ b/client/coral-admin/src/components/CommentFormatter.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import { matchLinks } from '../utils'; import memoize from 'lodash/memoize'; @@ -62,16 +63,43 @@ function markLinks(body) { return content; } -export default ({ suspectWords, bannedWords, body, ...rest }) => { - // First highlight links. - const content = markLinks(body).map((element, index) => { - // Keep highlighted links. - if (typeof element !== 'string') { - return element; - } +function format(body, { suspectWords, bannedWords, className = 'comment' }) { + // Breaking the body by line break + const textbreaks = body.split('\n'); - // Highlight suspect and banned phrase inside this part of text. - return markPhrases(element, suspectWords, bannedWords, index); - }); - return
{content}
; + return ( + + {textbreaks.map((line, i) => { + const content = markLinks(line).map((element, index) => { + // Keep highlighted links. + if (typeof element !== 'string') { + return element; + } + + // Highlight suspect and banned phrase inside this part of text. + return markPhrases(element, suspectWords, bannedWords, index); + }); + + return ( + + {content} + {i !== textbreaks.length - 1 && ( +
+ )} +
+ ); + })} +
+ ); +} + +const CommentFormatter = ({ body, settings, ...rest }) => { + return
{format(body, settings)}
; }; + +CommentFormatter.propTypes = { + settings: PropTypes.object, + body: PropTypes.string, +}; + +export default CommentFormatter; diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index fc6894a46..504c3e04d 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -8,7 +8,7 @@ import styles from './Comment.css'; import CommentLabels from 'coral-admin/src/components/CommentLabels'; import CommentAnimatedEdit from 'coral-admin/src/components/CommentAnimatedEdit'; import Slot from 'coral-framework/components/Slot'; -import CommentBodyHighlighter from 'coral-admin/src/components/CommentBodyHighlighter'; +import CommentFormatter from 'coral-admin/src/components/CommentFormatter'; import IfHasLink from 'coral-admin/src/components/IfHasLink'; import cn from 'classnames'; import ApproveButton from 'coral-admin/src/components/ApproveButton'; @@ -126,11 +126,14 @@ class Comment extends React.Component {
- {' '} + /> Date: Fri, 12 Jan 2018 15:51:49 -0300 Subject: [PATCH 2/8] Adding changes to the comments on the User Drawer Detail --- client/coral-admin/src/components/UserDetailComment.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/coral-admin/src/components/UserDetailComment.js b/client/coral-admin/src/components/UserDetailComment.js index b1cc486ec..669f035fe 100644 --- a/client/coral-admin/src/components/UserDetailComment.js +++ b/client/coral-admin/src/components/UserDetailComment.js @@ -5,7 +5,7 @@ import { Link } from 'react-router'; import { Icon } from 'coral-ui'; import CommentDetails from './CommentDetails'; import styles from './UserDetailComment.css'; -import CommentBodyHighlighter from 'coral-admin/src/components/CommentBodyHighlighter'; +import CommentFormatter from 'coral-admin/src/components/CommentFormatter'; import IfHasLink from 'coral-admin/src/components/IfHasLink'; import cn from 'classnames'; import CommentAnimatedEdit from './CommentAnimatedEdit'; @@ -78,9 +78,11 @@ class UserDetailComment extends React.Component {
- {' '} Date: Fri, 12 Jan 2018 15:53:32 -0300 Subject: [PATCH 3/8] Wrong name --- client/coral-admin/src/components/CommentAnimatedEdit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/components/CommentAnimatedEdit.js b/client/coral-admin/src/components/CommentAnimatedEdit.js index 43fbf9fbf..12280b204 100644 --- a/client/coral-admin/src/components/CommentAnimatedEdit.js +++ b/client/coral-admin/src/components/CommentAnimatedEdit.js @@ -4,7 +4,7 @@ import { CSSTransitionGroup } from 'react-transition-group'; import styles from './CommentAnimatedEdit.css'; import PropTypes from 'prop-types'; -const CommentBodyHighlighter = ({ children, body }) => { +const CommentAnimatedEdit = ({ children, body }) => { return ( { ); }; -CommentBodyHighlighter.propTypes = { +CommentAnimatedEdit.propTypes = { children: PropTypes.node, body: PropTypes.string, }; -export default CommentBodyHighlighter; +export default CommentAnimatedEdit; From bfa2f6edb958df93e5a042b6123d384cbb229c73 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 15 Jan 2018 12:59:39 -0300 Subject: [PATCH 4/8] Updates --- .../src/components/CommentFormatter.js | 18 +++++++++++------- .../src/components/UserDetailComment.js | 9 ++++----- .../routes/Moderation/components/Comment.js | 8 +++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/coral-admin/src/components/CommentFormatter.js b/client/coral-admin/src/components/CommentFormatter.js index 6c086b6aa..152ae8547 100644 --- a/client/coral-admin/src/components/CommentFormatter.js +++ b/client/coral-admin/src/components/CommentFormatter.js @@ -63,12 +63,18 @@ function markLinks(body) { return content; } -function format(body, { suspectWords, bannedWords, className = 'comment' }) { +const CommentFormatter = ( + body, + suspectWords, + bannedWords, + className = 'comment', + ...rest +) => { // Breaking the body by line break const textbreaks = body.split('\n'); return ( - + {textbreaks.map((line, i) => { const content = markLinks(line).map((element, index) => { // Keep highlighted links. @@ -91,14 +97,12 @@ function format(body, { suspectWords, bannedWords, className = 'comment' }) { })} ); -} - -const CommentFormatter = ({ body, settings, ...rest }) => { - return
{format(body, settings)}
; }; CommentFormatter.propTypes = { - settings: PropTypes.object, + className: PropTypes.string, + bannedWords: PropTypes.array, + suspectWords: PropTypes.array, body: PropTypes.string, }; diff --git a/client/coral-admin/src/components/UserDetailComment.js b/client/coral-admin/src/components/UserDetailComment.js index 669f035fe..2d98edcb3 100644 --- a/client/coral-admin/src/components/UserDetailComment.js +++ b/client/coral-admin/src/components/UserDetailComment.js @@ -79,12 +79,11 @@ class UserDetailComment extends React.Component {
{' '} + className="talk-admin-user-detail-comment" + />
Date: Mon, 15 Jan 2018 13:14:24 -0300 Subject: [PATCH 5/8] missing brackets --- client/coral-admin/src/components/CommentFormatter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/components/CommentFormatter.js b/client/coral-admin/src/components/CommentFormatter.js index 152ae8547..8874d123f 100644 --- a/client/coral-admin/src/components/CommentFormatter.js +++ b/client/coral-admin/src/components/CommentFormatter.js @@ -63,13 +63,13 @@ function markLinks(body) { return content; } -const CommentFormatter = ( +const CommentFormatter = ({ body, suspectWords, bannedWords, className = 'comment', ...rest -) => { +}) => { // Breaking the body by line break const textbreaks = body.split('\n'); From 7ca89435c6b7a6909e6b600ece002fff97b9f7e2 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 17 Jan 2018 11:24:36 -0700 Subject: [PATCH 6/8] added configuration options for webpack --- Dockerfile.onbuild | 1 + webpack.config.js | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Dockerfile.onbuild b/Dockerfile.onbuild index 20d34ffb9..dab06f336 100644 --- a/Dockerfile.onbuild +++ b/Dockerfile.onbuild @@ -5,6 +5,7 @@ ONBUILD ARG TALK_THREADING_LEVEL=3 ONBUILD ARG TALK_DEFAULT_STREAM_TAB=all ONBUILD ARG TALK_DEFAULT_LANG=en ONBUILD ARG TALK_PLUGINS_JSON +ONBUILD ARG TALK_WEBPACK_SOURCE_MAP # Bundle app source ONBUILD COPY . /usr/src/app diff --git a/webpack.config.js b/webpack.config.js index cb3327fe7..bbb4abee7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,12 +22,27 @@ const buildTargets = ['coral-admin', 'coral-docs']; const buildEmbeds = ['stream']; +// In production, default turn off source maps. In development, default use +// 'cheap-module-source-map'. +const devtool = + process.env.NODE_ENV === 'production' + ? process.env.TALK_WEBPACK_SOURCE_MAP + ? process.env.TALK_WEBPACK_SOURCE_MAP === 'none' + ? false + : process.env.TALK_WEBPACK_SOURCE_MAP + : false + : process.env.TALK_WEBPACK_SOURCE_MAP + ? process.env.TALK_WEBPACK_SOURCE_MAP === 'none' + ? false + : process.env.TALK_WEBPACK_SOURCE_MAP + : 'cheap-module-source-map'; + //============================================================================== // Base Webpack Config //============================================================================== const config = { - devtool: 'cheap-module-source-map', + devtool, target: 'web', output: { path: path.join(__dirname, 'dist'), From 68598d3c458a308b5a96a6d9649cfcd616b6c80e Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 17 Jan 2018 11:34:09 -0700 Subject: [PATCH 7/8] cleanup for logic --- webpack.config.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index bbb4abee7..270417148 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -24,18 +24,21 @@ const buildEmbeds = ['stream']; // In production, default turn off source maps. In development, default use // 'cheap-module-source-map'. +const DEFAULT_WEBPACK_SOURCE_MAP = + process.env.NODE_ENV === 'production' ? 'none' : 'cheap-module-source-map'; + +// TALK_WEBPACK_SOURCE_MAP is sourced from the environment, defaulting based on +// the environment. +const TALK_WEBPACK_SOURCE_MAP = _.get( + process.env, + 'TALK_WEBPACK_SOURCE_MAP', + DEFAULT_WEBPACK_SOURCE_MAP +); + +// Set the devtool based on the source map selection, 'none' just means turn off +// source maps. const devtool = - process.env.NODE_ENV === 'production' - ? process.env.TALK_WEBPACK_SOURCE_MAP - ? process.env.TALK_WEBPACK_SOURCE_MAP === 'none' - ? false - : process.env.TALK_WEBPACK_SOURCE_MAP - : false - : process.env.TALK_WEBPACK_SOURCE_MAP - ? process.env.TALK_WEBPACK_SOURCE_MAP === 'none' - ? false - : process.env.TALK_WEBPACK_SOURCE_MAP - : 'cheap-module-source-map'; + TALK_WEBPACK_SOURCE_MAP === 'none' ? false : TALK_WEBPACK_SOURCE_MAP; //============================================================================== // Base Webpack Config From 4960b34748d2e33f1e67b5d6e41a3ff83acc0f8a Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 17 Jan 2018 14:56:36 -0700 Subject: [PATCH 8/8] fixed deploy script --- scripts/docker.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/docker.sh b/scripts/docker.sh index e1e3f9725..06f0cb279 100755 --- a/scripts/docker.sh +++ b/scripts/docker.sh @@ -68,17 +68,16 @@ then docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS fi - if [ "$CIRCLE_BRANCH" = "master" ] + # deploy based on the env + if [ -n "$CIRCLE_TAG" ] then - - # deploy based on the env - if [ -n "$CIRCLE_TAG" ] - then - deploy_tag - else - deploy_latest - fi + deploy_tag else - deploy_branch + if [ "$CIRCLE_BRANCH" = "master" ] + then + deploy_latest + else + deploy_branch + fi fi fi \ No newline at end of file