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

fix for issue taas-apis/issues/477 #30

Merged
merged 6 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
TC_NOTIFICATION_URL: "https://api.topcoder-dev.com/v5/notifications",
CONNECT_DOMAIN: "https://connect.topcoder-dev.com",
COMMUNITY_DOMAIN: "https://www.topcoder-dev.com",
TAAS_APP: "https://platform.topcoder-dev.com/taas/myteams",
},
API: {
V3: "https://api.topcoder-dev.com/v3",
Expand Down
1 change: 1 addition & 0 deletions config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
TC_NOTIFICATION_URL: "https://api.topcoder.com/v5/notifications",
CONNECT_DOMAIN: "https://connect.topcoder.com",
COMMUNITY_DOMAIN: "https://www.topcoder.com",
TAAS_APP: "https://platform.topcoder.com/taas/myteams",
},
API: {
V3: "https://api.topcoder.com/v3",
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
transformIgnorePatterns: ["node_modules/?!(tc-auth-lib)"],
moduleNameMapper: {
"\\.(css|scss)$": "identity-obj-proxy",
"\\.svg$": "<rootDir>/__mocks__/fileMock.js",
"\\.(png|eot|otf|ttf|woff|woff2|svg)$": "<rootDir>/__mocks__/fileMock.js",
},
setupFilesAfterEnv: [
"../node_modules/@testing-library/jest-dom/dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* global process */
const express = require('express');
const express = require("express");

const app = express();

app.use(
"/navbar",
express.static("./dist", {
setHeaders: function setHeaders(res) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET');
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET");
res.header(
'Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept'
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
},
})
Expand Down
25 changes: 19 additions & 6 deletions src/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
NOTIFICATIONS_PENDING,
SET_NOTIFICATION_PLATFORM,
RESET_NOTIFICATIONS,
RESET_COMMUNITY_NOTIFICATIONS,
} from "../constants/notifications";
import notificationsService from "../services/notifications";
import {
Expand Down Expand Up @@ -83,6 +82,25 @@ export const getNotifications = () => (dispatch) => {
});
};

export const getTaaSNotifications = () => (dispatch) => {
dispatch({ type: GET_NOTIFICATIONS_PENDING });
notificationsService
.getTaaSNotifications()
.then((notifications) => {
dispatch({
type: GET_NOTIFICATIONS_SUCCESS,
payload: notifications,
});
})
.catch((err) => {
dispatch({
type: GET_NOTIFICATIONS_FAILURE,
payload: err,
});
console.error(`Failed to load notifications. ${err.message}`);
});
};

export const getCommunityNotifications = () => (dispatch) => {
dispatch({ type: GET_COMMUNITY_NOTIFICATIONS_PENDING });
notificationsService
Expand Down Expand Up @@ -243,10 +261,6 @@ export const resetNotifications = () => (dispatch) => {
dispatch({ type: RESET_NOTIFICATIONS });
};

export const resetCommunityNotifications = () => (dispatch) => {
dispatch({ type: RESET_COMMUNITY_NOTIFICATIONS });
};

export default {
getNotifications,
getCommunityNotifications,
Expand All @@ -262,5 +276,4 @@ export default {
markNotificationsRead,
setNotificationPlatform,
resetNotifications,
resetCommunityNotifications,
};
18 changes: 9 additions & 9 deletions src/components/Menu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
*
* General component to show menu with submenu.
*/
import React, { Fragment, useCallback, useState } from 'react';
import { useLocation } from '@reach/router';
import cn from 'classnames';
import { includes, map } from 'lodash';
import NavLink from '../NavLink';
import './styles.css';
import React, { Fragment, useCallback, useState } from "react";
import { useLocation } from "@reach/router";
import cn from "classnames";
import { includes, map } from "lodash";
import NavLink from "../NavLink";
import "./styles.css";

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

const [isOpen, setIsOpen] = useState(
includes(map(option.children, 'path'), location.pathname)
includes(map(option.children, "path"), location.pathname)
);

const toggleOpen = useCallback(() => {
Expand All @@ -24,8 +24,8 @@ const SubMenu = ({ option }) => {
return (
<>
<span
className={cn('menu-link menu-link-toggle', {
'menu-link-toggle-up': isOpen,
className={cn("menu-link menu-link-toggle", {
"menu-link-toggle-up": isOpen,
})}
onClick={toggleOpen}
role="button"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/NotificationsEmpty/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Bell from "../../../assets/icons/bell.svg";

const NotificationsEmpty = ({
children,
message = "Good job! Youre all caught up",
message = "Good job! Youre all caught up",
}) => (
<div className="notifications-empty">
<div className="icon">
Expand Down
38 changes: 19 additions & 19 deletions src/constants/apps.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
/**
* Config for the All Apps menu.
*/
import appDocumentationIcon from '../assets/images/learn.svg';
import appTaasIcon from '../assets/images/integrations.svg';
import appTaasAdminIcon from '../assets/images/taas-admin.png';
import myteamsIcon from '../assets/images/my-teams.svg';
import myteamsGreenIcon from '../assets/images/my-teams-green.svg';
import createTeamIcon from '../assets/images/create-team.svg';
import createTeamGreenIcon from '../assets/images/create-team-green.svg';
import appDocumentationIcon from "../assets/images/learn.svg";
import appTaasIcon from "../assets/images/integrations.svg";
import appTaasAdminIcon from "../assets/images/taas-admin.png";
import myteamsIcon from "../assets/images/my-teams.svg";
import myteamsGreenIcon from "../assets/images/my-teams-green.svg";
import createTeamIcon from "../assets/images/create-team.svg";
import createTeamGreenIcon from "../assets/images/create-team-green.svg";
import earnIcon from "../assets/images/earn.svg";

/**
* Micro-app categories
*/
export const APP_CATEGORIES = [
{
category: 'Manage',
category: "Manage",
apps: [
{
title: 'TaaS',
title: "TaaS",
icon: appTaasIcon,
path: '/taas',
path: "/taas",
menu: [
{
title: 'My Teams',
path: '/taas/myteams',
title: "My Teams",
path: "/taas/myteams",
icon: myteamsIcon,
activeIcon: myteamsGreenIcon,
isExact: false,
},
{
title: 'Create New Team',
path: '/taas/createnewteam',
title: "Create New Team",
path: "/taas/createnewteam",
icon: createTeamIcon,
activeIcon: createTeamGreenIcon,
isExact: false,
},
],
},
{
title: 'TaaS Admin',
title: "TaaS Admin",
icon: appTaasAdminIcon,
path: '/taas-admin',
path: "/taas-admin",
menu: [],
roles: ["bookingmanager","administrator"],
roles: ["bookingmanager", "administrator"],
},
{
title: 'Documentation',
title: "Documentation",
icon: appDocumentationIcon,
path: "/model",
menu: [],
Expand All @@ -57,7 +57,7 @@ export const APP_CATEGORIES = [
path: "/community-admin",
menu: [],
roles: ["Community Admin"],
}
},
],
},
{
Expand Down
56 changes: 54 additions & 2 deletions src/constants/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const NOTIFICATIONS_PENDING = "NOTIFICATIONS_PENDING";
export const MARK_NOTIFICATIONS_READ = "MARK_NOTIFICATIONS_READ";
export const SET_NOTIFICATION_PLATFORM = "SET_NOTIFICATION_PLATFORM";
export const RESET_NOTIFICATIONS = "RESET_NOTIFICATIONS";
export const RESET_COMMUNITY_NOTIFICATIONS = "RESET_COMMUNITY_NOTIFICATIONS";

/*
* Project member role
Expand Down Expand Up @@ -76,7 +75,7 @@ export const NOTIFICATIONS_LIMIT = 1000;
export const PLATFORM = {
CONNECT: "connect",
COMMUNITY: "community",
BOTH: "connect+community",
TAAS: "taas",
};

// Notifications event types
Expand Down Expand Up @@ -141,6 +140,13 @@ export const EVENT_TYPE = {
COMPLETED: "challenge.notification.completed",
},
BROADCAST: "admin.notification.broadcast",
TAAS: {
POST_INTERVIEW_ACTION_REQUIRED:
"taas.notification.post-interview-action-required",
RESOURCE_BOOKING_EXPIRATION:
"taas.notification.resource-booking-expiration",
RESOURCE_BOOKING_PLACED: "taas.notification.resource-booking-placed",
},
};

export const NOTIFICATION_TYPE = {
Expand All @@ -152,6 +158,7 @@ export const NOTIFICATION_TYPE = {
MEMBER_ADDED: "member-added",
CHALLENGE: "challenge",
BROADCAST: "broadcast",
TAAS: "taas",
};

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

// each notification can be displayed differently depend on WHO see them
Expand Down Expand Up @@ -1226,6 +1235,8 @@ export const NOTIFICATIONS = [
],
},

/// Community notification rules

{
eventType: EVENT_TYPE.CHALLENGE.ACTIVE,
type: NOTIFICATION_TYPE.CHALLENGE,
Expand Down Expand Up @@ -1258,6 +1269,47 @@ export const NOTIFICATIONS = [
},
],
},

/// TaaS notification rules

{
version: 1,
eventType: EVENT_TYPE.TAAS.POST_INTERVIEW_ACTION_REQUIRED,
type: NOTIFICATION_TYPE.TAAS,
rules: [
{
text: "Candidate action required for <strong>{{userHandle}}</strong> in job <strong>{{jobTitle}}</strong> of the team <strong>{{teamName}}</strong>",
shouldBundle: false,
goTo: GOTO.TAAS_CANDIDATES_INTERVIEWS,
},
],
},

{
version: 1,
eventType: EVENT_TYPE.TAAS.RESOURCE_BOOKING_EXPIRATION,
type: NOTIFICATION_TYPE.TAAS,
rules: [
{
text: "{{numOfExpiringResourceBookings}} resource booking{{pluralize numOfExpiringResourceBookings '' 's'}} {{pluralize numOfExpiringResourceBookings 'is' 'are'}} expiring in the team <strong>{{teamName}}</strong>",
shouldBundle: false,
goTo: GOTO.TAAS_PROJECT,
},
],
},

{
version: 1,
eventType: EVENT_TYPE.TAAS.RESOURCE_BOOKING_PLACED,
type: NOTIFICATION_TYPE.TAAS,
rules: [
{
text: "Resource <strong>{{userHandle}}</strong> is placed for the job <strong>{{jobTitle}}</strong> of the team <strong>{{teamName}}</strong>",
shouldBundle: false,
goTo: GOTO.TAAS_PROJECT,
},
],
},
];

// list of ignored notifications
Expand Down
4 changes: 2 additions & 2 deletions src/containers/NotificationsContainer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class NotificationsContainer extends Component {
render() {
const { notifications, communityNotifications, ...restProps } = this.props;
const preRenderedNotifications = preRenderNotifications(notifications);
const preRenderedNotifications2 = preRenderCommunityNotifications(
const preRenderedCommunityNotifications = preRenderCommunityNotifications(
communityNotifications
);

Expand All @@ -288,7 +288,7 @@ class NotificationsContainer extends Component {
{...{
...restProps,
notifications: preRenderedNotifications,
communityNotifications: preRenderedNotifications2,
communityNotifications: preRenderedCommunityNotifications,
}}
/>
);
Expand Down
Loading