From 36d535546c2240f24463d783ab8c05dc4632710a Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 14 Dec 2017 15:03:35 -0600 Subject: [PATCH 01/20] plugins serverside can now provide translations --- services/i18n.js | 81 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/services/i18n.js b/services/i18n.js index 4c65ed1d4..9d74ec0e4 100644 --- a/services/i18n.js +++ b/services/i18n.js @@ -1,22 +1,56 @@ -const has = require('lodash/has'); -const get = require('lodash/get'); - -const yaml = require('yamljs'); - -const da = yaml.load('./locales/da.yml'); -const es = yaml.load('./locales/es.yml'); -const en = yaml.load('./locales/en.yml'); -const fr = yaml.load('./locales/fr.yml'); -const pt_BR = yaml.load('./locales/pt_BR.yml'); - +const fs = require('fs'); +const path = require('path'); +const debug = require('debug')('talk:services:i18n'); const accepts = require('accepts'); +const _ = require('lodash'); +const yaml = require('yamljs'); +const plugins = require('./plugins'); -// default language -let defaultLanguage = 'en'; +const resolve = (...paths) => path.resolve(path.join(__dirname, '..', 'locales', ...paths)); + +// Load all the translations. +let translations = fs.readdirSync(resolve()) + + // Resolve all the filenames relative the the locales directory. + .map((filename) => resolve(filename)) + + // Translations are only yml/yaml files. + .filter((filename) => /\.(yaml|yml)$/.test(filename)) + + // Load the translation files from disk. + .map((filename) => fs.readFileSync(filename, 'utf8')) + + // Load the translation files. + .reduce((packs, contents) => { + + const pack = yaml.parse(contents); + + return _.merge(packs, pack); + }, {}); + +// Create a list of all supported translations. +const languages = Object.keys(translations); + +let defaultLanguage = process.env.TALK_DEFAULT_LANG || 'en'; let language = defaultLanguage; -const languages = ['en', 'da', 'es', 'fr', 'pt_BR']; -const translations = Object.assign(en, es, fr, pt_BR, da); +let loadedPluginTranslations = false; +const loadPluginTranslations = () => { + if (loadedPluginTranslations) { + return; + } + + // Load the plugin translations. + plugins.forEach('server', 'translations').forEach(({plugin, translations: filename}) => { + debug(`added plugin '${plugin.name}'`); + + const pack = yaml.parse(fs.readFileSync(filename, 'utf8')); + + translations = _.merge(translations, pack); + }); + + loadedPluginTranslations = true; +}; /** * Exposes a service object to allow translations. @@ -28,6 +62,11 @@ const i18n = { * Create the new Task kue. */ init(req) { + + // Loads the translations into the translations array from plugins. This is + // done lazily to ensure that we don't have an import cycle. + loadPluginTranslations(); + const lang = accepts(req).language(languages); language = lang ? lang : defaultLanguage; }, @@ -37,13 +76,15 @@ const i18n = { */ t(key, ...replacements) { - if (has(translations[language], key)) { + // Check if the translation exists on the object. + if (_.has(translations[language], key)) { - let translation = get(translations[language], key); + // Get the translation value. + let translation = _.get(translations[language], key); - // replace any {n} with the arguments passed to this method - replacements.forEach((str, i) => { - translation = translation.replace(new RegExp(`\\{${i}\\}`, 'g'), str); + // Replace any {n} with the arguments passed to this method. + replacements.forEach((str, n) => { + translation = translation.replace(new RegExp(`\\{${n}\\}`, 'g'), str); }); return translation; From d3965924aa8b32dbea1aeff8ffd6eae145ea0b3b Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 14 Dec 2017 15:51:53 -0600 Subject: [PATCH 02/20] fixed template --- services/email/email-confirm.html.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/email/email-confirm.html.ejs b/services/email/email-confirm.html.ejs index 8a1bd05f7..76a8ea47b 100644 --- a/services/email/email-confirm.html.ejs +++ b/services/email/email-confirm.html.ejs @@ -1,3 +1,3 @@

<%= t('email.confirm.has_been_requested') %> <%= email %>.

-

<%= t('email.confirm.to_confirm') %> Confirm Email

+

<%= t('email.confirm.to_confirm') %> <%= t('email.confirm.confirm_email') %>

<%= t('email.confirm.if_you_did_not') %>

