Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 163bbfd

Browse files
committed
implements issue 477
1 parent f1a3d4a commit 163bbfd

File tree

10 files changed

+146
-133
lines changed

10 files changed

+146
-133
lines changed

config/dev.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
TC_NOTIFICATION_URL: "https://api.topcoder-dev.com/v5/notifications",
66
CONNECT_DOMAIN: "https://connect.topcoder-dev.com",
77
COMMUNITY_DOMAIN: "https://www.topcoder-dev.com",
8+
TAAS_APP: "https://platform.topcoder-dev.com/taas/myteams",
89
},
910
API: {
1011
V3: "https://api.topcoder-dev.com/v3",

config/prod.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
TC_NOTIFICATION_URL: "https://api.topcoder.com/v5/notifications",
66
CONNECT_DOMAIN: "https://connect.topcoder.com",
77
COMMUNITY_DOMAIN: "https://www.topcoder.com",
8+
TAAS_APP: "https://platform.topcoder.com/taas/myteams",
89
},
910
API: {
1011
V3: "https://api.topcoder.com/v3",

src/actions/notifications.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
NOTIFICATIONS_PENDING,
2020
SET_NOTIFICATION_PLATFORM,
2121
RESET_NOTIFICATIONS,
22-
RESET_COMMUNITY_NOTIFICATIONS,
2322
} from "../constants/notifications";
2423
import notificationsService from "../services/notifications";
2524
import {
@@ -83,6 +82,25 @@ export const getNotifications = () => (dispatch) => {
8382
});
8483
};
8584

