Mailspring/app/internal_packages/activity/lib/list/activity-list-button.jsx
Ben Gotow 251d7c44d1
Activity Summary / Insights v1 🎉
* Initial commit

* SVG-based graph components

* Add histogram, pull data into graphs

* Loading animation, timespan descriptions

* Improvements to read receipt / link tracking section

* Initial pass at subject line analysis

* Fixes to subject-line stats

* Fix theme `ui-variables` include paths

* Add “Share this report” button

* Add “Learn More” button

* Make it more clear how to edit your shortcuts

* Merge activity-list and new activity-dashboard, move in sidebar
2017-11-07 20:05:25 +01:00

59 lines
1.5 KiB
JavaScript

import React from 'react';
import { Actions, ReactDOM } from 'mailspring-exports';
import { RetinaImg } from 'mailspring-component-kit';
import ActivityList from './activity-list';
import ActivityEventStore from '../activity-event-store';
class ActivityListButton extends React.Component {
static displayName = 'ActivityListButton';
constructor() {
super();
this.state = this._getStateFromStores();
}
componentDidMount() {
this._unsub = ActivityEventStore.listen(this._onDataChanged);
}
componentWillUnmount() {
this._unsub();
}
onClick = () => {
const buttonRect = ReactDOM.findDOMNode(this).getBoundingClientRect();
Actions.openPopover(<ActivityList />, { originRect: buttonRect, direction: 'down' });
};
_onDataChanged = () => {
this.setState(this._getStateFromStores());
};
_getStateFromStores() {
return {
unreadCount: ActivityEventStore.unreadCount(),
};
}
render() {
let unreadCountClass = 'unread-count';
let iconClass = 'activity-toolbar-icon';
if (this.state.unreadCount) {
unreadCountClass += ' active';
iconClass += ' unread';
}
return (
<div tabIndex={-1} className="toolbar-activity" title="View activity" onClick={this.onClick}>
<div className={unreadCountClass}>{this.state.unreadCount}</div>
<RetinaImg
name="icon-toolbar-activity.png"
className={iconClass}
mode={RetinaImg.Mode.ContentIsMask}
/>
</div>
);
}
}
export default ActivityListButton;