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

Commit 761146b

Browse files
authored
Merge pull request #30 from nqviet/dev
fix for issue taas-apis/issues/477
2 parents f1a3d4a + 9b0d8dc commit 761146b

File tree

16 files changed

+203
-170
lines changed

16 files changed

+203
-170
lines changed

config/dev.js

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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",

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
transformIgnorePatterns: ["node_modules/?!(tc-auth-lib)"],
77
moduleNameMapper: {
88
"\\.(css|scss)$": "identity-obj-proxy",
9-
"\\.svg$": "<rootDir>/__mocks__/fileMock.js",
9+
"\\.(png|eot|otf|ttf|woff|woff2|svg)$": "<rootDir>/__mocks__/fileMock.js",
1010
},
1111
setupFilesAfterEnv: [
1212
"../node_modules/@testing-library/jest-dom/dist/index.js",

server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* global process */
2-
const express = require('express');
2+
const express = require("express");
33

44
const app = express();
55

66
app.use(
77
"/navbar",
88
express.static("./dist", {
99
setHeaders: function setHeaders(res) {
10-
res.header('Access-Control-Allow-Origin', '*');
11-
res.header('Access-Control-Allow-Methods', 'GET');
10+
res.header("Access-Control-Allow-Origin", "*");
11+
res.header("Access-Control-Allow-Methods", "GET");
1212
res.header(
13-
'Access-Control-Allow-Headers',
14-
'Origin, X-Requested-With, Content-Type, Accept'
13+
"Access-Control-Allow-Headers",
14+
"Origin, X-Requested-With, Content-Type, Accept"
1515
);
1616
},
1717
})

src/actions/notifications.js

Lines changed: 19 additions & 6 deletions
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/Menu/index.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
*
44
* General component to show menu with submenu.
55
*/
6-
import React, { Fragment, useCallback, useState } from 'react';
7-
import { useLocation } from '@reach/router';
8-
import cn from 'classnames';
9-
import { includes, map } from 'lodash';
10-
import NavLink from '../NavLink';
11-
import './styles.css';
6+
import React, { Fragment, useCallback, useState } from "react";
7+
import { useLocation } from "@reach/router";
8+
import cn from "classnames";
9+
import { includes, map } from "lodash";
10+
import NavLink from "../NavLink";
11+
import "./styles.css";
1212

1313
const SubMenu = ({ option }) => {
1414
const location = useLocation();
1515

1616
const [isOpen, setIsOpen] = useState(
17-
includes(map(option.children, 'path'), location.pathname)
17+
includes(map(option.children, "path"), location.pathname)
1818
);
1919

2020
const toggleOpen = useCallback(() => {
@@ -24,8 +24,8 @@ const SubMenu = ({ option }) => {
2424
return (
2525
<>
2626
<span
27-
className={cn('menu-link menu-link-toggle', {
28-
'menu-link-toggle-up': isOpen,
27+
className={cn("menu-link menu-link-toggle", {
28+
"menu-link-toggle-up": isOpen,
2929
})}
3030
onClick={toggleOpen}
3131
role="button"

src/components/Notifications/NotificationsEmpty/index.jsx

Lines changed: 1 addition & 1 deletion
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/apps.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
/**
22
* Config for the All Apps menu.
33
*/
4-
import appDocumentationIcon from '../assets/images/learn.svg';
5-
import appTaasIcon from '../assets/images/integrations.svg';
6-
import appTaasAdminIcon from '../assets/images/taas-admin.png';
7-
import myteamsIcon from '../assets/images/my-teams.svg';
8-
import myteamsGreenIcon from '../assets/images/my-teams-green.svg';
9-
import createTeamIcon from '../assets/images/create-team.svg';
10-
import createTeamGreenIcon from '../assets/images/create-team-green.svg';
4+
import appDocumentationIcon from "../assets/images/learn.svg";
5+
import appTaasIcon from "../assets/images/integrations.svg";
6+
import appTaasAdminIcon from "../assets/images/taas-admin.png";
7+
import myteamsIcon from "../assets/images/my-teams.svg";
8+
import myteamsGreenIcon from "../assets/images/my-teams-green.svg";
9+
import createTeamIcon from "../assets/images/create-team.svg";
10+
import createTeamGreenIcon from "../assets/images/create-team-green.svg";
1111
import earnIcon from "../assets/images/earn.svg";
1212

1313
/**
1414
* Micro-app categories
1515
*/
1616
export const APP_CATEGORIES = [
1717
{
18-
category: 'Manage',
18+
category: "Manage",
1919
apps: [
2020
{
21-
title: 'TaaS',
21+
title: "TaaS",
2222
icon: appTaasIcon,
23-
path: '/taas',
23+
path: "/taas",
2424
menu: [
2525
{
26-
title: 'My Teams',
27-
path: '/taas/myteams',
26+
title: "My Teams",
27+
path: "/taas/myteams",
2828
icon: myteamsIcon,
2929
activeIcon: myteamsGreenIcon,
3030
isExact: false,
3131
},
3232
{
33-
title: 'Create New Team',
34-
path: '/taas/createnewteam',
33+
title: "Create New Team",
34+
path: "/taas/createnewteam",
3535
icon: createTeamIcon,
3636
activeIcon: createTeamGreenIcon,
3737
isExact: false,
3838
},
3939
],
4040
},
4141
{
42-
title: 'TaaS Admin',
42+
title: "TaaS Admin",
4343
icon: appTaasAdminIcon,
44-
path: '/taas-admin',
44+
path: "/taas-admin",
4545
menu: [],
46-
roles: ["bookingmanager","administrator"],
46+
roles: ["bookingmanager", "administrator"],
4747
},
4848
{
49-
title: 'Documentation',
49+
title: "Documentation",
5050
icon: appDocumentationIcon,
5151
path: "/model",
5252
menu: [],
@@ -57,7 +57,7 @@ export const APP_CATEGORIES = [
5757
path: "/community-admin",
5858
menu: [],
5959
roles: ["Community Admin"],
60-
}
60+
},
6161
],
6262
},
6363
{

src/constants/notifications.js

Lines changed: 54 additions & 2 deletions
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,13 @@ export const EVENT_TYPE = {
141140
COMPLETED: "challenge.notification.completed",
142141
},
143142
BROADCAST: "admin.notification.broadcast",
143+
TAAS: {
144+
POST_INTERVIEW_ACTION_REQUIRED:
145+
"taas.notification.post-interview-action-required",
146+
RESOURCE_BOOKING_EXPIRATION:
147+
"taas.notification.resource-booking-expiration",
148+
RESOURCE_BOOKING_PLACED: "taas.notification.resource-booking-placed",
149+
},
144150
};
145151

146152
export const NOTIFICATION_TYPE = {
@@ -152,6 +158,7 @@ export const NOTIFICATION_TYPE = {
152158
MEMBER_ADDED: "member-added",
153159
CHALLENGE: "challenge",
154160
BROADCAST: "broadcast",
161+
TAAS: "taas",
155162
};
156163

157164
/*
@@ -169,6 +176,8 @@ export const GOTO = {
169176
PHASE: `${config.URL.CONNECT_DOMAIN}/projects/{{projectId}}/plan#phase-{{phaseId}}`,
170177
TOPCODER_TEAM: `${config.URL.CONNECT_DOMAIN}/projects/{{projectId}}#manageTopcoderTeam`,
171178
CHALLENGE: `${config.URL.COMMUNITY_DOMAIN}/challenges/{{id}}`,
179+
TAAS_CANDIDATES_INTERVIEWS: `${config.URL.TAAS_APP}/{{projectId}}/positions/{{jobId}}/candidates/interviews`,
180+
TAAS_PROJECT: `${config.URL.TAAS_APP}/{{projectId}}`,
172181
};
173182

174183
// each notification can be displayed differently depend on WHO see them
@@ -1226,6 +1235,8 @@ export const NOTIFICATIONS = [
12261235
],
12271236
},
12281237

1238+
/// Community notification rules
1239+
12291240
{
12301241
eventType: EVENT_TYPE.CHALLENGE.ACTIVE,
12311242
type: NOTIFICATION_TYPE.CHALLENGE,
@@ -1258,6 +1269,47 @@ export const NOTIFICATIONS = [
12581269
},
12591270
],
12601271
},
1272+
1273+
/// TaaS notification rules
1274+
1275+
{
1276+
version: 1,
1277+
eventType: EVENT_TYPE.TAAS.POST_INTERVIEW_ACTION_REQUIRED,
1278+
type: NOTIFICATION_TYPE.TAAS,
1279+
rules: [
1280+
{
1281+
text: "Candidate action required for <strong>{{userHandle}}</strong> in job <strong>{{jobTitle}}</strong> of the team <strong>{{teamName}}</strong>",
1282+
shouldBundle: false,
1283+
goTo: GOTO.TAAS_CANDIDATES_INTERVIEWS,
1284+
},
1285+
],
1286+
},
1287+
1288+
{
1289+
version: 1,
1290+
eventType: EVENT_TYPE.TAAS.RESOURCE_BOOKING_EXPIRATION,
1291+
type: NOTIFICATION_TYPE.TAAS,
1292+
rules: [
1293+
{
1294+
text: "{{numOfExpiringResourceBookings}} resource booking{{pluralize numOfExpiringResourceBookings '' 's'}} {{pluralize numOfExpiringResourceBookings 'is' 'are'}} expiring in the team <strong>{{teamName}}</strong>",
1295+
shouldBundle: false,
1296+
goTo: GOTO.TAAS_PROJECT,
1297+
},
1298+
],
1299+
},
1300+
1301+
{
1302+
version: 1,
1303+
eventType: EVENT_TYPE.TAAS.RESOURCE_BOOKING_PLACED,
1304+
type: NOTIFICATION_TYPE.TAAS,
1305+
rules: [
1306+
{
1307+
text: "Resource <strong>{{userHandle}}</strong> is placed for the job <strong>{{jobTitle}}</strong> of the team <strong>{{teamName}}</strong>",
1308+
shouldBundle: false,
1309+
goTo: GOTO.TAAS_PROJECT,
1310+
},
1311+
],
1312+
},
12611313
];
12621314

12631315
// list of ignored notifications

src/containers/NotificationsContainer/index.jsx

Lines changed: 2 additions & 2 deletions
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
);

0 commit comments

Comments
 (0)