From ce73118f538b1ad20b6186f0f50d5d7ec36b54d3 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 24 Jan 2017 16:04:03 -0500 Subject: [PATCH 1/3] Loading history links in parent page. --- client/coral-embed-stream/src/Embed.js | 5 ++--- client/coral-embed-stream/src/PymConnection.js | 3 --- client/coral-embed-stream/src/graphql/queries/index.js | 2 +- client/coral-framework/PymConnection.js | 9 +++++++++ client/coral-framework/index.js | 4 +++- client/coral-plugin-history/Comment.js | 3 +-- client/coral-plugin-history/CommentHistory.js | 1 + client/coral-settings/containers/SettingsContainer.js | 2 ++ graph/loaders/users.js | 1 - test/client/coral-plugin-history/Comment.spec.js | 7 +++---- test/client/coral-plugin-history/CommentHistory.spec.js | 5 ++--- views/embed-stream.ejs | 6 +++++- 12 files changed, 29 insertions(+), 19 deletions(-) delete mode 100644 client/coral-embed-stream/src/PymConnection.js create mode 100644 client/coral-framework/PymConnection.js diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 95c5e8834..cf40cf716 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -9,10 +9,9 @@ const {logout, showSignInDialog} = authActions; const {addNotification, clearNotification} = notificationActions; const {fetchAssetSuccess} = assetActions; -import pym from './PymConnection'; import {queryStream} from './graphql/queries'; import {postComment, postAction, deleteAction} from './graphql/mutations'; -import {Notification, notificationActions, authActions, assetActions} from 'coral-framework'; +import {Notification, notificationActions, authActions, assetActions, pym} from 'coral-framework'; import Stream from './Stream'; import InfoBox from 'coral-plugin-infobox/InfoBox'; @@ -95,7 +94,7 @@ class Embed extends Component { const {loggedIn, isAdmin, user, showSignInDialog, signInOffset} = this.props.auth; const expandForLogin = showSignInDialog ? { - minHeight: document.body.scrollHeight + 150 + minHeight: document.body.scrollHeight + 200 } : {}; return
diff --git a/client/coral-embed-stream/src/PymConnection.js b/client/coral-embed-stream/src/PymConnection.js deleted file mode 100644 index cdbf95c2f..000000000 --- a/client/coral-embed-stream/src/PymConnection.js +++ /dev/null @@ -1,3 +0,0 @@ -import Pym from '../../../node_modules/pym.js'; - -export default new Pym.Child({polling: 100}); diff --git a/client/coral-embed-stream/src/graphql/queries/index.js b/client/coral-embed-stream/src/graphql/queries/index.js index b57c3ecf3..ae01ea9f4 100644 --- a/client/coral-embed-stream/src/graphql/queries/index.js +++ b/client/coral-embed-stream/src/graphql/queries/index.js @@ -1,6 +1,6 @@ import {graphql} from 'react-apollo'; import STREAM_QUERY from './streamQuery.graphql'; -import pym from '../../PymConnection'; +import pym from 'coral-framework/PymConnection'; let url = pym.parentUrl.split('#')[0] || 'http://localhost:3000/'; diff --git a/client/coral-framework/PymConnection.js b/client/coral-framework/PymConnection.js new file mode 100644 index 000000000..ca592b824 --- /dev/null +++ b/client/coral-framework/PymConnection.js @@ -0,0 +1,9 @@ +import Pym from '../../node_modules/pym.js'; + +const pym = new Pym.Child({polling: 100}); +export default pym; + +export const link = (url) => (e) => { + e.preventDefault(); + pym.sendMessage('navigate', url); +}; diff --git a/client/coral-framework/index.js b/client/coral-framework/index.js index 6ab7c6325..d3246f902 100644 --- a/client/coral-framework/index.js +++ b/client/coral-framework/index.js @@ -6,6 +6,7 @@ import * as notificationActions from './actions/notification'; import * as authActions from './actions/auth'; import * as configActions from './actions/config'; import * as assetActions from './actions/asset'; +import pym from './PymConnection'; export { Notification, @@ -15,5 +16,6 @@ export { notificationActions, authActions, configActions, - assetActions + assetActions, + pym }; diff --git a/client/coral-plugin-history/Comment.js b/client/coral-plugin-history/Comment.js index 036753623..895d47c75 100644 --- a/client/coral-plugin-history/Comment.js +++ b/client/coral-plugin-history/Comment.js @@ -1,12 +1,11 @@ import React, {PropTypes} from 'react'; - import styles from './Comment.css'; const Comment = props => { return (

- {props.asset.url} + {props.asset.url}

{props.comment.body}

diff --git a/client/coral-plugin-history/CommentHistory.js b/client/coral-plugin-history/CommentHistory.js index c18846066..add7c121a 100644 --- a/client/coral-plugin-history/CommentHistory.js +++ b/client/coral-plugin-history/CommentHistory.js @@ -11,6 +11,7 @@ const CommentHistory = props => { return ; })}
diff --git a/client/coral-settings/containers/SettingsContainer.js b/client/coral-settings/containers/SettingsContainer.js index e7b930255..3b635d203 100644 --- a/client/coral-settings/containers/SettingsContainer.js +++ b/client/coral-settings/containers/SettingsContainer.js @@ -3,6 +3,7 @@ import {connect} from 'react-redux'; import {saveBio, fetchCommentsByUserId} from 'coral-framework/actions/user'; +import {link} from '/coral-framework/PymConnection'; import BioContainer from './BioContainer'; import NotLoggedIn from '../components/NotLoggedIn'; import {TabBar, Tab, TabContent} from '../../coral-ui'; @@ -62,6 +63,7 @@ class SettingsContainer extends Component { user.myComments.length && user.myAssets.length ? items.assets[id])} /> :

{lang.t('user-no-comment')}

} diff --git a/graph/loaders/users.js b/graph/loaders/users.js index 793ecfbf9..583fcf8e6 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -5,7 +5,6 @@ const util = require('./util'); const UsersService = require('../../services/users'); const genUserByIDs = (context, ids) => { - console.log('genUserIds', ids); return UsersService .findByIdArray(ids) .then(util.singleJoinBy(ids, 'id')); diff --git a/test/client/coral-plugin-history/Comment.spec.js b/test/client/coral-plugin-history/Comment.spec.js index 78ad104bf..6d69d54cd 100644 --- a/test/client/coral-plugin-history/Comment.spec.js +++ b/test/client/coral-plugin-history/Comment.spec.js @@ -9,20 +9,19 @@ describe('coral-plugin-history/Comment', () => { const asset = {url: 'https://google.com'}; beforeEach(() => { - render = shallow(); + render = shallow({}}/>); }); it('should render the provided comment body', () => { - const wrapper = mount(); + const wrapper = mount({}}/>); expect(wrapper.find('.myCommentBody')).to.have.length(1); expect(wrapper.find('.myCommentBody').text()).to.equal('this is a comment'); }); it('should render the asset url as a link', () => { - const wrapper = mount(); + const wrapper = mount({}}/>); expect(wrapper.find('.myCommentAnchor')).to.have.length(1); expect(wrapper.find('.myCommentAnchor').text()).to.equal('https://google.com'); - expect(wrapper.find('.myCommentAnchor').props().href).to.equal('https://google.com#123'); }); it('should render the comment with styles', () => { diff --git a/test/client/coral-plugin-history/CommentHistory.spec.js b/test/client/coral-plugin-history/CommentHistory.spec.js index 3b6f5ee47..9d81f79cd 100644 --- a/test/client/coral-plugin-history/CommentHistory.spec.js +++ b/test/client/coral-plugin-history/CommentHistory.spec.js @@ -9,11 +9,11 @@ describe('coral-plugin-history/CommentHistory', () => { const assets = [{'settings': null, 'created_at':'2016-12-06T21:36:09.302Z', 'url':'localhost:3000/', 'scraped':null, 'status':'open', 'updated_at':'2016-12-08T02:11:15.943Z', '_id':'58472f499e775a38f23d5da0', 'type':'article', 'closedMessage':null, 'id':'7302e637-f884-47c0-9723-02cc10a18617', 'closedAt':null}, {'settings':null, 'created_at':'2016-12-07T02:25:31.983Z', 'url':'http://localhost:3000/', 'scraped':null, 'status':'open', 'updated_at':'2016-12-13T22:58:36.061Z', '_id':'5847731b9e775a38f23d5da1', 'type':'article', 'closedMessage':null, 'id':'96fddf96-7c83-4008-80ad-50091997d006', 'closedAt':null}, {'settings':null, 'created_at':'2016-12-12T19:04:05.770Z', 'url':'http://localhost:3000/embed/stream', 'scraped':null, 'updated_at':'2016-12-14T20:13:21.934Z', '_id':'584ef4a59e775a38f23d5e86', 'type':'article', 'closedMessage':null, 'id':'cef81015-1b53-4d70-b9af-6eca680f22fc', 'closedAt':null}]; beforeEach(() => { - render = shallow(); + render = shallow({}}/>); }); it('should render Comments as children when given comments and assets', () => { - const wrapper = mount(); + const wrapper = mount({}}/>); expect(wrapper.find('.commentHistory__list').children()).to.have.length(7); }); @@ -21,4 +21,3 @@ describe('coral-plugin-history/CommentHistory', () => { expect(render.props().style).to.be.defined; }); }); - diff --git a/views/embed-stream.ejs b/views/embed-stream.ejs index a05b699f1..c69773bcb 100644 --- a/views/embed-stream.ejs +++ b/views/embed-stream.ejs @@ -31,7 +31,11 @@ pymParent.sendMessage('DOMContentLoaded', window.location.hash); } }, 100); - }); + } + pymParent.onMessage('navigate', function (url) { + window.open(url, '_blank').focus(); + }) + ); // wait till images and other iframes are loaded before scrolling the page. // or do we want to be more aggressive and scroll when we hit DOM ready? From 7c3f566202feb7d86d1e51f9b2b940f21b77acb2 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 24 Jan 2017 16:21:49 -0500 Subject: [PATCH 2/3] Handling links inside of iframe in via Pym. --- client/coral-plugin-history/Comment.js | 2 +- client/coral-settings/containers/SettingsContainer.js | 2 +- views/article.ejs | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/coral-plugin-history/Comment.js b/client/coral-plugin-history/Comment.js index 895d47c75..df61b9e7d 100644 --- a/client/coral-plugin-history/Comment.js +++ b/client/coral-plugin-history/Comment.js @@ -5,7 +5,7 @@ const Comment = props => { return (

