Skip to content

Commit a21e2cb

Browse files
authored
Merge pull request #480 from topcoder-platform/develop
blockchain content update, new terms flow
2 parents bcf55a5 + fc869c9 commit a21e2cb

File tree

38 files changed

+815
-355
lines changed

38 files changed

+815
-355
lines changed

.exchange-rates.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1505736000,"base":"USD","rates":{"AED":3.673158,"AFN":68.5815,"ALL":111.8,"AMD":477.790313,"ANG":1.778804,"AOA":165.9215,"ARS":16.9755,"AUD":1.25125,"AWG":1.795504,"AZN":1.7,"BAM":1.634564,"BBD":2,"BDT":80.672708,"BGN":1.636335,"BHD":0.377082,"BIF":1741.930974,"BMD":1,"BND":1.34545,"BOB":6.960491,"BRL":3.109108,"BSD":1,"BTC":0.000253264491,"BTN":64.116668,"BWP":10.145655,"BYN":1.937212,"BZD":2.014389,"CAD":1.220886,"CDF":1562.881563,"CHF":0.959897,"CLF":0.02317,"CLP":624.3,"CNH":6.573772,"CNY":6.567823,"COP":2895.45,"CRC":576.47,"CUC":1,"CUP":25.5,"CVE":92.5,"CZK":21.844736,"DJF":178.57,"DKK":6.230533,"DOP":47.218414,"DZD":111.31,"EGP":17.657,"ERN":15.33,"ETB":23.555095,"EUR":0.837253,"FJD":2.021499,"FKP":0.738416,"GBP":0.738416,"GEL":2.4678,"GGP":0.738416,"GHS":4.389404,"GIP":0.738416,"GMD":45.875,"GNF":8956.4,"GTQ":7.288462,"GYD":207.825,"HKD":7.816553,"HNL":23.374343,"HRK":6.263403,"HTG":62.980903,"HUF":259.437857,"IDR":13250.485412,"ILS":3.522186,"IMP":0.738416,"INR":64.13575,"IQD":1165.334957,"IRR":33322.5,"ISK":106.536883,"JEP":0.738416,"JMD":130.80781,"JOD":0.7085,"JPY":111.36808333,"KES":103.163661,"KGS":68.5084,"KHR":4056.35,"KMF":412.198944,"KPW":900,"KRW":1127.07,"KWD":0.301343,"KYD":0.832734,"KZT":340.315,"LAK":8280.05,"LBP":1506.95,"LKR":153.01,"LRD":117.002232,"LSL":13.175459,"LYD":1.361065,"MAD":9.344244,"MDL":17.643449,"MGA":2988,"MKD":51.51,"MMK":1345.1,"MNT":2459.426676,"MOP":8.045534,"MRO":364.77,"MUR":33.434,"MVR":15.450233,"MWK":725.38,"MXN":17.68575,"MYR":4.186467,"MZN":61.32,"NAD":13.176312,"NGN":359.885566,"NIO":30.345231,"NOK":7.824174,"NPR":102.523085,"NZD":1.372936,"OMR":0.384999,"PAB":1,"PEN":3.250448,"PGK":3.237256,"PHP":51.254,"PKR":105.279978,"PLN":3.5905,"PYG":5655.55,"QAR":3.6391,"RON":3.8506,"RSD":99.645,"RUB":57.747,"RWF":830.004133,"SAR":3.7509,"SBD":7.830881,"SCR":13.550608,"SDG":6.672493,"SEK":7.970225,"SGD":1.346251,"SHP":0.738416,"SLL":7562.5,"SOS":577.104786,"SRD":7.438,"SSP":126.0479,"STD":20503.299805,"SVC":8.743343,"SYP":515.10499,"SZL":13.181602,"THB":33.090672,"TJS":8.79211,"TMT":3.50998,"TND":2.439804,"TOP":2.232925,"TRY":3.4586,"TTD":6.74155,"TWD":30.098212,"TZS":2244.6,"UAH":26.142754,"UGX":3593.6,"USD":1,"UYU":28.997418,"UZS":8086.95,"VEF":9.985022,"VND":22727.933333,"VUV":104.754453,"WST":2.500057,"XAF":549.202101,"XAG":0.05731152,"XAU":0.00076117,"XCD":2.70255,"XDR":0.702343,"XOF":549.202101,"XPD":0.00107202,"XPF":99.910884,"XPT":0.00103467,"YER":250.319142,"ZAR":13.207619,"ZMW":9.628588,"ZWL":322.355011}}
1+
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1505811600,"base":"USD","rates":{"AED":3.673014,"AFN":68.614,"ALL":111.776085,"AMD":478.295,"ANG":1.77968,"AOA":165.9215,"ARS":17.0995,"AUD":1.252216,"AWG":1.796504,"AZN":1.6855,"BAM":1.635351,"BBD":2,"BDT":80.708351,"BGN":1.63299,"BHD":0.377284,"BIF":1745.45,"BMD":1,"BND":1.348334,"BOB":6.963698,"BRL":3.13655,"BSD":1,"BTC":0.000253137519,"BTN":64.166558,"BWP":10.15073,"BYN":1.938191,"BZD":2.015375,"CAD":1.228379,"CDF":1562.881563,"CHF":0.961344,"CLF":0.02325,"CLP":624.6,"CNH":6.585748,"CNY":6.583106,"COP":2909,"CRC":576.745,"CUC":1,"CUP":25.5,"CVE":92.55,"CZK":21.791915,"DJF":178.57,"DKK":6.209958,"DOP":47.241072,"DZD":111.282333,"EGP":17.6487,"ERN":15.331922,"ETB":23.566647,"EUR":0.834449,"FJD":2.012549,"FKP":0.742007,"GBP":0.742007,"GEL":2.4717,"GGP":0.742007,"GHS":4.381672,"GIP":0.742007,"GMD":45.95,"GNF":8960.5,"GTQ":7.292123,"GYD":207.92,"HKD":7.803084,"HNL":23.385811,"HRK":6.235527,"HTG":63.0095,"HUF":258.117002,"IDR":13264.557907,"ILS":3.52281,"IMP":0.742007,"INR":64.245,"IQD":1165.609957,"IRR":33337.5,"ISK":105.94,"JEP":0.742007,"JMD":130.865,"JOD":0.709001,"JPY":111.5666875,"KES":103.367854,"KGS":68.455728,"KHR":4058.3,"KMF":412.561444,"KPW":900,"KRW":1131.54,"KWD":0.301307,"KYD":0.833119,"KZT":340.305898,"LAK":8284.05,"LBP":1507.65,"LKR":153.101598,"LRD":117.111232,"LSL":13.182434,"LYD":1.361748,"MAD":9.333026,"MDL":17.669492,"MGA":2989.5,"MKD":51.401508,"MMK":1345.8,"MNT":2468.97015,"MOP":8.049209,"MRO":364.935,"MUR":33.4205,"MVR":15.450233,"MWK":724.527458,"MXN":17.810955,"MYR":4.191489,"MZN":61.732957,"NAD":13.182434,"NGN":360.37226,"NIO":30.359705,"NOK":7.804146,"NPR":102.548085,"NZD":1.372687,"OMR":0.385015,"PAB":1,"PEN":3.247336,"PGK":3.23879,"PHP":50.99,"PKR":105.333422,"PLN":3.5831,"PYG":5658.3,"QAR":3.656908,"RON":3.840574,"RSD":99.257652,"RUB":58.1634,"RWF":831.55,"SAR":3.75035,"SBD":7.823231,"SCR":13.55,"SDG":6.675602,"SEK":7.95019,"SGD":1.348793,"SHP":0.742007,"SLL":7558.984779,"SOS":578.446731,"SRD":7.438,"SSP":126.2714,"STD":20487.565958,"SVC":8.747714,"SYP":515.00499,"SZL":13.187884,"THB":33.083,"TJS":8.795919,"TMT":3.50998,"TND":2.437494,"TOP":2.2232,"TRY":3.501853,"TTD":6.74491,"TWD":30.156,"TZS":2243.2,"UAH":26.155965,"UGX":3595.3,"USD":1,"UYU":28.986914,"UZS":8090.5,"VEF":9.995002,"VND":22731.335859,"VUV":104.480024,"WST":2.480432,"XAF":547.362622,"XAG":0.05821916,"XAU":0.00076407,"XCD":2.70255,"XDR":0.702671,"XOF":547.362622,"XPD":0.00107407,"XPF":99.576246,"XPT":0.00104276,"YER":250.344142,"ZAR":13.330636,"ZMW":9.633257,"ZWL":322.355011}}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If you need any operations related to currency conversions, pay attention to the
4747
- `PORT` Specifies the port to run the App at. Defaults to 3000;
4848
- `NODE_ENV` Specifies Topcoder backend to use. Should be either `development` either `production`. Defaults to `production`.
4949