85+
export const getTaaSNotifications = () => (dispatch) => {
86+
dispatch({ type: GET_NOTIFICATIONS_PENDING });
87+
notificationsService
88+
.getTaaSNotifications()
89+
.then((notifications) => {
90+
dispatch({
91+
type: GET_NOTIFICATIONS_SUCCESS,
92+
payload: notifications,
93+
});
94+
})
95+
.catch((err) => {
96+
dispatch({
97+
type: GET_NOTIFICATIONS_FAILURE,
98+
payload: err,
99+
});
100+
console.error(`Failed to load notifications. ${err.message}`);
101+
});
102+
};
103+
86104
export const getCommunityNotifications = () => (dispatch) => {
87105
dispatch({ type: GET_COMMUNITY_NOTIFICATIONS_PENDING });
88106
notificationsService
@@ -243,10 +261,6 @@ export const resetNotifications = () => (dispatch) => {
243261
dispatch({ type: RESET_NOTIFICATIONS });
244262
};
245263

246-
export const resetCommunityNotifications = () => (dispatch) => {
247-
dispatch({ type: RESET_COMMUNITY_NOTIFICATIONS });
248-
};
249-
250264
export default {
251265
getNotifications,
252266
getCommunityNotifications,
@@ -262,5 +276,4 @@ export default {
262276
markNotificationsRead,
263277
setNotificationPlatform,
264278
resetNotifications,
265-
resetCommunityNotifications,
266279
};

src/components/Notifications/NotificationsEmpty/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Bell from "../../../assets/icons/bell.svg";
88

99
const NotificationsEmpty = ({
1010
children,
11-
message = "Good job! Youre all caught up",
11+
message = "Good job! Youre all caught up",
1212
}) => (
1313
<div className="notifications-empty">
1414
<div className="icon">

src/constants/notifications.js

+52-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const NOTIFICATIONS_PENDING = "NOTIFICATIONS_PENDING";
2323
export const MARK_NOTIFICATIONS_READ = "MARK_NOTIFICATIONS_READ";
2424
export const SET_NOTIFICATION_PLATFORM = "SET_NOTIFICATION_PLATFORM";
2525
export const RESET_NOTIFICATIONS = "RESET_NOTIFICATIONS";
26-
export const RESET_COMMUNITY_NOTIFICATIONS = "RESET_COMMUNITY_NOTIFICATIONS";
2726

2827
/*
2928
* Project member role
@@ -76,7 +75,7 @@ export const NOTIFICATIONS_LIMIT = 1000;
7675
export const PLATFORM = {
7776
CONNECT: "connect",
7877
COMMUNITY: "community",
79-
BOTH: "connect+community",
78+
TAAS: "taas",
8079
};
8180

8281
// Notifications event types
@@ -141,6 +140,11 @@ export const EVENT_TYPE = {
141140
COMPLETED: "challenge.notification.completed",
142141
},
143142
BROADCAST: "admin.notification.broadcast",
143+
TAAS: {
144+
POST_INTERVIEW_ACTION_REQUIRED: 'taas.notification.post-interview-action-required',
145+
RESOURCE_BOOKING_EXPIRATION: 'taas.notification.resource-booking-expiration',
146+
RESOURCE_BOOKING_PLACED: 'taas.notification.resource-booking-placed',
147+
},
144148
};
145149

146150
export const NOTIFICATION_TYPE = {
@@ -152,6 +156,7 @@ export const NOTIFICATION_TYPE = {
152156
MEMBER_ADDED: "member-added",
153157
CHALLENGE: "challenge",
154158
BROADCAST: "broadcast",
159+
TAAS: "taas",
155160
};
156161

157162
/*
@@ -169,6 +174,8 @@ export const GOTO = {
169174
PHASE: `${config.URL.CONNECT_DOMAIN}/projects/{{projectId}}/plan#phase-{{phaseId}}`,
170175
TOPCODER_TEAM: `${config.URL.CONNECT_DOMAIN}/projects/{{projectId}}#manageTopcoderTeam`,
171176
CHALLENGE: `${config.URL.COMMUNITY_DOMAIN}/challenges/{{id}}`,
177+
TAAS_CANDIDATES_INTERVIEWS: `${config.URL.TAAS_APP}/{{projectId}}/positions/{{jobId}}/candidates/interviews`,
178+
TAAS_PROJECT: `${config.URL.TAAS_APP}/{{projectId}}`
172179
};
173180

174181
// each notification can be displayed differently depend on WHO see them
@@ -1226,6 +1233,8 @@ export const NOTIFICATIONS = [
12261233
],
12271234
},
12281235

1236+
/// Community notification rules
1237+
12291238
{
12301239
eventType: EVENT_TYPE.CHALLENGE.ACTIVE,
12311240
type: NOTIFICATION_TYPE.CHALLENGE,
@@ -1258,6 +1267,47 @@ export const NOTIFICATIONS = [
12581267
},
12591268
],
12601269
},
1270+
1271+
/// TaaS notification rules
1272+
1273+
{
1274+
version: 1,
1275+
eventType: EVENT_TYPE.TAAS.POST_INTERVIEW_ACTION_REQUIRED,
1276+
type: NOTIFICATION_TYPE.TAAS,
1277+
rules: [
1278+
{
1279+
text: "Candidate action required for <strong>{{userHandle}}</strong> in job <strong>{{jobTitle}}</strong> of the team <strong>{{teamName}}</strong>",
1280+
shouldBundle: false,
1281+
goTo: GOTO.TAAS_CANDIDATES_INTERVIEWS,
1282+
}
1283+
],
1284+
},
1285+
1286+
{
1287+
version: 1,
1288+
eventType: EVENT_TYPE.TAAS.RESOURCE_BOOKING_EXPIRATION,
1289+
type: NOTIFICATION_TYPE.TAAS,
1290+
rules: [
1291+
{
1292+
text: "{{numOfExpiringResourceBookings}} resource booking{{s}} {{be}} expiring in the team <strong>{{teamName}}</strong>",
1293+
shouldBundle: false,
1294+
goTo: GOTO.TAAS_PROJECT,
1295+
}
1296+
],
1297+
},
1298+
1299+
{
1300+
version: 1,
1301+
eventType: EVENT_TYPE.TAAS.RESOURCE_BOOKING_PLACED,
1302+
type: NOTIFICATION_TYPE.TAAS,
1303+
rules: [
1304+
{
1305+
text: "Resource <strong>{{userHandle}}</strong> is placed for the job <strong>{{jobTitle}}</strong> of the team <strong>{{teamName}}</strong>",
1306+
shouldBundle: false,
1307+
goTo: GOTO.TAAS_PROJECT,
1308+
}
1309+
],
1310+
},
12611311
];
12621312

12631313
// list of ignored notifications

src/containers/NotificationsContainer/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class NotificationsContainer extends Component {
279279
render() {
280280
const { notifications, communityNotifications, ...restProps } = this.props;
281281
const preRenderedNotifications = preRenderNotifications(notifications);
282-
const preRenderedNotifications2 = preRenderCommunityNotifications(
282+
const preRenderedCommunityNotifications = preRenderCommunityNotifications(
283283
communityNotifications
284284
);
285285

@@ -288,7 +288,7 @@ class NotificationsContainer extends Component {
288288
{...{
289289
...restProps,
290290
notifications: preRenderedNotifications,
291-
communityNotifications: preRenderedNotifications2,
291+
communityNotifications: preRenderedCommunityNotifications,
292292
}}
293293
/>
294294
);

src/containers/NotificationsDropdownContainer/index.jsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { TransitionGroup, Transition } from "react-transition-group";
1111
import {
1212
getNotifications,
1313
getCommunityNotifications,
14+
getTaaSNotifications,
1415
toggleNotificationSeen,
1516
markAllNotificationsRead,
1617
markAllNotificationsSeen,
@@ -19,7 +20,6 @@ import {
1920
viewOlderNotifications,
2021
hideOlderNotifications,
2122
resetNotifications,
22-
resetCommunityNotifications,
2323
} from "../../actions/notifications";
2424
import {
2525
splitNotificationsBySources,
@@ -70,6 +70,7 @@ const NotificationsDropdownContainerView = (props) => {
7070
toggleNotificationsDropdownMobile,
7171
toggleNotificationsDropdownWeb,
7272
markAllNotificationsSeen,
73+
platform,
7374
} = props;
7475
if (
7576
(!initialized && isLoading) ||
@@ -154,8 +155,9 @@ const NotificationsDropdownContainerView = (props) => {
154155
</NotificationsEmpty>
155156
);
156157
if (
157-
(!isLoading && !initialized) ||
158-
(!isCommunityLoading && !communityInitialized)
158+
(!isLoading && !initialized && platform == PLATFORM.CONNECT) ||
159+
(!isLoading && !initialized && platform == PLATFORM.TAAS) ||
160+
(!isCommunityLoading && !communityInitialized && platform == PLATFORM.COMMUNITY)
159161
) {
160162
notificationsEmpty = (
161163
<NotificationsEmpty message="Fail to load notifications">
@@ -543,10 +545,14 @@ class NotificationsDropdownContainer extends React.Component {
543545
}
544546

545547
componentWillReceiveProps(nextProps) {
546-
const { platform: oldPlatform } = this.props;
548+
const {
549+
platform: oldPlatform,
550+
resetNotifications,
551+
} = this.props;
547552
const { platform } = nextProps;
548553

549554
if (platform !== oldPlatform) {
555+
resetNotifications();
550556
this.getPlatformNotifications(platform);
551557
}
552558
}
@@ -555,23 +561,17 @@ class NotificationsDropdownContainer extends React.Component {
555561
const {
556562
getNotifications,
557563
getCommunityNotifications,
564+
getTaaSNotifications,
558565
platform,
559-
resetNotifications,
560-
resetCommunityNotifications,
561566
} = this.props;
562567

563568
p = p || platform;
564569

565-
if (p === PLATFORM.BOTH) {
566-
resetNotifications();
567-
resetCommunityNotifications();
568-
getNotifications();
569-
getCommunityNotifications();
570-
} else if (p === PLATFORM.CONNECT) {
571-
resetCommunityNotifications();
570+
if (p === PLATFORM.CONNECT) {
572571
getNotifications();
572+
} else if (p === PLATFORM.TAAS) {
573+
getTaaSNotifications();
573574
} else {
574-
resetNotifications();
575575
getCommunityNotifications();
576576
}
577577
}
@@ -619,6 +619,7 @@ const mapStateToProps = ({ notifications }) => notifications;
619619
const mapDispatchToProps = {
620620
getNotifications,
621621
getCommunityNotifications,
622+
getTaaSNotifications,
622623
toggleNotificationSeen,
623624
markAllNotificationsRead,
624625
markAllNotificationsSeen,
@@ -627,7 +628,6 @@ const mapDispatchToProps = {
627628
viewOlderNotifications,
628629
hideOlderNotifications,
629630
resetNotifications,
630-
resetCommunityNotifications,
631631
};
632632

633633
export default connect(

src/reducers/notifications.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
SET_NOTIFICATION_PLATFORM,
2121
PLATFORM,
2222
RESET_NOTIFICATIONS,
23-
RESET_COMMUNITY_NOTIFICATIONS,
2423
} from "../constants/notifications";
2524
import _ from "lodash";
2625
import { getActiveAndBroadcastNotifications } from "../utils/notifications";
@@ -266,14 +265,10 @@ export default (state = initialState, action) => {
266265
case RESET_NOTIFICATIONS:
267266
return {
268267
...state,
268+
filterBy: "",
269269
notifications: [],
270-
sources: [],
271-
};
272-
273-
case RESET_COMMUNITY_NOTIFICATIONS:
274-
return {
275-
...state,
276270
communityNotifications: [],
271+
sources: [],
277272
communitySources: [],
278273
};
279274

src/services/notifications.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { URL } from "../../config";
55
import {
66
prepareNotifications,
77
prepareCommunityNotifications,
8+
prepareTaaSNotifications,
89
} from "../utils/notifications";
910

1011
const logger = console;
@@ -51,6 +52,14 @@ const getNotifications = () => {
5152
.then((resp) => prepareNotifications(resp.data.items));
5253
};
5354

55+
const getTaaSNotifications = () => {
56+
return axiosInstance
57+
.get(
58+
`${URL.TC_NOTIFICATION_URL}/list?read=false&platform=taas&per_page=${NOTIFICATIONS_LIMIT}`
59+
)
60+
.then((resp) => prepareTaaSNotifications(resp.data.items));
61+
};
62+
5463
const getCommunityNotifications = () => {
5564
return axiosInstance
5665
.get(
@@ -64,4 +73,5 @@ export default {
6473
getCommunityNotifications,
6574
markNotificationsRead,
6675
markNotificationsSeen,
76+
getTaaSNotifications,
6777
};

0 commit comments

Comments
 (0)