From 4426be5f397d6529f6dd94cb5915bebc5c37041d Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 May 2018 13:56:05 -0600 Subject: [PATCH 01/13] improved dev experience, fixed css order --- client/coral-admin/src/components/App.css | 9 +++ client/coral-admin/src/components/App.js | 1 + middleware/staticTemplate.js | 8 ++- package.json | 1 + public/css/dev.css | 5 ++ routes/dev/assets.js | 45 ++++++++----- routes/dev/index.js | 2 - services/assets.js | 6 -- views/admin.ejs | 9 +-- views/dev/article.ejs | 80 ++++++++++------------- views/dev/articles.ejs | 50 ++++++++++---- views/embed/stream.ejs | 1 + views/login.ejs | 1 + views/partials/account.ejs | 3 +- views/partials/custom-css.ejs | 1 + views/partials/dev-nav.ejs | 8 +++ views/partials/dev.ejs | 5 ++ views/partials/head.ejs | 3 - yarn.lock | 15 +++++ 19 files changed, 158 insertions(+), 95 deletions(-) create mode 100644 client/coral-admin/src/components/App.css create mode 100644 public/css/dev.css create mode 100644 views/partials/custom-css.ejs create mode 100644 views/partials/dev-nav.ejs create mode 100644 views/partials/dev.ejs diff --git a/client/coral-admin/src/components/App.css b/client/coral-admin/src/components/App.css new file mode 100644 index 000000000..1404a9293 --- /dev/null +++ b/client/coral-admin/src/components/App.css @@ -0,0 +1,9 @@ +html, body, #root, #root > div { + min-height: 100%; +} + +body { + margin: 0; + background-color: #FAFAFA; + font-family: 'Roboto', sans-serif; +} diff --git a/client/coral-admin/src/components/App.js b/client/coral-admin/src/components/App.js index 52535f91a..a7ab1e336 100644 --- a/client/coral-admin/src/components/App.js +++ b/client/coral-admin/src/components/App.js @@ -1,5 +1,6 @@ import React from 'react'; import ToastContainer from './ToastContainer'; +import './App.css'; import 'material-design-lite'; import AppRouter from '../AppRouter'; diff --git a/middleware/staticTemplate.js b/middleware/staticTemplate.js index f16caaea9..d8137693e 100644 --- a/middleware/staticTemplate.js +++ b/middleware/staticTemplate.js @@ -94,9 +94,13 @@ const createResolveFactory = (() => { module.exports = async (req, res, next) => { try { - // Attach the custom css url. - const { customCssUrl } = await SettingsService.select('customCssUrl'); + // Attach the custom css url and organization name. + const { customCssUrl, organizationName } = await SettingsService.select( + 'customCssUrl', + 'organizationName' + ); res.locals.customCssUrl = customCssUrl; + res.locals.organizationName = organizationName; } catch (err) { console.warn(err); } diff --git a/package.json b/package.json index f6ff46a59..01b671dde 100644 --- a/package.json +++ b/package.json @@ -219,6 +219,7 @@ "babel-plugin-dynamic-import-node": "^1.1.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", "browserstack-local": "^1.3.0", + "casual": "^1.5.19", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", "chai-datetime": "^1.5.0", diff --git a/public/css/dev.css b/public/css/dev.css new file mode 100644 index 000000000..73ccaed2c --- /dev/null +++ b/public/css/dev.css @@ -0,0 +1,5 @@ +.container { + width: auto; + max-width: 680px; + padding: 0 15px; +} diff --git a/routes/dev/assets.js b/routes/dev/assets.js index cb1f27e43..aea0628e3 100644 --- a/routes/dev/assets.js +++ b/routes/dev/assets.js @@ -1,49 +1,58 @@ const express = require('express'); const router = express.Router(); - -const errors = require('../../errors'); -const Assets = require('../../services/assets'); - -const body = - 'Lorem ipsum dolor sponge amet, consectetur adipiscing clam. Ut lobortis sollicitudin pillar a ornare. Curabitur dignissim vestibulum cay non rhoncus. Cras laoreet ante vel nunc hendrerit, shelf imperdiet neque egestas. Suspendisse aliquet iaculis fermentum. Talk volutpat, tellus posuere laoreet consequat, mi lacus laoreet massa, sed vehicula mauris velit non lectus. Integer non trust nec neque congue faucibus porttitor sit amet elkhorn.'; +const casual = require('casual'); +const { ErrNotFound } = require('../../errors'); +const Asset = require('../../models/asset'); router.get('/id/:asset_id', async (req, res, next) => { try { - const asset = await Assets.findById(req.params.asset_id); + const asset = await Asset.findOne({ id: req.params.asset_id }); if (asset === null) { - return next(errors.ErrNotFound); + throw new ErrNotFound(); } res.render('dev/article', { title: asset.title, asset_id: asset.id, asset_url: asset.url, - body: '', - basePath: '/client/embed/stream', }); } catch (err) { return next(err); } }); +router.get('/random', (req, res) => { + const title = casual.title; + + res.redirect(`./title/${title.replace(/ /g, '-')}`); +}); + router.get('/title/:asset_title', (req, res) => { - return res.render('dev/article', { + res.render('dev/article', { title: req.params.asset_title.split('-').join(' '), asset_url: '', asset_id: null, - body: body, - basePath: '/client/embed/stream', }); }); router.get('/', async (req, res, next) => { - let skip = req.query.skip ? parseInt(req.query.skip) : 0; - let limit = req.query.limit ? parseInt(req.query.limit) : 25; - try { - const assets = await Assets.all(skip, limit); + const skip = req.query.skip ? parseInt(req.query.skip) : 0; + const limit = req.query.limit ? parseInt(req.query.limit) : 6; + + const [assets, count] = await Promise.all([ + Asset.find({}) + .sort({ created_at: 1 }) + .limit(limit) + .skip(skip), + Asset.count(), + ]); + res.render('dev/articles', { - assets: assets, + skip, + limit, + count, + assets, }); } catch (err) { return next(err); diff --git a/routes/dev/index.js b/routes/dev/index.js index ac72db254..58daca583 100644 --- a/routes/dev/index.js +++ b/routes/dev/index.js @@ -16,8 +16,6 @@ router.get('/', staticTemplate, async (req, res) => { title: 'Coral Talk', asset_url: '', asset_id: '', - body: '', - basePath: '/static/embed/stream', }); } }); diff --git a/services/assets.js b/services/assets.js index 794145eb3..5f1fa989d 100644 --- a/services/assets.js +++ b/services/assets.js @@ -232,11 +232,5 @@ module.exports = class AssetsService { await AssetModel.remove({ id: srcAssetID, }); - - // That's it! - } - - static all(limit = undefined) { - return AssetModel.find({}).limit(limit); } }; diff --git a/views/admin.ejs b/views/admin.ejs index b8f775d79..89cc150f7 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -3,16 +3,11 @@ Talk - Coral Admin - + <%- include partials/head %> - - - <%- include partials/head %> + <%- include partials/custom-css %>
diff --git a/views/dev/article.ejs b/views/dev/article.ejs index 8abfc34af..008d3989e 100644 --- a/views/dev/article.ejs +++ b/views/dev/article.ejs @@ -8,53 +8,45 @@ - - <%= title %> + <%- include ../partials/dev %> -
-

