Merge branch 'master' into next

This commit is contained in:
Kim Gardner
2017-12-20 09:48:18 -05:00
committed by GitHub
10 changed files with 84 additions and 23 deletions
+21
View File
@@ -1,8 +1,10 @@
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const uuid = require('uuid');
const merge = require('lodash/merge');
const helmet = require('helmet');
const plugins = require('./services/plugins');
const compression = require('compression');
const {HELMET_CONFIGURATION} = require('./config');
const {MOUNT_PATH} = require('./url');
@@ -11,6 +13,25 @@ const debug = require('debug')('talk:app');
const app = express();
// Request Identity Middleware
app.use((req, res, next) => {
req.id = uuid.v4();
next();
});
//==============================================================================
// PLUGIN PRE APPLICATION MIDDLEWARE
//==============================================================================
// Inject server route plugins.
plugins.get('server', 'app').forEach(({plugin, app: callback}) => {
debug(`added plugin '${plugin.name}'`);
// Pass the app to the plugin to mount it's routes.
callback(app);
});
//==============================================================================
// APPLICATION WIDE MIDDLEWARE
//==============================================================================
@@ -152,6 +152,10 @@ export function cleanUpQueue(root, queue, sortOrder, queueConfig) {
let nodes = root[queue].nodes;
let hasNextPage = root[queue].hasNextPage;
if (!nodes.length) {
return root;
}
if (queueConfig) {
nodes = root[queue].nodes.filter((comment) => commentBelongToQueue(queue, comment, queueConfig));
}
@@ -161,8 +165,8 @@ export function cleanUpQueue(root, queue, sortOrder, queueConfig) {
sortOrder,
);
if (nodes.length > 2) {
nodes = nodes.slice(0, 2);
if (nodes.length > 100) {
nodes = nodes.slice(0, 100);
hasNextPage = true;
}
+13
View File
@@ -0,0 +1,13 @@
.dialog {
}
:global(.backdrop) {
left: 0;
top: 0;
width: 100%;
height: 100%;
position: absolute;
background-color: black;
opacity: 0.1;
}
+11 -7
View File
@@ -2,6 +2,8 @@ import React, {Component} from 'react';
import PropTypes from 'prop-types';
import dialogPolyfill from 'dialog-polyfill';
import 'dialog-polyfill/dialog-polyfill.css';
import styles from './Dialog.css';
import {Portal} from 'react-portal';
export default class Dialog extends Component {
static propTypes = {
@@ -52,13 +54,15 @@ export default class Dialog extends Component {
const {children, className = '', onClose, onCancel, open, ...rest} = this.props; // eslint-disable-line
return (
<dialog
ref={(el) => { this.dialog = el; }}
className={`mdl-dialog ${className}`}
{...rest}
>
{children}
</dialog>
<Portal>
<dialog
ref={(el) => { this.dialog = el; }}
className={`mdl-dialog ${className} ${styles.dialog}`}
{...rest}
>
{children}
</dialog>
</Portal>
);
}
}
+10 -6
View File
@@ -42,14 +42,15 @@ const decorateContextPlugins = (context, contextPlugins) => {
* Stores the request context.
*/
class Context {
constructor({user = null}) {
constructor(parent) {
// Generate a new context id for the request.
this.id = uuid.v4();
// Generate a new context id for the request if the parent doesn't provide
// one.
this.id = parent.id || uuid.v4();
// Load the current logged in user to `user`, otherwise this'll be null.
if (user) {
this.user = user;
// Load the current logged in user to `user`, otherwise this will be null.
if (parent.user) {
this.user = parent.user;
}
// Attach the connectors.
@@ -66,6 +67,9 @@ class Context {
// Bind the publish/subscribe to the context.
this.pubsub = pubsub.getClient();
// Bind the parent context.
this.parent = parent;
}
}
+1
View File
@@ -160,6 +160,7 @@
"react-mdl": "^1.7.2",
"react-mdl-selectfield": "^0.2.0",
"react-paginate": "^5.0.0",
"react-portal": "^4.1.2",
"react-recaptcha": "^2.2.6",
"react-redux": "^4.4.5",
"react-router": "^3.0.0",
+3 -2
View File
@@ -55,7 +55,8 @@ const hookSchemas = {
loaders: Joi.func().maxArity(1),
mutators: Joi.func().maxArity(1),
resolvers: Joi.object().pattern(/\w/, Joi.object().pattern(/(?:__resolveType|\w+)/, Joi.func())),
typeDefs: Joi.string()
typeDefs: Joi.string(),
schemaLevelResolveFunction: Joi.func(),
};
/**
@@ -172,7 +173,7 @@ class PluginSection {
if (this.required) {
return;
}
this.required = true;
this.plugins.forEach((plugin) => {
+8 -4
View File
@@ -57,6 +57,10 @@ module.exports = {
suspendUserDialog: '.talk-admin-suspend-user-dialog',
suspendUserConfirmButton: '.talk-admin-suspend-user-dialog-confirm',
supendUserSendButton: '.talk-admin-suspend-user-dialog-send',
usernameDialog: '.talk-reject-username-dialog',
usernameDialogButtons: '.talk-reject-username-dialog-buttons',
usernameDialogSuspend: '.talk-reject-username-dialog-button-k',
usernameDialogSuspensionMessage: '.talk-reject-username-dialog-suspension-message',
toast: '.toastify',
toastClose: '.toastify__close',
},
@@ -97,10 +101,6 @@ module.exports = {
flaggedUser:'.talk-admin-community-flagged-user',
flaggedUserApproveButton: '.talk-admin-flagged-user-approve-button',
flaggedUserRejectButton: '.talk-admin-flagged-user-reject-button',
usernameDialog: '.talk-reject-username-dialog',
usernameDialogButtons: '.talk-reject-username-dialog-buttons',
usernameDialogSuspend: '.talk-reject-username-dialog-button-k',
usernameDialogSuspensionMessage: '.talk-reject-username-dialog-suspension-message'
},
sections: {
people: {
@@ -137,6 +137,10 @@ module.exports = {
this.parent
.click('@drawerOverlay')
.waitForElementNotPresent('@drawerOverlay');
// Wait a bit to let animations terminate cleanly.
this.api.pause(200);
return this.parent;
},
}],
+5 -2
View File
@@ -64,15 +64,18 @@ module.exports = {
.click('@flaggedUserRejectButton');
},
'admin suspends the user': (client) => {
const adminPage = client.page.admin();
const community = client.page.admin().section.community;
community
adminPage
.waitForElementVisible('@usernameDialog')
.waitForElementVisible('@usernameDialogButtons')
.waitForElementVisible('@usernameDialogSuspend')
.click('@usernameDialogSuspend')
.waitForElementVisible('@usernameDialogSuspensionMessage')
.click('@usernameDialogSuspend')
.click('@usernameDialogSuspend');
community
.waitForElementNotPresent('@flaggedUser');
},
'admin logs out': (client) => {
+6
View File
@@ -7473,6 +7473,12 @@ react-paginate@^5.0.0:
prop-types "^15.6.0"
react-addons-create-fragment "^15.0.0"
react-portal@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/react-portal/-/react-portal-4.1.2.tgz#7f28f3c8c2ed5c541907c0ed0f24e8996acf627f"
dependencies:
prop-types "^15.5.8"
react-recaptcha@^2.2.6:
version "2.3.5"
resolved "https://registry.yarnpkg.com/react-recaptcha/-/react-recaptcha-2.3.5.tgz#a5db337125bb00fb13c2fa2e4ebfbe8b0cd06bb7"