Merge branch 'master' into empty-states

This commit is contained in:
Gabriela Rodríguez Berón
2017-02-22 08:13:44 -08:00
committed by GitHub
16 changed files with 113 additions and 43 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ ENV TALK_PORT 5000
EXPOSE 5000
# Install app dependencies
COPY package.json /usr/src/app/
COPY package.json yarn.lock /usr/src/app/
RUN yarn install --production
# Bundle app source
+1 -1
View File
@@ -16,7 +16,7 @@ export const checkLogin = () => dispatch => {
})
.catch(error => {
console.error(error);
dispatch(checkLoginFailure(`${error.message}`));
dispatch(checkLoginFailure(`${error.translation_key}`));
});
};
+2 -2
View File
@@ -81,7 +81,7 @@ export const submitUser = () => (dispatch, getState) => {
})
.catch(error => {
console.error(error);
dispatch(installFailure(`${error.message}`));
dispatch(installFailure(`${error.translation_key}`));
});
});
};
@@ -104,6 +104,6 @@ export const checkInstall = next => dispatch => {
})
.catch(error => {
console.error(error);
dispatch(checkInstallFailure(`${error.message}`));
dispatch(checkInstallFailure(`${error.translation_key}`));
});
};
-1
View File
@@ -142,7 +142,6 @@ class Comment extends React.Component {
? <ReplyBox
commentPostedHandler={() => {
setActiveReplyBox('');
refetch();
}}
setActiveReplyBox={setActiveReplyBox}
parentId={parentId || comment.id}
-1
View File
@@ -128,7 +128,6 @@ class Embed extends Component {
{
user
? <CommentBox
commentPostedHandler={refetch}
addNotification={this.props.addNotification}
postItem={this.props.postItem}
appendItemArray={this.props.appendItemArray}
+2 -2
View File
@@ -123,7 +123,7 @@ export const fetchSignUp = (formData, redirectUri) => (dispatch) => {
dispatch(signUpSuccess(user));
})
.catch(error => {
dispatch(signUpFailure(lang.t(`error.${error.translation_key}`)));
dispatch(signUpFailure(lang.t(`error.${error.message}`)));
});
};
@@ -177,7 +177,7 @@ export const checkLogin = () => dispatch => {
})
.catch(error => {
console.error(error);
dispatch(checkLoginFailure(`${error.message}`));
dispatch(checkLoginFailure(`${error.translation_key}`));
});
};
@@ -26,7 +26,7 @@ class SuspendedAccount extends Component {
editName(username)
.then(() => location.reload())
.catch((error) => {
this.setState({alert: lang.t(`error.${error.message}`)});
this.setState({alert: lang.t(`error.${error.translation_key}`)});
});
} else {
this.setState({alert: lang.t('editName.error')});
@@ -10,16 +10,72 @@ export const postComment = graphql(POST_COMMENT, {
options: () => ({
fragments: commentView
}),
props: ({mutate}) => ({
postItem: ({asset_id, body, parent_id} /* , type */ ) => {
return mutate({
props: ({ownProps, mutate}) => ({
postItem: ({asset_id, body, parent_id}) =>
mutate({
variables: {
asset_id,
body,
parent_id
},
optimisticResponse: {
createComment: {
comment: {
user: {
id: ownProps.auth.user.id,
name: ownProps.auth.user.username
},
created_at: new Date().toISOString(),
body,
parent_id,
asset_id,
action_summaries: [],
tags: [],
status: null,
id: `${Date.now()}_temp_id`
}
}
},
updateQueries: {
AssetQuery: (oldData, {mutationResult:{data:{createComment:{comment}}}}) => {
if (oldData.asset.moderation === 'PRE') {
return oldData;
}
let updatedAsset;
// If posting a reply
if (parent_id) {
updatedAsset = {
...oldData,
asset: {
...oldData.asset,
comments: oldData.asset.comments.map((oldComment) => {
return oldComment.id === parent_id
? {...oldComment, replies: [...oldComment.replies, comment]}
: oldComment;
})
}
};
} else {
// If posting a top-level comment
updatedAsset = {
...oldData,
asset: {
...oldData.asset,
commentCount: oldData.asset.commentCount + 1,
comments: [comment, ...oldData.asset.comments]
}
};
}
return updatedAsset;
}
}
});
}}),
})
}),
});
export const postLike = graphql(POST_LIKE, {
@@ -4,6 +4,10 @@ mutation CreateComment ($asset_id: ID!, $parent_id: ID, $body: String!) {
createComment(asset_id:$asset_id, parent_id:$parent_id, body:$body) {
comment {
...commentView
replyCount
replies {
...commentView
}
}
errors {
translation_key
+2 -2
View File
@@ -49,7 +49,6 @@
},
"homepage": "https://github.com/coralproject/talk#readme",
"dependencies": {
"apollo-client": "^0.8.3",
"bcrypt": "^0.8.7",
"body-parser": "^1.15.2",
"cli-table": "^0.3.1",
@@ -66,7 +65,6 @@
"graphql": "^0.8.2",
"graphql-errors": "^2.1.0",
"graphql-server-express": "^0.5.0",
"graphql-tag": "^1.2.3",
"graphql-tools": "^0.9.0",
"helmet": "^3.1.0",
"inquirer": "^3.0.1",
@@ -88,6 +86,7 @@
"uuid": "^2.0.3"
},
"devDependencies": {
"apollo-client": "^0.8.3",
"autoprefixer": "^6.5.2",
"babel-core": "^6.21.0",
"babel-eslint": "^7.1.0",
@@ -122,6 +121,7 @@
"exports-loader": "^0.6.3",
"fetch-mock": "^5.5.0",
"graphql-docs": "^0.2.0",
"graphql-tag": "^1.2.3",
"hammerjs": "^2.0.8",
"ignore-styles": "^5.0.1",
"immutable": "^3.8.1",
+4 -10
View File
@@ -102,15 +102,13 @@ router.put('/password/reset', (req, res, next) => {
UsersService
.verifyPasswordResetToken(token)
.then(user => {
.then((user) => {
return UsersService.changePassword(user.id, password);
})
.then(() => {
res.status(204).end();
})
.catch(error => {
console.error(error);
.catch(() => {
next(authorization.ErrNotAuthorized);
});
});
@@ -121,12 +119,8 @@ router.put('/username', authorization.needed(), (req, res, next) => {
.then(() => {
res.status(204).end();
})
.catch(error => {
if (error.code === 11000) {
next(errors.ErrUsernameTaken);
} else {
next(error);
}
.catch((err) => {
next(err);
});
});
+16 -9
View File
@@ -79,7 +79,8 @@ router.get('/:asset_id', (req, res, next) => {
.findById(req.params.asset_id)
.then((asset) => {
if (!asset) {
return res.status(404).end();
res.status(404).end();
return;
}
res.json(asset);
@@ -97,15 +98,17 @@ router.post('/:asset_id/scrape', (req, res, next) => {
.findById(req.params.asset_id)
.then((asset) => {
if (!asset) {
return res.status(404).end();
res.status(404).end();
return;
}
return scraper.create(asset);
})
.then((job) => {
return scraper
.create(asset)
.then((job) => {
// Send the job back for monitoring.
res.status(201).json(job);
// Send the job back for monitoring.
res.status(201).json(job);
});
})
.catch((err) => {
next(err);
@@ -117,8 +120,12 @@ router.put('/:asset_id/settings', (req, res, next) => {
// Override the settings for the asset.
AssetsService
.overrideSettings(req.params.asset_id, req.body)
.then(() => res.status(204).end())
.catch((err) => next(err));
.then(() => {
res.status(204).end();
})
.catch((err) => {
next(err);
});
});
router.put('/:asset_id/status', (req, res, next) => {
+2 -1
View File
@@ -5,7 +5,8 @@ const router = express.Router();
router.get('/', (req, res, next) => {
SettingsService
.retrieve().then((settings) => {
.retrieve()
.then((settings) => {
res.json(settings);
})
.catch((err) => {
+1 -1
View File
@@ -43,7 +43,7 @@ router.post('/', (req, res, next) => {
res.status(204).end();
})
.catch((err) => {
return next(err);
next(err);
});
});
+2 -3
View File
@@ -136,7 +136,7 @@ router.post('/', (req, res, next) => {
res.status(201).json(user);
});
})
.catch(err => {
.catch((err) => {
next(err);
});
});
@@ -152,7 +152,7 @@ router.post('/:user_id/actions', authorization.needed(), (req, res, next) => {
.then((action) => {
// Set the user status to "pending" for review by moderators
if (action_type.slice(0, 4) === 'FLAG') {
if (action_type === 'FLAG') {
return UsersService.setStatus(req.params.user_id, 'PENDING')
.then(() => action);
} else {
@@ -163,7 +163,6 @@ router.post('/:user_id/actions', authorization.needed(), (req, res, next) => {
res.status(201).json(action);
})
.catch((err) => {
console.log('Error', err);
next(err);
});
});
+14 -3
View File
@@ -686,9 +686,20 @@ module.exports = class UsersService {
canEditName: false,
status: 'PENDING'
}
}).then((result) => {
return result.nModified > 0 ? result :
Promise.reject(errors.ErrPermissionUpdateUsername);
})
.then((result) => {
if (result.nModified <= 0) {
return Promise.reject(errors.ErrPermissionUpdateUsername);
}
return result;
})
.catch((err) => {
if (err.code === 11000) {
throw errors.ErrUsernameTaken;
}
throw err;
});
}
};