Skip to content

Commit 56db857

Browse files
committed
fix: private message only for topgear
1 parent b7440c8 commit 56db857

File tree

5 files changed

+79
-7
lines changed

5 files changed

+79
-7
lines changed

__tests__/__snapshots__/index.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Object {
3030
"loadResultsInit": [Function],
3131
"registerDone": [Function],
3232
"registerInit": [Function],
33+
"setCommunityId": [Function],
3334
"toggleCheckpointFeedback": [Function],
3435
"unregisterDone": [Function],
3536
"unregisterInit": [Function],

__tests__/reducers/__snapshots__/challenge.js.snap

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`Default reducer Creates expected intial state 1`] = `
44
Object {
55
"checkpoints": null,
6+
"communityId": null,
67
"details": null,
78
"loadingCheckpoints": false,
89
"loadingDetailsForChallengeId": "",
@@ -25,6 +26,7 @@ Object {
2526
exports[`Default reducer Handles CHALLENGE/GET_DETAILS_DONE as expected 1`] = `
2627
Object {
2728
"checkpoints": null,
29+
"communityId": null,
2830
"details": Object {
2931
"id": 123456789,
3032
"tag": "v3-normalized-details",
@@ -51,6 +53,7 @@ Object {
5153
exports[`Default reducer Handles CHALLENGE/GET_DETAILS_DONE with error as expected 1`] = `
5254
Object {
5355
"checkpoints": null,
56+
"communityId": null,
5457
"details": Object {
5558
"id": 123456789,
5659
"tag": "v3-normalized-details",
@@ -77,6 +80,7 @@ Object {
7780
exports[`Default reducer Handles CHALLENGE/GET_DETAILS_INIT as expected 1`] = `
7881
Object {
7982
"checkpoints": null,
83+
"communityId": null,
8084
"details": null,
8185
"fetchChallengeFailure": false,
8286
"loadingCheckpoints": false,
@@ -100,6 +104,7 @@ Object {
100104
exports[`Default reducer Handles deleteSubmissionDone as expected 1`] = `
101105
Object {
102106
"checkpoints": null,
107+
"communityId": null,
103108
"details": Object {
104109
"id": 123456789,
105110
"tag": "v3-normalized-details",
@@ -132,6 +137,7 @@ Object {
132137
exports[`Default reducer Handles fetchSubmissionsDone as expected 1`] = `
133138
Object {
134139
"checkpoints": null,
140+
"communityId": null,
135141
"details": Object {
136142
"id": 123456789,
137143
"tag": "v3-normalized-details",
@@ -166,6 +172,7 @@ Object {
166172
exports[`Default reducer Handles fetchSubmissionsDoneError as expected 1`] = `
167173
Object {
168174
"checkpoints": null,
175+
"communityId": null,
169176
"details": Object {
170177
"id": 123456789,
171178
"tag": "v3-normalized-details",
@@ -198,6 +205,7 @@ Object {
198205
exports[`Default reducer Handles fetchSubmissionsInit as expected 1`] = `
199206
Object {
200207
"checkpoints": null,
208+
"communityId": null,
201209
"details": Object {
202210
"id": 123456789,
203211
"tag": "v3-normalized-details",
@@ -229,6 +237,7 @@ exports[`Default reducer Handles getActiveChallengesCountDone as expected 1`] =
229237
Object {
230238
"activeChallengesCount": 5,
231239
"checkpoints": null,
240+
"communityId": null,
232241
"details": Object {
233242
"id": 123456789,
234243
"tag": "v3-normalized-details",
@@ -261,6 +270,7 @@ Object {
261270
exports[`Factory with server-side rendering Creates expected intial state 1`] = `
262271
Object {
263272
"checkpoints": null,
273+
"communityId": null,
264274
"details": Object {
265275
"id": 123456789,
266276
"tag": "v3-normalized-details",
@@ -295,6 +305,7 @@ Object {
295305
exports[`Factory with server-side rendering Handles CHALLENGE/GET_DETAILS_DONE as expected 1`] = `
296306
Object {
297307
"checkpoints": null,
308+
"communityId": null,
298309
"details": Object {
299310
"id": 123456789,
300311
"tag": "v3-normalized-details",
@@ -329,6 +340,7 @@ Object {
329340
exports[`Factory with server-side rendering Handles CHALLENGE/GET_DETAILS_DONE with error as expected 1`] = `
330341
Object {
331342
"checkpoints": null,
343+
"communityId": null,
332344
"details": Object {
333345
"id": 123456789,
334346
"tag": "v3-normalized-details",
@@ -363,6 +375,7 @@ Object {
363375
exports[`Factory with server-side rendering Handles CHALLENGE/GET_DETAILS_INIT as expected 1`] = `
364376
Object {
365377
"checkpoints": null,
378+
"communityId": null,
366379
"details": Object {
367380
"id": 123456789,
368381
"tag": "v3-normalized-details",
@@ -397,6 +410,7 @@ Object {
397410
exports[`Factory with server-side rendering Handles deleteSubmissionDone as expected 1`] = `
398411
Object {
399412
"checkpoints": null,
413+
"communityId": null,
400414
"details": Object {
401415
"id": 123456789,
402416
"tag": "v3-normalized-details",
@@ -429,6 +443,7 @@ Object {
429443
exports[`Factory with server-side rendering Handles fetchSubmissionsDone as expected 1`] = `
430444
Object {
431445
"checkpoints": null,
446+
"communityId": null,
432447
"details": Object {
433448
"id": 123456789,
434449
"tag": "v3-normalized-details",
@@ -463,6 +478,7 @@ Object {
463478
exports[`Factory with server-side rendering Handles fetchSubmissionsDoneError as expected 1`] = `
464479
Object {
465480
"checkpoints": null,
481+
"communityId": null,
466482
"details": Object {
467483
"id": 123456789,
468484
"tag": "v3-normalized-details",
@@ -495,6 +511,7 @@ Object {
495511
exports[`Factory with server-side rendering Handles fetchSubmissionsInit as expected 1`] = `
496512
Object {
497513
"checkpoints": null,
514+
"communityId": null,
498515
"details": Object {
499516
"id": 123456789,
500517
"tag": "v3-normalized-details",
@@ -526,6 +543,7 @@ exports[`Factory with server-side rendering Handles getActiveChallengesCountDone
526543
Object {
527544
"activeChallengesCount": 5,
528545
"checkpoints": null,
546+
"communityId": null,
529547
"details": Object {
530548
"id": 123456789,
531549
"tag": "v3-normalized-details",
@@ -558,6 +576,7 @@ Object {
558576
exports[`Factory without http request Creates expected intial state 1`] = `
559577
Object {
560578
"checkpoints": null,
579+
"communityId": null,
561580
"details": null,
562581
"loadingCheckpoints": false,
563582
"loadingDetailsForChallengeId": "",
@@ -580,6 +599,7 @@ Object {
580599
exports[`Factory without http request Handles CHALLENGE/GET_DETAILS_DONE as expected 1`] = `
581600
Object {
582601
"checkpoints": null,
602+
"communityId": null,
583603
"details": Object {
584604
"id": 123456789,
585605
"tag": "v3-normalized-details",
@@ -606,6 +626,7 @@ Object {
606626
exports[`Factory without http request Handles CHALLENGE/GET_DETAILS_DONE with error as expected 1`] = `
607627
Object {
608628
"checkpoints": null,
629+
"communityId": null,
609630
"details": Object {
610631
"id": 123456789,
611632
"tag": "v3-normalized-details",
@@ -632,6 +653,7 @@ Object {
632653
exports[`Factory without http request Handles CHALLENGE/GET_DETAILS_INIT as expected 1`] = `
633654
Object {
634655
"checkpoints": null,
656+
"communityId": null,
635657
"details": null,
636658
"fetchChallengeFailure": false,
637659
"loadingCheckpoints": false,
@@ -655,6 +677,7 @@ Object {
655677
exports[`Factory without http request Handles deleteSubmissionDone as expected 1`] = `
656678
Object {
657679
"checkpoints": null,
680+
"communityId": null,
658681
"details": Object {
659682
"id": 123456789,
660683
"tag": "v3-normalized-details",
@@ -687,6 +710,7 @@ Object {
687710
exports[`Factory without http request Handles fetchSubmissionsDone as expected 1`] = `
688711
Object {
689712
"checkpoints": null,
713+
"communityId": null,
690714
"details": Object {
691715
"id": 123456789,
692716
"tag": "v3-normalized-details",
@@ -721,6 +745,7 @@ Object {
721745
exports[`Factory without http request Handles fetchSubmissionsDoneError as expected 1`] = `
722746
Object {
723747
"checkpoints": null,
748+
"communityId": null,
724749
"details": Object {
725750
"id": 123456789,
726751
"tag": "v3-normalized-details",
@@ -753,6 +778,7 @@ Object {
753778
exports[`Factory without http request Handles fetchSubmissionsInit as expected 1`] = `
754779
Object {
755780
"checkpoints": null,
781+
"communityId": null,
756782
"details": Object {
757783
"id": 123456789,
758784
"tag": "v3-normalized-details",
@@ -784,6 +810,7 @@ exports[`Factory without http request Handles getActiveChallengesCountDone as ex
784810
Object {
785811
"activeChallengesCount": 5,
786812
"checkpoints": null,
813+
"communityId": null,
787814
"details": Object {
788815
"id": 123456789,
789816
"tag": "v3-normalized-details",
@@ -816,6 +843,7 @@ Object {
816843
exports[`Factory without server-side rendering Creates expected intial state 1`] = `
817844
Object {
818845
"checkpoints": null,
846+
"communityId": null,
819847
"details": null,
820848
"loadingCheckpoints": false,
821849
"loadingDetailsForChallengeId": "",
@@ -838,6 +866,7 @@ Object {
838866
exports[`Factory without server-side rendering Handles CHALLENGE/GET_DETAILS_DONE as expected 1`] = `
839867
Object {
840868
"checkpoints": null,
869+
"communityId": null,
841870
"details": Object {
842871
"id": 123456789,
843872
"tag": "v3-normalized-details",
@@ -864,6 +893,7 @@ Object {
864893
exports[`Factory without server-side rendering Handles CHALLENGE/GET_DETAILS_DONE with error as expected 1`] = `
865894
Object {
866895
"checkpoints": null,
896+
"communityId": null,
867897
"details": Object {
868898
"id": 123456789,
869899
"tag": "v3-normalized-details",
@@ -890,6 +920,7 @@ Object {
890920
exports[`Factory without server-side rendering Handles CHALLENGE/GET_DETAILS_INIT as expected 1`] = `
891921
Object {
892922
"checkpoints": null,
923+
"communityId": null,
893924
"details": null,
894925
"fetchChallengeFailure": false,
895926
"loadingCheckpoints": false,
@@ -913,6 +944,7 @@ Object {
913944
exports[`Factory without server-side rendering Handles deleteSubmissionDone as expected 1`] = `
914945
Object {
915946
"checkpoints": null,
947+
"communityId": null,
916948
"details": Object {
917949
"id": 123456789,
918950
"tag": "v3-normalized-details",
@@ -945,6 +977,7 @@ Object {
945977
exports[`Factory without server-side rendering Handles fetchSubmissionsDone as expected 1`] = `
946978
Object {
947979
"checkpoints": null,
980+
"communityId": null,
948981
"details": Object {
949982
"id": 123456789,
950983
"tag": "v3-normalized-details",
@@ -979,6 +1012,7 @@ Object {
9791012
exports[`Factory without server-side rendering Handles fetchSubmissionsDoneError as expected 1`] = `
9801013
Object {
9811014
"checkpoints": null,
1015+
"communityId": null,
9821016
"details": Object {
9831017
"id": 123456789,
9841018
"tag": "v3-normalized-details",
@@ -1011,6 +1045,7 @@ Object {
10111045
exports[`Factory without server-side rendering Handles fetchSubmissionsInit as expected 1`] = `
10121046
Object {
10131047
"checkpoints": null,
1048+
"communityId": null,
10141049
"details": Object {
10151050
"id": 123456789,
10161051
"tag": "v3-normalized-details",
@@ -1042,6 +1077,7 @@ exports[`Factory without server-side rendering Handles getActiveChallengesCountD
10421077
Object {
10431078
"activeChallengesCount": 5,
10441079
"checkpoints": null,
1080+
"communityId": null,
10451081
"details": Object {
10461082
"id": 123456789,
10471083
"tag": "v3-normalized-details",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
3232
"test": "npm run lint && npm run jest"
3333
},
34-
"version": "1000.29.10",
34+
"version": "1000.29.11",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",

src/actions/challenge.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@ function getSubmissionInformationDone(challengeId, submissionId, tokenV3) {
392392
});
393393
}
394394

395+
/**
396+
* @static
397+
* @desc Creates an action that gets communityId
398+
* @param {String} communityId The communityId
399+
* @return {Action}
400+
*/
401+
function setCommunityId(communityId) {
402+
return { communityId: _.toString(communityId) };
403+
}
404+
395405
/**
396406
* @static
397407
* @desc Creates an action that signals beginning of fetching challenge statistics
@@ -415,6 +425,7 @@ export default createActions({
415425
CHALLENGE: {
416426
DROP_CHECKPOINTS: dropCheckpoints,
417427
DROP_RESULTS: dropResults,
428+
SET_COMMUNITY_ID: setCommunityId,
418429
FETCH_CHECKPOINTS_INIT: fetchCheckpointsInit,
419430
FETCH_CHECKPOINTS_DONE: fetchCheckpointsDone,
420431
GET_DETAILS_INIT: getDetailsInit,

src/reducers/challenge.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,20 @@ function onGetDetailsDone(state, action) {
5353
if (action.error) {
5454
logger.error('Failed to get challenge details!', action.payload);
5555
if (action.payload.message === 'Forbidden') {
56-
fireErrorMessage(
57-
'ERROR: Private challenge',
58-
'The challenge is only available to those in a private group.'
59-
+ ' It looks like you are not part of the group.',
60-
'Please work with the challenge creator to get yourself added to the group.',
61-
);
56+
if (state.communityId === 'wipro') {
57+
fireErrorMessage(
58+
'ERROR: Private challenge',
59+
'The challenge is only available to those in a private group.'
60+
+ ' It looks like you are not part of the group.',
61+
'Please work with the challenge creator to get yourself added to the group.',
62+
);
63+
} else {
64+
fireErrorMessage(
65+
'ERROR: Private challenge',
66+
'This challenge is only available to those in a private group.'
67+
+ ' It looks like you do not have access to this challenge.',
68+
);
69+
}
6270
} else {
6371
fireErrorMessage(
6472
'ERROR: Failed to load the challenge',
@@ -404,6 +412,20 @@ function onFetchChallengeStatisticsDone(state, action) {
404412
};
405413
}
406414

415+
/**
416+
* Handles CHALLENGE/SET_COMMUNITY_ID action.
417+
* @param {Object} state
418+
* @param {Object} action
419+
* @return {Object} New state.
420+
*/
421+
function onSetCommunityId(state, action) {
422+
return {
423+
...state,
424+
communityId: action.payload.communityId,
425+
};
426+
}
427+
428+
407429
/**
408430
* Creates a new Challenge reducer with the specified initial state.
409431
* @param {Object} initialState Optional. Initial state.
@@ -449,6 +471,7 @@ function create(initialState) {
449471
[a.getSubmissionInformationDone]: onGetSubmissionInformationDone,
450472
[a.fetchChallengeStatisticsInit]: state => state,
451473
[a.fetchChallengeStatisticsDone]: onFetchChallengeStatisticsDone,
474+
[a.setCommunityId]: onSetCommunityId,
452475
}, _.defaults(initialState, {
453476
details: null,
454477
loadingCheckpoints: false,
@@ -457,6 +480,7 @@ function create(initialState) {
457480
loadingMMSubmissionsForChallengeId: '',
458481
loadingSubmissionInformationForSubmissionId: '',
459482
mySubmissions: {},
483+
communityId: null,
460484
checkpoints: null,
461485
registering: false,
462486
results: null,

0 commit comments

Comments
 (0)