Skip to content

Commit 97506da

Browse files
authored
Merge pull request #142 from topcoder-platform/develop
Member search feature migration
2 parents e84b94e + 5fe490c commit 97506da

File tree

9 files changed

+488
-2
lines changed

9 files changed

+488
-2
lines changed

Diff for: __tests__/__snapshots__/index.js.snap

+16
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ Object {
6767
"getSkillTagsDone": [Function],
6868
"getSkillTagsInit": [Function],
6969
},
70+
"memberSearch": Object {
71+
"checkIfSearchTermIsATag": [Function],
72+
"clearMemberSearch": [Function],
73+
"loadMoreUsernames": [Function],
74+
"memberSearchSuccess": [Function],
75+
"resetSearchTerm": [Function],
76+
"setSearchTag": [Function],
77+
"setSearchTerm": [Function],
78+
"topMemberSearchSuccess": [Function],
79+
"usernameSearchSuccess": [Function],
80+
},
7081
"memberTasks": Object {
7182
"dropAll": [Function],
7283
"getDone": [Function],
@@ -240,6 +251,7 @@ Object {
240251
"groups": [Function],
241252
"looker": [Function],
242253
"lookup": [Function],
254+
"memberSearch": [Function],
243255
"memberTasks": [Function],
244256
"members": [Function],
245257
"mySubmissionsManagement": [Function],
@@ -292,6 +304,10 @@ Object {
292304
"default": undefined,
293305
"getService": [Function],
294306
},
307+
"memberSearch": Object {
308+
"default": undefined,
309+
"getService": [Function],
310+
},
295311
"members": Object {
296312
"default": undefined,
297313
"getService": [Function],

Diff for: 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.11.1",
34+
"version": "0.12.0",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",

Diff for: src/actions/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import reviewOpportunityActions from './reviewOpportunity';
1313
import lookupActions from './lookup';
1414
import settingsActions from './settings';
1515
import lookerActions from './looker';
16+
import memberSearchActions from './member-search';
1617

1718
export const actions = {
1819
auth: authActions.auth,
@@ -30,6 +31,7 @@ export const actions = {
3031
lookup: lookupActions.lookup,
3132
settings: settingsActions.settings,
3233
looker: lookerActions.looker,
34+
memberSearch: memberSearchActions.memberSearch,
3335
};
3436

3537
export default undefined;

Diff for: src/actions/member-search.js

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* @module "actions.member-search"
3+
* @desc Actions for management of members search.
4+
*/
5+
import _ from 'lodash';
6+
import { createActions } from 'redux-actions';
7+
import { getService } from '../services/member-search';
8+
9+
/**
10+
* @desc Creates an action that fetchs the members data for a search term, and
11+
* adds result to the store cumulatively.
12+
* @param {String} searchTerm the search term
13+
* @param {Number} offset the number of records to skip
14+
* @param {Number} limit the maximum number of the return results
15+
* @return {Action}
16+
*/
17+
function loadMemberSearch(searchTerm, offset = 0, limit = 10) {
18+
return getService().getUsernameMatches(searchTerm, offset, limit);
19+
}
20+
21+
/**
22+
* @static
23+
* @desc Creates an action that fetchs the members data for a search tag, and
24+
* adds result to the store.
25+
* @param {Object} tag the tag
26+
* @return {Action}
27+
*/
28+
function loadMemberSearchForTag(tag) {
29+
return getService().getTopMembers(tag);
30+
}
31+
32+
/**
33+
* @static
34+
* @desc Creates an action that check if the term is a tag name. If it is unable to check,
35+
* or invalid data returned then resets the members data and search terms data in the store
36+
* to intial values.
37+
* @param {String} searchTerm the search term
38+
* @return {Action}
39+
*/
40+
function checkIfSearchTermIsATag(searchTerm) {
41+
return getService().checkIfSearchTermIsATag(searchTerm);
42+
}
43+
44+
/**
45+
* @static
46+
* @desc Creates an action that saves the current search term.
47+
* @param {String} searchTerm the search term
48+
* @return {Action}
49+
*/
50+
function setSearchTerm(searchTerm) {
51+
return {
52+
previousSearchTerm: searchTerm,
53+
};
54+
}
55+
56+
/**
57+
* @static
58+
* @desc Creates an action that saves the current search tag.
59+
* @param {Object} searchTag the search tag
60+
* @return {Action}
61+
*/
62+
function setSearchTag(searchTag) {
63+
return {
64+
searchTermTag: searchTag,
65+
};
66+
}
67+
68+
export default createActions({
69+
MEMBER_SEARCH: {
70+
USERNAME_SEARCH_SUCCESS: loadMemberSearch,
71+
CHECK_IF_SEARCH_TERM_IS_A_TAG: checkIfSearchTermIsATag,
72+
TOP_MEMBER_SEARCH_SUCCESS: loadMemberSearchForTag,
73+
CLEAR_MEMBER_SEARCH: _.noop,
74+
LOAD_MORE_USERNAMES: _.noop,
75+
MEMBER_SEARCH_SUCCESS: _.noop,
76+
SET_SEARCH_TERM: setSearchTerm,
77+
SET_SEARCH_TAG: setSearchTag,
78+
RESET_SEARCH_TERM: _.noop,
79+
},
80+
});

Diff for: src/reducers/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import settings, { factory as settingsFactory }
2222
from './settings';
2323
import looker, { factory as lookerFactory }
2424
from './looker';
25-
25+
import memberSearch, { factory as memberSearchFactory } from './member-search';
2626

2727
export function factory(options) {
2828
return redux.resolveReducers({
@@ -41,6 +41,7 @@ export function factory(options) {
4141
mySubmissionsManagement: mySubmissionsManagementFactory(options),
4242
settings: settingsFactory(options),
4343
looker: lookerFactory(options),
44+
memberSearch: memberSearchFactory(options),
4445
});
4546
}
4647

@@ -60,4 +61,5 @@ export default ({
6061
mySubmissionsManagement,
6162
settings,
6263
looker,
64+
memberSearch,
6365
});

0 commit comments

Comments
 (0)