<%= title %>

-

<%= body %>

-

Admin - All Assets

-
- + -
+ * You can listen to events using the example below. + * The argument passed is the event emitter from + * https://github.com/asyncly/EventEmitter2 + * + * events: function(events) { + * events.onAny(function(eventName, data) { + * console.log(eventName, data); + * }); + * }, + */ + plugins_config: { + /** + * You can disable rendering slot components of a plugin by doing: + * + * 'talk-plugin-love': { + * disable_components: true, + * }, + */ + test: 'data', + debug: false + } + }) + + diff --git a/views/dev/articles.ejs b/views/dev/articles.ejs index 0ce684029..3a67b53c5 100644 --- a/views/dev/articles.ejs +++ b/views/dev/articles.ejs @@ -1,14 +1,40 @@ - -

- Asset list -

-<% assets.forEach(function (asset) { %> - <%= asset.url %>
-<% }) %> -

- (For dev use only. FYI, you can: ?skip=100&limit=25) -

- - + + All Assets + <%- include ../partials/dev %> + + + <%- include ../partials/dev-nav %> +
+
+

All Assets

+ <%= skip + 1 %> - <%= skip + assets.length %> of <%= count %> +
+
+ <% if (skip === 0) { %> Create a random article<% } %> + <% assets.forEach(function (asset) { %> + +
+
<%= asset.title %>
+ Created <%= asset.created_at.toLocaleString('en-US') %> +
+ <%= asset.url %> +
+ <% }) %> +
+ <% if (count !== assets.length) { %> + + <% } %> +
+ diff --git a/views/embed/stream.ejs b/views/embed/stream.ejs index 2027f6069..a1c708b55 100644 --- a/views/embed/stream.ejs +++ b/views/embed/stream.ejs @@ -5,6 +5,7 @@ <%- include ../partials/head %> + <%- include ../partials/custom-css %>
diff --git a/views/login.ejs b/views/login.ejs index c5a86c2fb..671b25c83 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -6,6 +6,7 @@ <%- include partials/head %> + <%- include partials/custom-css %>
diff --git a/views/partials/account.ejs b/views/partials/account.ejs index 79857baf0..ff2166816 100644 --- a/views/partials/account.ejs +++ b/views/partials/account.ejs @@ -1,3 +1,4 @@ -<%- include ./head %> +<%- include head %> +<%- include custom-css %> diff --git a/views/partials/custom-css.ejs b/views/partials/custom-css.ejs new file mode 100644 index 000000000..d453c37e1 --- /dev/null +++ b/views/partials/custom-css.ejs @@ -0,0 +1 @@ +<% if (locals.customCssUrl) { %><% } %> diff --git a/views/partials/dev-nav.ejs b/views/partials/dev-nav.ejs new file mode 100644 index 000000000..0d6d067d6 --- /dev/null +++ b/views/partials/dev-nav.ejs @@ -0,0 +1,8 @@ + diff --git a/views/partials/dev.ejs b/views/partials/dev.ejs new file mode 100644 index 000000000..691b548e5 --- /dev/null +++ b/views/partials/dev.ejs @@ -0,0 +1,5 @@ + + + + + diff --git a/views/partials/head.ejs b/views/partials/head.ejs index e848b3909..dc3df7103 100644 --- a/views/partials/head.ejs +++ b/views/partials/head.ejs @@ -18,9 +18,6 @@ -<%_ if (locals.customCssUrl) { _%> - -<%_ } _%> <%- include data %> diff --git a/yarn.lock b/yarn.lock index 5cf363b6e..f0da6d006 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1828,6 +1828,13 @@ caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" +casual@^1.5.19: + version "1.5.19" + resolved "https://registry.yarnpkg.com/casual/-/casual-1.5.19.tgz#66fac46f7ae463f468f5913eb139f9c41c58bbf2" + dependencies: + mersenne-twister "^1.0.1" + moment "^2.15.2" + center-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" @@ -7154,6 +7161,10 @@ merge@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" +mersenne-twister@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" + metascraper-author@^3.9.2: version "3.9.2" resolved "https://registry.yarnpkg.com/metascraper-author/-/metascraper-author-3.9.2.tgz#ff2020ac428f59a875d655df3b0d4bea171fde19" @@ -7436,6 +7447,10 @@ moment@^2.10.3: version "2.19.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.19.1.tgz#56da1a2d1cbf01d38b7e1afc31c10bcfa1929167" +moment@^2.15.2: + version "2.22.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad" + mongodb-core@2.1.17: version "2.1.17" resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.17.tgz#a418b337a14a14990fb510b923dee6a813173df8" From 55a9c1e6b4a64e5a85556b48c7da4072b636edf9 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 May 2018 14:05:16 -0600 Subject: [PATCH 02/13] added link to graphiql --- public/css/dev.css | 4 ++++ views/partials/dev-nav.ejs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/css/dev.css b/public/css/dev.css index 73ccaed2c..2fd6c1982 100644 --- a/public/css/dev.css +++ b/public/css/dev.css @@ -3,3 +3,7 @@ max-width: 680px; padding: 0 15px; } + +.graphiql em { + font-family: georgia; +} diff --git a/views/partials/dev-nav.ejs b/views/partials/dev-nav.ejs index 0d6d067d6..088c52c20 100644 --- a/views/partials/dev-nav.ejs +++ b/views/partials/dev-nav.ejs @@ -2,7 +2,7 @@ <%= organizationName %> Organization
Admin - Development + GraphiQL All Assets
From 302cab8ca02150f1329cd217b65b0d503cdaa6dc Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 May 2018 14:12:27 -0600 Subject: [PATCH 03/13] added header to graphiql --- views/api/graphiql.ejs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/views/api/graphiql.ejs b/views/api/graphiql.ejs index b6d609de6..8007569b3 100644 --- a/views/api/graphiql.ejs +++ b/views/api/graphiql.ejs @@ -5,13 +5,17 @@ GraphiQL + <%- include ../partials/dev %> @@ -20,6 +24,8 @@ + <%- include ../partials/dev-nav %> +
- \ No newline at end of file + From 969206f9057ffac2c9b68e110014128b018846c2 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 May 2018 14:14:48 -0600 Subject: [PATCH 04/13] copy adjustment --- views/dev/articles.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/dev/articles.ejs b/views/dev/articles.ejs index 3a67b53c5..1b07ed116 100644 --- a/views/dev/articles.ejs +++ b/views/dev/articles.ejs @@ -8,7 +8,7 @@

