Skip to content

Commit 3c78567

Browse files
committed
fixed issue's comments #5068#issuecomment-741904592, #5068#issuecomment-741600474, #5068#issuecomment-741596441 and hide the sub-community select box for the review bucket
1 parent c91c817 commit 3c78567

File tree

15 files changed

+121
-201
lines changed

15 files changed

+121
-201
lines changed

__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
2424
setFilterState={[MockFunction]}
2525
/>
2626
</div>
27-
<div
28-
className="src-shared-components-challenge-listing-___style__sidebar-container-desktop___h0bz6"
29-
>
30-
<Connect(SidebarContainer)
31-
expanding={false}
32-
/>
33-
<Connect(Container)
34-
communityName={null}
35-
isAuth={false}
36-
setFilterState={[MockFunction]}
37-
/>
38-
</div>
3927
<Connect(Listing)
4028
activeBucket="abc"
4129
auth={Object {}}
@@ -79,19 +67,6 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
7967
<div
8068
className="src-shared-components-challenge-listing-___style__tc-content-wrapper___1MqlF"
8169
>
82-
<div
83-
className="src-shared-components-challenge-listing-___style__sidebar-container-mobile___3e65d"
84-
>
85-
<Connect(SidebarContainer)
86-
expanding={false}
87-
/>
88-
<Connect(Container)
89-
communityName={null}
90-
hidden={true}
91-
isAuth={false}
92-
setFilterState={[MockFunction]}
93-
/>
94-
</div>
9570
<div
9671
className="src-shared-components-challenge-listing-___style__sidebar-container-desktop___h0bz6"
9772
>
@@ -100,6 +75,7 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
10075
/>
10176
<Connect(Container)
10277
communityName={null}
78+
hidden={false}
10379
isAuth={false}
10480
setFilterState={[MockFunction]}
10581
/>

