diff --git a/js/actions/contract_list_actions.js b/js/actions/contract_list_actions.js
index 1c5c0913..d368ac73 100644
--- a/js/actions/contract_list_actions.js
+++ b/js/actions/contract_list_actions.js
@@ -28,12 +28,10 @@ class ContractListActions {
}
- changeContract(contract){
+ changeContract(contract) {
return Q.Promise((resolve, reject) => {
OwnershipFetcher.changeContract(contract)
- .then((res) => {
- resolve(res);
- })
+ .then(resolve)
.catch((err)=> {
console.logGlobal(err);
reject(err);
@@ -41,13 +39,11 @@ class ContractListActions {
});
}
- removeContract(contractId){
- return Q.Promise( (resolve, reject) => {
+ removeContract(contractId) {
+ return Q.Promise((resolve, reject) => {
OwnershipFetcher.deleteContract(contractId)
- .then((res) => {
- resolve(res);
- })
- .catch( (err) => {
+ .then(resolve)
+ .catch((err) => {
console.logGlobal(err);
reject(err);
});
diff --git a/js/actions/edition_actions.js b/js/actions/edition_actions.js
index 1727deff..1feee0dd 100644
--- a/js/actions/edition_actions.js
+++ b/js/actions/edition_actions.js
@@ -7,11 +7,11 @@ class EditionActions {
constructor() {
this.generateActions(
'fetchEdition',
- 'successFetchEdition',
'successFetchCoa',
- 'flushEdition',
+ 'successFetchEdition',
'errorCoa',
- 'errorEdition'
+ 'errorEdition',
+ 'flushEdition'
);
}
}
diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js
index 6f9881ee..a52e32b9 100644
--- a/js/actions/edition_list_actions.js
+++ b/js/actions/edition_list_actions.js
@@ -17,23 +17,31 @@ class EditionListActions {
);
}
- fetchEditionList(pieceId, page, pageSize, orderBy, orderAsc, filterBy) {
- if((!orderBy && typeof orderAsc === 'undefined') || !orderAsc) {
+ fetchEditionList({ pieceId, page, pageSize, orderBy, orderAsc, filterBy, maxEdition }) {
+ if ((!orderBy && typeof orderAsc === 'undefined') || !orderAsc) {
orderBy = 'edition_number';
orderAsc = true;
}
// Taken from: http://stackoverflow.com/a/519157/1263876
- if((typeof page === 'undefined' || !page) && (typeof pageSize === 'undefined' || !pageSize)) {
+ if ((typeof page === 'undefined' || !page) && (typeof pageSize === 'undefined' || !pageSize)) {
page = 1;
pageSize = 10;
}
+ let itemsToFetch = pageSize;
+ // If we only want to fetch up to a specified edition, fetch all pages up to it
+ // as one page and adjust afterwards
+ if (typeof maxEdition === 'number') {
+ itemsToFetch = Math.ceil(maxEdition / pageSize) * pageSize;
+ page = 1;
+ }
+
return Q.Promise((resolve, reject) => {
EditionListFetcher
- .fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy)
+ .fetch({ pieceId, page, itemsToFetch, orderBy, orderAsc, filterBy })
.then((res) => {
- if(res && !res.editions) {
+ if (res && !res.editions) {
throw new Error('Piece has no editions to fetch.');
}
@@ -44,8 +52,9 @@ class EditionListActions {
orderBy,
orderAsc,
filterBy,
- 'editionListOfPiece': res.editions,
- 'count': res.count
+ maxEdition,
+ count: res.count,
+ editionListOfPiece: res.editions
});
resolve(res);
})
@@ -54,7 +63,6 @@ class EditionListActions {
reject(err);
});
});
-
}
}
diff --git a/js/actions/facebook_actions.js b/js/actions/facebook_actions.js
new file mode 100644
index 00000000..2e784fba
--- /dev/null
+++ b/js/actions/facebook_actions.js
@@ -0,0 +1,14 @@
+'use strict';
+
+import { altThirdParty } from '../alt';
+
+
+class FacebookActions {
+ constructor() {
+ this.generateActions(
+ 'sdkReady'
+ );
+ }
+}
+
+export default altThirdParty.createActions(FacebookActions);
diff --git a/js/actions/notification_actions.js b/js/actions/notification_actions.js
index c3a6db93..5d80e1e7 100644
--- a/js/actions/notification_actions.js
+++ b/js/actions/notification_actions.js
@@ -9,10 +9,13 @@ class NotificationActions {
constructor() {
this.generateActions(
'updatePieceListNotifications',
+ 'flushPieceListNotifications',
'updateEditionListNotifications',
+ 'flushEditionListNotifications',
'updateEditionNotifications',
'updatePieceNotifications',
- 'updateContractAgreementListNotifications'
+ 'updateContractAgreementListNotifications',
+ 'flushContractAgreementListNotifications'
);
}
diff --git a/js/actions/piece_actions.js b/js/actions/piece_actions.js
index 9002e8c5..7ad3ae29 100644
--- a/js/actions/piece_actions.js
+++ b/js/actions/piece_actions.js
@@ -1,28 +1,19 @@
'use strict';
import { alt } from '../alt';
-import PieceFetcher from '../fetchers/piece_fetcher';
class PieceActions {
constructor() {
this.generateActions(
+ 'fetchPiece',
+ 'successFetchPiece',
+ 'errorPiece',
+ 'flushPiece',
'updatePiece',
- 'updateProperty',
- 'pieceFailed'
+ 'updateProperty'
);
}
-
- fetchOne(pieceId) {
- PieceFetcher.fetchOne(pieceId)
- .then((res) => {
- this.actions.updatePiece(res.piece);
- })
- .catch((err) => {
- console.logGlobal(err);
- this.actions.pieceFailed(err.json);
- });
- }
}
export default alt.createActions(PieceActions);
diff --git a/js/actions/piece_list_actions.js b/js/actions/piece_list_actions.js
index 7ef9cb59..c52ef5e2 100644
--- a/js/actions/piece_list_actions.js
+++ b/js/actions/piece_list_actions.js
@@ -15,7 +15,7 @@ class PieceListActions {
);
}
- fetchPieceList(page, pageSize, search, orderBy, orderAsc, filterBy) {
+ fetchPieceList({ page, pageSize, search, orderBy, orderAsc, filterBy }) {
// To prevent flickering on a pagination request,
// we overwrite the piecelist with an empty list before
// pieceListCount === -1 defines the loading state
@@ -34,7 +34,7 @@ class PieceListActions {
// afterwards, we can load the list
return Q.Promise((resolve, reject) => {
PieceListFetcher
- .fetch(page, pageSize, search, orderBy, orderAsc, filterBy)
+ .fetch({ page, pageSize, search, orderBy, orderAsc, filterBy })
.then((res) => {
this.actions.updatePieceList({
page,
diff --git a/js/actions/prize_list_actions.js b/js/actions/prize_list_actions.js
deleted file mode 100644
index da2f97df..00000000
--- a/js/actions/prize_list_actions.js
+++ /dev/null
@@ -1,34 +0,0 @@
-'use strict';
-
-import { alt } from '../alt';
-import Q from 'q';
-
-import PrizeListFetcher from '../fetchers/prize_list_fetcher';
-
-class PrizeListActions {
- constructor() {
- this.generateActions(
- 'updatePrizeList'
- );
- }
-
- fetchPrizeList() {
- return Q.Promise((resolve, reject) => {
- PrizeListFetcher
- .fetch()
- .then((res) => {
- this.actions.updatePrizeList({
- prizeList: res.prizes,
- prizeListCount: res.count
- });
- resolve(res);
- })
- .catch((err) => {
- console.logGlobal(err);
- reject(err);
- });
- });
- }
-}
-
-export default alt.createActions(PrizeListActions);
\ No newline at end of file
diff --git a/js/app.js b/js/app.js
index dc8204cf..dc8e3d62 100644
--- a/js/app.js
+++ b/js/app.js
@@ -1,14 +1,13 @@
'use strict';
import 'babel/polyfill';
+import 'classlist-polyfill';
import React from 'react';
import { Router, Redirect } from 'react-router';
import history from './history';
-/* eslint-disable */
import fetch from 'isomorphic-fetch';
-/* eslint-enable */
import ApiUrls from './constants/api_urls';
@@ -17,44 +16,27 @@ import getRoutes from './routes';
import requests from './utils/requests';
import { updateApiUrls } from './constants/api_urls';
-import { getSubdomainSettings } from './utils/constants_utils';
+import { getDefaultSubdomainSettings, getSubdomainSettings } from './utils/constants_utils';
import { initLogging } from './utils/error_utils';
import { getSubdomain } from './utils/general_utils';
import EventActions from './actions/event_actions';
-/* eslint-disable */
// You can comment out the modules you don't need
-// import DebugHandler from './third_party/debug';
-import GoogleAnalyticsHandler from './third_party/ga';
-import RavenHandler from './third_party/raven';
-import IntercomHandler from './third_party/intercom';
-import NotificationsHandler from './third_party/notifications';
-import FacebookHandler from './third_party/facebook';
-/* eslint-enable */
+// import DebugHandler from './third_party/debug_handler';
+import FacebookHandler from './third_party/facebook_handler';
+import GoogleAnalyticsHandler from './third_party/ga_handler';
+import IntercomHandler from './third_party/intercom_handler';
+import NotificationsHandler from './third_party/notifications_handler';
+import RavenHandler from './third_party/raven_handler';
-initLogging();
-let headers = {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
-};
-
-requests.defaults({
- urlMap: ApiUrls,
- http: {
- headers: headers,
- credentials: 'include'
- }
-});
-
-class AppGateway {
+const AppGateway = {
start() {
- let settings;
- let subdomain = getSubdomain();
-
try {
- settings = getSubdomainSettings(subdomain);
+ const subdomain = getSubdomain();
+ const settings = getSubdomainSettings(subdomain);
+
AppConstants.whitelabel = settings;
updateApiUrls(settings.type, subdomain);
this.load(settings);
@@ -62,28 +44,25 @@ class AppGateway {
// if there are no matching subdomains, we're routing
// to the default frontend
console.logGlobal(err);
- this.load();
+ this.load(getDefaultSubdomainSettings());
}
- }
+ },
load(settings) {
- let type = 'default';
- let subdomain = 'www';
+ const { subdomain, type } = settings;
let redirectRoute = (
{getLangText('There was an error generating your Certificate of Authenticity.')}
-- {getLangText('Try to refresh the page. If this happens repeatedly, please ')} - {getLangText('contact us')}. -
-{getLangText('There was an error generating your Certificate of Authenticity.')}
, ++ {getLangText('Try to refresh the page. If this happens repeatedly, please ')} + {getLangText('contact us')}. +
+ ]; + } else if (coa && coa.url_safe) { + coaDetailElement = [ +{getLangText("Just a sec, we\'re generating your COA")}
+ ]; + } else if (typeof coa === 'string') { + coaDetailElement = coa; + } else { + coaDetailElement = [ +{getLangText("Just a sec, we're generating your COA")}
,{getLangText('(you may leave the page)')}
+ ]; + } + + return ( ++
{getLangText('Drag %s here', fileClass)}
, +{getLangText('Drag %s here', fileClass)}
,{getLangText('or')}
]; } else { @@ -46,6 +46,8 @@ let FileDragAndDropDialog = React.createClass({ if (hasFiles) { return null; } else { + let dialogElement; + if (enableLocalHashing && !uploadMethod) { const currentQueryParams = getCurrentQueryParams(); @@ -55,9 +57,9 @@ let FileDragAndDropDialog = React.createClass({ const queryParamsUpload = Object.assign({}, currentQueryParams); queryParamsUpload.method = 'upload'; - return ( -{getLangText('Would you rather')}
+ dialogElement = ( +{getLangText('Would you rather')}
{/* The frontend in live is hosted under /app, Since `Link` is appending that base url, if its defined @@ -85,32 +87,40 @@ let FileDragAndDropDialog = React.createClass({ ); } else { if (multipleFiles) { - return ( - - {this.getDragDialog(fileClassToUpload.plural)} - - {getLangText('choose %s to upload', fileClassToUpload.plural)} - + dialogElement = [ + this.getDragDialog(fileClassToUpload.plural), + + {getLangText('choose %s to upload', fileClassToUpload.plural)} - ); + ]; } else { const dialog = uploadMethod === 'hash' ? getLangText('choose a %s to hash', fileClassToUpload.singular) : getLangText('choose a %s to upload', fileClassToUpload.singular); - return ( - - {this.getDragDialog(fileClassToUpload.singular)} - - {dialog} - + dialogElement = [ + this.getDragDialog(fileClassToUpload.singular), + + {dialog} - ); + ]; } } + + return ( ++ {getLangText('No files uploaded')} +
+
api |
diff --git a/js/components/global_action.js b/js/components/global_action.js
deleted file mode 100644
index 80df0c75..00000000
--- a/js/components/global_action.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-
-import React from 'react';
-
-let GlobalAction = React.createClass({
- propTypes: {
- requestActions: React.PropTypes.object
- },
-
- render() {
- let pieceActions = null;
- if (this.props.requestActions && this.props.requestActions.pieces){
- pieceActions = this.props.requestActions.pieces.map((item) => {
- return (
-
+ +
-
-
-
- {spinner}
+