@@ -5,17 +5,13 @@ import PropTypes from 'prop-types'
55import querystring from 'query-string'
66import { withRouter , Prompt } from 'react-router-dom'
77import { connect } from 'react-redux'
8- import cn from 'classnames'
98import _ from 'lodash'
109import SearchBar from 'appirio-tech-react-components/components/SearchBar/SearchBar'
1110import MenuBar from 'appirio-tech-react-components/components/MenuBar/MenuBar'
12- import Filters from './Filters'
1311import NotificationsDropdown from '../NotificationsDropdown/NotificationsDropdownContainer'
1412import NewProjectNavLink from './NewProjectNavLink'
1513import MobileMenu from '../MobileMenu/MobileMenu'
1614import MobileMenuToggle from '../MobileMenu/MobileMenuToggle'
17- import SearchFilter from '../../assets/icons/ui-filters.svg'
18- import SearchIcon from '../../assets/icons/ui-16px-1_zoom.svg'
1915import { projectSuggestions , loadProjects , setInfiniteAutoload } from '../../projects/actions/loadProjects'
2016import { loadProjectsMetadata } from '../../actions/templates'
2117import { getNewProjectLink } from '../../helpers/projectHelper'
@@ -26,17 +22,13 @@ class ProjectsToolBar extends Component {
2622 super ( props )
2723 this . state = {
2824 errorCreatingProject : false ,
29- isFilterVisible : false ,
3025 isMobileMenuOpen : false ,
3126 isMobileSearchVisible : false
3227 }
33- this . state . isFilterVisible = sessionStorage . getItem ( 'isFilterVisible' ) === 'true'
3428 this . applyFilters = this . applyFilters . bind ( this )
35- this . toggleFilter = this . toggleFilter . bind ( this )
3629 this . handleTermChange = this . handleTermChange . bind ( this )
3730 this . handleSearch = this . handleSearch . bind ( this )
3831 this . toggleMobileMenu = this . toggleMobileMenu . bind ( this )
39- this . toggleMobileSearch = this . toggleMobileSearch . bind ( this )
4032 this . onLeave = this . onLeave . bind ( this )
4133 }
4234
@@ -74,10 +66,6 @@ class ProjectsToolBar extends Component {
7466 }
7567
7668 componentDidMount ( ) {
77- const contentDiv = document . getElementById ( 'wrapper-main' )
78- if ( this . state . isFilterVisible ) {
79- contentDiv . classList . add ( 'with-filters' )
80- }
8169 // sets window unload hook to show unsaved changes alert and persist incomplete project
8270 window . addEventListener ( 'beforeunload' , this . onLeave )
8371 }
@@ -125,38 +113,10 @@ class ProjectsToolBar extends Component {
125113 this . routeWithParams ( criteria )
126114 }
127115
128- toggleFilter ( ) {
129- const { isFilterVisible, isMobileSearchVisible} = this . state
130- const contentDiv = document . getElementById ( 'wrapper-main' )
131- this . setState ( { isFilterVisible : ! isFilterVisible } , ( ) => {
132- sessionStorage . setItem ( 'isFilterVisible' , ( ! isFilterVisible ) . toString ( ) )
133- if ( this . state . isFilterVisible ) {
134- contentDiv . classList . add ( 'with-filters' )
135- } else {
136- contentDiv . classList . remove ( 'with-filters' )
137- }
138- } )
139- // if open filters, close search panel on mobile
140- if ( ! isFilterVisible && isMobileSearchVisible ) {
141- this . toggleMobileSearch ( )
142- }
143- }
144-
145116 toggleMobileMenu ( ) {
146117 this . setState ( { isMobileMenuOpen : ! this . state . isMobileMenuOpen } )
147118 }
148119
149- toggleMobileSearch ( ) {
150- const { isFilterVisible, isMobileSearchVisible } = this . state
151-
152- // if open mobile search and filter is visible, then close filter
153- if ( ! isMobileSearchVisible && isFilterVisible ) {
154- this . toggleFilter ( )
155- }
156-
157- this . setState ( { isMobileSearchVisible : ! isMobileSearchVisible } )
158- }
159-
160120 routeWithParams ( criteria ) {
161121 // because criteria is changed disable infinite autoload
162122 this . props . setInfiniteAutoload ( false )
@@ -171,7 +131,7 @@ class ProjectsToolBar extends Component {
171131
172132 shouldComponentUpdate ( nextProps , nextState ) {
173133 const { user, criteria, creatingProject, projectCreationError, searchTermTag, projectTypes } = this . props
174- const { errorCreatingProject, isFilterVisible , isMobileMenuOpen, isMobileSearchVisible } = this . state
134+ const { errorCreatingProject, isMobileMenuOpen, isMobileSearchVisible } = this . state
175135 return ( nextProps . user || { } ) . handle !== ( user || { } ) . handle
176136 || ( nextProps . user || { } ) . photoURL !== ( this . props . user || { } ) . photoURL
177137 || JSON . stringify ( nextProps . criteria ) !== JSON . stringify ( criteria )
@@ -180,24 +140,15 @@ class ProjectsToolBar extends Component {
180140 || nextProps . searchTermTag !== searchTermTag
181141 || ! ! nextProps . projectTypes && ! projectTypes
182142 || nextState . errorCreatingProject !== errorCreatingProject
183- || nextState . isFilterVisible !== isFilterVisible
184143 || nextState . isMobileMenuOpen !== isMobileMenuOpen
185144 || nextState . isMobileSearchVisible !== isMobileSearchVisible
186145 }
187146
188147 render ( ) {
189- const { renderLogoSection, userMenu, userRoles, criteria , isPowerUser, user, mobileMenu, location, projectTypes , orgConfig } = this . props
190- const { isFilterVisible , isMobileMenuOpen, isMobileSearchVisible } = this . state
148+ const { renderLogoSection, userMenu, userRoles, isPowerUser, user, mobileMenu, location, orgConfig } = this . props
149+ const { isMobileMenuOpen, isMobileSearchVisible } = this . state
191150 const isLoggedIn = ! ! ( userRoles && userRoles . length )
192151
193- let excludedFiltersCount = 1 // 1 for default sort criteria
194- if ( criteria . memberOnly ) {
195- // https://github.com/appirio-tech/connect-app/issues/1319
196- // The switch should not count as a filter in the menu!
197- excludedFiltersCount ++
198- }
199- // Ignore status from filters count
200- const noOfFilters = _ . keys ( _ . omit ( criteria , [ 'status' , 'keyword' ] ) ) . length - excludedFiltersCount
201152 const onLeaveMessage = this . onLeave ( ) || ''
202153
203154 const primaryNavigationItems = [
@@ -240,20 +191,6 @@ class ProjectsToolBar extends Component {
240191 onSearch = { this . handleSearch }
241192 onClearSearch = { this . handleSearch }
242193 />
243- < div className = "search-filter" >
244- < a
245- href = "javascript:"
246- className = { cn ( 'tc-btn tc-btn-sm mobile-search-toggle' , { active : isMobileSearchVisible } ) }
247- onClick = { this . toggleMobileSearch }
248- > < SearchIcon /> </ a >
249- { ! ! projectTypes &&
250- < a
251- href = "javascript:"
252- className = { cn ( 'tc-btn tc-btn-sm' , { active : isFilterVisible } ) }
253- onClick = { this . toggleFilter }
254- > < SearchFilter className = "icon-search-filter" /> < span className = "filter-text" > Filters</ span > { noOfFilters > 0 && < span className = "filter-indicator" > { noOfFilters } </ span > } </ a >
255- }
256- </ div >
257194 </ div >
258195 }
259196 < div className = "actions" >
@@ -277,15 +214,6 @@ class ProjectsToolBar extends Component {
277214 />
278215 </ div >
279216 }
280- { ! ! projectTypes && isFilterVisible && isLoggedIn &&
281- < div className = "secondary-toolbar" >
282- < Filters
283- applyFilters = { this . applyFilters }
284- criteria = { criteria }
285- projectTypes = { projectTypes }
286- />
287- </ div >
288- }
289217 { isMobileMenuOpen && < MobileMenu user = { user } onClose = { this . toggleMobileMenu } menu = { mobileMenu } /> }
290218 </ div >
291219 )
0 commit comments