From dbee3e1bedc710e1cdee40395f68d40642b778aa Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Tue, 7 Aug 2018 11:06:32 +0200 Subject: [PATCH 01/44] [WIP] Integrate Apollo --- app/API/graphql_api.js | 9 ++ app/components/Users/ActivityLog.jsx | 19 +++ app/components/Users/User.jsx | 25 ++-- app/config.js | 1 + app/i18n/en/main.js | 2 - app/i18n/fr/main.js | 2 - app/index.jsx | 42 ++++++ app/router.jsx | 84 +++++------- config/env/dev.env | 1 + config/env/prod.env | 1 + config/env/staging.env | 1 + package-lock.json | 194 ++++++++++++++++++++++++++- package.json | 4 + webpack.config.js | 4 +- webpack.production.config.js | 8 +- 15 files changed, 317 insertions(+), 80 deletions(-) create mode 100644 app/API/graphql_api.js create mode 100644 app/components/Users/ActivityLog.jsx create mode 100644 app/index.jsx diff --git a/app/API/graphql_api.js b/app/API/graphql_api.js new file mode 100644 index 000000000..6d988c11e --- /dev/null +++ b/app/API/graphql_api.js @@ -0,0 +1,9 @@ +import ApolloClient from 'apollo-boost' +import { GRAPHQL_API_URL } from '../config' + + +const GraphQLClient = new ApolloClient({ + uri: GRAPHQL_API_URL +}) + +export default GraphQLClient diff --git a/app/components/Users/ActivityLog.jsx b/app/components/Users/ActivityLog.jsx new file mode 100644 index 000000000..cdd6d2159 --- /dev/null +++ b/app/components/Users/ActivityLog.jsx @@ -0,0 +1,19 @@ +import React from 'react' +import { Query } from 'react-apollo' +import gql from 'graphql-tag' + + +const ActivityLog = () => ( + + {({loading, data}) => ( + null + )} + +) + +export default ActivityLog diff --git a/app/components/Users/User.jsx b/app/components/Users/User.jsx index 0a416bada..bbab26999 100644 --- a/app/components/Users/User.jsx +++ b/app/components/Users/User.jsx @@ -30,11 +30,11 @@ export default class User extends React.PureComponent { componentDidUpdate(oldProps) { // If user's username was updated - if (this.props.user.id === oldProps.user.id && - this.props.user.username !== oldProps.user.username) - // TODO Remove old user profile from history - // Redirect - this.props.router.replace(`/u/${this.props.user.username}`) + if (this.props.user.id === oldProps.user.id + && this.props.user.username !== oldProps.user.username) + // TODO Remove old user profile from history + // Redirect + this.props.router.replace(`/u/${this.props.user.username}`) // Showing another user else if (this.props.params.username !== oldProps.params.username) @@ -64,7 +64,7 @@ export default class User extends React.PureComponent { render() { if (this.props.errors) return - else if (this.props.isLoading) + if (this.props.isLoading) return const user = this.props.user @@ -76,13 +76,13 @@ export default class User extends React.PureComponent { {user.name || prettyUsername}
- {user.id !== 0 && - } - content={ -
+ content={( +
  @@ -94,7 +94,7 @@ export default class User extends React.PureComponent { />
- } +)} right={} /> } @@ -103,8 +103,7 @@ export default class User extends React.PureComponent {
    {this.getActiveTab('', 'user-circle', 'menu.profile')} {isSelf && this.getActiveTab('settings', 'cog', 'menu.settings')} - {isSelf && this.getActiveTab('bookmarks', 'bookmark', 'menu.bookmarks', true)} - {this.getActiveTab('activity', 'tasks', 'menu.activity', true)} + {this.getActiveTab('activity', 'tasks', 'menu.activity')}
{ this.props.children } diff --git a/app/config.js b/app/config.js index 9def2c14e..608a6e893 100644 --- a/app/config.js +++ b/app/config.js @@ -13,6 +13,7 @@ function boolFromConfig(value) { export const JS_ENV = process.env.JS_ENV export const HTTP_API_URL = process.env.HTTP_API_URL export const WS_API_URL = process.env.WS_API_URL +export const GRAPHQL_API_URL = process.env.GRAPHQL_API_URL export const FRONTEND_URL = process.env.FRONTEND_URL export const FB_APP_ID = process.env.FB_APP_ID export const INVITATION_SYSTEM = boolFromConfig(process.env.INVITATION_SYSTEM) diff --git a/app/i18n/en/main.js b/app/i18n/en/main.js index 1bf51a0b4..055e680d1 100644 --- a/app/i18n/en/main.js +++ b/app/i18n/en/main.js @@ -14,8 +14,6 @@ export default { profile: 'Profile', activity: 'Activity', myActivity: 'My $t(menu.activity)', - bookmarks: 'Favorites', - myBookmarks: 'My $t(menu.bookmarks)', content: 'Content', language: 'Language', other: 'Other', diff --git a/app/i18n/fr/main.js b/app/i18n/fr/main.js index 982c477eb..f4d5c202d 100644 --- a/app/i18n/fr/main.js +++ b/app/i18n/fr/main.js @@ -14,8 +14,6 @@ export default { profile: 'Profil', activity: 'Activité', myActivity: 'Mon $t(menu.activity)', - bookmarks: 'Signets', - myBookmarks: 'Mes signets', content: 'Contenu', language: 'Langue', other: 'Autre', diff --git a/app/index.jsx b/app/index.jsx new file mode 100644 index 000000000..ac633b32e --- /dev/null +++ b/app/index.jsx @@ -0,0 +1,42 @@ +// Import polyfills +import 'core-js/es6/promise' +import 'core-js/es6/symbol' +import 'core-js/es6/array' +import 'core-js/es6/string' +import 'core-js/es7/array' +import 'core-js/es7/object' +import 'core-js/modules/es6.math.trunc' + +import { polyfill as smoothSrollPolyfill } from 'smoothscroll-polyfill' + +// Import libs +import React from 'react' +import ReactDOM from 'react-dom' +import { Provider } from 'react-redux' +import { ApolloProvider } from 'react-apollo' + +// Load store +import store from './state' + +// Import APIs so they can load their configurations +import GraphQLClient from './API/graphql_api' + +// Import router +import CFRouter from './router' + +// Import styles +import './styles/application.sass' + + +// Activate polyfills +smoothSrollPolyfill() + +// Inject React app in DOM +ReactDOM.render( + + + + + , + document.getElementById('app') +) diff --git a/app/router.jsx b/app/router.jsx index dccc9c747..efa354b11 100644 --- a/app/router.jsx +++ b/app/router.jsx @@ -1,22 +1,6 @@ -// Import polyfills -import 'core-js/es6/promise' -import 'core-js/es6/symbol' -import 'core-js/es6/array' -import 'core-js/es6/string' -import 'core-js/es7/array' -import 'core-js/es7/object' -import 'core-js/modules/es6.math.trunc' - -import { polyfill as smoothSrollPolyfill } from 'smoothscroll-polyfill' - // Import libs import React from 'react' -import ReactDOM from 'react-dom' import { Router, Route, IndexRoute, browserHistory } from 'react-router' -import { Provider } from 'react-redux' - -// Load store -import store from './state' // Import Views import App from './components/App' @@ -36,43 +20,39 @@ import ConfirmEmail from './components/Users/ConfirmEmail' import Moderation from './components/Moderation/Moderation' import { SpeakerPage } from './components/Speakers/SpeakerPage' import NewsletterSubscription from './components/Users/NewsletterSubscription' +import ActivityLog from './components/Users/ActivityLog' -import './styles/application.sass' -smoothSrollPolyfill() - -ReactDOM.render( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const CFRouter = () => ( + + + + + + + + + + + + + + + - - , - document.getElementById('app') + + + + + + + + + + + + + ) + +export default CFRouter diff --git a/config/env/dev.env b/config/env/dev.env index 74389f6c9..8b78c7343 100644 --- a/config/env/dev.env +++ b/config/env/dev.env @@ -1,6 +1,7 @@ JS_ENV=dev HTTP_API_URL=http://localhost:4000 WS_API_URL=ws://localhost:4000/socket +GRAPHQL_API_URL=http://localhost:4002 OG_URL=http://localhost:4005 FRONTEND_URL=http://localhost:3333 STATIC_RESOURCES_URL=http://localhost:4000/resources/ diff --git a/config/env/prod.env b/config/env/prod.env index 5adbc707c..78c3e7ed7 100644 --- a/config/env/prod.env +++ b/config/env/prod.env @@ -1,6 +1,7 @@ JS_ENV=prod HTTP_API_URL=https://api.captainfact.io WS_API_URL=wss://api.captainfact.io/socket +GRAPHQL_API_URL=https://graphql.captainfact.io OG_URL=http://opengraph FRONTEND_URL=https://captainfact.io STATIC_RESOURCES_URL=https://s3.amazonaws.com/captainfact/resources/ diff --git a/config/env/staging.env b/config/env/staging.env index 95f2c3a93..516839ee4 100644 --- a/config/env/staging.env +++ b/config/env/staging.env @@ -1,6 +1,7 @@ JS_ENV=staging HTTP_API_URL=https://api.staging.captainfact.io WS_API_URL=wss://api.staging.captainfact.io/socket +GRAPHQL_API_URL=https://graphql.staging.captainfact.io OG_URL=http://opengraph FRONTEND_URL=https://staging.captainfact.io STATIC_RESOURCES_URL=https://s3.amazonaws.com/captainfact-staging/resources/ diff --git a/package-lock.json b/package-lock.json index ebb4c5c66..d61806672 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "captain-fact-frontend", - "version": "0.8.12", + "version": "0.8.13", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -310,12 +310,28 @@ "integrity": "sha512-2JsW7OArYnndGcXPSjIx9uwmSTCHByb+7WRmOhrOYM9N5GK5KMsX4APKxET73+zc1ZUqEj2yAPwYis72xJXIEQ==", "dev": true }, + "@types/async": { + "version": "2.0.49", + "resolved": "https://registry.npmjs.org/@types/async/-/async-2.0.49.tgz", + "integrity": "sha512-Benr3i5odUkvpFkOpzGqrltGdbSs+EVCkEBGXbuR7uT0VzhXKIkhem6PDzHdx5EonA+rfbB3QvP6aDOw5+zp5Q==", + "optional": true + }, + "@types/graphql": { + "version": "0.12.6", + "resolved": "https://registry.npmjs.org/@types/graphql/-/graphql-0.12.6.tgz", + "integrity": "sha512-wXAVyLfkG1UMkKOdMijVWFky39+OD/41KftzqfX1Oejd0Gm6dOIKjCihSVECg6X7PHjftxXmfOKA/d1H79ZfvQ==" + }, "@types/node": { "version": "9.6.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.6.tgz", "integrity": "sha512-SJe0g5cZeGNDP5sD8mIX3scb+eq8LQQZ60FXiKZHipYSeEFZ5EKml+NNMiO76F74TY4PoMWlNxF/YRY40FOvZQ==", "dev": true }, + "@types/zen-observable": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.0.tgz", + "integrity": "sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg==" + }, "@webassemblyjs/ast": { "version": "1.5.13", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.5.13.tgz", @@ -826,6 +842,114 @@ "normalize-path": "^2.1.1" } }, + "apollo-boost": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/apollo-boost/-/apollo-boost-0.1.12.tgz", + "integrity": "sha512-uv43RVUpuQFPLbNMoCStyipbZn46Qc2rN3U5PFQOAP/lKVKgkpNGJx1+Mwv267RFxOg0ZPifmyivTaStim9nhA==", + "requires": { + "apollo-cache": "^1.1.13", + "apollo-cache-inmemory": "^1.2.6", + "apollo-client": "^2.3.7", + "apollo-link": "^1.0.6", + "apollo-link-error": "^1.0.3", + "apollo-link-http": "^1.3.1", + "apollo-link-state": "^0.4.0", + "graphql-tag": "^2.4.2" + } + }, + "apollo-cache": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/apollo-cache/-/apollo-cache-1.1.13.tgz", + "integrity": "sha512-hkQESJLYFH7p6m3IfBV3JAPBtKcQjN+6ophh02qu5eKW7GuBFQpJbeVKTBTDc0FKulHsUw78HptqvVJxFtJOig==", + "requires": { + "apollo-utilities": "^1.0.17" + } + }, + "apollo-cache-inmemory": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/apollo-cache-inmemory/-/apollo-cache-inmemory-1.2.6.tgz", + "integrity": "sha512-Hz4VMfOz0iVtqAHQQWbkhBkVEDxrIPkc77poEfW1/Xq2snloAYD0o78yRQS+PrLuq2irlnL3Q/aVgrKC0uUcgA==", + "requires": { + "apollo-cache": "^1.1.13", + "apollo-utilities": "^1.0.17", + "graphql-anywhere": "^4.1.15" + } + }, + "apollo-client": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/apollo-client/-/apollo-client-2.3.7.tgz", + "integrity": "sha512-d9JMPS1UObBjc+wOXMvpQC/ZkR9ZtOAVuBftcdCjqDARWi7HywHP8TCT87Awf3p8iiSc3FEMYQns5cprzNShnA==", + "requires": { + "@types/async": "2.0.49", + "@types/zen-observable": "^0.8.0", + "apollo-cache": "^1.1.13", + "apollo-link": "^1.0.0", + "apollo-link-dedup": "^1.0.0", + "apollo-utilities": "^1.0.17", + "symbol-observable": "^1.0.2", + "zen-observable": "^0.8.0" + } + }, + "apollo-link": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/apollo-link/-/apollo-link-1.2.2.tgz", + "integrity": "sha512-Uk/BC09dm61DZRDSu52nGq0nFhq7mcBPTjy5EEH1eunJndtCaNXQhQz/BjkI2NdrfGI+B+i5he6YSoRBhYizdw==", + "requires": { + "@types/graphql": "0.12.6", + "apollo-utilities": "^1.0.0", + "zen-observable-ts": "^0.8.9" + } + }, + "apollo-link-dedup": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/apollo-link-dedup/-/apollo-link-dedup-1.0.9.tgz", + "integrity": "sha512-RbuEKpmSHVMtoREMPh2wUFTeh65q+0XPVeqgaOP/rGEAfvLyOMvX0vT2nVaejMohoMxuUnfZwpldXaDFWnlVbg==", + "requires": { + "apollo-link": "^1.2.2" + } + }, + "apollo-link-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/apollo-link-error/-/apollo-link-error-1.1.0.tgz", + "integrity": "sha512-4Vu/IUn6Kn6+Fthym4iuqypCKcLdwTg3MaCvtLdaLbt9X2hNCq3y8mv6vuWIlAY51X8wKhCgYghQSOs5R/embQ==", + "requires": { + "apollo-link": "^1.2.2" + } + }, + "apollo-link-http": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/apollo-link-http/-/apollo-link-http-1.5.4.tgz", + "integrity": "sha512-e9Ng3HfnW00Mh3TI6DhNRfozmzQOtKgdi+qUAsHBOEcTP0PTAmb+9XpeyEEOueLyO0GXhB92HUCIhzrWMXgwyg==", + "requires": { + "apollo-link": "^1.2.2", + "apollo-link-http-common": "^0.2.4" + } + }, + "apollo-link-http-common": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/apollo-link-http-common/-/apollo-link-http-common-0.2.4.tgz", + "integrity": "sha512-4j6o6WoXuSPen9xh4NBaX8/vL98X1xY2cYzUEK1F8SzvHe2oFONfxJBTekwU8hnvapcuq8Qh9Uct+gelu8T10g==", + "requires": { + "apollo-link": "^1.2.2" + } + }, + "apollo-link-state": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/apollo-link-state/-/apollo-link-state-0.4.1.tgz", + "integrity": "sha512-69/til4ENfl/Fvf7br2xSsLSBcxcXPbOHVNkzLLejvUZickl93HLO4/fO+uvoBi4dCYRgN17Zr8FwI41ueRx0g==", + "requires": { + "apollo-utilities": "^1.0.8", + "graphql-anywhere": "^4.1.0-alpha.0" + } + }, + "apollo-utilities": { + "version": "1.0.17", + "resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-1.0.17.tgz", + "integrity": "sha512-Mm8pS48QVV/CUbcUFN5TmbkdjIJtYw99qVqbBHnIwL8x0H2RW0NpzASpC+5+qSxD1sKNLUl9pA6F5Et/0bbaVg==", + "requires": { + "fast-json-stable-stringify": "^2.0.0" + } + }, "append-transform": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-1.0.0.tgz", @@ -5275,8 +5399,7 @@ "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "fast-levenshtein": { "version": "2.0.6", @@ -6733,6 +6856,27 @@ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, + "graphql": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-0.13.2.tgz", + "integrity": "sha512-QZ5BL8ZO/B20VA8APauGBg3GyEgZ19eduvpLWoq5x7gMmWnHoy8rlQWPLmWgFvo1yNgjSEFMesmS4R6pPr7xog==", + "requires": { + "iterall": "^1.2.1" + } + }, + "graphql-anywhere": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graphql-anywhere/-/graphql-anywhere-4.1.15.tgz", + "integrity": "sha512-yeGrsMQaGEz7VZTH5gA/easEkDmFkmqudYltYyYdvIXXlsYy5XAUBwaIlahJMKaBaXTfkPUY6Y+0RaPP+P0zvQ==", + "requires": { + "apollo-utilities": "^1.0.17" + } + }, + "graphql-tag": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.9.2.tgz", + "integrity": "sha512-qnNmof9pAqj/LUzs3lStP0Gw1qhdVCUS7Ab7+SUB6KD5aX1uqxWQRwMnOGTkhKuLvLNIs1TvNz+iS9kUGl1MhA==" + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -8080,6 +8224,11 @@ "handlebars": "^4.0.3" } }, + "iterall": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz", + "integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA==" + }, "jest": { "version": "23.4.1", "resolved": "https://registry.npmjs.org/jest/-/jest-23.4.1.tgz", @@ -12157,6 +12306,25 @@ "prop-types": "^15.6.0" } }, + "react-apollo": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/react-apollo/-/react-apollo-2.1.9.tgz", + "integrity": "sha512-o6otpfh/neSzNjaq2x1GL9+aFz13pxQ0si4h2XpE7ON1lXD24YwpdFF277s8h1KFSVRvZmpzLmrg9OyOU9mo+w==", + "requires": { + "fbjs": "^0.8.16", + "hoist-non-react-statics": "^2.5.0", + "invariant": "^2.2.2", + "lodash": "^4.17.10", + "prop-types": "^15.6.0" + }, + "dependencies": { + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + } + } + }, "react-dom": { "version": "16.3.2", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.3.2.tgz", @@ -13040,12 +13208,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -13065,7 +13235,8 @@ "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", @@ -16774,6 +16945,19 @@ "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", "dev": true + }, + "zen-observable": { + "version": "0.8.9", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.9.tgz", + "integrity": "sha512-Y9kPzjGvIZ5jchSlqlCpBW3I82zBBL4z+ulXDRVA1NwsKzjt5kwAi+gOYIy0htNkfuehGZZtP5mRXHRV6TjDWw==" + }, + "zen-observable-ts": { + "version": "0.8.9", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-0.8.9.tgz", + "integrity": "sha512-KJz2O8FxbAdAU5CSc8qZ1K2WYEJb1HxS6XDRF+hOJ1rOYcg6eTMmS9xYHCXzqZZzKw6BbXWyF4UpwSsBQnHJeA==", + "requires": { + "zen-observable": "^0.8.0" + } } } } diff --git a/package.json b/package.json index 93d805689..9debb72e4 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ }, "dependencies": { "animate.scss": "0.0.6", + "apollo-boost": "^0.1.12", "bulma": "^0.7.1", "classnames": "^2.2.5", "core-js": "^2.5.6", @@ -38,6 +39,8 @@ "debounce-promise": "^3.1.0", "diff": "^3.3.1", "dotenv-webpack": "^1.5.5", + "graphql": "^0.13.2", + "graphql-tag": "^2.9.2", "i18next": "^10.5.0", "immutable": "^4.0.0-rc.9", "is-promise": "^2.1.0", @@ -46,6 +49,7 @@ "prop-types": "^15.6.2", "re-reselect": "^1.0.1", "react": "^16.3.2", + "react-apollo": "^2.1.9", "react-dom": "^16.3.2", "react-flip-move": "^3.0.1", "react-helmet": "^5.2.0", diff --git a/webpack.config.js b/webpack.config.js index dc8d2e7bb..b7a6c495d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,6 @@ const webpack = require('webpack') const path = require('path') -const loadersConf = require('./webpack.loaders') // Plugins const HtmlWebpackPlugin = require('html-webpack-plugin') @@ -10,6 +9,7 @@ const DashboardPlugin = require('webpack-dashboard/plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin') const Dotenv = require('dotenv-webpack') +const loadersConf = require('./webpack.loaders') const HOST = process.env.HOST || 'localhost' const PORT = process.env.PORT || '3333' @@ -26,7 +26,7 @@ module.exports = { 'core-js/es6/object', 'core-js/es6/array', // app entry point - './app/router.jsx' + './app/index.jsx' ] }, // sourcemap complexity diff --git a/webpack.production.config.js b/webpack.production.config.js index 1e5d31f0c..fd358bc6f 100644 --- a/webpack.production.config.js +++ b/webpack.production.config.js @@ -1,8 +1,7 @@ -'use strict' + const webpack = require('webpack') const path = require('path') -const loadersConf = require('./webpack.loaders') // Plugins // const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin @@ -14,6 +13,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin') const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') const Dotenv = require('dotenv-webpack') +const loadersConf = require('./webpack.loaders') module.exports = { mode: 'production', @@ -26,7 +26,7 @@ module.exports = { 'core-js/es6/object', 'core-js/es6/array', // app entry point - './app/router.jsx' + './app/index.jsx' ] }, output: { @@ -41,7 +41,7 @@ module.exports = { path.join(__dirname, 'node_modules'), // the old 'fallback' option (needed for npm link-ed packages) ], alias: { - 'styles': path.resolve(__dirname, 'styles/'), + styles: path.resolve(__dirname, 'styles/'), } }, optimization: { From b7e92b06202b145534fa03e8d506b0d162160f3e Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Tue, 7 Aug 2018 11:57:56 +0200 Subject: [PATCH 02/44] [WIP] Fetch user actions and basic display --- app/components/Users/ActivityLog.jsx | 22 +++++++++++++++++++--- app/components/UsersActions/UserAction.jsx | 4 ++-- app/i18n/en/history.js | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/components/Users/ActivityLog.jsx b/app/components/Users/ActivityLog.jsx index cdd6d2159..e0e61da61 100644 --- a/app/components/Users/ActivityLog.jsx +++ b/app/components/Users/ActivityLog.jsx @@ -1,17 +1,33 @@ import React from 'react' import { Query } from 'react-apollo' import gql from 'graphql-tag' +import { UserAction } from '../UsersActions/UserAction' const ActivityLog = () => ( - {({loading, data}) => ( - null + {({loading, data: {user}}) => ( + !loading && ( + user.actions.map(a => ( + + )) + ) )} ) diff --git a/app/components/UsersActions/UserAction.jsx b/app/components/UsersActions/UserAction.jsx index dd45fc16d..5ff0b627d 100644 --- a/app/components/UsersActions/UserAction.jsx +++ b/app/components/UsersActions/UserAction.jsx @@ -12,7 +12,7 @@ import ActionIcon from './ActionIcon' @translate('history') export class UserAction extends React.PureComponent { render() { - const { action, className, t } = this.props + const { action, className, t, withoutDiff } = this.props const { user, type, entity, time } = action return ( @@ -30,7 +30,7 @@ export class UserAction extends React.PureComponent { { t(`this.${entity}`) } - + {!withoutDiff && } ) } diff --git a/app/i18n/en/history.js b/app/i18n/en/history.js index 96ce73c44..8a97237eb 100644 --- a/app/i18n/en/history.js +++ b/app/i18n/en/history.js @@ -16,12 +16,23 @@ export default { 3: 'Updated', 4: 'Deleted', 5: 'Added', - 6: 'Reverted' + 6: 'Reverted', + 7: 'Approved', + 8: 'Flagged', + 9: 'Voted up', + 10: 'Voted down', + 11: 'Self voted', + 12: 'Reverted upvote', + 13: 'Reverted downvote', + 14: 'Reverted self vote', }, this: { 1: 'Video', 2: 'Speaker', 3: 'Statement', - 4: 'Comment' + 4: 'Comment', + 5: 'Fact', + 6: 'Action', + 7: 'User' } } From 40dba78d13bce26876dd1b9b5c2f57aa82f1e9a8 Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Tue, 7 Aug 2018 15:52:30 +0200 Subject: [PATCH 03/44] [WIP] Proper query and advancement --- app/components/App/Sidebar.jsx | 23 ++++++++------ app/components/Users/ActivityLog.jsx | 36 ++++++++++++---------- app/components/Users/User.jsx | 2 +- app/components/UsersActions/ActionIcon.jsx | 33 +++++++++++++------- app/i18n/en/history.js | 3 +- app/i18n/fr/history.js | 14 +++++++-- 6 files changed, 68 insertions(+), 43 deletions(-) diff --git a/app/components/App/Sidebar.jsx b/app/components/App/Sidebar.jsx index 6ca59e59f..198329470 100644 --- a/app/components/App/Sidebar.jsx +++ b/app/components/App/Sidebar.jsx @@ -4,19 +4,20 @@ import { Link } from 'react-router' import { translate } from 'react-i18next' import classNames from 'classnames' +import capitalize from 'voca/capitalize' import { Icon } from '../Utils' import { MOBILE_WIDTH_THRESHOLD, USER_PICTURE_SMALL, MIN_REPUTATION_MODERATION } from '../../constants' import { LoadingFrame } from '../Utils/LoadingFrame' import RawIcon from '../Utils/RawIcon' import ReputationGuard from '../Utils/ReputationGuard' import LanguageSelector from './LanguageSelector' -import capitalize from 'voca/capitalize' import ScoreTag from '../Users/ScoreTag' import { logout } from '../../state/users/current_user/effects' import { closeSidebar, toggleSidebar } from '../../state/user_preferences/reducer' import UserPicture from '../Users/UserPicture' import i18n from '../../i18n/i18n' import Logo from './Logo' +import Button from '../Utils/Button' @connect(state => ({ CurrentUser: state.CurrentUser.data, @@ -69,21 +70,21 @@ export default class Sidebar extends React.PureComponent {
    + + { t('menu.myActivity') } + { t('menu.settings')} - - { t('menu.myActivity') } -
) } @@ -102,7 +103,7 @@ export default class Sidebar extends React.PureComponent { renderUserSection() { if (this.props.isLoadingUser) return (
) - else if (this.props.CurrentUser.id !== 0) + if (this.props.CurrentUser.id !== 0) return this.renderUserLinks() return this.renderConnectLinks() } @@ -110,8 +111,10 @@ export default class Sidebar extends React.PureComponent { render() { const { sidebarExpended, className, t } = this.props return ( -