- {props.asset.url} + {props.asset.url}

{props.comment.body}

diff --git a/client/coral-settings/containers/SettingsContainer.js b/client/coral-settings/containers/SettingsContainer.js index 3b635d203..001190f1d 100644 --- a/client/coral-settings/containers/SettingsContainer.js +++ b/client/coral-settings/containers/SettingsContainer.js @@ -3,7 +3,7 @@ import {connect} from 'react-redux'; import {saveBio, fetchCommentsByUserId} from 'coral-framework/actions/user'; -import {link} from '/coral-framework/PymConnection'; +import {link} from 'coral-framework/PymConnection'; import BioContainer from './BioContainer'; import NotLoggedIn from '../components/NotLoggedIn'; import {TabBar, Tab, TabContent} from '../../coral-ui'; diff --git a/views/article.ejs b/views/article.ejs index 302d76572..c63acc62b 100644 --- a/views/article.ejs +++ b/views/article.ejs @@ -46,6 +46,9 @@ } }, 100); }); + pymParent.onMessage('navigate', function (url) { + window.open(url, '_blank').focus(); + }) // wait till images and other iframes are loaded before scrolling the page. // or do we want to be more aggressive and scroll when we hit DOM ready? From fa300b1c24dfc912a826f8c1abe399ea9c7b07d4 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 24 Jan 2017 14:38:31 -0700 Subject: [PATCH 3/3] Fixes to circle --- circle.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index 4d1f54286..160bc7bb9 100644 --- a/circle.yml +++ b/circle.yml @@ -5,11 +5,21 @@ machine: - docker - redis +dependencies: + post: + # Lint the project here, before tests are ran. + - npm run lint + +database: + post: + # Initialize the settings in the database, this will create indicies for the + # database. + - ./bin/cli settings init + - sleep 2 + test: override: - - npm run lint - - ./bin/cli settings init - - sleep 5 + # Run the tests using the junit reporter. - MOCHA_FILE=$CIRCLE_TEST_REPORTS/junit/test-results.xml NPM_PACKAGE_CONFIG_MOCHA_REPORTER=mocha-junit-reporter npm run test deployment: