diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index d77e6356a..542a767e2 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -193,7 +193,12 @@ export default { }, updateQueries: { CoralEmbedStream_Embed: (prev, {mutationResult: {data: {createComment: {comment}}}}) => { - if (prev.asset.settings.moderation === 'PRE' || comment.status === 'PREMOD' || comment.status === 'REJECTED' || comment.status === 'SYSTEM_WITHHELD') { + if ( + prev.me.roles.indexOf('ADMIN') === -1 && prev.asset.settings.moderation === 'PRE' || + comment.status === 'PREMOD' || + comment.status === 'REJECTED' || + comment.status === 'SYSTEM_WITHHELD' + ) { return prev; } return insertCommentIntoEmbedQuery(prev, comment); diff --git a/client/coral-embed-stream/src/tabs/stream/containers/Stream.js b/client/coral-embed-stream/src/tabs/stream/containers/Stream.js index 1f80fe326..e1a6e14c8 100644 --- a/client/coral-embed-stream/src/tabs/stream/containers/Stream.js +++ b/client/coral-embed-stream/src/tabs/stream/containers/Stream.js @@ -285,6 +285,7 @@ const fragments = { ignoredUsers { id } + roles } settings { organizationName diff --git a/client/coral-framework/hocs/withQuery.js b/client/coral-framework/hocs/withQuery.js index 280191f89..15ec62a47 100644 --- a/client/coral-framework/hocs/withQuery.js +++ b/client/coral-framework/hocs/withQuery.js @@ -49,8 +49,9 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { memoized = null; resolvedDocument = null; lastNetworkStatus = null; - data = null; name = ''; + apolloData = null; + data = null; // Pending subscription data. subscriptionQueue = []; @@ -151,6 +152,7 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { }; nextData(data) { + this.apolloData = data; this.emitWhenNeeded(data); // If data was previously set, we update it in a immutable way. @@ -181,16 +183,24 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { variables: data.variables, networkStatus: data.networkStatus, loading: data.loading, - startPolling: data.startPolling, - stopPolling: data.stopPolling, - refetch: data.refetch, - updateQuery: data.updateQuery, subscribeToMoreThrottled: this.subscribeToMoreThrottled, + startPolling: (...args) => { + return this.apolloData.startPolling(...args); + }, + stopPolling: (...args) => { + return this.apolloData.stopPolling(...args); + }, + updateQuery: (...args) => { + return this.apolloData.updateQuery(...args); + }, + refetch: (...args) => { + return this.apolloData.refetch(...args); + }, subscribeToMore: (stmArgs) => { const resolvedDocument = this.resolveDocument(stmArgs.document); // Resolve document fragments before passing it to `apollo-client`. - return data.subscribeToMore({ + return this.apolloData.subscribeToMore({ ...stmArgs, document: resolvedDocument, onError: (err) => { @@ -209,7 +219,7 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { {variables: lmArgs.variables}); // Resolve document fragments before passing it to `apollo-client`. - return data.fetchMore({ + return this.apolloData.fetchMore({ ...lmArgs, query: resolvedDocument, }) diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index 1ad8b98c9..5b4f5f0ed 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -61,7 +61,7 @@ class ProfileContainer extends Component { return ; } - if (loading) { + if (loading || !me) { return ; } diff --git a/locales/da.yml b/locales/da.yml index 0a5152cd9..d4544043c 100644 --- a/locales/da.yml +++ b/locales/da.yml @@ -285,7 +285,7 @@ da: no_like_bio: "Jeg kan ikke lide denne biografi" no_like_username: "Jeg kan ikke lide dette brugernavn" other: "Andet" - permalink: "Link" + permalink: "Delen" personal_info: "Denne kommentar afslører personligt identificerbare oplysninger" post: "Post" profile: "Profil" diff --git a/locales/en.yml b/locales/en.yml index 9961cfe64..9257ecdcf 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -302,7 +302,7 @@ en: no_like_bio: "I don't like this bio" no_like_username: "I don't like this username" other: Other - permalink: Link + permalink: Share personal_info: "This comment reveals personally identifiable information" post: Post profile: Profile diff --git a/locales/es.yml b/locales/es.yml index 9441253c7..74dc325d8 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -283,7 +283,7 @@ es: no_like_bio: "No me gusta esta biografia" no_like_username: "No me gusta este nombre de usuario" other: Otro - permalink: Enlace + permalink: Compartir personal_info: "Este comentario muestra información personal" post: Publicar profile: Perfil diff --git a/locales/fr.yml b/locales/fr.yml index 31ad3ca91..e9f291b65 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -237,7 +237,7 @@ fr: no_like_bio: "Je n'aime pas cette biographie" no_like_username: "Je n'aime pas ce nom d'utilisateur" other: Autre - permalink: Lien + permalink: Partager personal_info: "Ce commentaire révèle des informations personnelles identifiables" post: Publier profile: Profil diff --git a/locales/pt_BR.yml b/locales/pt_BR.yml index bdfe72d5a..7ed111287 100644 --- a/locales/pt_BR.yml +++ b/locales/pt_BR.yml @@ -288,7 +288,7 @@ pt_BR: no_like_bio: "Eu não gosto dessa descrição de perfil" no_like_username: "Eu não gosto deste nome de usuário" other: Outro - permalink: Link + permalink: Compartilhar personal_info: "Este comentário revela informações de identificação pessoal" post: Publicar profile: Perfil diff --git a/plugin-api/beta/client/hocs/withTags.js b/plugin-api/beta/client/hocs/withTags.js index 66fd7ad2e..3edc66824 100644 --- a/plugin-api/beta/client/hocs/withTags.js +++ b/plugin-api/beta/client/hocs/withTags.js @@ -87,11 +87,12 @@ export default (tag, options = {}) => hoistStatics((WrappedComponent) => { } render() { - const {root, asset, comment, user, config} = this.props; + const {root, asset, comment, user, config, ...rest} = this.props; const alreadyTagged = isTagged(comment.tags, TAG); return hoistStatics((WrappedComponent) => { ${fragments.comment ? fragments.comment : ''} ` }), - connect(mapStateToProps, mapDispatchToProps), withAddTag, - withRemoveTag + withRemoveTag, + connect(mapStateToProps, mapDispatchToProps), ); WithTags.displayName = `WithTags(${getDisplayName(WrappedComponent)})`; diff --git a/plugins/talk-plugin-featured-comments/client/actions.js b/plugins/talk-plugin-featured-comments/client/actions.js new file mode 100644 index 000000000..e16f06f48 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/actions.js @@ -0,0 +1,16 @@ +import {OPEN_FEATURED_DIALOG, CLOSE_FEATURED_DIALOG} from './constants'; + +export const openFeaturedDialog = (comment, asset) => ({ + type: OPEN_FEATURED_DIALOG, + comment: { + id: comment.id, + tags: comment.tags, + }, + asset: { + id: asset.id, + }, +}); + +export const closeFeaturedDialog = () => ({ + type: CLOSE_FEATURED_DIALOG, +}); diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css new file mode 100644 index 000000000..4326d5c5c --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css @@ -0,0 +1,41 @@ +.dialog { + border: none; + box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2); + width: 400px; + top: 50%; + transform: translateY(-50%); + padding: 20px; + border-radius: 4px; +} + +.header { + color: black; + font-size: 1.5em; + font-weight: 500; + margin: 0 0 8px 0; +} + +.close { + display: block; + position: absolute; + top: 24px; + right: 20px; +} + +.cancel { + margin-right: 5px; +} + +.perform { + min-width: 90px; +} + +.buttons { + margin-top: 8px; + margin-bottom: 6px; + text-align: right; +} + +.content { + margin-bottom: 20px; +} diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js new file mode 100644 index 000000000..81c054ae8 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js @@ -0,0 +1,52 @@ +import React from 'react'; +import cn from 'classnames'; +import PropTypes from 'prop-types'; +import {Dialog} from 'coral-ui'; +import styles from './FeaturedDialog.css'; +import {t} from 'plugin-api/beta/client/services'; +import Button from 'coral-ui/components/Button'; + +const FeaturedDialog = ({showFeaturedDialog, closeFeaturedDialog, postTag}) => { + + const onPerform = async () => { + await postTag(); + await closeFeaturedDialog(); + }; + + return ( + + × +

{t('talk-plugin-featured-comments.feature_comment')}

+
+ {t('talk-plugin-featured-comments.are_you_sure')} +
+
+ + +
+
+ ); +}; + +FeaturedDialog.propTypes = { + showFeaturedDialog: PropTypes.bool.isRequired, + closeFeaturedDialog: PropTypes.func.isRequired, +}; + +export default FeaturedDialog; diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index 0664f07cd..70f51dcbc 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -1,9 +1,9 @@ import React from 'react'; +import PropTypes from 'prop-types'; import cn from 'classnames'; import styles from './ModTag.css'; import {t} from 'plugin-api/beta/client/services'; import {Icon} from 'plugin-api/beta/client/components/ui'; -import {getErrorMessages} from 'plugin-api/beta/client/utils'; export default class ModTag extends React.Component { constructor() { @@ -29,17 +29,12 @@ export default class ModTag extends React.Component { }); } - postTag = async () => { - try { - await this.props.postTag(); - } - catch(err) { - this.props.notify('error', getErrorMessages(err)); - } + openFeaturedDialog = (comment, asset) => { + this.props.openFeaturedDialog(comment, asset); } render() { - const {alreadyTagged, deleteTag} = this.props; + const {alreadyTagged, deleteTag, comment, asset} = this.props; return alreadyTagged ? ( ) : ( + onClick={() => this.openFeaturedDialog(comment, asset)} > {alreadyTagged ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.feature')} ); } } + +ModTag.propTypes = { + alreadyTagged: PropTypes.bool, + deleteTag: PropTypes.func, + notify: PropTypes.func, + openFeaturedDialog: PropTypes.func, + comment: PropTypes.object, + asset: PropTypes.object, +}; diff --git a/plugins/talk-plugin-featured-comments/client/constants.js b/plugins/talk-plugin-featured-comments/client/constants.js new file mode 100644 index 000000000..912f6f002 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/constants.js @@ -0,0 +1,4 @@ +const prefix = 'TALK_FEATURED_COMMENTS_ACTIONS'; + +export const OPEN_FEATURED_DIALOG = `${prefix}_OPEN_FEATURED_DIALOG`; +export const CLOSE_FEATURED_DIALOG = `${prefix}_CLOSE_FEATURED_DIALOG`; diff --git a/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js new file mode 100644 index 000000000..0440e9d08 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js @@ -0,0 +1,23 @@ +import {compose} from 'react-apollo'; +import {bindActionCreators} from 'redux'; +import FeaturedDialog from '../components/FeaturedDialog'; +import {withTags, connect} from 'plugin-api/beta/client/hocs'; +import {closeFeaturedDialog} from '../actions'; + +const mapStateToProps = ({talkPluginFeaturedComments: state}) => ({ + showFeaturedDialog: state.showFeaturedDialog, + comment: state.comment, + asset: state.asset, +}); + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ + closeFeaturedDialog, + }, dispatch); + +const enhance = compose( + connect(mapStateToProps, mapDispatchToProps), + withTags('featured'), +); + +export default enhance(FeaturedDialog); diff --git a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js index 88aee73f6..35e7edfcd 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js @@ -2,11 +2,13 @@ import ModTag from '../components/ModTag'; import {withTags, connect} from 'plugin-api/beta/client/hocs'; import {gql, compose} from 'react-apollo'; import {bindActionCreators} from 'redux'; +import {openFeaturedDialog} from '../actions'; import {notify} from 'plugin-api/beta/client/actions/notification'; const mapDispatchToProps = (dispatch) => bindActionCreators({ notify, + openFeaturedDialog, }, dispatch); const fragments = { @@ -24,4 +26,3 @@ const enhance = compose( ); export default enhance(ModTag); - diff --git a/plugins/talk-plugin-featured-comments/client/index.js b/plugins/talk-plugin-featured-comments/client/index.js index 7a0b9827d..304bff647 100644 --- a/plugins/talk-plugin-featured-comments/client/index.js +++ b/plugins/talk-plugin-featured-comments/client/index.js @@ -6,19 +6,22 @@ import update from 'immutability-helper'; import ModTag from './containers/ModTag'; import ModActionButton from './containers/ModActionButton'; import ModSubscription from './containers/ModSubscription'; +import FeaturedDialog from './containers/FeaturedDialog'; import {gql} from 'react-apollo'; +import reducer from './reducer'; import {findCommentInEmbedQuery} from 'coral-embed-stream/src/graphql/utils'; import {prependNewNodes} from 'plugin-api/beta/client/utils'; export default { translations, + reducer, slots: { streamTabsPrepend: [Tab], streamTabPanes: [TabPane], commentInfoBar: [Tag], moderationActions: [ModActionButton], - adminModeration: [ModSubscription], + adminModeration: [ModSubscription, FeaturedDialog], adminCommentInfoBar: [ModTag], }, mutations: { diff --git a/plugins/talk-plugin-featured-comments/client/reducer.js b/plugins/talk-plugin-featured-comments/client/reducer.js new file mode 100644 index 000000000..eb6d302ff --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/reducer.js @@ -0,0 +1,32 @@ +import {OPEN_FEATURED_DIALOG, CLOSE_FEATURED_DIALOG} from './constants'; + +const initialState = { + showFeaturedDialog: false, + comment: { + id: null, + tags: [] + }, + asset: { + id: null, + }, +}; + +export default function reducer(state = initialState, action) { + switch (action.type) { + case OPEN_FEATURED_DIALOG: + return { + ...state, + comment: action.comment, + asset: action.asset, + showFeaturedDialog: true, + }; + case CLOSE_FEATURED_DIALOG: + return { + ...state, + featuredCommentId: null, + showFeaturedDialog: false, + }; + default : + return state; + } +} diff --git a/plugins/talk-plugin-featured-comments/client/translations.yml b/plugins/talk-plugin-featured-comments/client/translations.yml index ea504cc9e..460a76be9 100644 --- a/plugins/talk-plugin-featured-comments/client/translations.yml +++ b/plugins/talk-plugin-featured-comments/client/translations.yml @@ -9,6 +9,10 @@ en: notify_self_featured: 'The comment from {0} is now featured and approved' notify_featured: '{0} featured and approved comment "{1}"' notify_unfeatured: '{0} unfeatured comment "{1}"' + feature_comment: Feature comment? + are_you_sure: Are you sure you would like to feature this comment? + cancel: Cancel + yes_feature_comment: Yes, feature comment es: talk-plugin-featured-comments: un_feature: Desmarcar @@ -17,3 +21,7 @@ es: featured_comments: Comentarios Remarcados go_to_conversation: Ir al comentario tooltip_description: Comentarios seleccionados por nuestro equipo que valen la pena ser leidos + feature_comment: Destacar comentario? + are_you_sure: Está seguro que desea destacar este comentario? + cancel: Cancelar + yes_feature_comment: Si, destacar comentario \ No newline at end of file diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index 3e9726340..b86edb319 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -8,7 +8,10 @@ E2E_MAX_RETRIES=${E2E_MAX_RETRIES:-1} # Safari >= 8 has issues connecting to browserstack-local. Safari < 8 is too old. # IE 64bit has issues with receiving keyboard input. Let's wait for them to fix it. -BROWSERS="chrome,firefox,edge" #ie safari + +# FIXME: disabled firefox,edge until fixing pass is done +# BROWSERS="chrome,firefox,edge" #ie safari +BROWSERS="chrome" if [[ "${CIRCLE_BRANCH}" == "master" && -n "$BROWSERSTACK_KEY" ]]; then echo Testing on browserstack