50-
5. To rebuild the App's frontend (initially, it is automatically build as a part of the install step) run one of (the result of build will be output into `/build` folder in both cases):
50+
5. To build the App's frontend run one of (the result of build will be output into `/build` folder in both cases):
5151
- `$ npm run build` To rebuild production frontend;
5252
- `$ npm run build:dev` This command should only be used to test whether development build of the front end works. You don't have to execute this command to run development version of the App (the server will automatically build frontend in memory anyway). You can't successfully execute this command without installing dev dependencies.
5353

__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
2323
<div>
2424
<SRMCard
2525
category="now"
26+
srmChallenge={null}
2627
/>
2728
</div>
2829
<div>
@@ -40,6 +41,7 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
4041
</div>
4142
<SRMCard
4243
category="past"
44+
srmChallenge={null}
4345
/>
4446
</div>
4547
</div>
@@ -135,6 +137,7 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
135137
<div>
136138
<SRMCard
137139
category="now"
140+
srmChallenge={null}
138141
/>
139142
</div>
140143
<div>
@@ -152,6 +155,7 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
152155
</div>
153156
<SRMCard
154157
category="past"
158+
srmChallenge={null}
155159
/>
156160
</div>
157161
</div>

__tests__/shared/reducers/challenge.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ function testReducer(reducer, istate) {
8686
resultsLoadedForChallengeId: '',
8787
selectedTab: 'details',
8888
unregistering: false,
89-
showTermsModal: false,
9089
});
9190
});
9291

