Skip to content

Commit dc52de0

Browse files
Refactor challenge list
1 parent 98fadbb commit dc52de0

File tree

20 files changed

+28430
-1762
lines changed

20 files changed

+28430
-1762
lines changed

package-lock.json

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

src/shared/actions/challenge-listing/index.js

+270-148
Large diffs are not rendered by default.

src/shared/actions/challenge-listing/sidebar.js

+63-63
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44

55
import _ from 'lodash';
66
import { createActions } from 'redux-actions';
7-
import { services } from 'topcoder-react-lib';
7+
// import { services } from 'topcoder-react-lib';
88

9-
const { getUserSettingsService } = services.userSetting;
9+
// const { getUserSettingsService } = services.userSetting;
1010

1111
/**
1212
* Changes name of the specified filter (but does not save it to the backend).
1313
* @param {String} index
1414
* @param {String} name
1515
*/
16-
function changeFilterName(index, name) {
17-
return { index, name };
18-
}
16+
// function changeFilterName(index, name) {
17+
// return { index, name };
18+
// }
1919

2020
/**
2121
* Deletes saved filter.
2222
* @param {String} id
2323
* @param {Object} tokenV2
2424
* @return {Promise}
2525
*/
26-
function deleteSavedFilter(id, tokenV2) {
27-
return getUserSettingsService(tokenV2)
28-
.deleteFilter(id).then(() => id);
29-
}
26+
// function deleteSavedFilter(id, tokenV2) {
27+
// return getUserSettingsService(tokenV2)
28+
// .deleteFilter(id).then(() => id);
29+
// }
3030

3131
/**
3232
* Handles drag move event.
@@ -44,50 +44,50 @@ function deleteSavedFilter(id, tokenV2) {
4444
* with DOM, and, most probably, it is just easier to adopt some 3-rd party
4545
* Drag-n-Drop library, then to find out a work-around.
4646
*/
47-
function dragSavedFilterMove(dragEvent, dragState) {
48-
/* For a reason not clear to me, shortly after starting to drag a filter,
49-
* and also when the user releases the mouse button, thus ending the drag,
50-
* this handler gets an event with 'screenY' position equal 0. This breaks
51-
* the dragging handling, which works just fine otherwise. Hence, this simple
52-
* fix of the issue, until the real problem is figured out.
53-
*/
54-
if (!dragEvent.screenY) return dragState;
55-
56-
/* Calculation of the target position of the dragged item inside the filters
57-
* array. */
58-
const shift = (dragEvent.screenY - dragState.y) / dragEvent.target.offsetHeight;
59-
const index = Math.round(dragState.startIndex + shift);
60-
if (index === dragState.index) return dragState;
61-
return { ...dragState, currentIndex: index };
62-
}
47+
// function dragSavedFilterMove(dragEvent, dragState) {
48+
/* For a reason not clear to me, shortly after starting to drag a filter,
49+
* and also when the user releases the mouse button, thus ending the drag,
50+
* this handler gets an event with 'screenY' position equal 0. This breaks
51+
* the dragging handling, which works just fine otherwise. Hence, this simple
52+
* fix of the issue, until the real problem is figured out.
53+
*/
54+
// if (!dragEvent.screenY) return dragState;
55+
56+
// /* Calculation of the target position of the dragged item inside the filters
57+
// * array. */
58+
// const shift = (dragEvent.screenY - dragState.y) / dragEvent.target.offsetHeight;
59+
// const index = Math.round(dragState.startIndex + shift);
60+
// if (index === dragState.index) return dragState;
61+
// return { ...dragState, currentIndex: index };
62+
// }
6363

6464
/**
6565
* Initializes drag of a filter item.
6666
* @param {Number} index
6767
* @param {Object} dragEvent
6868
* @return {Object}
6969
*/
70-
function dragSavedFilterStart(index, dragEvent) {
71-
return {
72-
currentIndex: index,
73-
startIndex: index,
74-
y: dragEvent.screenY,
75-
};
76-
}
77-
78-
function getSavedFilters(tokenV2) {
79-
return getUserSettingsService(tokenV2).getFilters();
80-
}
70+
// function dragSavedFilterStart(index, dragEvent) {
71+
// return {
72+
// currentIndex: index,
73+
// startIndex: index,
74+
// y: dragEvent.screenY,
75+
// };
76+
// }
77+
78+
// function getSavedFilters(tokenV2) {
79+
// return getUserSettingsService(tokenV2).getFilters();
80+
// }
8181

