Skip to content

Commit 4163e9d

Browse files
author
Parth Shah
committed
Merge branch 'dev'
2 parents af79a87 + e894057 commit 4163e9d

File tree

115 files changed

+2208
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2208
-563
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.21",
44
"description": "Customer pages in React and Redux",
55
"scripts": {
6-
"start": "webpack-dev-server --history-api-fallback --dev --hot --inline --progress --tc --port 3000",
6+
"start": "webpack-dev-server --history-api-fallback --dev --hot --inline --progress --tc --port 3000 --host 0.0.0.0",
77
"build": "webpack --bail --progress --build --tc",
88
"lint": "eslint --fix --format table --ext .js,.jsx .",
99
"test": "cross-env NODE_ENV=test mocha --colors --reporter nyan --compilers js:babel-core/register --require ignore-styles --recursive \"./src/**/*.spec.js\"",
@@ -42,6 +42,7 @@
4242
"formsy-react": "^0.18.1",
4343
"history": "^1.17.0",
4444
"isomorphic-fetch": "^2.2.1",
45+
"lodash": "^4.16.4",
4546
"moment": "^2.14.1",
4647
"react": "^15.3.1",
4748
"react-addons-css-transition-group": "^15.3.1",

src/api/messages.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export function getTopicPosts(topicId, postIds) {
2828
.then( resp => {
2929
return {
3030
totalCount: _.get(resp.data, 'result.metadata.totalCount', 0),
31-
posts: _.get(resp.data, 'result.content', [])
31+
posts: _.get(resp.data, 'result.content', []),
32+
topicId
3233
}
3334
})
3435
}
@@ -51,4 +52,4 @@ export function addTopicPost(topicId, post) {
5152
}
5253
})
5354
}
54-
/*eslint-enable*/
55+
/*eslint-enable*/

src/assets/images/check-white.svg

Lines changed: 16 additions & 0 deletions
Loading
Lines changed: 3 additions & 7 deletions
Loading
Lines changed: 5 additions & 10 deletions
Loading

src/components/ActionCard/ActionCard.scss

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
padding: $base-unit*4 0;
55
box-shadow: 0px 1px 3px 0px #C3C3C8;
66