All Assets

- <%= skip + 1 %> - <%= skip + assets.length %> of <%= count %> + <%= skip + 1 %> - <%= skip + assets.length %> of <%= count %> Assets
<% if (skip === 0) { %> Create a random article<% } %> From 2e37f78705dbaafd27202ea054dde01773f0fd57 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 10 May 2018 13:31:00 -0600 Subject: [PATCH 05/13] Email Attach Fixes --- client/coral-framework/components/Popup.js | 16 ++++++++++----- .../talk-plugin-local-auth/client/actions.js | 9 +++++++++ .../components/AddEmailAddressDialog.js | 20 ++++++++++++++++--- .../client/components/AddEmailContent.js | 9 +++------ .../client/constants.js | 4 ++++ .../containers/AddEmailAddressDialog.js | 16 +++++++++++---- .../talk-plugin-local-auth/client/index.js | 4 +++- .../talk-plugin-local-auth/client/reducer.js | 20 +++++++++++++++++++ plugins/talk-plugin-local-auth/index.js | 2 +- .../server/translations.yml | 9 --------- .../{client => }/translations.yml | 10 +++++++++- 11 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 plugins/talk-plugin-local-auth/client/actions.js create mode 100644 plugins/talk-plugin-local-auth/client/constants.js create mode 100644 plugins/talk-plugin-local-auth/client/reducer.js delete mode 100644 plugins/talk-plugin-local-auth/server/translations.yml rename plugins/talk-plugin-local-auth/{client => }/translations.yml (91%) diff --git a/client/coral-framework/components/Popup.js b/client/coral-framework/components/Popup.js index 53d8f7cd8..339ddb806 100644 --- a/client/coral-framework/components/Popup.js +++ b/client/coral-framework/components/Popup.js @@ -37,7 +37,8 @@ export default class Popup extends Component { this.onBlur(); }; - // Use `onunload` instead of `onbeforeunload` which is not supported in IOS Safari. + // Use `onunload` instead of `onbeforeunload` which is not supported in iOS + // Safari. this.ref.onunload = () => { this.onUnload(); @@ -46,10 +47,15 @@ export default class Popup extends Component { } this.resetCallbackInterval = setInterval(() => { - if (this.ref && this.ref.onload === null) { - clearInterval(this.resetCallbackInterval); - this.resetCallbackInterval = null; - this.setCallbacks(); + try { + if (this.ref && this.ref.onload === null) { + clearInterval(this.resetCallbackInterval); + this.resetCallbackInterval = null; + this.setCallbacks(); + } + } catch (err) { + // We could be getting a security exception here if the login page + // gets redirected to another domain to authenticate. } }, 50); diff --git a/plugins/talk-plugin-local-auth/client/actions.js b/plugins/talk-plugin-local-auth/client/actions.js new file mode 100644 index 000000000..9f2c9cfed --- /dev/null +++ b/plugins/talk-plugin-local-auth/client/actions.js @@ -0,0 +1,9 @@ +import * as actions from './constants'; + +export const startAttach = () => ({ + type: actions.STARTED_ATTACH, +}); + +export const finishAttach = () => ({ + type: actions.FINISH_ATTACH, +}); diff --git a/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js b/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js index dc7e0d974..76131c895 100644 --- a/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js +++ b/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js @@ -45,6 +45,10 @@ class AddEmailAddressDialog extends React.Component { ), }; + componentDidMount() { + this.props.startAttach(); + } + onChange = e => { const { name, value } = e.target; this.setState( @@ -99,7 +103,13 @@ class AddEmailAddressDialog extends React.Component { }); }; - confirmChanges = async () => { + finish = () => { + this.props.finishAttach(); + }; + + confirmChanges = async e => { + e.preventDefault(); + if (!this.validate()) { this.showErrors(); return; @@ -113,6 +123,8 @@ class AddEmailAddressDialog extends React.Component { email: emailAddress, password: confirmPassword, }); + + // TODO: translate this.props.notify('success', 'Email Added!'); this.goToNextStep(); } catch (err) { @@ -143,13 +155,13 @@ class AddEmailAddressDialog extends React.Component { )} {step === 1 && !settings.requireEmailConfirmation && ( - {}} /> + )} {step === 1 && settings.requireEmailConfirmation && ( {}} + done={this.finish} /> )} @@ -161,6 +173,8 @@ AddEmailAddressDialog.propTypes = { attachLocalAuth: PropTypes.func.isRequired, notify: PropTypes.func.isRequired, root: PropTypes.object.isRequired, + startAttach: PropTypes.func.isRequired, + finishAttach: PropTypes.func.isRequired, }; export default AddEmailAddressDialog; diff --git a/plugins/talk-plugin-local-auth/client/components/AddEmailContent.js b/plugins/talk-plugin-local-auth/client/components/AddEmailContent.js index 8d3fc308f..de296c812 100644 --- a/plugins/talk-plugin-local-auth/client/components/AddEmailContent.js +++ b/plugins/talk-plugin-local-auth/client/components/AddEmailContent.js @@ -41,7 +41,7 @@ const AddEmailContent = ({ -
+
diff --git a/plugins/talk-plugin-local-auth/client/constants.js b/plugins/talk-plugin-local-auth/client/constants.js new file mode 100644 index 000000000..86f5242f7 --- /dev/null +++ b/plugins/talk-plugin-local-auth/client/constants.js @@ -0,0 +1,4 @@ +const prefix = 'TALK_LOCAL_AUTH'; + +export const STARTED_ATTACH = `${prefix}_STARTED_ATTACH`; +export const FINISH_ATTACH = `${prefix}_FINISH_ATTACH`; diff --git a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js index 841dc8420..4cc80d022 100644 --- a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js +++ b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js @@ -3,10 +3,15 @@ import { bindActionCreators } from 'redux'; import { connect, withFragments, excludeIf } from 'plugin-api/beta/client/hocs'; import AddEmailAddressDialog from '../components/AddEmailAddressDialog'; import { notify } from 'coral-framework/actions/notification'; - import { withAttachLocalAuth } from '../hocs'; +import { startAttach, finishAttach } from '../actions'; -const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch); +const mapStateToProps = ({ talkPluginLocalAuth: state }) => ({ + inProgress: state.inProgress, +}); + +const mapDispatchToProps = dispatch => + bindActionCreators({ notify, startAttach, finishAttach }, dispatch); const withData = withFragments({ root: gql` @@ -23,8 +28,11 @@ const withData = withFragments({ }); export default compose( - connect(null, mapDispatchToProps), + connect(mapStateToProps, mapDispatchToProps), withAttachLocalAuth, withData, - excludeIf(({ root: { me } }) => !me || me.email) + excludeIf( + ({ root: { me }, inProgress }) => + !((me && !me.email) || (me && me.email && inProgress)) + ) )(AddEmailAddressDialog); diff --git a/plugins/talk-plugin-local-auth/client/index.js b/plugins/talk-plugin-local-auth/client/index.js index 9c89e0490..a4dc01ac2 100644 --- a/plugins/talk-plugin-local-auth/client/index.js +++ b/plugins/talk-plugin-local-auth/client/index.js @@ -1,10 +1,12 @@ import ChangePassword from './containers/ChangePassword'; import AddEmailAddressDialog from './containers/AddEmailAddressDialog'; import Profile from './containers/Profile'; -import translations from './translations.yml'; +import translations from '../translations.yml'; import graphql from './graphql'; +import reducer from './reducer'; export default { + reducer, translations, slots: { profileHeader: [Profile], diff --git a/plugins/talk-plugin-local-auth/client/reducer.js b/plugins/talk-plugin-local-auth/client/reducer.js new file mode 100644 index 000000000..403a84814 --- /dev/null +++ b/plugins/talk-plugin-local-auth/client/reducer.js @@ -0,0 +1,20 @@ +import * as actions from './constants'; + +const initialState = { + inProgress: false, +}; + +export default function reducer(state = initialState, action) { + switch (action.type) { + case actions.STARTED_ATTACH: + return { + inProgress: true, + }; + case actions.FINISH_ATTACH: + return { + inProgress: false, + }; + default: + return state; + } +} diff --git a/plugins/talk-plugin-local-auth/index.js b/plugins/talk-plugin-local-auth/index.js index 7e4ee6a3c..fabe1dd2b 100644 --- a/plugins/talk-plugin-local-auth/index.js +++ b/plugins/talk-plugin-local-auth/index.js @@ -4,7 +4,7 @@ const mutators = require('./server/mutators'); const path = require('path'); module.exports = { - translations: path.join(__dirname, 'server', 'translations.yml'), + translations: path.join(__dirname, 'translations.yml'), typeDefs, mutators, resolvers, diff --git a/plugins/talk-plugin-local-auth/server/translations.yml b/plugins/talk-plugin-local-auth/server/translations.yml deleted file mode 100644 index d81de6c6d..000000000 --- a/plugins/talk-plugin-local-auth/server/translations.yml +++ /dev/null @@ -1,9 +0,0 @@ -en: - email: - email_change_original: - subject: Email change - body: Your email address has been changed from {0} to {1}. If you did not initiate this change, please contact {2}. # TODO: update translation - error: - NO_LOCAL_PROFILE: No existing email address is associated with this account. - LOCAL_PROFILE: An email address is already associated with this account. - INCORRECT_PASSWORD: Provided password was incorrect. diff --git a/plugins/talk-plugin-local-auth/client/translations.yml b/plugins/talk-plugin-local-auth/translations.yml similarity index 91% rename from plugins/talk-plugin-local-auth/client/translations.yml rename to plugins/talk-plugin-local-auth/translations.yml index fcb80782a..7180268ea 100644 --- a/plugins/talk-plugin-local-auth/client/translations.yml +++ b/plugins/talk-plugin-local-auth/translations.yml @@ -1,4 +1,12 @@ en: + email: + email_change_original: + subject: Email change + body: Your email address has been changed from {0} to {1}. If you did not initiate this change, please contact {2}. # TODO: update translation + error: + NO_LOCAL_PROFILE: No existing email address is associated with this account. + LOCAL_PROFILE: An email address is already associated with this account. + INCORRECT_PASSWORD: Provided password was incorrect. talk-plugin-local-auth: change_password: change_password: "Change Password" @@ -43,7 +51,7 @@ en: email_does_not_match: "Email Address does not match" insert_password: "Insert Password:" required_field: "This field is required" - done: "done" + done: "Done" content: title: "Add an Email Address" description: "For your added security, we require users to add an email address to their accounts. Your email address will be used to:" From 631206f3603431d3456f445aff22f418738f48df Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 11 May 2018 00:30:12 +0200 Subject: [PATCH 06/13] Disable autofocus on IOS Safari, prevent zoom on narrow screens --- plugins/talk-plugin-rich-text/client/components/Editor.css | 7 +++++++ plugins/talk-plugin-rich-text/client/components/Editor.js | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/talk-plugin-rich-text/client/components/Editor.css b/plugins/talk-plugin-rich-text/client/components/Editor.css index 2259d01a3..be2646121 100644 --- a/plugins/talk-plugin-rich-text/client/components/Editor.css +++ b/plugins/talk-plugin-rich-text/client/components/Editor.css @@ -1,5 +1,12 @@ +@custom-media --narrow-viewport (max-width: 420px); + .commentContent { composes: content from "./CommentContent.css"; + + /* Prevent zoom on narrow viewports */ + @media (--narrow-viewport) { + font-size: 16px; + } } .placeholder { diff --git a/plugins/talk-plugin-rich-text/client/components/Editor.js b/plugins/talk-plugin-rich-text/client/components/Editor.js index e09931d38..089900e1a 100644 --- a/plugins/talk-plugin-rich-text/client/components/Editor.js +++ b/plugins/talk-plugin-rich-text/client/components/Editor.js @@ -8,6 +8,7 @@ import RTE from './rte/RTE'; import { Icon } from 'plugin-api/beta/client/components/ui'; import { Bold, Italic, Blockquote } from './rte/features'; import { t } from 'plugin-api/beta/client/services'; +import bowser from 'bowser'; class Editor extends React.Component { ref = null; @@ -40,7 +41,7 @@ class Editor extends React.Component { } }); } - if (this.props.isReply) { + if (this.props.isReply && !bowser.ios) { this.ref.focus(); } } From fc5621a06042de9b0ca42d3da720e4cfcbde1477 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 11 May 2018 17:12:28 +0200 Subject: [PATCH 07/13] Add reference to story --- plugins/talk-plugin-rich-text/client/components/Editor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/talk-plugin-rich-text/client/components/Editor.js b/plugins/talk-plugin-rich-text/client/components/Editor.js index 089900e1a..99d2be617 100644 --- a/plugins/talk-plugin-rich-text/client/components/Editor.js +++ b/plugins/talk-plugin-rich-text/client/components/Editor.js @@ -41,6 +41,8 @@ class Editor extends React.Component { } }); } + + // Skip IOS due to a bug, see https://www.pivotaltracker.com/story/show/157434928 if (this.props.isReply && !bowser.ios) { this.ref.focus(); } From 42d4abf8426b499bc9722c7ac1a2ea5f29b7fc2c Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 11 May 2018 09:33:18 -0600 Subject: [PATCH 08/13] review updates --- plugins/talk-plugin-local-auth/client/actions.js | 2 +- .../client/components/AddEmailAddressDialog.js | 6 ++++-- plugins/talk-plugin-local-auth/client/constants.js | 2 +- plugins/talk-plugin-local-auth/client/reducer.js | 2 +- plugins/talk-plugin-local-auth/translations.yml | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/talk-plugin-local-auth/client/actions.js b/plugins/talk-plugin-local-auth/client/actions.js index 9f2c9cfed..972e1f6fd 100644 --- a/plugins/talk-plugin-local-auth/client/actions.js +++ b/plugins/talk-plugin-local-auth/client/actions.js @@ -1,7 +1,7 @@ import * as actions from './constants'; export const startAttach = () => ({ - type: actions.STARTED_ATTACH, + type: actions.START_ATTACH, }); export const finishAttach = () => ({ diff --git a/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js b/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js index 76131c895..a5bfd7096 100644 --- a/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js +++ b/plugins/talk-plugin-local-auth/client/components/AddEmailAddressDialog.js @@ -124,8 +124,10 @@ class AddEmailAddressDialog extends React.Component { password: confirmPassword, }); - // TODO: translate - this.props.notify('success', 'Email Added!'); + this.props.notify( + 'success', + t('talk-plugin-local-auth.add_email.added.alert') + ); this.goToNextStep(); } catch (err) { this.props.notify('error', getErrorMessages(err)); diff --git a/plugins/talk-plugin-local-auth/client/constants.js b/plugins/talk-plugin-local-auth/client/constants.js index 86f5242f7..d410a10fa 100644 --- a/plugins/talk-plugin-local-auth/client/constants.js +++ b/plugins/talk-plugin-local-auth/client/constants.js @@ -1,4 +1,4 @@ const prefix = 'TALK_LOCAL_AUTH'; -export const STARTED_ATTACH = `${prefix}_STARTED_ATTACH`; +export const START_ATTACH = `${prefix}_START_ATTACH`; export const FINISH_ATTACH = `${prefix}_FINISH_ATTACH`; diff --git a/plugins/talk-plugin-local-auth/client/reducer.js b/plugins/talk-plugin-local-auth/client/reducer.js index 403a84814..11666e505 100644 --- a/plugins/talk-plugin-local-auth/client/reducer.js +++ b/plugins/talk-plugin-local-auth/client/reducer.js @@ -6,7 +6,7 @@ const initialState = { export default function reducer(state = initialState, action) { switch (action.type) { - case actions.STARTED_ATTACH: + case actions.START_ATTACH: return { inProgress: true, }; diff --git a/plugins/talk-plugin-local-auth/translations.yml b/plugins/talk-plugin-local-auth/translations.yml index 7180268ea..5fd2264e6 100644 --- a/plugins/talk-plugin-local-auth/translations.yml +++ b/plugins/talk-plugin-local-auth/translations.yml @@ -67,6 +67,7 @@ en: subtitle: "Need to change your email address?" description_2: "You can change your account settings by visiting" path: "My Profile > Settings" + alert: "Email Added!" es: talk-plugin-local-auth: change_password: From faa0ee8ceb2f6ef1504906e4e49060bffe1ce465 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 11 May 2018 10:22:45 -0600 Subject: [PATCH 09/13] added global wrap --- client/coral-admin/src/components/App.css | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/client/coral-admin/src/components/App.css b/client/coral-admin/src/components/App.css index 1404a9293..39c7cf942 100644 --- a/client/coral-admin/src/components/App.css +++ b/client/coral-admin/src/components/App.css @@ -1,9 +1,11 @@ -html, body, #root, #root > div { - min-height: 100%; -} +:global { + html, body, #root, #root > div { + min-height: 100%; + } -body { - margin: 0; - background-color: #FAFAFA; - font-family: 'Roboto', sans-serif; + body { + margin: 0; + background-color: #FAFAFA; + font-family: 'Roboto', sans-serif; + } } From f018ccf33ee894ed75c097070b623cfb71de038c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 11 May 2018 18:38:41 +0200 Subject: [PATCH 10/13] Prevent showing add email address dialog when usernam is not set --- .../client/containers/AddEmailAddressDialog.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js index 4cc80d022..d8ccd18b0 100644 --- a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js +++ b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js @@ -19,6 +19,13 @@ const withData = withFragments({ me { id email + state { + status { + username { + status + } + } + } } settings { requireEmailConfirmation @@ -33,6 +40,7 @@ export default compose( withData, excludeIf( ({ root: { me }, inProgress }) => + me.state.status.username.status === 'UNSET' || !((me && !me.email) || (me && me.email && inProgress)) ) )(AddEmailAddressDialog); From 6cf4203c9b7ca9db28ec253ef469ddeb45398cea Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 11 May 2018 11:38:54 -0600 Subject: [PATCH 11/13] Update translations.yml --- plugins/talk-plugin-local-auth/translations.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/talk-plugin-local-auth/translations.yml b/plugins/talk-plugin-local-auth/translations.yml index 5fd2264e6..7f67e33bd 100644 --- a/plugins/talk-plugin-local-auth/translations.yml +++ b/plugins/talk-plugin-local-auth/translations.yml @@ -2,7 +2,7 @@ en: email: email_change_original: subject: Email change - body: Your email address has been changed from {0} to {1}. If you did not initiate this change, please contact {2}. # TODO: update translation + body: Your email address has been changed from {0} to {1}. If you did not request this change, please contact {2}. error: NO_LOCAL_PROFILE: No existing email address is associated with this account. LOCAL_PROFILE: An email address is already associated with this account. From f0dcd844a787d5309b90509806389ddfccba4455 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 11 May 2018 20:44:45 +0200 Subject: [PATCH 12/13] Fix excludeIf condition --- .../client/containers/AddEmailAddressDialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js index d8ccd18b0..44ee17df7 100644 --- a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js +++ b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js @@ -40,7 +40,8 @@ export default compose( withData, excludeIf( ({ root: { me }, inProgress }) => + !me || me.state.status.username.status === 'UNSET' || - !((me && !me.email) || (me && me.email && inProgress)) + (me.email && !inProgress) ) )(AddEmailAddressDialog); From 7d8d5a6115ef0b77103c39143368f6655f7f46ee Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 11 May 2018 20:46:32 +0200 Subject: [PATCH 13/13] Use lodash get --- .../client/containers/AddEmailAddressDialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js index 44ee17df7..f6de3b39c 100644 --- a/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js +++ b/plugins/talk-plugin-local-auth/client/containers/AddEmailAddressDialog.js @@ -5,6 +5,7 @@ import AddEmailAddressDialog from '../components/AddEmailAddressDialog'; import { notify } from 'coral-framework/actions/notification'; import { withAttachLocalAuth } from '../hocs'; import { startAttach, finishAttach } from '../actions'; +import get from 'lodash/get'; const mapStateToProps = ({ talkPluginLocalAuth: state }) => ({ inProgress: state.inProgress, @@ -41,7 +42,7 @@ export default compose( excludeIf( ({ root: { me }, inProgress }) => !me || - me.state.status.username.status === 'UNSET' || + get(me, 'state.status.username.status') === 'UNSET' || (me.email && !inProgress) ) )(AddEmailAddressDialog);