Skip to content

issue 2786 fix #2952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ exports[`Matches shallow shapshot 1`] = `
options={
Array [
Object {
"label": <div>
Sample community
</div>,
"label": "Sample community",
"name": "Sample community",
"value": "123",
},
Expand Down Expand Up @@ -299,9 +297,7 @@ exports[`Matches shallow shapshot 2`] = `
options={
Array [
Object {
"label": <div>
Sample community
</div>,
"label": "Sample community",
"name": "Sample community",
"value": "123",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ import PT from 'prop-types';
import Select from 'components/Select';
import moment from 'moment';
import { Button, PrimaryButton } from 'topcoder-react-ui-kit';
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 CheckmarkIcon from './CheckmarkIcon';
import DateRangePicker from '../DateRangePicker';
import style from './style.scss';
import UiSimpleRemove from '../../Icons/ui-simple-remove.svg';
Expand All @@ -43,10 +40,8 @@ export default function FiltersPanel({
communityFilters,
defaultCommunityId,
filterState,
challenges,
hidden,
isAuth,
auth,
isReviewOpportunitiesBucket,
onClose,
onSaveFilter,
Expand All @@ -61,126 +56,9 @@ export default function FiltersPanel({
let className = 'FiltersPanel';
if (hidden) className += ' hidden';

const isVisitorRegisteredToCommunity = (visitorGroupIds, communityGroupIds) => Boolean(
_.intersection(visitorGroupIds, communityGroupIds).length,
);

const getLabel = (community) => {
const { communityName } = community;
if (!isAuth) {
return (
<div>
{communityName}
</div>
);
}

const visitorGroupIds = auth.profile ? auth.profile.groups.map(g => g.id) : [];
const visitorRegisteredToCommunity = isVisitorRegisteredToCommunity(
visitorGroupIds,
community.groupIds,
);

const registrationStatus = visitorRegisteredToCommunity
? (
<div>
Registered
</div>
)
: (
<div>
You are
{' '}
<span styleName="bold uppercase">
not
</span>
{' '}
registered.
<Link
onMouseDown={(e) => {
const url = community.mainSubdomain ? (
config.URL.BASE.replace(/www/, community.mainSubdomain)
) : `/community/${community.communityId}`;
window.open(url);
e.stopPropagation();
e.preventDefault();
}}
styleName="learn-more-link"
to=""
openInNewTab
>
Learn more
</Link>
</div>
);

const filterFunction = Filter.getFilterFunction(community.challengeFilter);
const challengesInCommunity = challenges.filter(filterFunction).length;

const selectItem = (
<div styleName="community-select-item">
<div>
<div styleName="community-name">
<div>
{communityName}
</div>
{visitorRegisteredToCommunity && (
<div styleName="checkmark-icon-container">
<CheckmarkIcon color="#fff" />
</div>
)}
</div>
<div styleName="registration-status">
{communityName === 'All'
? 'Select to see all challenges'
: registrationStatus}
</div>
</div>
<div>
{challengesInCommunity}
</div>
</div>
);

if (communityName === 'All') {
return selectItem;
}

return (
<div>
<Tooltip
position="bottom"
trigger={['hover']}
content={(
<div style={{ padding: '15px', fontSize: '13px', borderRadius: '5px' }}>
<p>
You are
{ !visitorRegisteredToCommunity && (
<span styleName="bold">
NOT
</span>
)}
{' '}
registered for this sub community.
</p>
<p>
There are
{challengesInCommunity}
{' '}
challenges in this sub community
</p>
</div>
)}
>
{selectItem}
</Tooltip>
</div>
);
};

const communityOps = communityFilters.filter(community => !community.hidden)
.map(community => ({
label: getLabel(community),
label: community.communityName,
value: community.communityId,
name: community.communityName,
}));
Expand Down