From d9654b52cf89f9f7e24384538522b5eb4418ca51 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 14 Dec 2017 16:09:41 -0600 Subject: [PATCH 03/20] some fixes --- services/i18n.js | 11 +++++------ services/mailer.js | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/services/i18n.js b/services/i18n.js index 9d74ec0e4..338f6680a 100644 --- a/services/i18n.js +++ b/services/i18n.js @@ -41,7 +41,7 @@ const loadPluginTranslations = () => { } // Load the plugin translations. - plugins.forEach('server', 'translations').forEach(({plugin, translations: filename}) => { + plugins.get('server', 'translations').forEach(({plugin, translations: filename}) => { debug(`added plugin '${plugin.name}'`); const pack = yaml.parse(fs.readFileSync(filename, 'utf8')); @@ -62,11 +62,6 @@ const i18n = { * Create the new Task kue. */ init(req) { - - // Loads the translations into the translations array from plugins. This is - // done lazily to ensure that we don't have an import cycle. - loadPluginTranslations(); - const lang = accepts(req).language(languages); language = lang ? lang : defaultLanguage; }, @@ -76,6 +71,10 @@ const i18n = { */ t(key, ...replacements) { + // Loads the translations into the translations array from plugins. This is + // done lazily to ensure that we don't have an import cycle. + loadPluginTranslations(); + // Check if the translation exists on the object. if (_.has(translations[language], key)) { diff --git a/services/mailer.js b/services/mailer.js index a4f694b30..0a085ea4a 100644 --- a/services/mailer.js +++ b/services/mailer.js @@ -99,8 +99,8 @@ const mailer = module.exports = { attachLocals(locals); - // Attach the templating function. - locals['t'] = i18n.t; + // Attach the translation function. + locals.t = i18n.t; return Promise.all([ @@ -112,7 +112,7 @@ const mailer = module.exports = { ]) .then(([html, text]) => { - // Create the job. + // Create the job. return mailer.task.create({ title: 'Mail', message: { From d207b240f2ddd7fc27438a495020ba18890d6b42 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 14 Dec 2017 16:28:08 -0600 Subject: [PATCH 04/20] added support for changing the subject prefi --- config.js | 3 +++ docs/_docs/02-02-advanced-configuration.md | 8 +++++++- services/mailer.js | 5 +++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config.js b/config.js index 76d488a0d..e14997be9 100644 --- a/config.js +++ b/config.js @@ -20,6 +20,9 @@ const CONFIG = { // WEBPACK indicates when webpack is currently building. WEBPACK: process.env.WEBPACK === 'TRUE', + // EMAIL_SUBJECT_PREFIX is the string before emails in the subject. + EMAIL_SUBJECT_PREFIX: process.env.TALK_EMAIL_SUBJECT_PREFIX || '[Talk]', + // When TRUE, it ensures that database indexes created in core will not add // indexes. CREATE_MONGO_INDEXES: process.env.DISABLE_CREATE_MONGO_INDEXES !== 'TRUE', diff --git a/docs/_docs/02-02-advanced-configuration.md b/docs/_docs/02-02-advanced-configuration.md index 94a6b402d..47be44fcc 100644 --- a/docs/_docs/02-02-advanced-configuration.md +++ b/docs/_docs/02-02-advanced-configuration.md @@ -460,4 +460,10 @@ Could be read as: ## TALK_DISABLE_IGNORE_FLAGS_AGAINST_STAFF When `TRUE`, staff members will have their accounts and comments moderated the -same as any other user in the system. (Default `FALSE`) \ No newline at end of file +same as any other user in the system. (Default `FALSE`) + +## TALK_EMAIL_SUBJECT_PREFIX + +The prefix for the subject of emails sent. An email with the specified subject +of `Email Confirmation` would then be sent as `[Talk] Email Confirmation`. +(Default `[Talk]`) \ No newline at end of file diff --git a/services/mailer.js b/services/mailer.js index 0a085ea4a..4433b9ef5 100644 --- a/services/mailer.js +++ b/services/mailer.js @@ -13,7 +13,8 @@ const { SMTP_USERNAME, SMTP_PORT, SMTP_PASSWORD, - SMTP_FROM_ADDRESS + SMTP_FROM_ADDRESS, + EMAIL_SUBJECT_PREFIX, } = require('../config'); // load all the templates as strings @@ -95,7 +96,7 @@ const mailer = module.exports = { } // Prefix the subject with `[Talk]`. - subject = `[Talk] ${subject}`; + subject = `${EMAIL_SUBJECT_PREFIX} ${subject}`; attachLocals(locals); From eb9827a3aec8a9a4904eb106b92ca8f669ed1ba4 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 14 Dec 2017 16:48:03 -0600 Subject: [PATCH 05/20] more fixes for i18n --- config.js | 4 +++ middleware/i18n.js | 6 +++++ routes/index.js | 13 ++++----- services/i18n.js | 66 +++++++++++++++++++++------------------------- 4 files changed, 47 insertions(+), 42 deletions(-) create mode 100644 middleware/i18n.js diff --git a/config.js b/config.js index e14997be9..d3a6344cc 100644 --- a/config.js +++ b/config.js @@ -23,6 +23,10 @@ const CONFIG = { // EMAIL_SUBJECT_PREFIX is the string before emails in the subject. EMAIL_SUBJECT_PREFIX: process.env.TALK_EMAIL_SUBJECT_PREFIX || '[Talk]', + // DEFAULT_LANG is the default language used for server sent emails and + // rendered text. + DEFAULT_LANG: process.env.TALK_DEFAULT_LANG || 'en', + // When TRUE, it ensures that database indexes created in core will not add // indexes. CREATE_MONGO_INDEXES: process.env.DISABLE_CREATE_MONGO_INDEXES !== 'TRUE', diff --git a/middleware/i18n.js b/middleware/i18n.js new file mode 100644 index 000000000..c2ca2436a --- /dev/null +++ b/middleware/i18n.js @@ -0,0 +1,6 @@ +const i18n = require('../services/i18n'); + +module.exports = (req, res, next) => { + res.locals.t = i18n.request(req); + next(); +}; diff --git a/routes/index.js b/routes/index.js index 0ee012a79..a769d6b6f 100644 --- a/routes/index.js +++ b/routes/index.js @@ -7,7 +7,7 @@ const debug = require('debug')('talk:routes'); const enabled = require('debug').enabled; const errors = require('../errors'); const express = require('express'); -const i18n = require('../services/i18n'); +const i18n = require('../middleware/i18n'); const path = require('path'); const plugins = require('../services/plugins'); const pubsub = require('../middleware/pubsub'); @@ -64,6 +64,9 @@ if (!DISABLE_STATIC_SERVER) { router.get('/embed.js.map', serveFile('../dist/embed.js.map')); } +// Add the i18n middleware to all routes. +router.use(i18n); + //============================================================================== // STATIC ROUTES //============================================================================== @@ -116,19 +119,19 @@ if (process.env.NODE_ENV !== 'production') { }); }); - // GraphQL documention. + // GraphQL documentation. router.get('/admin/docs', (req, res) => { res.render('admin/docs'); }); } +router.use('/api/v1', require('./api')); + //============================================================================== // ROUTES //============================================================================== -router.use('/api/v1', require('./api')); - // Development routes. if (process.env.NODE_ENV !== 'production') { router.use('/assets', staticTemplate, require('./assets')); @@ -184,8 +187,6 @@ router.use('/', (err, req, res, next) => { console.error(err); } - i18n.init(req); - if (err instanceof errors.APIError) { res.status(err.status); res.render('error', { diff --git a/services/i18n.js b/services/i18n.js index 338f6680a..cd1bacd93 100644 --- a/services/i18n.js +++ b/services/i18n.js @@ -5,6 +5,7 @@ const accepts = require('accepts'); const _ = require('lodash'); const yaml = require('yamljs'); const plugins = require('./plugins'); +const {DEFAULT_LANG} = require('../config'); const resolve = (...paths) => path.resolve(path.join(__dirname, '..', 'locales', ...paths)); @@ -31,9 +32,6 @@ let translations = fs.readdirSync(resolve()) // Create a list of all supported translations. const languages = Object.keys(translations); -let defaultLanguage = process.env.TALK_DEFAULT_LANG || 'en'; -let language = defaultLanguage; - let loadedPluginTranslations = false; const loadPluginTranslations = () => { if (loadedPluginTranslations) { @@ -52,46 +50,42 @@ const loadPluginTranslations = () => { loadedPluginTranslations = true; }; +const t = (language) => (key, ...replacements) => { + + // Loads the translations into the translations array from plugins. This is + // done lazily to ensure that we don't have an import cycle. + loadPluginTranslations(); + + // Check if the translation exists on the object. + if (_.has(translations[language], key)) { + + // Get the translation value. + let translation = _.get(translations[language], key); + + // Replace any {n} with the arguments passed to this method. + replacements.forEach((str, n) => { + translation = translation.replace(new RegExp(`\\{${n}\\}`, 'g'), str); + }); + + return translation; + } else { + console.warn(`${key} language key not set`); + return key; + } +}; + /** * Exposes a service object to allow translations. * @type {Object} */ const i18n = { - - /** - * Create the new Task kue. - */ - init(req) { + request(req) { const lang = accepts(req).language(languages); - language = lang ? lang : defaultLanguage; - }, - - /** - * Translates a key. - */ - t(key, ...replacements) { - - // Loads the translations into the translations array from plugins. This is - // done lazily to ensure that we don't have an import cycle. - loadPluginTranslations(); - - // Check if the translation exists on the object. - if (_.has(translations[language], key)) { - - // Get the translation value. - let translation = _.get(translations[language], key); - - // Replace any {n} with the arguments passed to this method. - replacements.forEach((str, n) => { - translation = translation.replace(new RegExp(`\\{${n}\\}`, 'g'), str); - }); - - return translation; - } else { - console.warn(`${key} language key not set`); - return key; - } + const language = lang ? lang : DEFAULT_LANG; + + return t(language); }, + t: t(DEFAULT_LANG), }; module.exports = i18n; From fdd5cbb0d759528ed9a627d77dc870403468cfdf Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 14 Dec 2017 16:56:24 -0600 Subject: [PATCH 06/20] moved email contents to translation files --- locales/en.yml | 5 +++++ services/users.js | 39 ++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index f1d566475..9961cfe64 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -166,6 +166,11 @@ en: minute: "minute" minutes_plural: "minutes" email: + suspended: + subject: "Your account has been suspended" + banned: + subject: "Your account has been banned" + body: "In accordance with The Coral Project’s community guidelines, your account has been banned. You are now longer allowed to comment, flag or engage with our community." confirm: has_been_requested: "A email confirmation has been requested for the following account:" to_confirm: "To confirm the account, please visit the following link:" diff --git a/services/users.js b/services/users.js index fbaf89609..ef3cf7a34 100644 --- a/services/users.js +++ b/services/users.js @@ -24,6 +24,7 @@ const RECAPTCHA_INCORRECT_TRIGGER = 5; // after 3 incorrect attempts, recaptcha const ActionsService = require('./actions'); const MailerService = require('./mailer'); const Wordlist = require('./wordlist'); +const i18n = require('./i18n'); const Domainlist = require('./domainlist'); const {escapeRegExp} = require('./regex'); @@ -430,16 +431,14 @@ module.exports = class UsersService { if (status === 'BANNED') { let localProfile = user.profiles.find((profile) => profile.provider === 'local'); if (localProfile) { - const options = - { - template: 'banned', // needed to know which template to render! - locals: { // specifies the template locals. - body: 'In accordance with The Coral Project’s community guidelines, your account has been banned. You are now longer allowed to comment, flag or engage with our community.' - }, - subject: 'Your account has been banned', - to: localProfile.id // This only works if the user has registered via e-mail. - // We may want a standard way to access a user's e-mail address in the future - }; + const options = { + template: 'banned', + locals: { + body: i18n.t('email.banned.body'), + }, + subject: i18n.t('email.banned.subject'), + to: localProfile.id + }; await MailerService.sendSimple(options); } } @@ -467,16 +466,14 @@ module.exports = class UsersService { if (message) { let localProfile = user.profiles.find((profile) => profile.provider === 'local'); if (localProfile) { - const options = - { - template: 'suspension', // needed to know which template to render! - locals: { // specifies the template locals. - body: message - }, - subject: 'Your account has been suspended', - to: localProfile.id // This only works if the user has registered via e-mail. - // We may want a standard way to access a user's e-mail address in the future - }; + const options = { + template: 'suspension', + locals: { + body: message + }, + subject: i18n.t('email.suspended.subject'), + to: localProfile.id, + }; await MailerService.sendSimple(options); } @@ -509,7 +506,7 @@ module.exports = class UsersService { locals: { // specifies the template locals. body: message }, - subject: 'Email Suspension', + subject: i18n.t('email.suspended.subject'), to: localProfile.id // This only works if the user has registered via e-mail. // We may want a standard way to access a user's e-mail address in the future }; From d7a5e613fad3b5cfaba883018225b151ee8a2096 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 12:19:46 -0300 Subject: [PATCH 07/20] Adding reducer --- .../client/reducer.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/talk-plugin-featured-comments/client/reducer.js 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..3840155b3 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/reducer.js @@ -0,0 +1,22 @@ +import {OPEN_FEATURED_DIALOG, CLOSE_FEATURED_DIALOG} from './constants'; + +const initialState = { + showFeaturedDialog: false, +}; + +export default function reducer(state = initialState, action) { + switch (action.type) { + case OPEN_FEATURED_DIALOG: + return { + ...state, + showFeaturedDialog: true, + }; + case CLOSE_FEATURED_DIALOG: + return { + ...state, + showFeaturedDialog: false, + }; + default : + return state; + } +} From 5a1393c0396b689721da05c9d6e536774938ebb2 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 12:20:06 -0300 Subject: [PATCH 08/20] Adding translations --- .../talk-plugin-featured-comments/client/translations.yml | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 02da749c656df814819dfadbd744204881481d90 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 12:20:20 -0300 Subject: [PATCH 09/20] Adding containers and components --- .../components/FeaturedConfirmation.css | 38 ++++++++++++++ .../client/components/FeaturedConfirmation.js | 50 +++++++++++++++++++ .../client/containers/FeaturedConfirmation.js | 17 +++++++ .../client/index.js | 3 +- 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.css create mode 100644 plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js create mode 100644 plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.css b/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.css new file mode 100644 index 000000000..9a8b93eec --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.css @@ -0,0 +1,38 @@ +.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; +} diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js b/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js new file mode 100644 index 000000000..5acd29183 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js @@ -0,0 +1,50 @@ +import React from 'react'; +import cn from 'classnames'; +import PropTypes from 'prop-types'; +import {Dialog} from 'coral-ui'; +import styles from './FeaturedConfirmation.css'; + +import Button from 'coral-ui/components/Button'; +import t from 'coral-framework/services/i18n'; + +const FeaturedConfirmation = ({open, onCancel, onPerform}) => ( + + × +
+

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

