Skip to content

Submission redirect to details page when user not logged in #4570

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

Merged
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 @@ -29,6 +29,7 @@ export default function ChallengesCard({
userHandle,
expandedTags,
expandTag,
isLoggedIn,
}) {
const {
id,
Expand Down Expand Up @@ -101,6 +102,7 @@ export default function ChallengesCard({
selectChallengeDetailsTab={_.noop}
userHandle={userHandle}
className={styles['challenge-status-container']}
isLoggedIn={isLoggedIn}
/>
</div>
</div>
Expand Down Expand Up @@ -132,4 +134,5 @@ ChallengesCard.propTypes = {
userHandle: PT.string,
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
isLoggedIn: PT.bool.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function RecommendedActiveChallenges({
auth,
expandedTags,
expandTag,
isLoggedIn,
}) {
const items = _.map(challenges, (c, idx) => (
<ChallengesCard
Expand All @@ -27,6 +28,7 @@ export default function RecommendedActiveChallenges({
challengeTypes={challengeTypes}
expandedTags={expandedTags}
expandTag={expandTag}
isLoggedIn={isLoggedIn}
/>
));

Expand Down Expand Up @@ -69,4 +71,5 @@ RecommendedActiveChallenges.propTypes = {
}).isRequired,
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
isLoggedIn: PT.bool.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function NumSubmissions({
newChallengeDetails,
selectChallengeDetailsTab,
openChallengesInNewTabs,
isLoggedIn,
}) {
let tip;
const numOfSub = numOfSubmissions || 0;
Expand All @@ -31,7 +32,8 @@ export default function NumSubmissions({
case 1: tip = '1 total submission'; break;
default: tip = `${numOfSub} total submissions`;
}
const query = numOfSub ? `?tab=${DETAIL_TABS.SUBMISSIONS}` : '';

const query = (numOfSub && isLoggedIn) ? `?tab=${DETAIL_TABS.SUBMISSIONS}` : '';
const { track } = legacy;
let link = `${challengesUrl}/${id}${query}`;
if (!newChallengeDetails && track !== 'DATA_SCIENCE') {
Expand Down Expand Up @@ -81,4 +83,5 @@ NumSubmissions.propTypes = {
newChallengeDetails: PT.bool.isRequired,
selectChallengeDetailsTab: PT.func.isRequired,
openChallengesInNewTabs: PT.bool,
isLoggedIn: PT.bool.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function ChallengeStatus(props) {
selectChallengeDetailsTab,
openChallengesInNewTabs,
userId,
isLoggedIn,
} = props;

/* TODO: Split into a separate ReactJS component! */
Expand Down Expand Up @@ -183,6 +184,7 @@ export default function ChallengeStatus(props) {
newChallengeDetails={newChallengeDetails}
selectChallengeDetailsTab={selectChallengeDetailsTab}
openChallengesInNewTabs={openChallengesInNewTabs}
isLoggedIn={isLoggedIn}
/>
</div>
{
Expand Down Expand Up @@ -247,6 +249,7 @@ export default function ChallengeStatus(props) {
newChallengeDetails={newChallengeDetails}
selectChallengeDetailsTab={selectChallengeDetailsTab}
openChallengesInNewTabs={openChallengesInNewTabs}
isLoggedIn={isLoggedIn}
/>
</div>
{
Expand Down Expand Up @@ -308,4 +311,5 @@ ChallengeStatus.propTypes = {
selectChallengeDetailsTab: PT.func.isRequired,
className: PT.string,
userId: PT.string,
isLoggedIn: PT.bool.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function ChallengeCard({
selectChallengeDetailsTab,
userId,
domRef,
isLoggedIn,
}) {
const challenge = passedInChallenge;
const {
Expand Down Expand Up @@ -117,6 +118,7 @@ function ChallengeCard({
sampleWinnerProfile={sampleWinnerProfile}
selectChallengeDetailsTab={selectChallengeDetailsTab}
userId={userId}
isLoggedIn={isLoggedIn}
/>
</div>
</div>
Expand Down Expand Up @@ -149,6 +151,7 @@ ChallengeCard.propTypes = {
expandedTags: PT.arrayOf(PT.number),
expandTag: PT.func,
domRef: PT.func,
isLoggedIn: PT.bool.isRequired,
};

export default ChallengeCard;
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function Bucket({
expandTag,
activeBucket,
searchTimestamp,
isLoggedIn,
}) {
const refs = useRef([]);
refs.current = [];
Expand Down Expand Up @@ -113,6 +114,7 @@ export default function Bucket({
expandedTags={expandedTags}
expandTag={expandTag}
domRef={addToRefs}
isLoggedIn={isLoggedIn}
/>
));

Expand Down Expand Up @@ -219,4 +221,5 @@ Bucket.propTypes = {
expandTag: PT.func,
activeBucket: PT.string,
searchTimestamp: PT.number,
isLoggedIn: PT.bool.isRequired,
};
4 changes: 4 additions & 0 deletions src/shared/components/challenge-listing/Listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Listing({
expandedTags,
expandTag,
pastSearchTimestamp,
isLoggedIn,
}) {
const buckets = getBuckets(userChallenges);
const isChallengesAvailable = (bucket) => {
Expand Down Expand Up @@ -92,6 +93,7 @@ function Listing({
setSort={sort => setSort(bucket, sort)}
sort={sorts[bucket]}
challengeTypes={challengeTypes}
isLoggedIn={isLoggedIn}
/>
)
: (
Expand Down Expand Up @@ -121,6 +123,7 @@ function Listing({
userId={_.get(auth, 'user.userId')}
activeBucket={activeBucket}
searchTimestamp={searchTimestamp}
isLoggedIn={isLoggedIn}
/>
)
);
Expand Down Expand Up @@ -214,6 +217,7 @@ Listing.propTypes = {
sorts: PT.shape().isRequired,
pastSearchTimestamp: PT.number,
userChallenges: PT.arrayOf(PT.shape()),
isLoggedIn: PT.bool.isRequired,
};

const mapStateToProps = (state) => {
Expand Down
3 changes: 3 additions & 0 deletions src/shared/components/challenge-listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function ChallengeListing(props) {
loadingChallenges,
preListingMsg,
isBucketSwitching,
isLoggedIn,
} = props;

let { challenges } = props;
Expand Down Expand Up @@ -116,6 +117,7 @@ export default function ChallengeListing(props) {
loadMoreActive={props.loadMoreActive}
loadingActiveChallenges={props.loadingChallenges}
userChallenges={props.userChallenges}
isLoggedIn={isLoggedIn}
/>
);
}
Expand Down Expand Up @@ -239,4 +241,5 @@ ChallengeListing.propTypes = {
loadMoreActive: PT.func,
isBucketSwitching: PT.bool,
userChallenges: PT.arrayOf(PT.string),
isLoggedIn: PT.bool.isRequired,
};
1 change: 1 addition & 0 deletions src/shared/containers/challenge-detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ class ChallengeDetailPageContainer extends React.Component {
auth={auth}
expandedTags={expandedTags}
expandTag={expandTag}
isLoggedIn={isLoggedIn}
/>
) : null
}
Expand Down
3 changes: 3 additions & 0 deletions src/shared/containers/challenge-listing/Listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export class ListingContainer extends React.Component {

const { tokenV3 } = auth;

const isLoggedIn = !_.isEmpty(auth.tokenV3);

let loadMorePast;
if (!allPastChallengesLoaded) {
loadMorePast = () => {
Expand Down Expand Up @@ -312,6 +314,7 @@ export class ListingContainer extends React.Component {
auth={auth}
isBucketSwitching={isBucketSwitching}
userChallenges={userChallenges}
isLoggedIn={isLoggedIn}
/>
</div>
);
Expand Down