Skip to content

Feature : notifications #4151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
40cf4ab
Added notification popup
luizrrodrigues Feb 10, 2020
c6d120e
Update package.json to packages use notifications branch
luizrrodrigues Feb 10, 2020
05375ac
Fix tests
luizrrodrigues Feb 10, 2020
4574f37
Updated package.json to install topcoder-react-lib notifications branch
luizrrodrigues Feb 11, 2020
a9112f5
Notifications Popup Fixes
luizrrodrigues Feb 17, 2020
bf6e262
ci: deploying on test for QA
sushilshinde Feb 19, 2020
c524036
Notifications Listing Page
luizrrodrigues Feb 27, 2020
28ad54c
Fix Issue #4041 : Align tab to left
luizrrodrigues Mar 2, 2020
991b67a
Fix Issue #4040 : Remove blue border (focus) from links
luizrrodrigues Mar 2, 2020
86ab4a3
Notifications: Fix listing page
luizrrodrigues Mar 2, 2020
4d35f30
Fix lint errors
luizrrodrigues Mar 2, 2020
227add9
Backend Integration + Fixes + Broadcast type
luizrrodrigues Mar 9, 2020
2c34da7
Fix CircleCI errors
luizrrodrigues Mar 9, 2020
e11e1c2
#4085 : Notification items clickable
luizrrodrigues Mar 10, 2020
9d88998
#4013: Fix duplication KEY in notification list
luizrrodrigues Mar 10, 2020
b5ee8ee
Remove submission event.
luizrrodrigues Mar 11, 2020
642e6dd
Prevent follow link when click in "Mark As Read" button
luizrrodrigues Mar 11, 2020
26c3ac7
Hide Notificaitons Settings until this page ready
luizrrodrigues Mar 13, 2020
af9d7ce
Temporary remove "Complete Challenge" from Listing Page
luizrrodrigues Mar 17, 2020
112fd58
#4122: Allow HTML tag in notification msg
luizrrodrigues Mar 21, 2020
2ced31a
ci: deploying on beta for QA
sushilshinde Mar 23, 2020
9472329
ci: deploying to beta
LieutenantRoger Mar 24, 2020
d8f1fc9
#4140: Added check if token expired in Header
luizrrodrigues Mar 27, 2020
04479f8
#4140: Change check token to load in right place
luizrrodrigues Mar 28, 2020
2a85acd
#4140: Added "authenticating" check before Notification load
luizrrodrigues Mar 28, 2020
be09cf4
#4140: Changed the approach to reload notifications if auth token is …
luizrrodrigues Mar 28, 2020
e06275a
ci:deploying to test
LieutenantRoger Mar 30, 2020
1e0ceb8
Merge branch 'develop' into notifications
sushilshinde Mar 30, 2020
1cd22a1
Merge pull request #4132 from topcoder-platform/notifications
sushilshinde Mar 30, 2020
b51436e
feat: notifications feature release
sushilshinde Mar 30, 2020
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
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ workflows:
branches:
only:
- develop
- feature-stats-history
# This is alternate dev env for parallel testing
- "build-test":
context : org-global
filters:
branches:
only:
- nav-hot-fix
- develop
- notifications
# This is beta env for production soft releases
- "build-prod-beta":
context : org-global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ exports[`Default render 1`] = `
},
]
}
auth={null}
authURLs={
Object {
"href": "https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main",
"location": "https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main",
}
}
loggedIn={true}
notificationButtonState="none"
notificationButtonState="new"
notifications={Array []}
onMenuOpen={[Function]}
onSwitch={[Function]}
Expand All @@ -174,7 +175,7 @@ exports[`Default render 1`] = `
"photoURL": "https://d1aahxkjiobka8.cloudfront.net/avatar/https%3A%2F%2Ftopcoder-dev-media.s3.amazonaws.com%2Fmember%2Fprofile%2Fhuanner-1552562543506.png?size=32",
}
}
showNotification={false}
showNotification={true}
switchText={
Object {
"href": "https://connect.topcoder-dev.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

exports[`Matches shallow snapshot 1`] = `
<Header
auth={
Object {
"profile": Object {},
}
}
closeMenu={[Function]}
closeMobileMenu={[Function]}
closeSearch={[Function]}
dismissChallengeNotifications={[Function]}
loadNotifications={[Function]}
markAllNotificationAsRead={[Function]}
markAllNotificationAsSeen={[Function]}
markNotificationAsRead={[Function]}
notifications={Array []}
openMenu={[Function]}
openMobileMenu={[Function]}
openSearch={[Function]}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
"supertest": "^3.1.0",
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
"topcoder-react-lib": "0.13.0",
"tc-ui": "^1.0.12",
"topcoder-react-lib": "0.12.0",
"topcoder-react-ui-kit": "^1.0.11",
"topcoder-react-utils": "0.7.8",
"turndown": "^4.0.2",
Expand Down
5 changes: 5 additions & 0 deletions src/assets/images/notifications/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 32 additions & 4 deletions src/shared/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ try {
// window is undefined
}

const Header = ({ profile }) => {
const Header = ({
profile, auth, notifications, loadNotifications, markNotificationAsRead,
markAllNotificationAsRead, markAllNotificationAsSeen, dismissChallengeNotifications,
}) => {
const [activeLevel1Id, setActiveLevel1Id] = useState();
const [path, setPath] = useState();
const [openMore, setOpenMore] = useState(true);
Expand Down Expand Up @@ -48,6 +51,17 @@ const Header = ({ profile }) => {
useEffect(() => {
setPath(window.location.pathname);
}, []);

/*
* Reload notificaitons if token was changed
* This prevent to use expired token in API call
*/
if (auth) {
useEffect(() => {
loadNotifications(auth.tokenV3);
}, [auth.tokenV3]);
}

if (TopNavRef) {
return (
<div>
Expand All @@ -56,13 +70,19 @@ const Header = ({ profile }) => {
rightMenu={(
<LoginNavRef
loggedIn={!_.isEmpty(profile)}
notificationButtonState="none"
notifications={[]}
notificationButtonState="new"
notifications={notifications || []}
loadNotifications={loadNotifications}
markNotificationAsRead={markNotificationAsRead}
markAllNotificationAsRead={markAllNotificationAsRead}
markAllNotificationAsSeen={markAllNotificationAsSeen}
dismissChallengeNotifications={dismissChallengeNotifications}
accountMenu={config.ACCOUNT_MENU}
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
onSwitch={handleSwitchMenu}
onMenuOpen={handleCloseOpenMore}
showNotification={false}
showNotification
auth={auth}
profile={normalizedProfile}
authURLs={config.HEADER_AUTH_URLS}
/>
Expand All @@ -86,13 +106,21 @@ const Header = ({ profile }) => {

Header.defaultProps = {
profile: null,
auth: null,
};

Header.propTypes = {
profile: PT.shape({
photoURL: PT.string,
handle: PT.string,
}),
auth: PT.shape(),
notifications: PT.arrayOf(PT.object).isRequired,
loadNotifications: PT.func.isRequired,
markNotificationAsRead: PT.func.isRequired,
markAllNotificationAsRead: PT.func.isRequired,
markAllNotificationAsSeen: PT.func.isRequired,
dismissChallengeNotifications: PT.func.isRequired,
};

export default Header;
102 changes: 102 additions & 0 deletions src/shared/components/Notifications/TabsPanel/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React from 'react';
import PropTypes from 'prop-types';
import cn from 'classnames';
import styles from './style.scss';


const TABS = {
COMPLETED: 'completed',
BROADCAST: 'broadcast',
ACTIVE: 'active',
};

export default class TabsPanel extends React.Component {
constructor(props) {
super(props);
this.state = {
tab: TABS.ACTIVE,
};
}


render() {
const { changeTab } = this.props;
const { tab } = this.state;
return (
<div className={styles.container}>
<div className={styles.lefts}>
<div
className={cn([styles.btn, tab === TABS.ACTIVE && styles.active])}
role="tab"
tabIndex="0"
onClick={
() => {
this.setState({ tab: TABS.ACTIVE });
changeTab(TABS.ACTIVE);
}
}
onKeyPress={
() => {
this.setState({ tab: TABS.ACTIVE });
changeTab(TABS.ACTIVE);
}
}
>CHALLENGES
</div>
<div
className={cn([styles.btn, tab === TABS.BROADCAST && styles.active])}
role="tab"
tabIndex="0"
onClick={
() => {
this.setState({ tab: TABS.BROADCAST });
changeTab(TABS.BROADCAST);
}
}
onKeyPress={
() => {
this.setState({ tab: TABS.BROADCAST });
changeTab(TABS.BROADCAST);
}
}
>NOTIFICATIONS
</div>
{/*
* Disabled until Backend updated (add flag completed in notifications)
*
<div
className={cn([styles.btn, tab === TABS.COMPLETED && styles.active])}
role="tab"
tabIndex="0"
onClick={
() => {
this.setState({ tab: TABS.COMPLETED });
changeTab(TABS.COMPLETED);
}
}
onKeyPress={
() => {
this.setState({ tab: TABS.COMPLETED });
changeTab(TABS.COMPLETED);
}
}
>COMPLETED CHALLENGES
</div>
*/}
</div>
{/*
* Disabled until Settings page is ready
*
<div className={styles.rights}>
<div className={styles['notification-setting']}>Notification Settings</div>
</div>
*/}
</div>
);
}
}


TabsPanel.propTypes = {
changeTab: PropTypes.func.isRequired,
};
62 changes: 62 additions & 0 deletions src/shared/components/Notifications/TabsPanel/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@import "~styles/mixins";

.container {
display: flex;
justify-content: space-between;
width: 100%;
height: 30px;
margin-top: 50px;
margin-bottom: 20px;

.lefts {
display: flex;
justify-content: space-between;

.btn {
@include roboto-bold;

color: #2a2a2a;
background-color: $tc-white;
font-size: 12px;
font-weight: 400;
text-transform: uppercase;
line-height: 30px;
text-align: center;
height: 30px;
padding: 0 15px;
cursor: pointer;

&:not(:first-of-type) {
margin-left: 5px;
}
}

.active {
color: #fff;
background-color: #7f7f7f;
box-shadow: inset 0 0 2px 0 rgba(0, 0, 0, 0.25);
border-radius: 15px;
}
}

.rights {
.notification-setting {
color: #0d61bf;

@include roboto-bold;

font-size: 14px;
font-weight: 400;
line-height: 22px;
text-align: left;
text-decoration: underline;
cursor: pointer;
}
}
}

@media (max-width: $screen-sm + 1px) {
.container {
margin: 15px 0;
}
}
Loading