Skip to content

Commit 6f2df59

Browse files
authored
Merge pull request #132 from topcoder-platform/feature-mm-submissions
Feature mm submissions
2 parents 8c70aae + 16ee657 commit 6f2df59

File tree

18 files changed

+206
-72
lines changed

18 files changed

+206
-72
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
at: .
3030
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
3131
- run: npm publish
32-
32+
# dont change anything
3333
workflows:
3434
version: 2
3535
build:

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The [Topcoder](https://www.topcoder.com) lib for internal ReactJS projects.
1010

1111
Change the property in `AV_SCAN_SCORER_REVIEW_TYPE_ID` in config.
1212

13+
### Configuration for AV-Scan scorer review type ID
14+
15+
Change the property in `PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID` in config.
16+
1317
### Development
1418
```shell
1519
# Install dependencies
@@ -19,7 +23,7 @@ npm install
1923
npm test
2024
npm run build
2125

22-
# Go to other project which depends on the topcoder-react-lib, config its package.json so
26+
# Go to other project which depends on the topcoder-react-lib, config its package.json so
2327
# that the 'topcoder-react-lib' points to the local foler path of topcoder-react-lib:
2428
#
2529
# "dependencies": {

__tests__/__snapshots__/index.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Object {
6262
"getAllCountriesInit": [Function],
6363
"getCountriesDone": [Function],
6464
"getCountriesInit": [Function],
65+
"getReviewTypesDone": [Function],
66+
"getReviewTypesInit": [Function],
6567
"getSkillTagsDone": [Function],
6668
"getSkillTagsInit": [Function],
6769
},

__tests__/actions/__snapshots__/lookup.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Object {
77
"getAllCountriesInit": [Function],
88
"getCountriesDone": [Function],
99
"getCountriesInit": [Function],
10+
"getReviewTypesDone": [Function],
11+
"getReviewTypesInit": [Function],
1012
"getSkillTagsDone": [Function],
1113
"getSkillTagsInit": [Function],
1214
},

__tests__/reducers/__snapshots__/lookup.js.snap

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Object {
1111
],
1212
"loadingCountriesError": false,
1313
"loadingSkillTagsError": true,
14+
"reviewTypes": Array [],
1415
"skillTags": Array [
1516
Object {
1617
"domain": "SKILLS",
@@ -33,6 +34,7 @@ Object {
3334
],
3435
"loadingCountriesError": true,
3536
"loadingSkillTagsError": true,
37+
"reviewTypes": Array [],
3638
"skillTags": Array [
3739
Object {
3840
"domain": "SKILLS",
@@ -49,6 +51,7 @@ Object {
4951
"allCountries": Array [],
5052
"countries": Array [],
5153
"loadingSkillTagsError": false,
54+
"reviewTypes": Array [],
5255
"skillTags": Array [
5356
Object {
5457
"domain": "SKILLS",
@@ -65,6 +68,7 @@ Object {
6568
"allCountries": Array [],
6669
"countries": Array [],
6770
"loadingSkillTagsError": true,
71+
"reviewTypes": Array [],
6872
"skillTags": Array [
6973
Object {
7074
"domain": "SKILLS",
@@ -80,6 +84,7 @@ exports[`Default reducer Initial state 1`] = `
8084
Object {
8185
"allCountries": Array [],
8286
"countries": Array [],
87+
"reviewTypes": Array [],
8388
"skillTags": Array [],
8489
}
8590
`;
@@ -95,6 +100,7 @@ Object {
95100
],
96101
"loadingCountriesError": false,
97102
"loadingSkillTagsError": true,
103+
"reviewTypes": Array [],
98104
"skillTags": Array [
99105
Object {
100106
"domain": "SKILLS",
@@ -117,6 +123,7 @@ Object {
117123
],
118124
"loadingCountriesError": true,
119125
"loadingSkillTagsError": true,
126+
"reviewTypes": Array [],
120127
"skillTags": Array [
121128
Object {
122129
"domain": "SKILLS",
@@ -133,6 +140,7 @@ Object {
133140
"allCountries": Array [],
134141
"countries": Array [],
135142
"loadingSkillTagsError": false,
143+
"reviewTypes": Array [],
136144
"skillTags": Array [
137145
Object {
138146
"domain": "SKILLS",
@@ -149,6 +157,7 @@ Object {
149157
"allCountries": Array [],
150158
"countries": Array [],
151159
"loadingSkillTagsError": true,
160+
"reviewTypes": Array [],
152161
"skillTags": Array [
153162
Object {
154163
"domain": "SKILLS",
@@ -164,6 +173,7 @@ exports[`Factory without server side rendering Initial state 1`] = `
164173
Object {
165174
"allCountries": Array [],
166175
"countries": Array [],
176+
"reviewTypes": Array [],
167177
"skillTags": Array [],
168178
}
169179
`;

config/default.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "",
3+
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "",
34
"PAGE_SIZE": 50,
45
"REVIEW_OPPORTUNITY_PAGE_SIZE": 1000
56
}

config/development.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "68c5a381-c8ab-48af-92a7-7a869a4ee6c3"
2+
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "68c5a381-c8ab-48af-92a7-7a869a4ee6c3",
3+
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "52c91e85-745f-4e62-b592-9879a2dfe9fd"
34
}

config/production.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "55bbb17d-aac2-45a6-89c3-a8d102863d05"
2+
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "55bbb17d-aac2-45a6-89c3-a8d102863d05",
3+
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "df51ca7d-fb0a-4147-9569-992fcf5aae48"
34
}

dist/dev/index.js

+57-57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/actions.lookup.md

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Actions related to lookup data.
1111
* [.getCountriesDone()](#module_actions.lookup.getCountriesDone) ⇒ <code>Action</code>
1212
* [.getAllCountriesInit()](#module_actions.lookup.getCountriesInit) ⇒ <code>Action</code>
1313
* [.getAllCountriesDone(tokenV3)](#module_actions.lookup.getCountriesDone) ⇒ <code>Action</code>
14+
* [.getReviewTypesInit()](#module_actions.lookup.getReviewTypesInit) ⇒ <code>Action</code>
15+
* [.getReviewTypesDone(tokenV3)](#module_actions.lookup.ggetReviewTypesDone) ⇒ <code>Action</code>
1416

1517
<a name="module_actions.lookup.getSkillTagsInit"></a>
1618

@@ -40,3 +42,19 @@ Creates an action that gets all countries new version.
4042
| Param | Type | Description |
4143
| --- | --- | --- |
4244
| tokenV3 | <code>String</code> | Topcoder v3 auth token. |
45+
<a name="module_actions.lookup.getReviewTypesInit"></a>
46+
47+
### actions.lookup.getReviewTypesInit() ⇒ <code>Action</code>
48+
Creates an action that gets all reiview types.
49+
50+
**Kind**: static method of [<code>actions.lookup</code>](#module_actions.lookup)
51+
<a name="module_actions.lookup.getReviewTypesDone"></a>
52+
53+
### actions.lookup.getReviewTypesDone(tokenV3) ⇒ <code>Action</code>
54+
Creates an action that gets all review types.
55+
56+
**Kind**: static method of [<code>actions.lookup</code>](#module_actions.lookup)
57+
58+
| Param | Type | Description |
59+
| --- | --- | --- |
60+
| tokenV3 | <code>String</code> | Topcoder v3 auth token. |

docs/reducers.lookup.md

+22-9
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,48 @@ State segment managed by this reducer has the following structure:
1818
* _inner_
1919
* [~onGetSkillTagsDone(state, action)](#module_reducers.lookup..onGetSkillTagsDone) ⇒ <code>Object</code>
2020
* [~onGetCountriesDone(state, action)](#module_reducers.lookup..onGetCountriesDone) ⇒ <code>Object</code>
21+
* [~onGetReviewTypesDone(state, action)](#module_reducers.lookup..onGetReviewTypesDone) ⇒ <code>Object</code>
2122
* [~create(initialState)](#module_reducers.lookup..create) ⇒ <code>function</code>
2223

2324
<a name="module_reducers.lookup.default"></a>
2425

2526
### reducers.lookup.default
2627
Reducer with default initial state.
2728

28-
**Kind**: static property of [<code>reducers.lookup</code>](#module_reducers.lookup)
29+
**Kind**: static property of [<code>reducers.lookup</code>](#module_reducers.lookup)
2930
<a name="module_reducers.lookup.factory"></a>
3031

3132
### reducers.lookup.factory() ⇒ <code>Promise</code>
3233
Factory which creates a new reducer.
3334

34-
**Kind**: static method of [<code>reducers.lookup</code>](#module_reducers.lookup)
35-
**Resolves**: <code>Function(state, action): state</code> New reducer.
35+
**Kind**: static method of [<code>reducers.lookup</code>](#module_reducers.lookup)
36+
**Resolves**: <code>Function(state, action): state</code> New reducer.
3637
<a name="module_reducers.lookup..onGetSkillTagsDone"></a>
3738

3839
### reducers.lookup~onGetSkillTagsDone(state, action) ⇒ <code>Object</code>
3940
Handles LOOKUP/GET_SKILL_TAGS_DONE action.
4041

41-
**Kind**: static method of [<code>reducers.lookup</code>](#module_reducers.lookup)
42-
**Resolves**: <code>Function(state, action): state</code> New reducer.
42+
**Kind**: static method of [<code>reducers.lookup</code>](#module_reducers.lookup)
43+
**Resolves**: <code>Function(state, action): state</code> New reducer.
4344
<a name="module_reducers.lookup..onGetCountriesDone"></a>
4445

4546
### reducers.lookup~onGetCountriesDone(state, action) ⇒ <code>Object</code>
4647
Handles LOOKUP/GET_COUNTRIES_DONE action.
4748

48-
**Kind**: inner method of [<code>reducers.lookup</code>](#module_reducers.lookup)
49-
**Returns**: <code>Object</code> - New state
49+
**Kind**: inner method of [<code>reducers.lookup</code>](#module_reducers.lookup)
50+
**Returns**: <code>Object</code> - New state
51+
52+
| Param | Type | Description |
53+
| --- | --- | --- |
54+
| state | <code>Object</code> | |
55+
| action | <code>Object</code> | Payload will be JSON from api call |
56+
<a name="module_reducers.lookup..onGetReviewTypesDone"></a>
57+
58+
### reducers.lookup~onGetReviewTypesDone(state, action) ⇒ <code>Object</code>
59+
Handles LOOKUP/GET_REVIEW_TYPES_DONE action.
60+
61+
**Kind**: inner method of [<code>reducers.lookup</code>](#module_reducers.lookup)
62+
**Returns**: <code>Object</code> - New state
5063

5164
| Param | Type | Description |
5265
| --- | --- | --- |
@@ -58,8 +71,8 @@ Handles LOOKUP/GET_COUNTRIES_DONE action.
5871
### reducers.lookup~create(initialState) ⇒ <code>function</code>
5972
Creates a new Lookup reducer with the specified initial state.
6073

61-
**Kind**: inner method of [<code>reducers.lookup</code>](#module_reducers.lookup)
62-
**Returns**: <code>function</code> - Lookup reducer.
74+
**Kind**: inner method of [<code>reducers.lookup</code>](#module_reducers.lookup)
75+
**Returns**: <code>function</code> - Lookup reducer.
6376

6477
| Param | Type | Description |
6578
| --- | --- | --- |

docs/services.submissions.md

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ via API V5.
1313
* [new SubmissionsService(tokenV3)](#new_module_services.submissions..SubmissionsService_new)
1414
* [.getSubmissions(filters, params)](#module_services.submissions..SubmissionsService+getSubmissions) ⇒ <code>Promise</code>
1515
* [.getSubmissionInformation(submissionId)](#module_services.submissions..SubmissionsService+getSubmissionInformation) ⇒ <code>Promise</code>
16+
* [.downloadSubmission(submissionId)](#module_services.submissions..SubmissionsService+downloadSubmission) ⇒ <code>Promise</code>
1617

1718
<a name="module_services.submissions.getService"></a>
1819

@@ -35,6 +36,7 @@ Returns a new or existing submissions service.
3536
* [new SubmissionsService(tokenV3)](#new_module_services.submissions..SubmissionsService_new)
3637
* [.getSubmissions(filters, params)](#module_services.submissions..SubmissionsService+getSubmissions) ⇒ <code>Promise</code>
3738
* [.getSubmissionInformation(submissionId)](#module_services.submissions..SubmissionsService+getSubmissionInformation) ⇒ <code>Promise</code>
39+
* [.downloadSubmission(submissionId)](#module_services.submissions..SubmissionsService+downloadSubmission) ⇒ <code>Promise</code>
3840

3941
<a name="new_module_services.submissions..SubmissionsService_new"></a>
4042

@@ -68,3 +70,15 @@ Gets submission information.
6870
| Param | Type | Description |
6971
| --- | --- | --- |
7072
| submissionId | <code>String</code> | The id of submission |
73+
74+
<a name="module_services.submissions..SubmissionsService+downloadSubmission"></a>
75+
76+
#### submissionsService.downloadSubmission(submissionId) ⇒ <code>Promise</code>
77+
Download submission.
78+
79+
**Kind**: instance method of [<code>SubmissionsService</code>](#module_services.submissions..SubmissionsService)
80+
**Returns**: <code>Promise</code> - Resolves to the submission file.
81+
82+
| Param | Type | Description |
83+
| --- | --- | --- |
84+
| submissionId | <code>String</code> | The id of submission |

package.json

+1-1
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": "0.10.0",
34+
"version": "0.11.0",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",

src/actions/lookup.js

+19
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ function getCountriesDone() {
4242
return getService().getCountries();
4343
}
4444

45+
/**
46+
* @static
47+
* @desc Creates an action that signals beginning of getting all review types.
48+
* @return {Action}
49+
*/
50+
function getReviewTypesInit() {}
51+
52+
/**
53+
* @static
54+
* @desc Creates an action that gets all review types.
55+
* @param {String} tokenV3 Optional. Auth token for Topcoder API v3.
56+
* @return {Action}
57+
*/
58+
function getReviewTypesDone(tokenV3) {
59+
return getService(tokenV3).getReviewTypes();
60+
}
61+
4562
/**
4663
* @static
4764
* @desc Creates an action that signals beginning of getting all countries api version 5.
@@ -65,6 +82,8 @@ export default createActions({
6582
GET_SKILL_TAGS_DONE: getSkillTagsDone,
6683
GET_COUNTRIES_INIT: getCountriesInit,
6784
GET_COUNTRIES_DONE: getCountriesDone,
85+
GET_REVIEW_TYPES_INIT: getReviewTypesInit,
86+
GET_REVIEW_TYPES_DONE: getReviewTypesDone,
6887
GET_ALL_COUNTRIES_INIT: getAllCountriesInit,
6988
GET_ALL_COUNTRIES_DONE: getAllCountriesDone,
7089
},

src/reducers/lookup.js

+22
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ function onGetCountriesDone(state, { payload, error }) {
4848
});
4949
}
5050

51+
/**
52+
* Handles LOOKUP/GET_REVIEW_TYPES_DONE action.
53+
* @param {Object} state
54+
* @param {Object} action Payload will be JSON from api call
55+
* @return {Object} New state
56+
*/
57+
function onGetReviewTypesDone(state, { payload, error }) {
58+
if (error) {
59+
logger.error('Failed to get review types', payload);
60+
return { ...state, loadingReviewTypesError: true };
61+
}
62+
63+
return ({
64+
...state,
65+
loadingReviewTypesError: false,
66+
reviewTypes: payload,
67+
});
68+
}
69+
5170
/**
5271
* Handles LOOKUP/GET_ALL_COUNTRIES_DONE action.
5372
* @param {Object} state
@@ -79,12 +98,15 @@ function create(initialState = {}) {
7998
[a.getSkillTagsDone]: onGetSkillTagsDone,
8099
[a.getCountriesInit]: state => state,
81100
[a.getCountriesDone]: onGetCountriesDone,
101+
[a.getReviewTypesInit]: state => state,
102+
[a.getReviewTypesDone]: onGetReviewTypesDone,
82103
[a.getAllCountriesInit]: state => state,
83104
[a.getAllCountriesDone]: onGetAllCountriesDone,
84105
}, _.defaults(initialState, {
85106
skillTags: [],
86107
countries: [],
87108
allCountries: [],
109+
reviewTypes: [],
88110
}));
89111
}
90112

src/services/lookup.js

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ class LookupService {
4848
const jsonResult = await res.json();
4949
return jsonResult;
5050
}
51+
52+
/**
53+
* Gets all reviewTypes.
54+
* @return {Promise} Resolves to the review types.
55+
*/
56+
async getReviewTypes() {
57+
const res = await this.private.apiV5.get('/reviewTypes');
58+
const jsonResult = await res.json();
59+
return jsonResult;
60+
}
5161
}
5262

5363
let lastInstance = null;

src/services/submissions.js

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ class SubmissionsService {
5050
.then(res => (res.ok ? res.json() : new Error(res.statusText)))
5151
.then(res => res);
5252
}
53+
54+
/**
55+
* Download submission.
56+
* @param {Number|String} submissionId Submission ID.
57+
* @return {Promise} Resolves to the list of submission object.
58+
*/
59+
async downloadSubmission(submissionId) {
60+
return this.private.apiV5.get(`/submissions/${submissionId}/download`)
61+
.then(response => response.blob());
62+
}
5363
}
5464

5565
let lastInstance = null;

0 commit comments

Comments
 (0)