@@ -112,7 +111,6 @@ function testReducer(reducer, istate) {
112111
resultsLoadedForChallengeId: '',
113112
selectedTab: 'details',
114113
unregistering: false,
115-
showTermsModal: false,
116114
});
117115
});
118116

@@ -132,7 +130,6 @@ function testReducer(reducer, istate) {
132130
resultsLoadedForChallengeId: '',
133131
selectedTab: 'details',
134132
unregistering: false,
135-
showTermsModal: false,
136133
});
137134
});
138135

@@ -154,7 +151,6 @@ function testReducer(reducer, istate) {
154151
resultsLoadedForChallengeId: '',
155152
selectedTab: 'details',
156153
unregistering: false,
157-
showTermsModal: false,
158154
});
159155
});
160156

@@ -177,7 +173,6 @@ function testReducer(reducer, istate) {
177173
resultsLoadedForChallengeId: '',
178174
selectedTab: 'details',
179175
unregistering: false,
180-
showTermsModal: false,
181176
});
182177
});
183178

@@ -200,7 +195,6 @@ function testReducer(reducer, istate) {
200195
resultsLoadedForChallengeId: '',
201196
selectedTab: 'details',
202197
unregistering: false,
203-
showTermsModal: false,
204198
});
205199
});
206200

@@ -223,7 +217,6 @@ function testReducer(reducer, istate) {
223217
resultsLoadedForChallengeId: '',
224218
selectedTab: 'details',
225219
unregistering: false,
226-
showTermsModal: false,
227220
});
228221
});
229222
}
@@ -242,7 +235,6 @@ describe('Default reducer', () =>
242235
resultsLoadedForChallengeId: '',
243236
selectedTab: 'details',
244237
unregistering: false,
245-
showTermsModal: false,
246238
}),
247239
);
248240