7+
// FIXME: Hide the top border on the new post composer to be better looking
8+
.new-post-title + .tc-textarea .textarea-footer {border-top: none;}
9+
710
.panel-row,
811
.modal-row{
912
padding: $base-unit*2 $base-unit*6;
@@ -187,7 +190,7 @@
187190
padding: 12px 15px;
188191
background: $tc-gray-neutral-light;
189192
border: 1px solid $tc-gray-20;
190-
border-top: none;
193+
border-top: 1px solid $tc-dark-blue-90;
191194
display: flex;
192195
.textarea-buttons{
193196
display: flex;
@@ -357,13 +360,6 @@
357360
height: 40px;
358361
border-radius: 33px;
359362
}
360-
&:empty {
361-
border: 2px solid $tc-gray-50;
362-
background: url('../../assets/images/user-add.svg') no-repeat;
363-
background-position: center;
364-
background-size: 16px;
365-
border-radius: 33px;
366-
}
367363
}
368364
.buttons{
369365
display: flex;

src/components/ActionCard/AddComment.jsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ export default class AddComment extends React.Component {
88
constructor(props) {
99
super(props)
1010
this.state = {
11-
isFocused: false
11+
isFocused: false,
12+
canSubmit: false
1213
}
1314
this.onAdd = this.onAdd.bind(this)
15+
this.onTextAreaChange = this.onTextAreaChange.bind(this)
1416
}
1517

1618
onAdd(e) {
@@ -23,9 +25,15 @@ export default class AddComment extends React.Component {
2325
this.refs.input.focus()
2426
}
2527

28+
onTextAreaChange(evt) {
29+
const val = evt.target.value
30+
this.setState({canSubmit: val && val.trim().length})
31+
this.props.onChange(val, evt)
32+
}
33+
2634
render() {
27-
const { className, avatarUrl, authorName, onChange, content, placeholder, isAdding } = this.props
28-
const { isFocused } = this.state
35+
const { className, avatarUrl, authorName, content, placeholder, isAdding } = this.props
36+
const { isFocused, canSubmit } = this.state
2937
const isCollapsed = !isFocused && !content
3038

3139
return (
@@ -42,10 +50,10 @@ export default class AddComment extends React.Component {
4250
value={content}
4351
onFocus={() => this.setState({isFocused: true})}
4452
onBlur={() => this.setState({isFocused: false})}
45-
onChange={(e) => onChange(e.target.value, e)}
53+
onChange={this.onTextAreaChange}
4654
/>
4755
{!isCollapsed && <div className="textarea-footer">
48-
<button className="tc-btn tc-btn-primary tc-btn-sm" onClick={this.onAdd} disabled={ this.props.isAdding }>
56+
<button className="tc-btn tc-btn-primary tc-btn-sm" onClick={this.onAdd} disabled={ isAdding || !canSubmit }>
4957
{ isAdding ? 'Posting...' : 'Post' }
5058
</button>
5159
</div>}

src/components/ColorSelector/ColorSelector.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
z-index: 2;
2424
right: 0;
2525
top: 50px;
26+
width: 340px;
2627
background: white;
2728
position: absolute;
2829
display: flex;

src/components/Feed/FeedComments.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Panel from '../Panel/Panel'
44
import AddComment from '../ActionCard/AddComment'
55
import Comment from '../ActionCard/Comment'
66
import cn from 'classnames'
7-
import { THREAD_MESSAGES_PAGE_SIZE } from '../../config/constants'
7+
// import { THREAD_MESSAGES_PAGE_SIZE } from '../../config/constants'
88

99
const getCommentCount = (totalComments) => {
1010
if (!totalComments) {
@@ -24,7 +24,7 @@ class FeedComments extends React.Component {
2424

2525
render() {
2626
const {
27-
comments, currentUser, totalComments, /*onLoadMoreComments,*/ isLoadingComments, hasMoreComments, onAdd,
27+
comments, currentUser, totalComments, onLoadMoreComments, isLoadingComments, hasMoreComments, onAdd,
2828
onChange, content, avatarUrl, isAddingComment
2929
} = this.props
3030
let authorName = currentUser.firstName
@@ -35,17 +35,17 @@ class FeedComments extends React.Component {
3535
this.setState({showAll: true})
3636
// TODO - handle the case when a topic has more than 20 comments
3737
// since those will have to retrieved from the server
38-
// if (!isLoadingComments) {
39-
// onLoadMoreComments()
40-
// }
38+
if (!isLoadingComments) {
39+
onLoadMoreComments()
40+
}
4141
}
4242

43-
let _comments = comments
44-
let _hasMoreComments = hasMoreComments
45-
if (!this.state.showAll && _comments.length > THREAD_MESSAGES_PAGE_SIZE) {
46-
_comments = _comments.slice(-THREAD_MESSAGES_PAGE_SIZE)
47-
_hasMoreComments = true
48-
}
43+
// let _comments = comments
44+
// let _hasMoreComments = hasMoreComments
45+
// if (!this.state.showAll && _comments.length > THREAD_MESSAGES_PAGE_SIZE) {
46+
// _comments = _comments.slice(-THREAD_MESSAGES_PAGE_SIZE)
47+
// _hasMoreComments = true
48+
// }
4949

5050
return (
5151
<div>
@@ -57,15 +57,15 @@ class FeedComments extends React.Component {
5757
{getCommentCount(totalComments)}
5858
</div>
5959
<hr className={cn({'no-margin': !comments.length})} />
60-
{_hasMoreComments && <div className={cn('comment-collapse', {'loading-comments': isLoadingComments})}>
60+
{hasMoreComments && <div className={cn('comment-collapse', {'loading-comments': isLoadingComments})}>
6161
<a href="javascript:" onClick={ handleLoadMoreClick } className="comment-collapse-button">
6262
{isLoadingComments ? 'Loading...' : 'View older comments'}
6363
</a>
6464
</div>}
6565
</div>
6666
</div>
6767
</Panel.Body>
68-
{_comments.map((item, idx) =>
68+
{comments.map((item, idx) =>
6969
<Comment
7070
key={idx}
7171
avatarUrl={item.author.photoURL}

src/components/Feed/NewPost.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ class NewPost extends React.Component {
5858
document.removeEventListener('click', this.onClickOutside)
5959
}
6060

61+
componentWillReceiveProps(nextProps) {
62+
if (!(nextProps.isCreating || nextProps.hasError && !nextProps.isCreating)) {
63+
this.setState({editorState: EditorState.createEmpty()})
64+
this.refs.title.value = ''
65+
}
66+
this.onNewPostChange()
67+
}
68+
6169
onClickOutside(evt) {
6270
let currNode = evt.target
6371
let isEditor = false
@@ -122,7 +130,7 @@ class NewPost extends React.Component {
122130

123131
onNewPostChange() {
124132
this.setState({
125-
canSubmit: !!this.refs.title.value.trim().length && this.state.editorState.getCurrentContent().hasText()
133+
canSubmit: this.refs.title && !!this.refs.title.value.trim().length && this.state.editorState.getCurrentContent().hasText()
126134
})
127135
}
128136

@@ -150,8 +158,8 @@ class NewPost extends React.Component {
150158
const content = stateToMarkdown(editorState.getCurrentContent())
151159
if (title && content) {
152160
this.props.onPost({title, content})
153-
this.setState({editorState: EditorState.createEmpty()})
154-
this.refs.title.value = ''
161+
// this.setState({editorState: EditorState.createEmpty()})
162+
// this.refs.title.value = ''
155163
}
156164
}
157165

0 commit comments

Comments
 (0)