Skip to content

Commit e82e9a4

Browse files
authored
Merge pull request #212 from topcoder-platform/feature/teamManagement
Merging Team Member Invites changes to dev.
2 parents 06dffae + 581e640 commit e82e9a4

31 files changed

+3118
-1217
lines changed

config/default.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@
5151
"AUTH0_URL": "",
5252
"TOKEN_CACHE_TIME": "",
5353
"whitelistedOriginsForUserIdAuth": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
54-
"AUTH0_PROXY_SERVER_URL" : ""
54+
"AUTH0_PROXY_SERVER_URL" : "",
55+
"EMAIL_INVITE_FROM_NAME":"Topcoder Connect",
56+
"EMAIL_INVITE_FROM_EMAIL":"noreply@connect.topcoder.com"
57+
5558
}

local/mock-services/server.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const middlewares = jsonServer.defaults();
1414
const authMiddleware = require('./authMiddleware');
1515

1616
const members = require('./services.json').members;
17+
const roles = require('./services.json').roles;
1718

1819
server.use(middlewares);
1920

@@ -29,7 +30,12 @@ server.get('/v3/members/_search', (req, res) => {
2930
const ret = {};
3031
const splitted = single.split(':');
3132
// if the result can be parsed successfully
32-
const parsed = jsprim.parseInteger(splitted[1], { allowTrailing: true, trimWhitespace: true });
33+
let parsed = Error();
34+
try {
35+
parsed = jsprim.parseInteger(splitted[1], { allowTrailing: true, trimWhitespace: true });
36+
} catch (e) {
37+
// no-empty
38+
}
3339
if (parsed instanceof Error) {
3440
ret[splitted[0]] = splitted[1];
3541
} else {
@@ -38,6 +44,7 @@ server.get('/v3/members/_search', (req, res) => {
3844
return ret;
3945
});
4046
const userIds = _.map(criteria, 'userId');
47+
const handles = _.map(criteria, 'handle');
4148
const cloned = _.cloneDeep(members);
4249
const response = {
4350
id: 'res1',
@@ -53,13 +60,42 @@ server.get('/v3/members/_search', (req, res) => {
5360
found = _.pick(found, fields);
5461
}
5562
return found;
63+
} else if (_.indexOf(handles, single.result.content.handle) > -1) {
64+
let found = single.result.content;
65+
if (fields.length > 0) {
66+
found = _.pick(found, fields);
67+
}
68+
return found;
5669
}
5770
return null;
5871
}).filter(_.identity);
5972
response.result.metadata = { totalCount: response.result.content.length };
6073
res.status(200).json(response);
6174
});
6275

76+
// add additional search route for project members
77+
server.get('/roles', (req, res) => {
78+
const filter = _.isString(req.query.filter) ?
79+
req.query.filter.replace('%2520', ' ').replace('%20', ' ').split('=') : [];
80+
const cloned = _.cloneDeep(roles);
81+
const response = {
82+
id: 'res1',
83+
result: {
84+
success: true,
85+
status: 200,
86+
},
87+
};
88+
const role = filter ? _.find(cloned, (single) => {
89+
if (single.userId === filter[1]) {
90+
return single.roles;
91+
}
92+
return null;
93+
}) : null;
94+
95+
response.result.content = role ? role.roles : [];
96+
res.status(200).json(response);
97+
});
98+
6399
server.use(router);
64100

65101
server.listen(PORT, () => {

local/mock-services/services.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,5 +300,13 @@
300300
},
301301
"version": "v3"
302302
}
303+
],
304+
"roles": [
305+
{ "userId": "40051334", "roles": [ { "roleName": "Connect Manager" } ] },
306+
{ "userId": "40051332", "roles": [ { "roleName": "Connect Copilot" } ] },
307+
{ "userId": "40051333", "roles": [ { "roleName": "administrator" } ] },
308+
{ "userId": "40051336", "roles": [ { "roleName": "Connect Admin" }, { "roleName": "Connect Copilot" } ] },
309+
{ "userId": "40051331", "roles": [ ] },
310+
{ "userId": "40051335", "roles": [ ] }
303311
]
304312
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--
2+
-- CREATE NEW TABLES:
3+
-- project_member_invites
4+
--
5+
6+
--
7+
-- project_member_invites
8+
--
9+
10+
CREATE TABLE project_member_invites (
11+
id bigint NOT NULL,
12+
"projectId" bigint,
13+
"userId" bigint,
14+
email character varying(255),
15+
role character varying(255) NOT NULL,
16+
status character varying(255) NOT NULL,
17+
"createdAt" timestamp with time zone,
18+
"updatedAt" timestamp with time zone,
19+
"deletedAt" timestamp with time zone,
20+
"createdBy" integer NOT NULL,
21+
"updatedBy" integer NOT NULL,
22+
"deletedBy" bigint
23+
);
24+
25+
CREATE SEQUENCE project_member_invites_id_seq
26+
START WITH 1
27+
INCREMENT BY 1
28+
NO MINVALUE
29+
NO MAXVALUE
30+
CACHE 1;
31+
32+
ALTER SEQUENCE project_member_invites_id_seq OWNED BY project_member_invites.id;
33+
34+
ALTER TABLE ONLY project_member_invites
35+
ADD CONSTRAINT "project_member_invites_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES projects(id) ON UPDATE CASCADE ON DELETE CASCADE;

0 commit comments

Comments
 (0)