From b1ec512721ba53c1fda474bd1eb34c0be6dba8cf Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 14:42:57 -0300 Subject: [PATCH 01/17] Adding whitelist step, sending whitelist --- .../src/containers/Install/InstallContainer.js | 2 ++ .../Install/components/Steps/WhitelistStep.js | 15 +++++++++++++++ client/coral-admin/src/reducers/install.js | 11 +++++++++-- client/coral-ui/components/WizardNav.css | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js diff --git a/client/coral-admin/src/containers/Install/InstallContainer.js b/client/coral-admin/src/containers/Install/InstallContainer.js index 7a8634180..b015140ed 100644 --- a/client/coral-admin/src/containers/Install/InstallContainer.js +++ b/client/coral-admin/src/containers/Install/InstallContainer.js @@ -18,6 +18,7 @@ import { import InitialStep from './components/Steps/InitialStep'; import AddOrganizationName from './components/Steps/AddOrganizationName'; import CreateYourAccount from './components/Steps/CreateYourAccount'; +import WhitelistStep from './components/Steps/WhitelistStep'; import FinalStep from './components/Steps/FinalStep'; class InstallContainer extends Component { @@ -43,6 +44,7 @@ class InstallContainer extends Component { + diff --git a/client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js b/client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js new file mode 100644 index 000000000..e246b457e --- /dev/null +++ b/client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js @@ -0,0 +1,15 @@ +import React from 'react'; +import styles from './style.css'; +import {Button} from 'coral-ui'; + +const WhitelistStep = props => { + const {nextStep} = props; + return ( +
+

Domain Whitelist

+ +
+ ); +}; + +export default WhitelistStep; diff --git a/client/coral-admin/src/reducers/install.js b/client/coral-admin/src/reducers/install.js index 596fd16cd..429d5cce0 100644 --- a/client/coral-admin/src/reducers/install.js +++ b/client/coral-admin/src/reducers/install.js @@ -1,4 +1,4 @@ -import {Map} from 'immutable'; +import {Map, List} from 'immutable'; import * as actions from '../constants/install'; @@ -6,7 +6,10 @@ const initialState = Map({ isLoading: false, data: Map({ settings: Map({ - organizationName: '' + organizationName: '', + domains: Map({ + whitelist: List() + }) }), user: Map({ username: '', @@ -33,6 +36,10 @@ const initialState = Map({ { text: '2. Create your account', step: 2 + }, + { + text: '3. Domain Whitelist', + step: 3 }], installRequest: null, installRequestError: null, diff --git a/client/coral-ui/components/WizardNav.css b/client/coral-ui/components/WizardNav.css index 001ee8603..1f0b78d86 100644 --- a/client/coral-ui/components/WizardNav.css +++ b/client/coral-ui/components/WizardNav.css @@ -13,6 +13,7 @@ position: relative; padding-left: 40px; border-radius: 1px; + min-height: 24px; &:hover { cursor: pointer; From 9305853502ca738bd70211a1d2ee0c15e9862efd Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 15:50:07 -0300 Subject: [PATCH 02/17] Renamed to PermittedDomains --- client/coral-admin/src/actions/install.js | 34 ++++++++++++------- .../containers/Install/InstallContainer.js | 7 ++-- .../components/Steps/PermittedDomainsStep.js | 31 +++++++++++++++++ .../Install/components/Steps/WhitelistStep.js | 15 -------- .../src/containers/Install/translations.json | 16 +++++++++ client/coral-admin/src/reducers/install.js | 5 +-- 6 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js delete mode 100644 client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js create mode 100644 client/coral-admin/src/containers/Install/translations.json diff --git a/client/coral-admin/src/actions/install.js b/client/coral-admin/src/actions/install.js index c1d05d253..73e7aaa82 100644 --- a/client/coral-admin/src/actions/install.js +++ b/client/coral-admin/src/actions/install.js @@ -71,21 +71,31 @@ export const submitSettings = () => (dispatch, getState) => { export const submitUser = () => (dispatch, getState) => { const userFormData = getState().install.toJS().data.user; validation(userFormData, dispatch, function() { - const data = getState().install.toJS().data; - dispatch(installRequest()); - coralApi('/setup', {method: 'POST', body: data}) - .then(result => { - console.log(result); - dispatch(installSuccess()); - dispatch(nextStep()); - }) - .catch(error => { - console.error(error); - dispatch(installFailure(`${error.translation_key}`)); - }); + dispatch(nextStep()); }); }; +export const submitWhitelistDomains = () => (dispatch) => { + submitForm().then(() => { + dispatch(installSuccess()); + }); +}; + +const submitForm = () => (dispatch, getState) => { + const data = getState().install.toJS().data; + dispatch(installRequest()); + return coralApi('/setup', { method: 'POST', body: data }) + .then(result => { + console.log(result); + dispatch(installSuccess()); + dispatch(nextStep()); + }) + .catch(error => { + console.error(error); + dispatch(installFailure(`${error.translation_key}`)); + }); +}; + export const updateSettingsFormData = (name, value) => ({type: actions.UPDATE_FORMDATA_SETTINGS, name, value}); export const updateUserFormData = (name, value) => ({type: actions.UPDATE_FORMDATA_USER, name, value}); diff --git a/client/coral-admin/src/containers/Install/InstallContainer.js b/client/coral-admin/src/containers/Install/InstallContainer.js index b015140ed..fe41e12e4 100644 --- a/client/coral-admin/src/containers/Install/InstallContainer.js +++ b/client/coral-admin/src/containers/Install/InstallContainer.js @@ -18,7 +18,7 @@ import { import InitialStep from './components/Steps/InitialStep'; import AddOrganizationName from './components/Steps/AddOrganizationName'; import CreateYourAccount from './components/Steps/CreateYourAccount'; -import WhitelistStep from './components/Steps/WhitelistStep'; +import PermittedDomainsStep from './components/Steps/PermittedDomainsStep'; import FinalStep from './components/Steps/FinalStep'; class InstallContainer extends Component { @@ -41,10 +41,7 @@ class InstallContainer extends Component {

Welcome to the Coral Project

{ install.step !== 0 ? : null } - - - - + diff --git a/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js b/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js new file mode 100644 index 000000000..c5fae148e --- /dev/null +++ b/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js @@ -0,0 +1,31 @@ +import React from 'react'; +import styles from './style.css'; +import {Button, Card} from 'coral-ui'; +import TagsInput from 'react-tagsinput'; + +const lang = new I18n(translations); +import translations from '../../translations.json'; +import I18n from 'coral-framework/modules/i18n/i18n'; + +const PermittedDomainsStep = props => { + const {nextStep, onChangeDomainlist} = props; + const domains = []; + return ( +
+

{lang.t('PERMITTED_DOMAINS.TITLE')}

+ +

{lang.t('PERMITTED_DOMAINS.DESCRIPTION')}

+ data.split(',').map(d => d.trim())} + onChange={tags => onChangeDomainlist(tags)} + /> +
+ +
+ ); +}; + +export default PermittedDomainsStep; diff --git a/client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js b/client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js deleted file mode 100644 index e246b457e..000000000 --- a/client/coral-admin/src/containers/Install/components/Steps/WhitelistStep.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import styles from './style.css'; -import {Button} from 'coral-ui'; - -const WhitelistStep = props => { - const {nextStep} = props; - return ( -
-

Domain Whitelist

- -
- ); -}; - -export default WhitelistStep; diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json new file mode 100644 index 000000000..494a020f4 --- /dev/null +++ b/client/coral-admin/src/containers/Install/translations.json @@ -0,0 +1,16 @@ +{ + "en": { + "PERMITTED_DOMAINS": { + "TITLE": "Permitted domains", + "DESCRIPTION": "Add permitted domains", + "SUBMIT": "Finish install" + } + }, + "es": { + "PERMITTED_DOMAINS": { + "TITLE": "Dominios Permitidos", + "DESCRIPTION": "Agrega dominios permitidos", + "SUBMIT": "Finalizar instalación" + } + } +} diff --git a/client/coral-admin/src/reducers/install.js b/client/coral-admin/src/reducers/install.js index 429d5cce0..8d3ea0f76 100644 --- a/client/coral-admin/src/reducers/install.js +++ b/client/coral-admin/src/reducers/install.js @@ -6,10 +6,7 @@ const initialState = Map({ isLoading: false, data: Map({ settings: Map({ - organizationName: '', - domains: Map({ - whitelist: List() - }) + organizationName: '' }), user: Map({ username: '', From ab16e5bfe7a396377e4784873549384f9bffe125 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 27 Feb 2017 14:26:20 -0500 Subject: [PATCH 03/17] Retrieving comment y id from backend --- graph/loaders/comments.js | 17 +++++++++++++++++ graph/resolvers/comment.js | 7 +++++++ graph/resolvers/root_query.js | 4 +++- graph/typeDefs.graphql | 6 ++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/graph/loaders/comments.js b/graph/loaders/comments.js index ad78a1e92..b5f493831 100644 --- a/graph/loaders/comments.js +++ b/graph/loaders/comments.js @@ -270,6 +270,22 @@ const genRecentComments = (_, ids) => { .then(util.arrayJoinBy(ids, 'asset_id')); }; +/** + * genComments returns the comments by the id's specified that are considered + * public comments (i.e., accepted or not rejected). + */ +const genComments = (context, ids) => { + return CommentModel.find({ + id: { + $in: ids + }, + status: { + $in: ['NONE', 'ACCEPTED'] + } + }) + .then(util.singleJoinBy(ids, 'id')); +}; + /** * Creates a set of loaders based on a GraphQL context. * @param {Object} context the context of the GraphQL request @@ -277,6 +293,7 @@ const genRecentComments = (_, ids) => { */ module.exports = (context) => ({ Comments: { + get: new DataLoader((ids) => genComments(context, ids)), getByQuery: (query) => getCommentsByQuery(context, query), getCountByQuery: (query) => getCommentCountByQuery(context, query), countByAssetID: new util.SharedCacheDataLoader('Comments.countByAssetID', 3600, (ids) => getCountsByAssetID(context, ids)), diff --git a/graph/resolvers/comment.js b/graph/resolvers/comment.js index ef77ff6b5..43577dca0 100644 --- a/graph/resolvers/comment.js +++ b/graph/resolvers/comment.js @@ -1,4 +1,11 @@ const Comment = { + parent({parent_id}, _, {loaders: {Comments}}) { + if (parent_id == null) { + return null; + } + + return Comments.get.load(parent_id); + }, user({author_id}, _, {loaders: {Users}}) { return Users.getByID.load(author_id); }, diff --git a/graph/resolvers/root_query.js b/graph/resolvers/root_query.js index ced4e65cf..6622fd17f 100644 --- a/graph/resolvers/root_query.js +++ b/graph/resolvers/root_query.js @@ -38,7 +38,9 @@ const RootQuery = { return Comments.getByQuery(query); }, - + comment(_, {id}, {loaders: {Comments}}) { + return Comments.get.load(id); + }, commentCount(_, {query: {action_type, statuses, asset_id, parent_id}}, {user, loaders: {Actions, Comments}}) { if (user == null || !user.hasRoles('ADMIN')) { return null; diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index fbdeb4279..b9ab770ac 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -149,6 +149,9 @@ input CommentCountQuery { # Comment is the base representation of user interaction in Talk. type Comment { + # The parent of the comment (if there is one). + parent: Comment + # The ID of the comment. id: ID! @@ -477,6 +480,9 @@ type RootQuery { # Site wide settings and defaults. settings: Settings + # Finds a specific comment based on it's id. + comment(id: ID!): Comment + # All assets. Requires the `ADMIN` role. assets: [Asset] From 013625df274c2e8b40743bd798592bff9299bc01 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 16:39:52 -0300 Subject: [PATCH 04/17] no validation for domains --- client/coral-admin/src/actions/install.js | 38 ++++++++--------- client/coral-admin/src/constants/install.js | 1 + .../src/containers/Configure/Domainlist.js | 42 ++++++++++--------- .../containers/Install/InstallContainer.js | 23 ++++++---- .../components/Steps/PermittedDomainsStep.js | 10 ++--- .../Install/components/Steps/style.css | 6 +++ client/coral-admin/src/reducers/install.js | 8 +++- 7 files changed, 76 insertions(+), 52 deletions(-) diff --git a/client/coral-admin/src/actions/install.js b/client/coral-admin/src/actions/install.js index 73e7aaa82..970c15141 100644 --- a/client/coral-admin/src/actions/install.js +++ b/client/coral-admin/src/actions/install.js @@ -20,13 +20,17 @@ const validation = (formData, dispatch, next) => { return dispatch(hasError()); } + const validKeys = Object.keys(formData) + .filter(name => name !== 'domains'); + // Required Validation - const empty = Object.keys(formData).filter(name => { + const empty = validKeys + .filter(name => { const cond = !formData[name].length; if (cond) { - // Adding Error + // Adding Error dispatch(addError(name, 'This field is required.')); } else { dispatch(addError(name, '')); @@ -40,18 +44,19 @@ const validation = (formData, dispatch, next) => { } // RegExp Validation - const validation = Object.keys(formData).filter(name => { - const cond = !validate[name](formData[name]); - if (cond) { + const validation = validKeys + .filter(name => { + const cond = !validate[name](formData[name]); + if (cond) { // Adding Error - dispatch(addError(name, errorMsj[name])); - } else { - dispatch(addError(name, '')); - } + dispatch(addError(name, errorMsj[name])); + } else { + dispatch(addError(name, '')); + } - return cond; - }); + return cond; + }); if (validation.length) { return dispatch(hasError()); @@ -75,16 +80,10 @@ export const submitUser = () => (dispatch, getState) => { }); }; -export const submitWhitelistDomains = () => (dispatch) => { - submitForm().then(() => { - dispatch(installSuccess()); - }); -}; - -const submitForm = () => (dispatch, getState) => { +export const finishInstall = () => (dispatch, getState) => { const data = getState().install.toJS().data; dispatch(installRequest()); - return coralApi('/setup', { method: 'POST', body: data }) + return coralApi('/setup', {method: 'POST', body: data}) .then(result => { console.log(result); dispatch(installSuccess()); @@ -98,6 +97,7 @@ const submitForm = () => (dispatch, getState) => { export const updateSettingsFormData = (name, value) => ({type: actions.UPDATE_FORMDATA_SETTINGS, name, value}); export const updateUserFormData = (name, value) => ({type: actions.UPDATE_FORMDATA_USER, name, value}); +export const updatePermittedDomains = (value) => ({type: actions.UPDATE_PERMITTED_DOMAINS_SETTINGS, value}); const checkInstallRequest = () => ({type: actions.CHECK_INSTALL_REQUEST}); const checkInstallSuccess = installed => ({type: actions.CHECK_INSTALL_SUCCESS, installed}); diff --git a/client/coral-admin/src/constants/install.js b/client/coral-admin/src/constants/install.js index b3fd7e0d0..743d68593 100644 --- a/client/coral-admin/src/constants/install.js +++ b/client/coral-admin/src/constants/install.js @@ -10,6 +10,7 @@ export const INSTALL_SUCCESS = 'INSTALL_SUCCESS'; export const INSTALL_FAILURE = 'INSTALL_FAILURE'; export const UPDATE_FORMDATA_USER = 'UPDATE_FORMDATA_USER'; export const UPDATE_FORMDATA_SETTINGS = 'UPDATE_FORMDATA_SETTINGS'; +export const UPDATE_PERMITTED_DOMAINS_SETTINGS = 'UPDATE_PERMITTED_DOMAINS_SETTINGS'; export const CHECK_INSTALL_REQUEST = 'CHECK_INSTALL_REQUEST'; export const CHECK_INSTALL_SUCCESS = 'CHECK_INSTALL_SUCCESS'; diff --git a/client/coral-admin/src/containers/Configure/Domainlist.js b/client/coral-admin/src/containers/Configure/Domainlist.js index f845dfeaa..6918c0471 100644 --- a/client/coral-admin/src/containers/Configure/Domainlist.js +++ b/client/coral-admin/src/containers/Configure/Domainlist.js @@ -1,26 +1,28 @@ import React from 'react'; +import {Card} from 'coral-ui'; +import styles from './Configure.css'; +import TagsInput from 'react-tagsinput'; + import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../../translations.json'; -import TagsInput from 'react-tagsinput'; -import styles from './Configure.css'; -import {Card} from 'coral-ui'; +const lang = new I18n(translations); -const Domainlist = ({domains, onChangeDomainlist}) => ( -
-

{lang.t('configure.domain-list-title')}

- -

{lang.t('configure.domain-list-text')}

- data.split(',').map(d => d.trim())} - onChange={tags => onChangeDomainlist('whitelist', tags)} - /> -
-
-); +const Domainlist = ({domains, onChangeDomainlist}) => { + return ( +
+

{lang.t('configure.domain-list-title')}

+ +

{lang.t('configure.domain-list-text')}

+ data.split(',').map(d => d.trim())} + onChange={tags => onChangeDomainlist('whitelist', tags)} + /> +
+
+ ); +}; export default Domainlist; - -const lang = new I18n(translations); diff --git a/client/coral-admin/src/containers/Install/InstallContainer.js b/client/coral-admin/src/containers/Install/InstallContainer.js index fe41e12e4..b70d3b8c9 100644 --- a/client/coral-admin/src/containers/Install/InstallContainer.js +++ b/client/coral-admin/src/containers/Install/InstallContainer.js @@ -5,14 +5,16 @@ import {Wizard, WizardNav} from 'coral-ui'; import {Layout} from '../../components/ui/Layout'; import { - nextStep, - previousStep, goToStep, + nextStep, + submitUser, + checkInstall, + previousStep, + finishInstall, + submitSettings, updateUserFormData, updateSettingsFormData, - submitSettings, - submitUser, - checkInstall + updatePermittedDomains } from '../../actions/install'; import InitialStep from './components/Steps/InitialStep'; @@ -41,6 +43,9 @@ class InstallContainer extends Component {

Welcome to the Coral Project

{ install.step !== 0 ? : null } + + + @@ -64,10 +69,14 @@ const mapStateToProps = state => ({ }); const mapDispatchToProps = dispatch => ({ - checkInstall: next => dispatch(checkInstall(next)), nextStep: () => dispatch(nextStep()), - previousStep: () => dispatch(previousStep()), goToStep: step => dispatch(goToStep(step)), + previousStep: () => dispatch(previousStep()), + finishInstall: () => dispatch(finishInstall()), + checkInstall: next => dispatch(checkInstall(next)), + handleDomainsChange: value => { + dispatch(updatePermittedDomains(value)); + }, handleSettingsChange: e => { const {name, value} = e.currentTarget; dispatch(updateSettingsFormData(name, value)); diff --git a/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js b/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js index c5fae148e..f2c1546f6 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js +++ b/client/coral-admin/src/containers/Install/components/Steps/PermittedDomainsStep.js @@ -8,22 +8,22 @@ import translations from '../../translations.json'; import I18n from 'coral-framework/modules/i18n/i18n'; const PermittedDomainsStep = props => { - const {nextStep, onChangeDomainlist} = props; - const domains = []; + const {finishInstall, install, handleDomainsChange} = props; + const domains = install.data.settings.domains.whitelist; return (

{lang.t('PERMITTED_DOMAINS.TITLE')}

- +

{lang.t('PERMITTED_DOMAINS.DESCRIPTION')}

data.split(',').map(d => d.trim())} - onChange={tags => onChangeDomainlist(tags)} + onChange={tags => handleDomainsChange(tags)} />
- +
); }; diff --git a/client/coral-admin/src/containers/Install/components/Steps/style.css b/client/coral-admin/src/containers/Install/components/Steps/style.css index a5867e960..dea752298 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/style.css +++ b/client/coral-admin/src/containers/Install/components/Steps/style.css @@ -59,6 +59,12 @@ } } } + + .card { + max-width: 500px; + margin: 20px auto; + text-align: left; + } } .finalStep { diff --git a/client/coral-admin/src/reducers/install.js b/client/coral-admin/src/reducers/install.js index 8d3ea0f76..1f0f079ff 100644 --- a/client/coral-admin/src/reducers/install.js +++ b/client/coral-admin/src/reducers/install.js @@ -6,7 +6,10 @@ const initialState = Map({ isLoading: false, data: Map({ settings: Map({ - organizationName: '' + organizationName: '', + domains: Map({ + whitelist: List() + }) }), user: Map({ username: '', @@ -54,6 +57,9 @@ export default function install (state = initialState, action) { case actions.GO_TO_STEP: return state .set('step', action.step); + case actions.UPDATE_PERMITTED_DOMAINS_SETTINGS: + return state + .setIn(['data', 'settings', 'domains', 'whitelist'], action.value); case actions.UPDATE_FORMDATA_SETTINGS: return state .setIn(['data', 'settings', action.name], action.value); From 1e52c579cc318703494d5170c6cb03c8d1b467b3 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 16:50:04 -0300 Subject: [PATCH 05/17] =?UTF-8?q?=C3=8Dnitial=20translations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Install/components/Steps/InitialStep.js | 12 ++++++------ .../src/containers/Install/translations.json | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/client/coral-admin/src/containers/Install/components/Steps/InitialStep.js b/client/coral-admin/src/containers/Install/components/Steps/InitialStep.js index 9f9770fe9..1838e3178 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/InitialStep.js +++ b/client/coral-admin/src/containers/Install/components/Steps/InitialStep.js @@ -2,16 +2,16 @@ import React from 'react'; import styles from './style.css'; import {Button} from 'coral-ui'; +const lang = new I18n(translations); +import translations from '../../translations.json'; +import I18n from 'coral-framework/modules/i18n/i18n'; + const InitialStep = props => { const {nextStep} = props; return (
-

- The remainder of the Talk installation will take about ten minutes. - Once you complete the following two steps, you will have a free - installation and provision of Mongo and Redis. -

- +

{lang.t('INITIAL.DESCRIPTION')}

+
); }; diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index 494a020f4..5b3c5f036 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -1,5 +1,9 @@ { "en": { + "INITIAL" : { + "DESCRIPTION": "The remainder of the Talk installation will take about ten minutes. Once you complete the following two steps, you will have a free installation and provision of Mongo and Redis.", + "SUBMIT": "Get Started" + }, "PERMITTED_DOMAINS": { "TITLE": "Permitted domains", "DESCRIPTION": "Add permitted domains", @@ -7,6 +11,10 @@ } }, "es": { + "INITIAL" : { + "DESCRIPTION": "La instalación de Talk tomará aproximadamente diez minutos. Tan pronto como termines los tres pasos, tendrás una gratis instalación y provision de Mongo y Redis", + "SUBMIT": "Empezá!" + }, "PERMITTED_DOMAINS": { "TITLE": "Dominios Permitidos", "DESCRIPTION": "Agrega dominios permitidos", From 7341fdff4eb9b3b5bf1cfd36f7b628555cc18dbf Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 16:54:03 -0300 Subject: [PATCH 06/17] add Organization translations --- .../Install/components/Steps/AddOrganizationName.js | 13 +++++++------ .../src/containers/Install/translations.json | 10 ++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js b/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js index ae23d0048..127c4afa1 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js +++ b/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js @@ -2,25 +2,26 @@ import React from 'react'; import styles from './style.css'; import {TextField, Button} from 'coral-ui'; +const lang = new I18n(translations); +import translations from '../../translations.json'; +import I18n from 'coral-framework/modules/i18n/i18n'; + const AddOrganizationName = props => { const {handleSettingsChange, handleSettingsSubmit, install} = props; return (
-

- Please tell us the name of your organization. This will appear in emails when - inviting new team members -

+

{lang.t('ADD_ORGANIZATION.DESCRIPTION')}

- +
diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index 5b3c5f036..aee01c3cd 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -4,6 +4,11 @@ "DESCRIPTION": "The remainder of the Talk installation will take about ten minutes. Once you complete the following two steps, you will have a free installation and provision of Mongo and Redis.", "SUBMIT": "Get Started" }, + "ADD_ORGANIZATION": { + "DESCRIPTION": "Please tell us the name of your organization. This will appear in emails when inviting new team members", + "LABEL": "Organization Name", + "SAVE": "Save" + }, "PERMITTED_DOMAINS": { "TITLE": "Permitted domains", "DESCRIPTION": "Add permitted domains", @@ -15,6 +20,11 @@ "DESCRIPTION": "La instalación de Talk tomará aproximadamente diez minutos. Tan pronto como termines los tres pasos, tendrás una gratis instalación y provision de Mongo y Redis", "SUBMIT": "Empezá!" }, + "ADD_ORGANIZATION": { + "DESCRIPTION": "Por favor, dinos el nombre de tu organización. Este aparecerá en los emails cuando invites nuevos miembros", + "LABEL": "Nombre de la Organización", + "SAVE": "Guardar" + }, "PERMITTED_DOMAINS": { "TITLE": "Dominios Permitidos", "DESCRIPTION": "Agrega dominios permitidos", From b47fd3543740c55fc61779710196a0c6f7727773 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 16:58:16 -0300 Subject: [PATCH 07/17] add user translations --- .../Install/components/Steps/CreateYourAccount.js | 10 +++++----- .../src/containers/Install/translations.json | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js b/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js index cb0f4635f..ec1e34607 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js +++ b/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js @@ -12,7 +12,7 @@ const InitialStep = props => { className={styles.textField} id="email" type="email" - label='Email address' + label={lang.t('CREATE.EMAIL')} onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.email} @@ -23,7 +23,7 @@ const InitialStep = props => { className={styles.textField} id="username" type="text" - label='Username' + label={lang.t('CREATE.USERNAME')} onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.username} @@ -33,7 +33,7 @@ const InitialStep = props => { className={styles.textField} id="password" type="password" - label='Password' + label={lang.t('CREATE.PASSWORD')} onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.password} @@ -43,7 +43,7 @@ const InitialStep = props => { className={styles.textField} id="confirmPassword" type="password" - label='Confirm Password' + label={lang.t('CREATE.CONFIRM_PASSWORD')} onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.confirmPassword} @@ -51,7 +51,7 @@ const InitialStep = props => { { !props.install.isLoading ? - + : } diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index aee01c3cd..64b18101a 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -9,6 +9,13 @@ "LABEL": "Organization Name", "SAVE": "Save" }, + "CREATE": { + "EMAIL": "Email address", + "USERNAME": "Username", + "PASSWORD": "Password", + "CONFIRM_PASSWORD": "Confirm Password", + "SAVE": "Save" + }, "PERMITTED_DOMAINS": { "TITLE": "Permitted domains", "DESCRIPTION": "Add permitted domains", @@ -25,6 +32,13 @@ "LABEL": "Nombre de la Organización", "SAVE": "Guardar" }, + "CREATE": { + "EMAIL": "Dirección de E-Mail", + "USERNAME": "Usuario", + "PASSWORD": "Contraseña", + "CONFIRM_PASSWORD": "Confirmar contraseña", + "SAVE": "Guardar" + }, "PERMITTED_DOMAINS": { "TITLE": "Dominios Permitidos", "DESCRIPTION": "Agrega dominios permitidos", From 628e8844f3ff6dcdd087e7380f37a8d9e7a5fbd6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 17:04:14 -0300 Subject: [PATCH 08/17] final translations --- .../Install/components/Steps/CreateYourAccount.js | 4 ++++ .../Install/components/Steps/FinalStep.js | 14 +++++++------- .../src/containers/Install/translations.json | 10 ++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js b/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js index ec1e34607..416fac195 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js +++ b/client/coral-admin/src/containers/Install/components/Steps/CreateYourAccount.js @@ -2,6 +2,10 @@ import React from 'react'; import styles from './style.css'; import {TextField, Button, Spinner} from 'coral-ui'; +const lang = new I18n(translations); +import translations from '../../translations.json'; +import I18n from 'coral-framework/modules/i18n/i18n'; + const InitialStep = props => { const {handleUserChange, handleUserSubmit, install} = props; return ( diff --git a/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js b/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js index e549ebe63..0ad918487 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js +++ b/client/coral-admin/src/containers/Install/components/Steps/FinalStep.js @@ -3,16 +3,16 @@ import styles from './style.css'; import {Button} from 'coral-ui'; import {Link} from 'react-router'; +const lang = new I18n(translations); +import translations from '../../translations.json'; +import I18n from 'coral-framework/modules/i18n/i18n'; + const InitialStep = () => { return (
-

- Thanks for installing Talk! We sent an email to verify your email - address. While you finish setting the account, you can start engaging - with your readers now. -

- - +

{lang.t('FINAL.DESCRIPTION')}

+ +
); }; diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index 64b18101a..3bae62c3a 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -20,6 +20,11 @@ "TITLE": "Permitted domains", "DESCRIPTION": "Add permitted domains", "SUBMIT": "Finish install" + }, + "FINAL": { + "DESCRIPTION": "Thanks for installing Talk! We sent an email to verify your email address. While you finish setting the account, you can start engaging with your readers now.", + "LAUNCH": "Launch Talk", + "CLOSE": "Close this Installer" } }, "es": { @@ -43,6 +48,11 @@ "TITLE": "Dominios Permitidos", "DESCRIPTION": "Agrega dominios permitidos", "SUBMIT": "Finalizar instalación" + }, + "FINAL": { + "DESCRIPTION": "Gracias por instalar Talk! Te enviamos un email para verificar tu identidad. Mientras se termina de configurar la cuenta, ya puedes empezar a interactuar con tus lectores", + "LAUNCH": "Lanzar Talk", + "CLOSE": "Cerrar este instalador" } } } From b9e9d3e7fa60b5e1e11141d27df9dc339a62b3d9 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 17:06:22 -0300 Subject: [PATCH 09/17] status --- .../containers/Install/components/Steps/AddOrganizationName.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js b/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js index 127c4afa1..bcac6ef29 100644 --- a/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js +++ b/client/coral-admin/src/containers/Install/components/Steps/AddOrganizationName.js @@ -17,7 +17,7 @@ const AddOrganizationName = props => { className={styles.TextField} id="organizationName" type="text" - label={lang.t('ADD_ORGANIZATION.DESCRIPTION')} + label={lang.t('ADD_ORGANIZATION.LABEL')} onChange={handleSettingsChange} showErrors={install.showErrors} errorMsg={install.errors.organizationName} /> From 1234a99a0d75d634fc94f11babe12635655fb1a4 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 17:16:19 -0300 Subject: [PATCH 10/17] copy for install permitted domains updated --- client/coral-admin/src/containers/Install/translations.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index 3bae62c3a..8f651240c 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -18,7 +18,7 @@ }, "PERMITTED_DOMAINS": { "TITLE": "Permitted domains", - "DESCRIPTION": "Add permitted domains", + "DESCRIPTION": "Enter the domains you would like to permit for Talk, e.g. your local, staging and production environments (ex. localhost:3000, staging.domain.com, domain.com).", "SUBMIT": "Finish install" }, "FINAL": { @@ -46,7 +46,7 @@ }, "PERMITTED_DOMAINS": { "TITLE": "Dominios Permitidos", - "DESCRIPTION": "Agrega dominios permitidos", + "DESCRIPTION": "Agrega dominios permitidos a Talk, e.g. tu localhost, staging y ambientes de production (ex. localhost:3000, staging.domain.com, domain.com).", "SUBMIT": "Finalizar instalación" }, "FINAL": { From 555faa02f5629eb4d97a7e0522af5c890cc8a8a0 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 27 Feb 2017 17:18:37 -0300 Subject: [PATCH 11/17] new translations for configure --- client/coral-admin/src/translations.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index 7219a22ca..e32d3fb9d 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -86,7 +86,7 @@ "comment-count-text-post": " characters.", "comment-count-error": "Please enter a valid number.", "domain-list-title": "Domain Whitelist", - "domain-list-text": "Some instructions on how to type the urls." + "domain-list-text": "Enter the domains you would like to permit for Talk, e.g. your local, staging and production environments (ex. localhost:3000, staging.domain.com, domain.com)." }, "bandialog": { "ban_user": "Ban User?", @@ -206,7 +206,7 @@ "comment-count-text-post": " caracteres", "comment-count-error": "Por favor escribe un número válido.", "domain-list-title": "Lista de Dominios Permitidos", - "domain-list-text": "Instrucciones de como ingresar las URLs." + "domain-list-text": "Agrega dominios permitidos a Talk, e.g. tu localhost, staging y ambientes de production (ex. localhost:3000, staging.domain.com, domain.com)." }, "embedlink": { "copy": "Copiar" From bf23fc29740ba1f70cd15dbbde9acfef555cbf2e Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 28 Feb 2017 12:02:51 -0500 Subject: [PATCH 12/17] Moving comment id into query. --- client/coral-embed-stream/src/Embed.js | 3 ++- client/coral-embed/index.js | 17 +++++++++++------ .../graphql/queries/commentQuery.graphql | 13 +++++++++++++ client/coral-framework/graphql/queries/index.js | 9 +++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 client/coral-framework/graphql/queries/commentQuery.graphql diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index ac9c09eac..b0f5d5c5a 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -12,7 +12,7 @@ const {logout, showSignInDialog, requestConfirmEmail} = authActions; const {addNotification, clearNotification} = notificationActions; const {fetchAssetSuccess} = assetActions; -import {queryStream} from 'coral-framework/graphql/queries'; +import {queryStream, commentQuery} from 'coral-framework/graphql/queries'; import {postComment, postFlag, postLike, postDontAgree, deleteAction} from 'coral-framework/graphql/mutations'; import {editName} from 'coral-framework/actions/user'; import {updateCountCache} from 'coral-framework/actions/asset'; @@ -251,5 +251,6 @@ export default compose( postLike, postDontAgree, deleteAction, + commentQuery, queryStream )(Embed); diff --git a/client/coral-embed/index.js b/client/coral-embed/index.js index 4a7e753ca..9f3b23aaf 100644 --- a/client/coral-embed/index.js +++ b/client/coral-embed/index.js @@ -58,10 +58,11 @@ // ensure el has an id, as pym can't directly accept the HTMLElement if ( ! el.id) {el.id = '_' + String(Math.random());} - var asset = opts.asset || window.location; + var asset = opts.asset || window.location.href.split('#')[0]; + var comment = window.location.hash.slice(1); var pymParent = new pym.Parent( el.id, - buildStreamIframeUrl(opts.talk, asset), + buildStreamIframeUrl(opts.talk, asset, comment), { title: opts.title, asset_url: asset, @@ -76,14 +77,18 @@ return Coral; // build the URL to load in the pym iframe - function buildStreamIframeUrl(talkBaseUrl, asset) { - var iframeUrl = [ + function buildStreamIframeUrl(talkBaseUrl, asset, comment) { + var iframeArray = [ talkBaseUrl, (talkBaseUrl.match(/\/$/) ? '' : '/'), // make sure no double-'/' if opts.talk already ends with '/' 'embed/stream?asset_url=', encodeURIComponent(asset) - ].join(''); - return iframeUrl; + ]; + + if (comment) { + iframeArray.push(`&comment_id=${comment}`); + } + return iframeArray.join(''); } // Set up postMessage listeners/handlers on the pymParent diff --git a/client/coral-framework/graphql/queries/commentQuery.graphql b/client/coral-framework/graphql/queries/commentQuery.graphql new file mode 100644 index 000000000..83f92b8f5 --- /dev/null +++ b/client/coral-framework/graphql/queries/commentQuery.graphql @@ -0,0 +1,13 @@ +#import "../fragments/commentView.graphql" + +query commentQuery($id: ID!) { + comment(id: $id) { + ...commentView + parent { + ...commentView + replies { + ...commentView + } + } + } +} diff --git a/client/coral-framework/graphql/queries/index.js b/client/coral-framework/graphql/queries/index.js index c993dfb6a..8d61c9f8b 100644 --- a/client/coral-framework/graphql/queries/index.js +++ b/client/coral-framework/graphql/queries/index.js @@ -2,6 +2,7 @@ import {graphql} from 'react-apollo'; import STREAM_QUERY from './streamQuery.graphql'; import LOAD_MORE from './loadMore.graphql'; import GET_COUNTS from './getCounts.graphql'; +import COMMENT_QUERY from './commentQuery.graphql'; import MY_COMMENT_HISTORY from './myCommentHistory.graphql'; function getQueryVariable(variable) { @@ -97,4 +98,12 @@ export const queryStream = graphql(STREAM_QUERY, { }) }); +export const commentQuery = graphql(COMMENT_QUERY, { + options: () => ({ + variables: { + id: getQueryVariable('comment_id') + } + }) +}); + export const myCommentHistory = graphql(MY_COMMENT_HISTORY, {}); From 3bfde67d5821d7fbc25c01488675ab94cff7ad34 Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Tue, 28 Feb 2017 12:32:51 -0500 Subject: [PATCH 13/17] Copy updates with translations --- .../src/containers/Install/translations.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index 8f651240c..0b702a81d 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -1,11 +1,11 @@ { "en": { "INITIAL" : { - "DESCRIPTION": "The remainder of the Talk installation will take about ten minutes. Once you complete the following two steps, you will have a free installation and provision of Mongo and Redis.", + "DESCRIPTION": "Let's set up your Talk community in just a few short steps.", "SUBMIT": "Get Started" }, "ADD_ORGANIZATION": { - "DESCRIPTION": "Please tell us the name of your organization. This will appear in emails when inviting new team members", + "DESCRIPTION": "Please tell us the name of your organization. This will appear in emails when inviting new team members.", "LABEL": "Organization Name", "SAVE": "Save" }, @@ -22,18 +22,18 @@ "SUBMIT": "Finish install" }, "FINAL": { - "DESCRIPTION": "Thanks for installing Talk! We sent an email to verify your email address. While you finish setting the account, you can start engaging with your readers now.", + "DESCRIPTION": "Thanks for installing Talk! We sent an email to verify your email address. While you finish setting up the account, you can start engaging with your readers now.", "LAUNCH": "Launch Talk", "CLOSE": "Close this Installer" } }, "es": { "INITIAL" : { - "DESCRIPTION": "La instalación de Talk tomará aproximadamente diez minutos. Tan pronto como termines los tres pasos, tendrás una gratis instalación y provision de Mongo y Redis", + "DESCRIPTION": "Configuremos su comunidad de Talk en sólo algunos pasos.", "SUBMIT": "Empezá!" }, "ADD_ORGANIZATION": { - "DESCRIPTION": "Por favor, dinos el nombre de tu organización. Este aparecerá en los emails cuando invites nuevos miembros", + "DESCRIPTION": "Por favor, dinos el nombre de tu organización. Este aparecerá en los emails cuando invites nuevos miembros.", "LABEL": "Nombre de la Organización", "SAVE": "Guardar" }, From b3b10efbbabfd1016eaeb3c5fbf094f5cf6e0b19 Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Tue, 28 Feb 2017 12:35:20 -0500 Subject: [PATCH 14/17] =?UTF-8?q?Use=20t=C3=BA=20to=20match=20other=20tran?= =?UTF-8?q?slations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/coral-admin/src/containers/Install/translations.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/Install/translations.json b/client/coral-admin/src/containers/Install/translations.json index 0b702a81d..e5b9f1542 100644 --- a/client/coral-admin/src/containers/Install/translations.json +++ b/client/coral-admin/src/containers/Install/translations.json @@ -29,7 +29,7 @@ }, "es": { "INITIAL" : { - "DESCRIPTION": "Configuremos su comunidad de Talk en sólo algunos pasos.", + "DESCRIPTION": "Configuremos tu comunidad de Talk en sólo algunos pasos.", "SUBMIT": "Empezá!" }, "ADD_ORGANIZATION": { From 158f31d603d8f1d755d08a17dba61e246758ee30 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 28 Feb 2017 13:55:28 -0500 Subject: [PATCH 15/17] Highlighting permalinked comment. --- client/coral-embed-stream/src/Comment.js | 10 ++- client/coral-embed-stream/src/Embed.js | 78 ++++++++++++++----- client/coral-embed-stream/src/Stream.js | 19 +---- client/coral-embed-stream/style/default.css | 5 ++ .../coral-framework/graphql/queries/index.js | 12 +-- .../graphql/queries/streamQuery.graphql | 11 ++- 6 files changed, 85 insertions(+), 50 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 7262d10ed..8a81f9fe6 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -38,12 +38,12 @@ class Comment extends React.Component { // id of currently opened ReplyBox. tracked in Stream.js activeReplyBox: PropTypes.string.isRequired, setActiveReplyBox: PropTypes.func.isRequired, - refetch: PropTypes.func.isRequired, showSignInDialog: PropTypes.func.isRequired, postFlag: PropTypes.func.isRequired, postLike: PropTypes.func.isRequired, deleteAction: PropTypes.func.isRequired, parentId: PropTypes.string, + highlighted: PropTypes.string, addNotification: PropTypes.func.isRequired, postItem: PropTypes.func.isRequired, depth: PropTypes.number.isRequired, @@ -85,10 +85,10 @@ class Comment extends React.Component { asset, depth, postItem, - refetch, addNotification, showSignInDialog, postLike, + highlighted, postFlag, postDontAgree, loadMore, @@ -100,10 +100,12 @@ class Comment extends React.Component { const like = getActionSummary('LikeActionSummary', comment); const flag = getActionSummary('FlagActionSummary', comment); const dontagree = getActionSummary('DontAgreeActionSummary', comment); + let commentClass = parentId ? `reply ${styles.Reply}` : `comment ${styles.Comment}`; + commentClass += highlighted === comment.id ? ' highlighted-comment' : ''; return (

@@ -158,7 +160,6 @@ class Comment extends React.Component { comment.replies && comment.replies.map(reply => { return { @@ -60,22 +61,24 @@ class Embed extends Component { componentDidMount () { pym.sendMessage('childReady'); - pym.onMessage('DOMContentLoaded', hash => { - const commentId = hash.replace('#', 'c_'); - let count = 0; - const interval = setInterval(() => { - if (document.getElementById(commentId)) { - window.clearInterval(interval); - pym.scrollParentToChildEl(commentId); - } + // pym.onMessage('DOMContentLoaded', hash => { - if (++count > 100) { // ~10 seconds - // give up waiting for the comments to load. - // it would be weird for the page to jump after that long. - window.clearInterval(interval); - } - }, 100); - }); + // const commentId = hash.replace('#', 'c_'); + // let count = 0; + + // const interval = setInterval(() => { + // if (document.getElementById(commentId)) { + // window.clearInterval(interval); + // pym.scrollParentToChildEl(commentId); + // } + // + // if (++count > 100) { // ~10 seconds + // // give up waiting for the comments to load. + // // it would be weird for the page to jump after that long. + // window.clearInterval(interval); + // } + // }, 100); + // }); } componentWillReceiveProps (nextProps) { @@ -83,13 +86,27 @@ class Embed extends Component { if(!isEqual(nextProps.data.asset, this.props.data.asset)) { loadAsset(nextProps.data.asset); } + + // if(!isEqual(nextProps.data.comment, this.props.data.comment)) { + // pym.scrollParentToChildEl(nextProps.data.comment.id); + // } + } + + setActiveReplyBox (reactKey) { + if (!this.props.currentUser) { + const offset = document.getElementById(`c_${reactKey}`).getBoundingClientRect().top - 75; + this.props.showSignInDialog(offset); + } else { + this.setState({activeReplyBox: reactKey}); + } } render () { const {activeTab} = this.state; const {closedAt, countCache = {}} = this.props.asset; - const {loading, asset, refetch} = this.props.data; + const {loading, asset, refetch, comment} = this.props.data; const {loggedIn, isAdmin, user, showSignInDialog, signInOffset} = this.props.auth; + const highlightedComment = comment && comment.parent ? comment.parent : comment; const openStream = closedAt === null; @@ -159,6 +176,28 @@ class Embed extends Component { } {!loggedIn && } {loggedIn && user && } + { + highlightedComment && + + } ({limit, cursor, parent_id, asset_id, sort}, n export const queryStream = graphql(STREAM_QUERY, { options: () => ({ variables: { - asset_url: getQueryVariable('asset_url') + asset_url: getQueryVariable('asset_url'), + comment_id: getQueryVariable('comment_id') } }), props: ({data}) => ({ @@ -98,12 +98,4 @@ export const queryStream = graphql(STREAM_QUERY, { }) }); -export const commentQuery = graphql(COMMENT_QUERY, { - options: () => ({ - variables: { - id: getQueryVariable('comment_id') - } - }) -}); - export const myCommentHistory = graphql(MY_COMMENT_HISTORY, {}); diff --git a/client/coral-framework/graphql/queries/streamQuery.graphql b/client/coral-framework/graphql/queries/streamQuery.graphql index 0a7f6c549..4f09f628e 100644 --- a/client/coral-framework/graphql/queries/streamQuery.graphql +++ b/client/coral-framework/graphql/queries/streamQuery.graphql @@ -1,6 +1,15 @@ #import "../fragments/commentView.graphql" -query AssetQuery($asset_url: String!) { +query AssetQuery($asset_url: String!, $comment_id: ID!) { + comment(id: $comment_id) { + ...commentView + parent { + ...commentView + replies { + ...commentView + } + } + } asset(url: $asset_url) { id title From 62fe63d323c34cb42ebc5fa2e5f60271669f889e Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 28 Feb 2017 14:27:53 -0500 Subject: [PATCH 16/17] Scrolling to permalinked comment or reply. --- client/coral-embed-stream/src/Embed.js | 29 +++++++------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 2854de68c..5526d70e1 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -60,25 +60,6 @@ class Embed extends Component { componentDidMount () { pym.sendMessage('childReady'); - - // pym.onMessage('DOMContentLoaded', hash => { - - // const commentId = hash.replace('#', 'c_'); - // let count = 0; - - // const interval = setInterval(() => { - // if (document.getElementById(commentId)) { - // window.clearInterval(interval); - // pym.scrollParentToChildEl(commentId); - // } - // - // if (++count > 100) { // ~10 seconds - // // give up waiting for the comments to load. - // // it would be weird for the page to jump after that long. - // window.clearInterval(interval); - // } - // }, 100); - // }); } componentWillReceiveProps (nextProps) { @@ -86,10 +67,14 @@ class Embed extends Component { if(!isEqual(nextProps.data.asset, this.props.data.asset)) { loadAsset(nextProps.data.asset); } + } - // if(!isEqual(nextProps.data.comment, this.props.data.comment)) { - // pym.scrollParentToChildEl(nextProps.data.comment.id); - // } + componentDidUpdate(prevProps) { + if(!isEqual(prevProps.data.comment, this.props.data.comment)) { + + // Scroll to a permalinked comment if one is in the URL once the page is done rendering. + setTimeout(()=>pym.scrollParentToChildEl(`c_${this.props.data.comment.id}`), 0); + } } setActiveReplyBox (reactKey) { From d8117494d1f968bb6452bcd3a98ab6141959699c Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 28 Feb 2017 18:18:17 -0500 Subject: [PATCH 17/17] Cleaning up after merge conflict. --- graph/loaders/comments.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/graph/loaders/comments.js b/graph/loaders/comments.js index 6c9d4bcbc..afa79ea5c 100644 --- a/graph/loaders/comments.js +++ b/graph/loaders/comments.js @@ -39,14 +39,7 @@ const getCountsByAssetID = (context, asset_ids) => { /** * Returns the comment count for all comments that are public based on their * parent ids. - * @param {Object} - - - - - - - graph context + * * @param {Array} parent_ids the ids of parents for which there are * comments that we want to get */ @@ -284,7 +277,7 @@ const genRecentComments = (_, ids) => { * @return {Promise} resolves to the comments */ const genComments = ({user}, ids) => { - let comments + let comments; if (user && user.hasRoles('ADMIN')) { comments = CommentModel.find({ id: { @@ -300,11 +293,8 @@ const genComments = ({user}, ids) => { $in: ['NONE', 'ACCEPTED'] } }); + } return comments.then(util.singleJoinBy(ids, 'id')); - - */ -const genCommentsByID = (context, ids) => { - }; /**