@@ -260,7 +252,6 @@ describe('Factory without http request', () =>
260252
mySubmissionsManagement: {},
261253
registering: false,
262254
unregistering: false,
263-
showTermsModal: false,
264255
}),
265256
),
266257
);
@@ -282,7 +273,6 @@ describe('Factory with server-side rendering', () =>
282273
mySubmissionsManagement: {},
283274
registering: false,
284275
unregistering: false,
285-
showTermsModal: false,
286276
}),
287277
),
288278
);
@@ -300,7 +290,6 @@ describe('Factory without server-side rendering', () =>
300290
mySubmissionsManagement: {},
301291
registering: false,
302292
unregistering: false,
303-
showTermsModal: false,
304293
}),
305294
),
306295
);

docs/how-to-add-a-new-topcoder-community.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ To add a new community with the name **demo**, we should follow the following pr
123123

124124
5. At this point **demo** community is ready and accessible at the `/community/demo` route of the App (i.e., if we deploy dev version of the App to `community-west.topcoder-dev.com`, community will be accessible as `community-west.topcoder-dev.com/community/demo`).
125125

126-
To make **demo** community accessible via a dedicated sub-domain, e.g. like `demo.topcoder-dev.com`, you should edit `/src/shared/routes/index.jsx`. In the first `if-else` block inside `Routes()` function add the line
127-
```js
128-
else if (subdomains.indexOf('demo') >= 0) communityId = 'demo';
129-
```
130-
This takes care about proper sub-domain routing from our App's side. Beside it you should:
126+
To make **demo** community accessible via a dedicated sub-domain, e.g. like `demo.topcoder-dev.com`, you should edit `/src/shared/routes/subdomains.js`; add `demo: 'demo',` record (i.e. the format is `subdomain: 'communityId'`) into the `SUBDOMAIN_COMMUNITY` map. Beside it you should:
131127
- Ensure that the web-server where the App is deployed allows access to the subdomain `demo.topcoder-dev`, and redirects incoming requests to the App.
132128
- Ensure that Topcoder `accounts-app` allows to authenticate from the new subdomain address.

package-lock.json

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import path from 'path';
99
import favicon from 'serve-favicon';
1010
import requestIp from 'request-ip';
1111
import stream from 'stream';
12+
import serializeJs from 'serialize-javascript';
1213
import { getRates as getExchangeRates } from 'services/money';
1314
import { toJson as xmlToJson } from 'utils/xml2json';
1415

@@ -105,9 +106,10 @@ app.use('/api/exchange-rates', (req, res) => {
105106
getExchangeRates().then(rates => res.send(rates));
106107
});
107108

109+
/* Receive the signing result from DocuSign server, and then send result to client
110+
*/
108111
app.use('/iframe-break', (req, res) => {
109-
const url = req.query.dest;
110-
res.send(`<script>window.top.location.href="${url}"</script>`);
112+
res.send(`<script>parent.postMessage(${serializeJs({ ...req.query, type: 'DocuSign' })}, '*')</script>`);
111113
});
112114

113115
/* Serves a mock DocuSign page. Which is, actually, just a simple local

src/shared/actions/challenge.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ export default createActions({
171171
REGISTER_DONE: registerDone,
172172
UNREGISTER_INIT: _.noop,
173173
UNREGISTER_DONE: unregisterDone,
174-
OPEN_TERMS_MODAL: _.noop,
175-
CLOSE_TERMS_MODAL: _.noop,
176174
SELECT_TAB: _.identity,
177175
},
178176
});

src/shared/actions/terms.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,80 @@ function getTermDetailsDone(termId, tokenV2) {
5454
return service.getTermDetails(termId).then(details => ({ termId, details }));
5555
}
5656

57+
/**
58+
* Payload creator for TERMS/GET_DOCU_SIGN_URL_INIT
59+
* @param {Number|String} templateId id of document template to sign
60+
* @return {String} string format of the id
61+
*/
5762
function getDocuSignUrlInit(templateId) {
5863
return _.toString(templateId);
5964
}
6065

