From 5d141631d4883c252d09faec0d7ecc404a7a9e57 Mon Sep 17 00:00:00 2001 From: Luiz Ricardo Rodrigues Date: Mon, 7 Nov 2022 23:01:41 -0300 Subject: [PATCH] Revert "Prod 2993" --- .../__snapshots__/FiltersPanel.jsx.snap | 3 -- .../Sidebar/__snapshots__/index.jsx.snap | 4 -- .../__snapshots__/index.jsx.snap | 2 - .../challenge-listing.helper.ts | 6 +-- .../Filters/FiltersPanel/index.jsx | 6 --- .../Listing/ReviewOpportunityBucket/index.jsx | 4 +- .../challenge-listing/Listing/index.jsx | 47 ++++++++----------- .../Sidebar/BucketSelector/Bucket/index.jsx | 12 +---- .../Sidebar/BucketSelector/Bucket/style.scss | 4 +- .../Sidebar/BucketSelector/index.jsx | 20 +------- .../challenge-listing/Sidebar/index.jsx | 12 +---- .../components/challenge-listing/index.jsx | 32 +------------ .../challenge-listing/Listing/index.jsx | 8 ---- .../containers/challenge-listing/Sidebar.jsx | 15 ------ .../reducers/challenge-listing/index.js | 4 -- src/shared/utils/challenge-listing/buckets.js | 2 +- src/shared/utils/challenge-listing/helper.js | 17 ------- 17 files changed, 31 insertions(+), 167 deletions(-) diff --git a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap index 71281dcec4..3e08a0f553 100644 --- a/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap +++ b/__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap @@ -66,10 +66,7 @@ exports[`Matches shallow shapshot 2`] = ` disabled={false} expanding={false} isAuth={false} - isReviewer={false} - loading={true} past={false} - reviewCount={0} /> diff --git a/__tests__/shared/components/challenge-listing/Sidebar/__snapshots__/index.jsx.snap b/__tests__/shared/components/challenge-listing/Sidebar/__snapshots__/index.jsx.snap index aa2d45e0eb..1baf5a8b91 100644 --- a/__tests__/shared/components/challenge-listing/Sidebar/__snapshots__/index.jsx.snap +++ b/__tests__/shared/components/challenge-listing/Sidebar/__snapshots__/index.jsx.snap @@ -13,9 +13,7 @@ exports[`Matches shallow shapshot 1`] = ` disabled={false} expanding={false} isAuth={false} - loading={true} past={false} - reviewCount={0} selectBucket={[MockFunction]} /> @@ -38,9 +36,7 @@ exports[`Matches shallow shapshot 2`] = ` disabled={false} expanding={false} isAuth={false} - loading={true} past={false} - reviewCount={0} selectBucket={[MockFunction]} /> diff --git a/__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap b/__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap index 88fee86659..455a808b80 100644 --- a/__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap +++ b/__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap @@ -29,7 +29,6 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = ` > CommonHelper.findElementByText( diff --git a/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx b/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx index bb51b1f3fd..9506f868d6 100644 --- a/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx +++ b/src/shared/components/challenge-listing/Filters/FiltersPanel/index.jsx @@ -31,7 +31,6 @@ import Tooltip from 'components/Tooltip'; import { config, Link } from 'topcoder-react-utils'; import { COMPOSE, PRIORITY } from 'react-css-super-themr'; import { REVIEW_OPPORTUNITY_TYPES } from 'utils/tc'; -import { isReviewerOrAdmin } from 'utils/challenge-listing/helper'; import { isFilterEmpty, isPastBucket, BUCKETS } from 'utils/challenge-listing/buckets'; import SwitchWithLabel from 'components/SwitchWithLabel'; import ChallengeSearchBar from 'containers/challenge-listing/ChallengeSearchBar'; @@ -72,7 +71,6 @@ export default function FiltersPanel({ setExpanded, setSort, selectBucket, - reviewCount, }) { if (hidden && !expanded) { return ( @@ -384,10 +382,8 @@ export default function FiltersPanel({ disabled={disabled} expanding={expanding} isAuth={isAuth} - isReviewer={isReviewerOrAdmin(auth)} selectBucket={selectBucket} past={past} - reviewCount={reviewCount} /> @@ -761,7 +757,6 @@ FiltersPanel.defaultProps = { onClose: _.noop, expanding: false, disabled: false, - reviewCount: 0, }; FiltersPanel.propTypes = { @@ -792,5 +787,4 @@ FiltersPanel.propTypes = { selectBucket: PT.func.isRequired, expanding: PT.bool, disabled: PT.bool, - reviewCount: PT.number, }; diff --git a/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx b/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx index 9408e22f31..07cc41627d 100644 --- a/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx +++ b/src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx @@ -84,7 +84,7 @@ export default function ReviewOpportunityBucket({ filteredOpportunities ? filteredOpportunities.length > 0 && ( ({ label: Sort[item].name, @@ -100,7 +100,7 @@ export default function ReviewOpportunityBucket({ ) : ( ({ diff --git a/src/shared/components/challenge-listing/Listing/index.jsx b/src/shared/components/challenge-listing/Listing/index.jsx index 52b91f5681..dc4b67d2d3 100644 --- a/src/shared/components/challenge-listing/Listing/index.jsx +++ b/src/shared/components/challenge-listing/Listing/index.jsx @@ -15,7 +15,6 @@ import Bucket from './Bucket'; import ReviewOpportunityBucket from './ReviewOpportunityBucket'; import CardPlaceholder from '../placeholders/ChallengeCard'; import './style.scss'; -import { isReviewerOrAdmin } from '../../../utils/challenge-listing/helper'; // const Filter = challengeUtils.filter; const LOADING_MESSAGE = 'Loading Challenges'; @@ -147,33 +146,25 @@ function Listing({ * and are only shown when explicitly chosen from the sidebar */ isReviewOpportunitiesBucket(bucket) ? ( - - { - isReviewerOrAdmin(auth) ? ( - setSort(bucket, sort)} - sort={sorts[bucket]} - challengeTypes={challengeTypes} - isLoggedIn={isLoggedIn} - setSearchText={setSearchText} - /> - ) : ( -
You have no access to review page.
- ) - } -
+ setSort(bucket, sort)} + sort={sorts[bucket]} + challengeTypes={challengeTypes} + isLoggedIn={isLoggedIn} + setSearchText={setSearchText} + /> ) : ( {BUCKET_DATA[bucket].name} - {(bucket !== BUCKETS.ALL && bucket !== BUCKETS.REVIEW_OPPORTUNITIES && count > 0 && !loading) ? {count} : null} - {(bucket === BUCKETS.REVIEW_OPPORTUNITIES && count > 0) ? {count} : null} + {(bucket !== BUCKETS.ALL && count > 0) ? {count} : null} ); } @@ -106,8 +100,6 @@ Bucket.defaultProps = { disabled: false, onClick: _.noop, meta: {}, - reviewCount: 0, - loading: true, }; Bucket.propTypes = { @@ -124,8 +116,6 @@ Bucket.propTypes = { onClick: PT.func, meta: PT.shape(), // allActiveChallengesLoaded: PT.bool.isRequired, - loading: PT.bool, - reviewCount: PT.number, }; const mapStateToProps = (state) => { diff --git a/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/style.scss b/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/style.scss index 9f660fa94e..08fff51366 100644 --- a/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/style.scss +++ b/src/shared/components/challenge-listing/Sidebar/BucketSelector/Bucket/style.scss @@ -52,7 +52,7 @@ font-weight: 400; font-size: 16px; - line-height: 26px; + line-height: 24px; color: $tco-black; margin-left: 5px; } @@ -74,7 +74,7 @@ text-align: center; padding: 0 8px; margin-left: 8px; - margin-bottom: 8px; + margin-bottom: 5px; } } diff --git a/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx b/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx index 00d50cbdba..db92ca637c 100644 --- a/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx +++ b/src/shared/components/challenge-listing/Sidebar/BucketSelector/index.jsx @@ -7,7 +7,6 @@ import PT from 'prop-types'; import React from 'react'; import { BUCKETS } from 'utils/challenge-listing/buckets'; -import { isReviewerOrAdmin } from 'utils/challenge-listing/helper'; // import { challenge as challengeUtils } from 'topcoder-react-lib'; import Bucket from './Bucket'; @@ -30,15 +29,11 @@ export default function BucketSelector({ // extraBucket, // filterState, isAuth, - // isReviewer, // savedFilters, selectBucket, // selectSavedFilter, // setEditSavedFiltersMode, past, - auth, - reviewCount, - loading, }) { // let filteredChallenges = challenges.filter(Filter.getFilterFunction(filterState)); @@ -54,7 +49,6 @@ export default function BucketSelector({ { @@ -63,7 +57,6 @@ export default function BucketSelector({ document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }} - loading={loading} /> ); }; @@ -96,7 +89,7 @@ export default function BucketSelector({ {getBucket(BUCKETS.OPEN_FOR_REGISTRATION)} {/* DISABLED: Until api receive fix community-app#5073 */} {/* {getBucket(BUCKETS.ONGOING)} */} - {isReviewerOrAdmin(auth) ? getBucket(BUCKETS.REVIEW_OPPORTUNITIES) : null} + {getBucket(BUCKETS.REVIEW_OPPORTUNITIES)} {/* {getBucket(BUCKETS.PAST)} */} {/* NOTE: We do not show upcoming challenges for now, for various reasons, * more political than technical ;) @@ -147,19 +140,11 @@ BucketSelector.defaultProps = { disabled: false, // extraBucket: null, isAuth: false, - // isReviewer: false, expanding: false, past: false, - reviewCount: 0, - loading: true, }; BucketSelector.propTypes = { - auth: PT.shape({ - profile: PT.shape(), - tokenV3: PT.string, - user: PT.shape(), - }).isRequired, activeBucket: PT.string.isRequired, expanding: PT.bool, // activeSavedFilter: PT.number.isRequired, @@ -171,12 +156,9 @@ BucketSelector.propTypes = { // extraBucket: PT.string, // filterState: PT.shape().isRequired, isAuth: PT.bool, - // isReviewer: PT.bool, // savedFilters: PT.arrayOf(PT.shape()).isRequired, selectBucket: PT.func.isRequired, - reviewCount: PT.number, // selectSavedFilter: PT.func.isRequired, // setEditSavedFiltersMode: PT.func.isRequired, past: PT.bool, - loading: PT.bool, }; diff --git a/src/shared/components/challenge-listing/Sidebar/index.jsx b/src/shared/components/challenge-listing/Sidebar/index.jsx index 5ecd71537b..b0ad3de237 100644 --- a/src/shared/components/challenge-listing/Sidebar/index.jsx +++ b/src/shared/components/challenge-listing/Sidebar/index.jsx @@ -17,7 +17,7 @@ import React from 'react'; import PT from 'prop-types'; -// import { isReviewerOrAdmin } from 'utils/challenge-listing/helper'; +// import _ from 'lodash'; import { isPastBucket } from 'utils/challenge-listing/buckets'; import ChallengeSearchBar from 'containers/challenge-listing/ChallengeSearchBar'; import BucketSelector from './BucketSelector'; @@ -42,7 +42,6 @@ export default function SideBarFilters({ // extraBucket, // filterState, // hideTcLinksInFooter, - auth, isAuth, // resetFilterName, // savedFilters, @@ -53,8 +52,6 @@ export default function SideBarFilters({ // updateSavedFilter, // setFilter, setFilterState, - reviewCount, - loading, }) { const past = isPastBucket(activeBucket); @@ -116,14 +113,11 @@ export default function SideBarFilters({ // extraBucket={extraBucket} // filterState={filterState} isAuth={isAuth} - auth={auth} - reviewCount={reviewCount} // savedFilters={savedFilters} selectBucket={selectBucket} // selectSavedFilter={selectSavedFilter} // setEditSavedFiltersMode={setEditSavedFiltersMode} past={past} - loading={loading} /> {/* )} */} @@ -140,7 +134,6 @@ SideBarFilters.defaultProps = { // extraBucket: null, // hideTcLinksInFooter: false, isAuth: false, - reviewCount: 0, expanding: false, }; @@ -162,9 +155,7 @@ SideBarFilters.propTypes = { // extraBucket: PT.string, // filterState: PT.shape().isRequired, // hideTcLinksInFooter: PT.bool, - auth: PT.shape().isRequired, isAuth: PT.bool, - reviewCount: PT.number, // resetFilterName: PT.func.isRequired, // savedFilters: PT.arrayOf(PT.shape()).isRequired, selectBucket: PT.func.isRequired, @@ -174,5 +165,4 @@ SideBarFilters.propTypes = { // updateSavedFilter: PT.func.isRequired, // setFilter: PT.func.isRequired, setFilterState: PT.func.isRequired, - loading: PT.bool.isRequired, }; diff --git a/src/shared/components/challenge-listing/index.jsx b/src/shared/components/challenge-listing/index.jsx index c8bec33705..00b5c564e7 100644 --- a/src/shared/components/challenge-listing/index.jsx +++ b/src/shared/components/challenge-listing/index.jsx @@ -7,10 +7,6 @@ import FilterPanel from 'containers/challenge-listing/FilterPanel'; // import moment from 'moment'; import React from 'react'; -import { - BUCKET_DATA, -} from 'utils/challenge-listing/buckets'; -import { challenge as challengeUtils } from 'topcoder-react-lib'; import PT from 'prop-types'; // import { challenge as challengeUtils } from 'topcoder-react-lib'; import Sidebar from 'containers/challenge-listing/Sidebar'; @@ -24,7 +20,7 @@ import ChallengeTab from './ChallengeTab'; import './style.scss'; -const Filter = challengeUtils.filter; +// const Filter = challengeUtils.filter; // Number of challenge placeholder card to display // const CHALLENGE_PLACEHOLDER_COUNT = 8; @@ -58,30 +54,10 @@ export default function ChallengeListing(props) { setPreviousBucketOfPastChallengesTab, previousBucketOfPastChallengesTab, previousBucketOfActiveTab, - reviewOpportunities, - filterState, - challengeTypes, } = props; // const { challenges } = props; - // const activeSort = sort || BUCKET_DATA[bucket].sorts[0]; - - // const sortedOpportunities = _.clone(opportunities); - // sortedOpportunities.sort(Sort[activeSort].func); - - /* Filtering for Review Opportunities will be done entirely in the front-end - * which means it can be done at render, rather than in the reducer, - * which avoids reloading the review opportunities from server every time - * a filter is changed. */ - const filteredOpportunities = reviewOpportunities.filter( - Filter.getReviewOpportunitiesFilterFunction({ - ...BUCKET_DATA.reviewOpportunities.filter, // Default bucket filters from utils/buckets.js - ...filterState, // User selected filters - }, challengeTypes), - // }), - ); - // if (communityFilter) { // challenges = challenges.filter(Filter.getFilterFunction(props.communityFilter)); // } @@ -199,10 +175,6 @@ export default function ChallengeListing(props) { { this.setState({ previousBucketOfPastChallengesTab: bucket }); }} - loading={loading} /> ); } @@ -171,9 +160,6 @@ SidebarContainer.propTypes = { // user: PT.shape(), // userChallenges: PT.arrayOf(PT.string), expanding: PT.bool, - loadingMyChallenges: PT.bool.isRequired, - loadingOpenForRegistrationChallenges: PT.bool.isRequired, - loadingReviewOpportunities: PT.bool.isRequired, }; function mapDispatchToProps(dispatch) { @@ -203,7 +189,6 @@ function mapStateToProps(state) { // hideTcLinksInFooter: ownProps.hideTcLinksInFooter, filterState: state.challengeListing.filter, isAuth: Boolean(state.auth.user), - auth: state.auth, // communityFilters: state.tcCommunities.list.data, // selectedCommunityId: state.challengeListing.selectedCommunityId, // tokenV2: state.auth.tokenV2, diff --git a/src/shared/reducers/challenge-listing/index.js b/src/shared/reducers/challenge-listing/index.js index c831296092..319c245e0b 100644 --- a/src/shared/reducers/challenge-listing/index.js +++ b/src/shared/reducers/challenge-listing/index.js @@ -507,10 +507,6 @@ function onGetReviewOpportunitiesDone(state, { payload, error }) { reviewOpportunities, loadingReviewOpportunitiesUUID: '', allReviewOpportunitiesLoaded: loaded.length === 0, - meta: { - ...state.meta, - openReviewCount: reviewOpportunities.length, - }, }; } diff --git a/src/shared/utils/challenge-listing/buckets.js b/src/shared/utils/challenge-listing/buckets.js index 368aa533a4..ca85e0572a 100644 --- a/src/shared/utils/challenge-listing/buckets.js +++ b/src/shared/utils/challenge-listing/buckets.js @@ -114,7 +114,7 @@ export const BUCKET_DATA = { [BUCKETS.REVIEW_OPPORTUNITIES]: { filter: {}, // hideCount: true, - name: 'Review Opportunities', + name: 'Open for Review', sorts: [ SORTS.REVIEW_OPPORTUNITIES_START_DATE, SORTS.REVIEW_OPPORTUNITIES_PAYMENT, diff --git a/src/shared/utils/challenge-listing/helper.js b/src/shared/utils/challenge-listing/helper.js index 11998eb42f..919bba5f86 100644 --- a/src/shared/utils/challenge-listing/helper.js +++ b/src/shared/utils/challenge-listing/helper.js @@ -1,4 +1,3 @@ -import _ from 'lodash'; import moment from 'moment'; /** @@ -63,19 +62,3 @@ export const formatOrdinals = (n) => { return ord; }; - -/** - * Check if user's role is reviewer or admin - * @param {Object || null} auth - * - * @returns {Boolean} - */ -export const isReviewerOrAdmin = (auth) => { - const roles = _.get(auth, 'user.roles'); - - if (!roles || !_.isArray(roles)) { - return false; - } - - return _.intersection(roles, ['administrator', 'Reviewer', 'Gamification Admin', 'Connect Admin', 'admin']).length; -};