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

Commit 761146b

Browse files
authoredAug 13, 2021
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
);

‎src/containers/NotificationsDropdownContainer/index.jsx

Lines changed: 14 additions & 15 deletions
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,11 @@ 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 &&
161+
!communityInitialized &&
162+
platform == PLATFORM.COMMUNITY)
159163
) {
160164
notificationsEmpty = (
161165
<NotificationsEmpty message="Fail to load notifications">
@@ -543,10 +547,11 @@ class NotificationsDropdownContainer extends React.Component {
543547
}
544548

545549
componentWillReceiveProps(nextProps) {
546-
const { platform: oldPlatform } = this.props;
550+
const { platform: oldPlatform, resetNotifications } = this.props;
547551
const { platform } = nextProps;
548552

549553
if (platform !== oldPlatform) {
554+
resetNotifications();
550555
this.getPlatformNotifications(platform);
551556
}
552557
}
@@ -555,23 +560,17 @@ class NotificationsDropdownContainer extends React.Component {
555560
const {
556561
getNotifications,
557562
getCommunityNotifications,
563+
getTaaSNotifications,
558564
platform,
559-
resetNotifications,
560-
resetCommunityNotifications,
561565
} = this.props;
562566

563567
p = p || platform;
564568

565-
if (p === PLATFORM.BOTH) {
566-
resetNotifications();
567-
resetCommunityNotifications();
568-
getNotifications();
569-
getCommunityNotifications();
570-
} else if (p === PLATFORM.CONNECT) {
571-
resetCommunityNotifications();
569+
if (p === PLATFORM.CONNECT) {
572570
getNotifications();
571+
} else if (p === PLATFORM.TAAS) {
572+
getTaaSNotifications();
573573
} else {
574-
resetNotifications();
575574
getCommunityNotifications();
576575
}
577576
}
@@ -619,6 +618,7 @@ const mapStateToProps = ({ notifications }) => notifications;
619618
const mapDispatchToProps = {
620619
getNotifications,
621620
getCommunityNotifications,
621+
getTaaSNotifications,
622622
toggleNotificationSeen,
623623
markAllNotificationsRead,
624624
markAllNotificationsSeen,
@@ -627,7 +627,6 @@ const mapDispatchToProps = {
627627
viewOlderNotifications,
628628
hideOlderNotifications,
629629
resetNotifications,
630-
resetCommunityNotifications,
631630
};
632631

633632
export default connect(

‎src/reducers/notifications.js

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

Lines changed: 10 additions & 0 deletions
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
};

‎src/utils/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export const getLoginUrl = () =>
2020
* Generate Business Login URL
2121
*/
2222
export const getBusinessLoginUrl = () =>
23-
`${
24-
config.URL.AUTH
25-
}?regSource=taasApp&mode=login&retUrl=${encodeURIComponent(
23+
`${config.URL.AUTH}?regSource=taasApp&mode=login&retUrl=${encodeURIComponent(
2624
window.location.href.match(/[^?]*/)[0]
2725
)}`;
2826

‎src/utils/notifications.js

Lines changed: 61 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,27 @@ const handlebarsFallbackHelper = (value, fallbackValue) => {
5959
return new Handlebars.SafeString(out);
6060
};
6161

62+
/**
63+
* Handlebars helper which displays single or plural noun
64+
*
65+
* Example:
66+
* ```
67+
* {{pluralize count resource resources}}
68+
* ```
69+
* Will output `resource` if `count` equals 0 or 1; otherwise `resources`
70+
*
71+
* @param {Number} count quantity
72+
* @param {String} single noun
73+
* @param {String} plural nouns
74+
*/
75+
const handlebarsPluralizeHelper = (number, single, plural) => {
76+
return Math.abs(number) > 1 ? plural : single;
77+
};
78+
6279
// register handlebars helpers
6380
Handlebars.registerHelper("showMore", handlebarsShowMoreHelper);
6481
Handlebars.registerHelper("fallback", handlebarsFallbackHelper);
82+
Handlebars.registerHelper("pluralize", handlebarsPluralizeHelper);
6583

6684
export const renderGoTo = (goTo, contents) => {
6785
let goToHandlebars = "";
@@ -244,105 +262,6 @@ export const filterReadNotifications = (notifications) =>
244262
export const filterSeenNotifications = (notifications) =>
245263
_.filter(notifications, { seen: false });
246264

247-
/**
248-
* Filter notifications that belongs to project:projectId
249-
*
250-
* @param {Array} notifications list of notifications
251-
*
252-
* @param {Number} projectId
253-
*
254-
* @return {Array} notifications list filtered of notifications
255-
*/
256-
export const filterNotificationsByProjectId = (notifications, projectId) =>
257-
_.filter(notifications, (notification) => {
258-
return notification.sourceId === `${projectId}`;
259-
});
260-
261-
/**
262-
* Filter notifications about Topic and Post changed
263-
*
264-
* @param {Array} notifications list of notifications
265-
* @param {RegExp} [tagRegExp] regexp to filter notification by tags
266-
*
267-
* @return {Array} notifications list filtered of notifications
268-
*/
269-
export const filterTopicAndPostChangedNotifications = (
270-
notifications,
271-
tagRegExp
272-
) => {
273-
let topicAndPostNotifications = _.filter(
274-
notifications,
275-
(notification) =>
276-
notification.eventType === EVENT_TYPE.TOPIC.CREATED ||
277-
notification.eventType === EVENT_TYPE.POST.CREATED ||
278-
notification.eventType === EVENT_TYPE.POST.UPDATED ||
279-
notification.eventType === EVENT_TYPE.POST.MENTION
280-
);
281-
282-
// filter messages using `tags`
283-
if (tagRegExp) {
284-
topicAndPostNotifications = _.filter(
285-
topicAndPostNotifications,
286-
(notification) => {
287-
const tags = _.get(notification, "contents.tags", []);
288-
289-
return _.some(tags, (tag) => tagRegExp.test(tag));
290-
}
291-
);
292-
}
293-
294-
return topicAndPostNotifications;
295-
};
296-
297-
/**
298-
* Filter notifications about Link and File changed
299-
*
300-
* @param {Array} notifications list of notifications
301-
*
302-
* @return {Array} notifications list filtered of notifications
303-
*/
304-
export const filterFileAndLinkChangedNotifications = (notifications) => {
305-
return _.filter(
306-
notifications,
307-
(notification) =>
308-
notification.eventType === EVENT_TYPE.PROJECT.FILE_UPLOADED ||
309-
notification.eventType === EVENT_TYPE.PROJECT.LINK_CREATED
310-
);
311-
};
312-
313-
/**
314-
* Filter notification about post mentions
315-
* @param {Array} notifications list of notifications
316-
*
317-
* @return {Array} notifications list filtered by post mention event type
318-
*/
319-
export const filterPostsMentionNotifications = (notifications) =>
320-
_.filter(notifications, (notification) => {
321-
return notification.eventType === EVENT_TYPE.POST.MENTION;
322-
});
323-
324-
/**
325-
* Filter notifications about the project
326-
*
327-
* @param {Array} notifications list of notifications
328-
*
329-
* @return {Array} notifications list filtered of notifications
330-
*/
331-
export const filterProjectNotifications = (notifications) =>
332-
_.filter(notifications, (notification) => {
333-
return (
334-
notification.eventType === EVENT_TYPE.PROJECT.CREATED ||
335-
notification.eventType === EVENT_TYPE.PROJECT.APPROVED ||
336-
notification.eventType === EVENT_TYPE.PROJECT.PAUSED ||
337-
notification.eventType === EVENT_TYPE.PROJECT.COMPLETED ||
338-
notification.eventType === EVENT_TYPE.PROJECT.SPECIFICATION_MODIFIED ||
339-
notification.eventType === EVENT_TYPE.PROJECT.SUBMITTED_FOR_REVIEW ||
340-
notification.eventType === EVENT_TYPE.PROJECT.FILE_UPLOADED ||
341-
notification.eventType === EVENT_TYPE.PROJECT.CANCELED ||
342-
notification.eventType === EVENT_TYPE.PROJECT.LINK_CREATED
343-
);
344-
});
345-
346265
/**
347266
* Limits notifications quantity per source
348267
*
@@ -669,7 +588,49 @@ export const preRenderNotifications = (notifications) => {
669588
return preRenderedNotifications;
670589
};
671590

672-
//----- //
591+
// --- TaaS --- //
592+
593+
export const prepareTaaSNotifications = (rawNotifications) => {
594+
const notifications = rawNotifications.map((rawNotification) => ({
595+
id: `${rawNotification.id}`,
596+
sourceId: rawNotification.contents.projectId
597+
? `${rawNotification.contents.projectId}`
598+
: "team",
599+
sourceName: rawNotification.contents.projectId
600+
? rawNotification.contents.teamName || "Team"
601+
: "Global",
602+
eventType: rawNotification.type,
603+
date: rawNotification.createdAt,
604+
isRead: rawNotification.read,
605+
seen: rawNotification.seen,
606+
contents: rawNotification.contents,
607+
version: rawNotification.version,
608+
}));
609+
610+
notifications.forEach((notification) => {
611+
const notificationRule = getNotificationRule(notification);
612+
613+
if (notificationRule) {
614+
notification.type = notificationRule.type;
615+
if (notificationRule.goTo) {
616+
notification.goto = renderGoTo(
617+
notificationRule.goTo,
618+
notification.contents
619+
);
620+
}
621+
notification.rule = notificationRule;
622+
} else {
623+
console.warn(
624+
`Cannot find notification rule for eventType '${notification.eventType}' version '${notification.version}'.`
625+
);
626+
}
627+
});
628+
629+
return notifications;
630+
};
631+
632+
// --- Community --- //
633+
673634
const getCommunityNotificationRule = (notification) => {
674635
const notificationRule = _.find(NOTIFICATION_RULES, (_notificationRule) => {
675636
return _notificationRule.eventType === notification.eventType;

‎webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ module.exports = (webpackConfigEnv, options) => {
1414
disableHtmlGeneration: true,
1515
});
1616

17+
const unusedFilesWebpackPlugin = defaultConfig.plugins.find(p => p.constructor.name === "UnusedFilesWebpackPlugin");
18+
unusedFilesWebpackPlugin.globOptions.ignore.push("**/assets/icons/*.svg", "**/__mocks__/**");
19+
1720
let cssLocalIdent;
1821
if (options.mode === "production") {
1922
cssLocalIdent = "[hash:base64:6]";

0 commit comments

Comments
 (0)
This repository has been archived.