8282
/**
8383
* After changing filter name with changeFilterName(..) this action can be used
8484
* to reset filter name to the one last saved into API. No API call is made,
8585
* as the last saved name is kept inside the state.
8686
* @param {String} index
8787
*/
88-
function resetFilterName(index) {
89-
return index;
90-
}
88+
// function resetFilterName(index) {
89+
// return index;
90+
// }
9191

9292
/**
9393
* Saves filter to the backend.
@@ -96,63 +96,63 @@ function resetFilterName(index) {
9696
* @param {String} tokenV2
9797
* @return {Promise}
9898
*/
99-
function saveFilter(name, filter, tokenV2) {
100-
return getUserSettingsService(tokenV2)
101-
.saveFilter(name, filter);
102-
}
99+
// function saveFilter(name, filter, tokenV2) {
100+
// return getUserSettingsService(tokenV2)
101+
// .saveFilter(name, filter);
102+
// }
103103

104104
/**
105105
* Updates all saved filters (basically to update their ordering in the
106106
* backend).
107107
* @param {Array} savedFilters
108108
* @param {String} tokenV2
109109
*/
110-
function updateAllSavedFilters(savedFilters, tokenV2) {
111-
const service = getUserSettingsService(tokenV2);
112-
savedFilters.forEach(filter => service.updateFilter(filter.id, filter.name, filter.filter));
113-
}
110+
// function updateAllSavedFilters(savedFilters, tokenV2) {
111+
// const service = getUserSettingsService(tokenV2);
112+
// savedFilters.forEach(filter => service.updateFilter(filter.id, filter.name, filter.filter));
113+
// }
114114

115115
/**
116116
* Saves updated fitler to the backend.
117117
* @param {Object} filter
118118
* @param {String} tokenV2
119119
* @return {Promise}
120120
*/
121-
function updateSavedFilter(filter, tokenV2) {
122-
return getUserSettingsService(tokenV2)
123-
.updateFilter(filter.id, filter.name, filter.filter);
124-
}
121+
// function updateSavedFilter(filter, tokenV2) {
122+
// return getUserSettingsService(tokenV2)
123+
// .updateFilter(filter.id, filter.name, filter.filter);
124+
// }
125125

126126
export default createActions({
127127
CHALLENGE_LISTING: {
128128
SIDEBAR: {
129-
CHANGE_FILTER_NAME: changeFilterName,
129+
// CHANGE_FILTER_NAME: changeFilterName,
130130

131-
DELETE_SAVED_FILTER: deleteSavedFilter,
131+
// DELETE_SAVED_FILTER: deleteSavedFilter,
132132

133-
DRAG_SAVED_FILTER_MOVE: dragSavedFilterMove,
134-
DRAG_SAVED_FILTER_START: dragSavedFilterStart,
133+
// DRAG_SAVED_FILTER_MOVE: dragSavedFilterMove,
134+
// DRAG_SAVED_FILTER_START: dragSavedFilterStart,
135135

136-
GET_SAVED_FILTERS: getSavedFilters,
136+
// GET_SAVED_FILTERS: getSavedFilters,
137137

138-
RESET_FILTER_NAME: resetFilterName,
138+
// RESET_FILTER_NAME: resetFilterName,
139139

140-
SAVE_FILTER_DONE: saveFilter,
140+
// SAVE_FILTER_DONE: saveFilter,
141141

142-
SAVE_FILTER_INIT: _.noop,
142+
// SAVE_FILTER_INIT: _.noop,
143143

144144
/* Pass in the bucket type. */
145145
SELECT_BUCKET: _.identity,
146146
SELECT_BUCKET_DONE: _.noop,
147147

148148
/* Pass in the index of filter inside savedFilters array. */
149-
SELECT_SAVED_FILTER: _.identity,
149+
// SELECT_SAVED_FILTER: _.identity,
150150

151151
/* Pass in true/false to enable/disable. */
152-
SET_EDIT_SAVED_FILTERS_MODE: _.identity,
152+
// SET_EDIT_SAVED_FILTERS_MODE: _.identity,
153153

154-
UPDATE_ALL_SAVED_FILTERS: updateAllSavedFilters,
155-
UPDATE_SAVED_FILTER: updateSavedFilter,
154+
// UPDATE_ALL_SAVED_FILTERS: updateAllSavedFilters,
155+
// UPDATE_SAVED_FILTER: updateSavedFilter,
156156
},
157157
},
158158
});

0 commit comments

Comments
 (0)