@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
import classNames from 'classnames' ;
4
4
import { get , debounce } from 'lodash' ;
5
5
6
- import { gettext } from 'utils' ;
6
+ import { gettext , getConfig } from 'utils' ;
7
7
import server from 'server' ;
8
8
import { KEYS } from 'common' ;
9
9
@@ -315,9 +315,9 @@ export class LocationFilter extends React.Component<any, any> {
315
315
*/
316
316
renderRegionSearchResult ( item : any , index : any ) {
317
317
const { selectedIndex} = this . state ;
318
-
319
- if ( item . type === LOCATION_TYPE . CITY ) {
320
- return (
318
+ const enabledOptions = getConfig ( 'calendar_location_filter_options' ) ;
319
+ if ( item . type === LOCATION_TYPE . CITY && enabledOptions . city ) {
320
+ return (
321
321
< button
322
322
key = { `city.${ item . name } [${ index } ]` }
323
323
data-item-index = { index }
@@ -336,7 +336,8 @@ export class LocationFilter extends React.Component<any, any> {
336
336
} ) }
337
337
</ button >
338
338
) ;
339
- } else if ( item . type === LOCATION_TYPE . STATE ) {
339
+ } else if ( item . type === LOCATION_TYPE . STATE && enabledOptions . state ) {
340
+ const stateLabel = getConfig ( 'location_state_display_label' ) ;
340
341
return (
341
342
< button
342
343
key = { `state.${ item . name } [${ index } ]` }
@@ -349,13 +350,14 @@ export class LocationFilter extends React.Component<any, any> {
349
350
) }
350
351
onClick = { ( ) => this . onChange ( item ) }
351
352
>
352
- { gettext ( '{{ name }} (State , {{ country }})' , {
353
+ { gettext ( '{{ name }} ({{ label }} , {{ country }})' , {
353
354
name : item . name ,
355
+ label : stateLabel ,
354
356
country : item . country ,
355
357
} ) }
356
358
</ button >
357
359
) ;
358
- } else if ( item . type === LOCATION_TYPE . COUNTRY ) {
360
+ } else if ( item . type === LOCATION_TYPE . COUNTRY && enabledOptions . country ) {
359
361
return (
360
362
< button
361
363
key = { `country.${ item . name } [${ index } ]` }
@@ -371,7 +373,7 @@ export class LocationFilter extends React.Component<any, any> {
371
373
{ gettext ( '{{ name }} (Country)' , { name : item . name } ) }
372
374
</ button >
373
375
) ;
374
- } else {
376
+ } else if ( enabledOptions . places && ! [ 'city' , 'state' , 'country' ] . includes ( item . type ) ) {
375
377
const results = this . state . results ;
376
378
377
379
return (
@@ -389,6 +391,8 @@ export class LocationFilter extends React.Component<any, any> {
389
391
{ item }
390
392
</ button >
391
393
) ;
394
+ } else {
395
+ return null ;
392
396
}
393
397
}
394
398
@@ -432,6 +436,7 @@ export class LocationFilter extends React.Component<any, any> {
432
436
render ( ) {
433
437
const activeFilter = get ( this . props , 'activeFilter.location' ) || { } ;
434
438
const isActive = activeFilter . type != null ;
439
+ const isPlaceEnabled = getConfig ( 'calendar_location_filter_options' ) . places ;
435
440
436
441
return (
437
442
< div
@@ -522,17 +527,21 @@ export class LocationFilter extends React.Component<any, any> {
522
527
</ button >
523
528
) }
524
529
525
- < h6 className = "dropdown-menu__section-heading" > { gettext ( 'Places' ) } </ h6 >
526
- { this . state . results . places . length > 0 ? (
527
- this . state . results . places . map ( this . renderRegionSearchResult )
528
- ) : (
529
- < button
530
- key = "empty-places"
531
- className = "dropdown-item disabled"
532
- disabled = { true }
533
- >
534
- { gettext ( 'No places found' ) }
535
- </ button >
530
+ { isPlaceEnabled && (
531
+ < >
532
+ < h6 className = "dropdown-menu__section-heading" > { gettext ( 'Places' ) } </ h6 >
533
+ { this . state . results . places . length > 0 ? (
534
+ this . state . results . places . map ( this . renderRegionSearchResult )
535
+ ) : (
536
+ < button
537
+ key = "empty-places"
538
+ className = "dropdown-item disabled"
539
+ disabled = { true }
540
+ >
541
+ { gettext ( 'No places found' ) }
542
+ </ button >
543
+ ) }
544
+ </ >
536
545
) }
537
546
</ React . Fragment >
538
547
) }
0 commit comments