Skip to content

Commit 4e7b129

Browse files
author
Sachin Maheshwari
committed
Merge branch 'feature/project-listing-updates' into feature/project-listing-updates#1268
2 parents 09d43f2 + 880e628 commit 4e7b129

File tree

14 files changed

+446
-35
lines changed

14 files changed

+446
-35
lines changed

npm-shrinkwrap.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"react-datetime": "2.7.1",
8787
"react-dom": "^15.6.1",
8888
"react-dotdotdot": "^1.0.4",
89+
"react-infinite-scroller": "^1.1.1",
8990
"react-layout-pane": "^0.1.16",
9091
"react-modal": "^1.9.7",
9192
"react-redux": "^4.4.5",

src/components/ProjectStatus/ProjectStatus.jsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
1111
this.onSelect = this.onSelect.bind(this)
1212
this.onClickOutside = this.onClickOutside.bind(this)
1313
this.onClickOtherDropdown = this.onClickOtherDropdown.bind(this)
14+
this.refreshEventHandlers = this.refreshEventHandlers.bind(this)
15+
}
16+
17+
refreshEventHandlers() {
18+
if (this.state.isOpen) {
19+
document.addEventListener('click', this.onClickOutside)
20+
document.addEventListener('dropdownClicked', this.onClickOtherDropdown)
21+
} else {
22+
document.removeEventListener('click', this.onClickOutside)
23+
document.removeEventListener('dropdownClicked', this.onClickOtherDropdown)
24+
}
1425
}
1526

1627
handleClick() {
@@ -19,7 +30,9 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
1930

2031
document.dispatchEvent(dropdownClicked)
2132

22-
this.setState({ isOpen: !this.state.isOpen })
33+
this.setState({ isOpen: !this.state.isOpen }, () => {
34+
this.refreshEventHandlers()
35+
})
2336
}
2437

2538
onSelect(value) {
@@ -47,20 +60,26 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
4760
} while (currNode.tagName)
4861

4962
if (!isDropdown) {
50-
this.setState({ isOpen: false })
63+
this.setState({ isOpen: false }, () => {
64+
this.refreshEventHandlers()
65+
})
5166
}
5267
}
5368

5469
onClickOtherDropdown() {
55-
this.setState({ isOpen: false })
70+
this.setState({ isOpen: false }, () => {
71+
this.refreshEventHandlers()
72+
})
5673
}
5774

5875
componentDidMount() {
5976
document.removeEventListener('click', this.onClickOutside)
6077
document.removeEventListener('dropdownClicked', this.onClickOtherDropdown)
6178

62-
document.addEventListener('click', this.onClickOutside)
63-
document.addEventListener('dropdownClicked', this.onClickOtherDropdown)
79+
if (this.state.isOpen) {
80+
document.addEventListener('click', this.onClickOutside)
81+
document.addEventListener('dropdownClicked', this.onClickOtherDropdown)
82+
}
6483
}
6584

6685
componentWillUnmount() {
@@ -126,5 +145,5 @@ ProjectStatus.propTypes = {
126145
ProjectStatus.defaultProps = {
127146
}
128147

129-
export default enhanceDropdown(ProjectStatus)
148+
export default ProjectStatus
130149

src/components/ProjectStatus/editableProjectStatus.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component} from 'react'
22
import ProjectStatusChangeConfirmation from './ProjectStatusChangeConfirmation'
33
import cn from 'classnames'
44
import _ from 'lodash'
5+
import { enhanceDropdown} from './ProjectStatus'
56
import {
67
PROJECT_STATUS_COMPLETED,
78
PROJECT_STATUS_CANCELLED
@@ -51,10 +52,11 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {
5152

5253
render() {
5354
const { showStatusChangeDialog, newStatus, statusChangeReason } = this.state
55+
const EnhancedProjectStatus = enhanceDropdown(CompositeComponent)
5456
return (
5557
<div className={cn('panel', {'modal-active': showStatusChangeDialog})}>
5658
<div className="modal-overlay"></div>
57-
<CompositeComponent
59+
<EnhancedProjectStatus
5860
{ ...this.props }
5961
onSelect={ this.showStatusChangeDialog }
6062
/>

src/components/TopBar/ProjectsToolBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ProjectsToolBar extends Component {
148148
target: '_blank'
149149
}
150150
]
151-
const menuBar = !isPowerUser && <MenuBar mobileBreakPoint={767} items={primaryNavigationItems} orientation="horizontal" forReactRouter />
151+
const menuBar = !!isLoggedIn && !isPowerUser && <MenuBar mobileBreakPoint={767} items={primaryNavigationItems} orientation="horizontal" forReactRouter />
152152

153153
return (
154154
<div className="ProjectsToolBar">

0 commit comments

Comments
 (0)