+
+
+

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

+
+
+ + +
+
+); + +FeaturedConfirmation.propTypes = { + open: PropTypes.bool, + onPerform: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired, +}; + +export default FeaturedConfirmation; diff --git a/plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js b/plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js new file mode 100644 index 000000000..f12ba76cf --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js @@ -0,0 +1,17 @@ +import {compose} from 'react-apollo'; +import {bindActionCreators} from 'redux'; +import FeaturedConfirmation from '../components/FeaturedConfirmation'; +import {withTags, connect} from 'plugin-api/beta/client/hocs'; +import {closeMenu} from 'plugins/talk-plugin-moderation-actions/client/actions'; + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ + closeMenu, + }, dispatch); + +const enhance = compose( + withTags('featured'), + connect(null, mapDispatchToProps), +); + +export default enhance(FeaturedConfirmation); diff --git a/plugins/talk-plugin-featured-comments/client/index.js b/plugins/talk-plugin-featured-comments/client/index.js index 7a0b9827d..21d61d21a 100644 --- a/plugins/talk-plugin-featured-comments/client/index.js +++ b/plugins/talk-plugin-featured-comments/client/index.js @@ -6,6 +6,7 @@ import update from 'immutability-helper'; import ModTag from './containers/ModTag'; import ModActionButton from './containers/ModActionButton'; import ModSubscription from './containers/ModSubscription'; +import FeaturedConfirmation from './containers/FeaturedConfirmation'; import {gql} from 'react-apollo'; import {findCommentInEmbedQuery} from 'coral-embed-stream/src/graphql/utils'; @@ -18,7 +19,7 @@ export default { streamTabPanes: [TabPane], commentInfoBar: [Tag], moderationActions: [ModActionButton], - adminModeration: [ModSubscription], + adminModeration: [ModSubscription, FeaturedConfirmation], adminCommentInfoBar: [ModTag], }, mutations: { From 5b8f335b2aa8aa77b9ff9682568929e522cd9e97 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 18 Dec 2017 16:41:05 +0100 Subject: [PATCH 10/20] Fix new admin comments not showing up in premod --- client/coral-embed-stream/src/graphql/index.js | 7 ++++++- .../src/tabs/stream/containers/Stream.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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 e132ab954..bdd63b821 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 From 4d6f38a3d9d6af4354d0985cca09571628fb3430 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 12:43:46 -0300 Subject: [PATCH 11/20] wip --- .../client/actions.js | 9 +++++ ...redConfirmation.css => FeaturedDialog.css} | 0 ...turedConfirmation.js => FeaturedDialog.js} | 11 +++-- .../client/components/ModTag.js | 19 +++++---- .../client/constants.js | 4 ++ .../client/containers/FeaturedConfirmation.js | 17 -------- .../client/containers/FeaturedDialog.js | 40 +++++++++++++++++++ .../client/containers/ModTag.js | 3 +- 8 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 plugins/talk-plugin-featured-comments/client/actions.js rename plugins/talk-plugin-featured-comments/client/components/{FeaturedConfirmation.css => FeaturedDialog.css} (100%) rename plugins/talk-plugin-featured-comments/client/components/{FeaturedConfirmation.js => FeaturedDialog.js} (84%) create mode 100644 plugins/talk-plugin-featured-comments/client/constants.js delete mode 100644 plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js create mode 100644 plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js 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..c5c81baa8 --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/actions.js @@ -0,0 +1,9 @@ +import {OPEN_FEATURED_DIALOG, CLOSE_FEATURED_DIALOG} from './constants'; + +export const openFeaturedDialog = () => ({ + type: OPEN_FEATURED_DIALOG +}); + +export const closeFeaturedDialog = () => ({ + type: CLOSE_FEATURED_DIALOG, +}); diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.css b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css similarity index 100% rename from plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.css rename to plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js similarity index 84% rename from plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js rename to plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js index 5acd29183..3408e0d6e 100644 --- a/plugins/talk-plugin-featured-comments/client/components/FeaturedConfirmation.js +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js @@ -2,12 +2,11 @@ import React from 'react'; import cn from 'classnames'; import PropTypes from 'prop-types'; import {Dialog} from 'coral-ui'; -import styles from './FeaturedConfirmation.css'; - +import styles from './FeaturedDialog.css'; +import {t} from 'plugin-api/beta/client/services'; import Button from 'coral-ui/components/Button'; -import t from 'coral-framework/services/i18n'; -const FeaturedConfirmation = ({open, onCancel, onPerform}) => ( +const FeaturedDialog = ({open, onCancel, onPerform}) => ( ( ); -FeaturedConfirmation.propTypes = { +FeaturedDialog.propTypes = { open: PropTypes.bool, onPerform: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired, }; -export default FeaturedConfirmation; +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..c66b688ab 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -1,4 +1,5 @@ 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'; @@ -29,15 +30,6 @@ export default class ModTag extends React.Component { }); } - postTag = async () => { - try { - await this.props.postTag(); - } - catch(err) { - this.props.notify('error', getErrorMessages(err)); - } - } - render() { const {alreadyTagged, deleteTag} = this.props; @@ -51,10 +43,17 @@ export default class ModTag extends React.Component { ) : ( + onClick={this.props.openFeaturedDialog} > {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, +}; 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/FeaturedConfirmation.js b/plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js deleted file mode 100644 index f12ba76cf..000000000 --- a/plugins/talk-plugin-featured-comments/client/containers/FeaturedConfirmation.js +++ /dev/null @@ -1,17 +0,0 @@ -import {compose} from 'react-apollo'; -import {bindActionCreators} from 'redux'; -import FeaturedConfirmation from '../components/FeaturedConfirmation'; -import {withTags, connect} from 'plugin-api/beta/client/hocs'; -import {closeMenu} from 'plugins/talk-plugin-moderation-actions/client/actions'; - -const mapDispatchToProps = (dispatch) => - bindActionCreators({ - closeMenu, - }, dispatch); - -const enhance = compose( - withTags('featured'), - connect(null, mapDispatchToProps), -); - -export default enhance(FeaturedConfirmation); 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..b5d6ddd2d --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js @@ -0,0 +1,40 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +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'; + +class FeaturedDialogContainer extends React.Component { + render() { + const {showFeaturedDialog, closeFeaturedDialog, postTag} = this.props; + return ; + } +} + +FeaturedDialogContainer.propTypes = { + showFeaturedDialog: PropTypes.func, + closeFeaturedDialog: PropTypes.func, + postTag: PropTypes.func, +}; + +const mapStateToProps = ({talkPluginFeaturedComments: state}) => ({ + showFeaturedDialog: state.showFeaturedDialog, +}); + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ + closeFeaturedDialog, + }, dispatch); + +const enhance = compose( + withTags('featured'), + connect(mapStateToProps, mapDispatchToProps), +); + +export default enhance(FeaturedDialogContainer); 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); - From 338c23dc3dda86cf4fa4b84cda9fe6c411a5778b Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 12:46:24 -0300 Subject: [PATCH 12/20] unnecesary class --- .../client/components/FeaturedDialog.js | 18 ++++++++-------- .../client/containers/FeaturedDialog.js | 21 +------------------ 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js index 3408e0d6e..cad872e12 100644 --- a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js @@ -6,13 +6,13 @@ import styles from './FeaturedDialog.css'; import {t} from 'plugin-api/beta/client/services'; import Button from 'coral-ui/components/Button'; -const FeaturedDialog = ({open, onCancel, onPerform}) => ( +const FeaturedDialog = ({showFeaturedDialog, closeFeaturedDialog, postTag}) => ( - × + open={showFeaturedDialog} + onCancel={closeFeaturedDialog} > + ×

{t('talk-plugin-featured-comments.feature_comment')} @@ -25,14 +25,14 @@ const FeaturedDialog = ({open, onCancel, onPerform}) => ( @@ -41,9 +41,9 @@ const FeaturedDialog = ({open, onCancel, onPerform}) => ( ); FeaturedDialog.propTypes = { - open: PropTypes.bool, - onPerform: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired, + showFeaturedDialog: PropTypes.bool, + postTag: PropTypes.func.isRequired, + closeFeaturedDialog: PropTypes.func.isRequired, }; export default FeaturedDialog; diff --git a/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js index b5d6ddd2d..66e9a6a30 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js +++ b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js @@ -1,28 +1,9 @@ -import React from 'react'; -import PropTypes from 'prop-types'; 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'; -class FeaturedDialogContainer extends React.Component { - render() { - const {showFeaturedDialog, closeFeaturedDialog, postTag} = this.props; - return ; - } -} - -FeaturedDialogContainer.propTypes = { - showFeaturedDialog: PropTypes.func, - closeFeaturedDialog: PropTypes.func, - postTag: PropTypes.func, -}; - const mapStateToProps = ({talkPluginFeaturedComments: state}) => ({ showFeaturedDialog: state.showFeaturedDialog, }); @@ -37,4 +18,4 @@ const enhance = compose( connect(mapStateToProps, mapDispatchToProps), ); -export default enhance(FeaturedDialogContainer); +export default enhance(FeaturedDialog); From 9fb8e01cd2d55c47237ba0c54c3a8ebeea85ca88 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 18 Dec 2017 13:34:48 -0300 Subject: [PATCH 13/20] working, still wip --- plugin-api/beta/client/hocs/withTags.js | 7 ++++--- .../talk-plugin-featured-comments/client/actions.js | 6 ++++-- .../client/components/FeaturedDialog.js | 5 ++--- .../client/components/ModTag.js | 7 ++++--- .../client/containers/FeaturedDialog.js | 4 +++- plugins/talk-plugin-featured-comments/client/index.js | 6 ++++-- .../talk-plugin-featured-comments/client/reducer.js | 10 ++++++++++ 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/plugin-api/beta/client/hocs/withTags.js b/plugin-api/beta/client/hocs/withTags.js index 66fd7ad2e..14ae4fcf4 100644 --- a/plugin-api/beta/client/hocs/withTags.js +++ b/plugin-api/beta/client/hocs/withTags.js @@ -87,7 +87,7 @@ 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); @@ -100,6 +100,7 @@ export default (tag, options = {}) => hoistStatics((WrappedComponent) => { postTag={this.postTag} deleteTag={this.deleteTag} config={config} + {...rest} />; } } @@ -134,9 +135,9 @@ export default (tag, options = {}) => 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 index c5c81baa8..d212ae736 100644 --- a/plugins/talk-plugin-featured-comments/client/actions.js +++ b/plugins/talk-plugin-featured-comments/client/actions.js @@ -1,7 +1,9 @@ import {OPEN_FEATURED_DIALOG, CLOSE_FEATURED_DIALOG} from './constants'; -export const openFeaturedDialog = () => ({ - type: OPEN_FEATURED_DIALOG +export const openFeaturedDialog = (comment, asset) => ({ + type: OPEN_FEATURED_DIALOG, + comment, + asset, }); export const closeFeaturedDialog = () => ({ diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js index cad872e12..4975f8e59 100644 --- a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js @@ -9,7 +9,7 @@ import Button from 'coral-ui/components/Button'; const FeaturedDialog = ({showFeaturedDialog, closeFeaturedDialog, postTag}) => ( × @@ -41,8 +41,7 @@ const FeaturedDialog = ({showFeaturedDialog, closeFeaturedDialog, postTag}) => ( ); FeaturedDialog.propTypes = { - showFeaturedDialog: PropTypes.bool, - postTag: PropTypes.func.isRequired, + showFeaturedDialog: PropTypes.bool.isRequired, closeFeaturedDialog: PropTypes.func.isRequired, }; diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index c66b688ab..c3cced4f2 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -4,7 +4,6 @@ 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() { @@ -31,7 +30,7 @@ export default class ModTag extends React.Component { } render() { - const {alreadyTagged, deleteTag} = this.props; + const {alreadyTagged, deleteTag, comment, asset} = this.props; return alreadyTagged ? ( ) : ( + onClick={() => this.props.openFeaturedDialog(comment, asset)} > {alreadyTagged ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.feature')} @@ -56,4 +55,6 @@ ModTag.propTypes = { deleteTag: PropTypes.func, notify: PropTypes.func, openFeaturedDialog: PropTypes.func, + comment: PropTypes.object, + asset: PropTypes.object, }; diff --git a/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js index 66e9a6a30..0440e9d08 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js +++ b/plugins/talk-plugin-featured-comments/client/containers/FeaturedDialog.js @@ -6,6 +6,8 @@ import {closeFeaturedDialog} from '../actions'; const mapStateToProps = ({talkPluginFeaturedComments: state}) => ({ showFeaturedDialog: state.showFeaturedDialog, + comment: state.comment, + asset: state.asset, }); const mapDispatchToProps = (dispatch) => @@ -14,8 +16,8 @@ const mapDispatchToProps = (dispatch) => }, dispatch); const enhance = compose( - withTags('featured'), connect(mapStateToProps, mapDispatchToProps), + withTags('featured'), ); export default enhance(FeaturedDialog); diff --git a/plugins/talk-plugin-featured-comments/client/index.js b/plugins/talk-plugin-featured-comments/client/index.js index 21d61d21a..304bff647 100644 --- a/plugins/talk-plugin-featured-comments/client/index.js +++ b/plugins/talk-plugin-featured-comments/client/index.js @@ -6,20 +6,22 @@ import update from 'immutability-helper'; import ModTag from './containers/ModTag'; import ModActionButton from './containers/ModActionButton'; import ModSubscription from './containers/ModSubscription'; -import FeaturedConfirmation from './containers/FeaturedConfirmation'; +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, FeaturedConfirmation], + 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 index 3840155b3..eb6d302ff 100644 --- a/plugins/talk-plugin-featured-comments/client/reducer.js +++ b/plugins/talk-plugin-featured-comments/client/reducer.js @@ -2,6 +2,13 @@ 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) { @@ -9,11 +16,14 @@ export default function reducer(state = initialState, action) { 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 : From 8f1f875d76b0d3dd1a212ab78a88ca89882fda2f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 18 Dec 2017 13:36:30 -0300 Subject: [PATCH 14/20] less data to the store --- plugins/talk-plugin-featured-comments/client/actions.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/talk-plugin-featured-comments/client/actions.js b/plugins/talk-plugin-featured-comments/client/actions.js index d212ae736..e16f06f48 100644 --- a/plugins/talk-plugin-featured-comments/client/actions.js +++ b/plugins/talk-plugin-featured-comments/client/actions.js @@ -2,8 +2,13 @@ import {OPEN_FEATURED_DIALOG, CLOSE_FEATURED_DIALOG} from './constants'; export const openFeaturedDialog = (comment, asset) => ({ type: OPEN_FEATURED_DIALOG, - comment, - asset, + comment: { + id: comment.id, + tags: comment.tags, + }, + asset: { + id: asset.id, + }, }); export const closeFeaturedDialog = () => ({ From 6ad218782e7531d314e9c0560b7a4456ef09da60 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 18 Dec 2017 13:39:02 -0300 Subject: [PATCH 15/20] styling --- .../client/components/FeaturedDialog.css | 5 ++++- .../client/components/FeaturedDialog.js | 10 +++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css index 9a8b93eec..4326d5c5c 100644 --- a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.css @@ -22,7 +22,6 @@ right: 20px; } - .cancel { margin-right: 5px; } @@ -36,3 +35,7 @@ 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 index 4975f8e59..f49148f24 100644 --- a/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js +++ b/plugins/talk-plugin-featured-comments/client/components/FeaturedDialog.js @@ -13,13 +13,9 @@ const FeaturedDialog = ({showFeaturedDialog, closeFeaturedDialog, postTag}) => ( open={showFeaturedDialog} onCancel={closeFeaturedDialog} > × -
-

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

-
-
-

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

+

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

+
+ {t('talk-plugin-featured-comments.are_you_sure')}
- -
-
-); +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, From 0e01d40aa7b2429d4860eee9ab7b118ab1fccbc9 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 18 Dec 2017 19:01:43 +0100 Subject: [PATCH 17/20] Fix sign in on profile tab --- client/coral-framework/hocs/withQuery.js | 24 +++++++++++++------ .../containers/ProfileContainer.js | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) 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 ; } From 82fd56dc6716d7840c0922963f1a781b2ea7433a Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Mon, 18 Dec 2017 13:09:39 -0500 Subject: [PATCH 18/20] Update permalink copy to Share on stream --- locales/da.yml | 2 +- locales/en.yml | 2 +- locales/es.yml | 2 +- locales/fr.yml | 2 +- locales/pt_BR.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) 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 f1d566475..a2197652e 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -297,7 +297,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 From 1cdef8f86471abcf775a46dff424bfec2409d83d Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 15:20:06 -0300 Subject: [PATCH 19/20] bounded --- .../client/components/ModTag.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index c3cced4f2..70f51dcbc 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -29,6 +29,10 @@ export default class ModTag extends React.Component { }); } + openFeaturedDialog = (comment, asset) => { + this.props.openFeaturedDialog(comment, asset); + } + render() { const {alreadyTagged, deleteTag, comment, asset} = this.props; @@ -42,7 +46,7 @@ export default class ModTag extends React.Component { ) : ( this.props.openFeaturedDialog(comment, asset)} > + onClick={() => this.openFeaturedDialog(comment, asset)} > {alreadyTagged ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.feature')} From 35c88ffab4f2c30c436ed2c843862ece26d274d3 Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 18 Dec 2017 15:21:02 -0300 Subject: [PATCH 20/20] spreading the rest first --- plugin-api/beta/client/hocs/withTags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-api/beta/client/hocs/withTags.js b/plugin-api/beta/client/hocs/withTags.js index 14ae4fcf4..3edc66824 100644 --- a/plugin-api/beta/client/hocs/withTags.js +++ b/plugin-api/beta/client/hocs/withTags.js @@ -92,6 +92,7 @@ export default (tag, options = {}) => hoistStatics((WrappedComponent) => { const alreadyTagged = isTagged(comment.tags, TAG); return hoistStatics((WrappedComponent) => { postTag={this.postTag} deleteTag={this.deleteTag} config={config} - {...rest} />; } }