Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

fix/375#1 Remove notifications when they are viewed #392

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
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
20 changes: 12 additions & 8 deletions client/modules/users/components/Notifications.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import {connect} from 'react-redux'
import {Link} from 'react-router-dom'
//import {Link} from 'react-router-dom'
import {Button} from 'react-bootstrap'
import {SizePerPageDropDown, BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table'
import 'react-bootstrap-table/dist/react-bootstrap-table.min.css'
Expand Down Expand Up @@ -52,13 +52,17 @@ class NotificationsList extends Component {
`Notification ${id} will be permanently deleted`
)

viewAndDeleteNotification = notification => () => {
this.props.deleteNotification(notification.index)
this.props.deleteNotificationState(notification.index)
}

getActionButtons2 = (_, notification) =>
<div>
<Link
to={`${notification.url}`}
className="btn btn-info btn-sm"
><i className="fa fa-eye" /></Link>
{' '}
<a className="btn btn-info btn-sm" href={`${notification.url}`} onClick={this.viewAndDeleteNotification(notification)}>
<i className="fa fa-eye" />
</a>
<Button bsStyle="danger" bsSize="sm" onClick={this.deleteNotification(notification.index)}>
<i className="fa fa-trash" />
</Button>
Expand All @@ -67,7 +71,8 @@ class NotificationsList extends Component {
formatData2 = () => this.props.notifications ?
this.props.notifications.map((d, index) => ({
...d,
index
index,
nicerDate:new Date(d.date)
})) :
[]

Expand Down Expand Up @@ -112,9 +117,8 @@ class NotificationsList extends Component {
search
>
<TableHeaderColumn dataField="index" width="70px" dataSort>#</TableHeaderColumn>
<TableHeaderColumn dataField="date" dataSort>Date</TableHeaderColumn>
<TableHeaderColumn dataField="nicerDate" dataSort>Date</TableHeaderColumn>
<TableHeaderColumn dataField="message" dataSort>Message</TableHeaderColumn>
<TableHeaderColumn dataField="url" dataSort>Url</TableHeaderColumn>
<TableHeaderColumn
dataFormat={this.getActionButtons2}
dataAlign="center"
Expand Down