66+
/**
67+
* Payload creator for TERMS/GET_DOCU_SIGN_URL_DONE
68+
* which generate the url of DoduSign term
69+
* @param {Number|String} templateId id of document template to sign
70+
* @param {String} returnUrl callback url after finishing singing
71+
* @param {String} tokenV2 auth token
72+
* @return {Promise} promise of request result
73+
*/
6174
function getDocuSignUrlDone(templateId, returnUrl, tokenV2) {
6275
const service = getService(tokenV2);
6376
return service.getDocuSignUrl(templateId, returnUrl)
6477
.then(resp => ({ templateId, docuSignUrl: resp.recipientViewUrl }));
6578
}
6679

80+
/**
81+
* Payload creator for TERMS/AGREE_TERM_INIT
82+
* @param {Number|String} termId id of term
83+
* @return {String} string format of the id
84+
*/
6785
function agreeTermInit(termId) {
6886
return _.toString(termId);
6987
}
7088

89+
/**
90+
* Payload creator for TERMS/AGREE_TERM_DONE
91+
* @param {Number|String} termId id of term
92+
* @param {String} tokenV2 auth token
93+
* @return {Promise} promise of request result
94+
*/
7195
function agreeTermDone(termId, tokenV2) {
7296
const service = getService(tokenV2);
7397
return service.agreeTerm(termId).then(resp => ({ termId, success: resp.success }));
7498
}
7599

100+
/**
101+
* Payload creator for TERMS/CHECK_STATUS_DONE
102+
* which will check if all terms of specified challenge have been agreed,
103+
* if not, it will try again after a timeout
104+
* @param {Number|String} challengeId id of challenge to check
105+
* @param {String} tokenV2 auth token
106+
* @return {Promise} promise of request result
107+
*/
108+
function checkStatusDone(challengeId, tokenV2) {
109+
const TIME_OUT = 10000;
110+
const service = getService(tokenV2);
111+
const getStatus = (resolve, reject, callback) => {
112+
service.getTerms(challengeId).then((res) => {
113+
const allAgreed = _.every(res.terms, 'agreed');
114+
callback(allAgreed, res.terms);
115+
}).catch(err => reject(err));
116+
};
117+
return new Promise((resolve, reject) => {
118+
getStatus(resolve, reject, (allAgreed, terms) => {
119+
if (allAgreed) {
120+
resolve(terms);
121+
} else {
122+
// retrive terms again after a timeout, DocuSign result
123+
// might take few seconds to get updated
124+
setTimeout(() => getStatus(resolve, reject,
125+
(a, t) => resolve(t)), TIME_OUT);
126+
}
127+
});
128+
});
129+
}
130+
76131
export default createActions({
77132
TERMS: {
78133
GET_TERMS_INIT: getTermsInit,
@@ -83,5 +138,11 @@ export default createActions({
83138
GET_DOCU_SIGN_URL_DONE: getDocuSignUrlDone,
84139
AGREE_TERM_INIT: agreeTermInit,
85140
AGREE_TERM_DONE: agreeTermDone,
141+
OPEN_TERMS_MODAL: _.identity,
142+
CLOSE_TERMS_MODAL: _.noop,
143+
SELECT_TERM: _.identity,
144+
SIGN_DOCU: _.identity,
145+
CHECK_STATUS_INIT: _.noop,
146+
CHECK_STATUS_DONE: checkStatusDone,
86147
},
87148
});

0 commit comments

Comments
 (0)