From aa51ae82f0d1bd0b9e8995ef828ac5111e04a6ed Mon Sep 17 00:00:00 2001 From: undemian Date: Mon, 26 Mar 2018 12:00:43 +0300 Subject: [PATCH 1/2] Use happychat-client npm package --- client/me/happychat/index.jsx | 23 ++++++++++++----------- package.json | 1 + webpack.config.js | 4 ++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/client/me/happychat/index.jsx b/client/me/happychat/index.jsx index 700d13b8d1275b..967279489321f4 100644 --- a/client/me/happychat/index.jsx +++ b/client/me/happychat/index.jsx @@ -1,26 +1,27 @@ +/** @format */ + /** - * /* - * External Deps - * - * @format + * External dependencies */ - -import React from 'react'; import page from 'page'; import { translate } from 'i18n-calypso'; -/* - Internal deps -*/ +/** + * Internal dependencies + */ import config from 'config'; import controller from 'me/controller'; -import Happychat from './main'; import { setDocumentHeadTitle } from 'state/document-head/actions'; import { makeLayout, render as clientRender } from 'controller'; +import HappychatClient from 'happychat-client'; const renderChat = ( context, next ) => { context.store.dispatch( setDocumentHeadTitle( translate( 'Chat', { textOnly: true } ) ) ); - context.primary = ; + HappychatClient.open( { + nodeId: 'primary', + accessToken: 'your-happychat-client-oauth-token', + entry: 'chat', + } ); next(); }; diff --git a/package.json b/package.json index b51b8c16c38975..22f863ebe7010e 100644 --- a/package.json +++ b/package.json @@ -259,6 +259,7 @@ "eslint-plugin-react": "7.1.0", "eslint-plugin-wpcalypso": "3.4.1", "glob": "7.0.3", + "happychat-client": "0.0.1", "husky": "0.13.3", "ignore": "3.3.5", "jest": "22.0.3", diff --git a/webpack.config.js b/webpack.config.js index 2abb2ee8a61182..855116906a978d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -174,6 +174,10 @@ const webpackConfig = { }, getAliasesForExtensions() ), + // This is needed because babel doesn't play well with symlinks, this allows node_modules to + // work as symlinks (`npm link`) needed when developing one of the dependencies. + // Reference https://github.com/babel/babel-loader/issues/149 + symlinks: false, }, node: false, plugins: _.compact( [ From 3416529b6e431241bf4d6002d2d7a3e6c633d94e Mon Sep 17 00:00:00 2001 From: undemian Date: Thu, 29 Mar 2018 13:35:50 +0300 Subject: [PATCH 2/2] Update authentication --- client/me/happychat/index.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/me/happychat/index.jsx b/client/me/happychat/index.jsx index 967279489321f4..34099b6af7c3f3 100644 --- a/client/me/happychat/index.jsx +++ b/client/me/happychat/index.jsx @@ -14,12 +14,18 @@ import controller from 'me/controller'; import { setDocumentHeadTitle } from 'state/document-head/actions'; import { makeLayout, render as clientRender } from 'controller'; import HappychatClient from 'happychat-client'; +import wpcom from 'lib/wp'; const renderChat = ( context, next ) => { context.store.dispatch( setDocumentHeadTitle( translate( 'Chat', { textOnly: true } ) ) ); HappychatClient.open( { nodeId: 'primary', - accessToken: 'your-happychat-client-oauth-token', + authentication: { + type: 'wpcom-proxy-iframe', + options: { + proxy: wpcom, + }, + }, entry: 'chat', } ); next();