__tests__/shared/components/challenge-listing/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ describe('Matches shallow shapshot 1', () => {
4343
describe('Matches shallow shapshot 2', () => {
4444
beforeEach(() => {
4545
jest.resetModules();
46+
jest.mock('react-responsive', () => ({
47+
useMediaQuery: () => true,
48+
}));
4649
ChallengeListing = require('components/challenge-listing').default;
4750
});
4851

__tests__/shared/reducers/challenge-listing/sidebar.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const defaultReducer = require('reducers/challenge-listing/sidebar').default;
22

33
const expectedState = {
44
activeBucket: 'openForRegistration',
5-
past: false,
65
};
76

87
function testReducer(reducer) {

src/shared/actions/challenge-listing/sidebar.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ export default createActions({
153153

154154
// UPDATE_ALL_SAVED_FILTERS: updateAllSavedFilters,
155155
// UPDATE_SAVED_FILTER: updateSavedFilter,
156-
157-
SET_PAST: isPast => ({ past: isPast }),
158156
},
159157
},
160158
});

src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import Tooltip from 'components/Tooltip';
3232
import { config, Link } from 'topcoder-react-utils';
3333
import { COMPOSE, PRIORITY } from 'react-css-super-themr';
3434
import { REVIEW_OPPORTUNITY_TYPES } from 'utils/tc';
35-
import { isFilterEmpty } from 'utils/challenge-listing/buckets';
35+
import { isFilterEmpty, isPastBucket } from 'utils/challenge-listing/buckets';
3636
import SwitchWithLabel from 'components/SwitchWithLabel';
3737
import { challenge as challengeUtils } from 'topcoder-react-lib';
3838
import { createStaticRanges } from 'utils/challenge-listing/date-range';
@@ -64,7 +64,6 @@ export default function FiltersPanel({
6464
// isSavingFilter,
6565
expanded,
6666
setExpanded,
67-
past,
6867
}) {
6968
if (hidden && !expanded) {
7069
return (
@@ -226,7 +225,7 @@ export default function FiltersPanel({
226225
data: getLabel(community),
227226
}));
228227

229-
const disableClearFilterButtons = isFilterEmpty(filterState, past ? 'past' : '', activeBucket);
228+
const disableClearFilterButtons = isFilterEmpty(filterState);
230229

231230
// const mapOps = item => ({ label: item, value: item });
232231
const mapTypes = item => ({ label: item.name, value: item.abbreviation });
@@ -249,6 +248,7 @@ export default function FiltersPanel({
249248
};
250249

251250
const staticRanges = createStaticRanges();
251+
const past = isPastBucket(activeBucket);
252252

253253
return (
254254
<div styleName="FiltersPanel">
@@ -495,47 +495,52 @@ export default function FiltersPanel({
495495
) : null
496496
}
497497

498-
<div styleName="filter-row">
499-
<div styleName="filter filter community">
500-
<label htmlFor="community-select" styleName="label">
501-
Sub community
502-
<input type="hidden" />
503-
</label>
504-
<Select
505-
autoBlur
506-
clearable={false}
507-
id="community-select"
508-
// onChange={selectCommunity}
509-
onChange={(value) => {
510-
if (value && value.startsWith('event_')) {
511-
const event = value.split('_')[1];
512-
setFilterState({
513-
..._.clone(filterState),
514-
events: event === '' ? [] : [event],
515-
groups: [],
516-
});
517-
} else {
518-
const group = value;
519-
setFilterState({
520-
..._.clone(filterState),
521-
groups: group === '' ? [] : [group],
522-
events: [],
523-
});
524-
}
525-
// setFilterState({ ..._.clone(filterState), groups: [value] });
526-
}}
527-
options={communityOps}
528-
simpleValue
529-
value={getCommunityOption()}
530-
valueRenderer={option => (
531-
<span styleName="active-community">
532-
{option.name}
533-
</span>
534-
)}
535-
/>
536-
</div>
537-
</div>
498+
{ !isReviewOpportunitiesBucket
499+
&& (
500+
<div styleName="filter-row">
501+
<div styleName="filter filter community">
502+
<label htmlFor="community-select" styleName="label">
503+
Sub community
504+
<input type="hidden" />
505+
</label>
506+
<Select
507+
autoBlur
508+
clearable={false}
509+
id="community-select"
510+
// onChange={selectCommunity}
511+
onChange={(value) => {
512+
if (value && value.startsWith('event_')) {
513+
const event = value.split('_')[1];
514+
setFilterState({
515+
..._.clone(filterState),
516+
events: event === '' ? [] : [event],
517+
groups: [],
518+
});
519+
} else {
520+
const group = value;
521+
setFilterState({
522+
..._.clone(filterState),
523+
groups: group === '' ? [] : [group],
524+
events: [],
525+
});
526+
}
527+
// setFilterState({ ..._.clone(filterState), groups: [value] });
528+
}}
529+
options={communityOps}
530+
simpleValue
531+
value={getCommunityOption()}
532+
valueRenderer={option => (
533+
<span styleName="active-community">
534+
{option.name}
535+
</span>
536+
)}
537+
/>
538+
</div>
539+
</div>
540+
)
541+
}
538542
</div>
543+
539544
<div styleName="buttons">
540545
<Button
541546
composeContextTheme={COMPOSE.SOFT}
@@ -607,5 +612,4 @@ FiltersPanel.propTypes = {
607612
onClose: PT.func,
608613
expanded: PT.bool.isRequired,
609614
setExpanded: PT.func.isRequired,
610-
past: PT.bool.isRequired,
611615
};

src/shared/components/challenge-listing/Filters/FiltersPanel/style.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
display: block;
120120
color: $tc-black;
121121
font-size: 11px;
122-
line-height: 13px;
123-
margin-bottom: 4px;
122+
line-height: 15px;
123+
margin-bottom: 8px;
124124
}
125125

126126
@include xs-to-md {

src/shared/components/challenge-listing/Listing/Bucket/index.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ export default function Bucket({
125125
challengeType={_.find(challengeTypes, { name: challenge.type })}
126126
challengesUrl={challengesUrl}
127127
newChallengeDetails={newChallengeDetails}
128-
onTechTagClicked={tag => setFilterState({ ..._.clone(filterState), tags: [tag], types: [] })}
128+
onTechTagClicked={(tag) => {
129+
setFilterState({
130+
..._.clone(filterState),
131+
tags: [tag],
132+
types: challengeTypes.map(type => type.abbreviation),
133+
});
134+
}}
129135
openChallengesInNewTabs={openChallengesInNewTabs}
130136
prizeMode={prizeMode}
131137
key={challenge.id}

src/shared/components/challenge-listing/Sidebar/index.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import React from 'react';
1919
import PT from 'prop-types';
2020
// import _ from 'lodash';
21-
import { BUCKETS } from 'utils/challenge-listing/buckets';
21+
import { BUCKETS, isPastBucket } from 'utils/challenge-listing/buckets';
2222
import BucketSelector from './BucketSelector';
2323
// import FiltersEditor from './FiltersEditor';
2424
// import Footer from './Footer';
@@ -50,19 +50,18 @@ export default function SideBarFilters({
5050
// updateAllSavedFilters,
5151
// updateSavedFilter,
5252
// setFilter,
53-
past,
54-
setPast,
5553
previousBucketOfActiveTab,
5654
previousBucketOfPastChallengesTab,
5755
setPreviousBucketOfActiveTab,
5856
setPreviousBucketOfPastChallengesTab,
5957
}) {
58+
const past = isPastBucket(activeBucket);
59+
6060
const onActiveClick = () => {
6161
if (!past) {
6262
return;
6363
}
6464
setPreviousBucketOfPastChallengesTab(activeBucket);
65-
setPast(false);
6665
if (previousBucketOfActiveTab) {
6766
selectBucket(previousBucketOfActiveTab);
6867
} else {
@@ -75,7 +74,6 @@ export default function SideBarFilters({
7574
return;
7675
}
7776
setPreviousBucketOfActiveTab(activeBucket);
78-
setPast(true);
7977
if (previousBucketOfPastChallengesTab) {
8078
selectBucket(previousBucketOfPastChallengesTab);
8179
} else {
@@ -193,8 +191,6 @@ SideBarFilters.propTypes = {
193191
// updateAllSavedFilters: PT.func.isRequired,
194192
// updateSavedFilter: PT.func.isRequired,
195193
// setFilter: PT.func.isRequired,
196-
past: PT.bool.isRequired,
197-
setPast: PT.func.isRequired,
198194
previousBucketOfActiveTab: PT.string,
199195
previousBucketOfPastChallengesTab: PT.string,
200196
setPreviousBucketOfActiveTab: PT.func,

src/shared/components/challenge-listing/index.jsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import PT from 'prop-types';
1313
import Sidebar from 'containers/challenge-listing/Sidebar';
1414
// import { isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
1515
// import { config } from 'topcoder-react-utils';
16+
import { useMediaQuery } from 'react-responsive';
1617

1718
import Listing from './Listing';
1819
// import ChallengeCardPlaceholder from './placeholders/ChallengeCard';
@@ -147,14 +148,16 @@ export default function ChallengeListing(props) {
147148
);
148149
// }
149150

151+
const desktop = useMediaQuery({ minWidth: 1024 });
152+
150153
return (
151154
<div styleName="ChallengeFiltersExample" id="challengeFilterContainer">
152155
<ChallengeSearchBar
153156
setFilterState={props.setFilterState}
154157
/>
155158

156159
<div styleName="tc-content-wrapper">
157-
<div styleName="sidebar-container-mobile">
160+
<div styleName={desktop ? 'sidebar-container-desktop' : 'sidebar-container-mobile'}>
158161
<Sidebar
159162
expanding={expanding}
160163
/>
@@ -165,23 +168,8 @@ export default function ChallengeListing(props) {
165168
hideSrm={hideSrm}
166169
isAuth={Boolean(auth.user)}
167170
setFilterState={props.setFilterState}
168-
hidden
169-
/>
170-
</div>
171-
172-
<div styleName="sidebar-container-desktop">
173-
<Sidebar
174-
expanding={expanding}
171+
hidden={!desktop}
175172
/>
176-
177-
<FilterPanel
178-
communityName={communityName}
179-
defaultCommunityId={defaultCommunityId}
180-
hideSrm={hideSrm}
181-
isAuth={Boolean(auth.user)}
182-
setFilterState={props.setFilterState}
183-
/>
184-
185173
</div>
186174

187175
{challengeCardContainer}

src/shared/containers/challenge-detail/index.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,14 @@ const mapDispatchToProps = (dispatch) => {
877877
return challengeDetails;
878878
});
879879
},
880-
setChallengeListingFilter: (filter) => {
880+
setChallengeListingFilter: (filter, stateProps) => {
881881
const cl = challengeListingActions.challengeListing;
882882
const cls = challengeListingSidebarActions.challengeListing.sidebar;
883-
const newFilter = _.assign({}, { types: [], tags: [] }, filter);
883+
const newFilter = _.assign(
884+
{},
885+
{ types: stateProps.challengeTypesMap.map(type => type.abbreviation), tags: [] },
886+
filter,
887+
);
884888
dispatch(cls.selectBucket(BUCKETS.OPEN_FOR_REGISTRATION));
885889
dispatch(cl.setFilter(newFilter));
886890
},
@@ -943,9 +947,17 @@ const mapDispatchToProps = (dispatch) => {
943947
};
944948
};
945949

950+
const mergeProps = (stateProps, dispatchProps, ownProps) => ({
951+
...ownProps,
952+
...stateProps,
953+
...dispatchProps,
954+
setChallengeListingFilter: filter => dispatchProps.setChallengeListingFilter(filter, stateProps),
955+
});
956+
946957
const ChallengeDetailContainer = connect(
947958
mapStateToProps,
948959
mapDispatchToProps,
960+
mergeProps,
949961
)(ChallengeDetailPageContainer);
950962

951963
export default ChallengeDetailContainer;

0 commit comments

Comments
 (0)