| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 |
2x
1x
1x
12x
6x
1x
1x
1x
1x
1x
| import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import AddReport from '@bufferapp/add-report';
import PostsTable from './components/PostsTable';
import { actions } from './reducer';
export const PostsTableWrapper = props => (<div id="js-dom-to-png-posts"><PostsTable
{...props}
postsCounts={[
{ value: '5' },
{ value: '10' },
{ value: '25' },
{ value: '50' },
{ value: 'All' },
]}
addToReportButton={<AddReport
chart="posts"
state={{
descending: props.isDescendingSelected,
sortBy: props.selectedMetric.apiKey,
limit: props.activePostsCount,
searchTerms: props.searchTerms,
}}
/>}
/></div>);
PostsTableWrapper.defaultProps = {
isDropdownOpen: false,
loading: false,
};
PostsTableWrapper.propTypes = {
isDescendingSelected: PropTypes.bool.isRequired,
selectedMetric: PropTypes.shape({
key: PropTypes.string,
apiKey: PropTypes.string,
label: PropTypes.string,
}).isRequired,
activePostsCount: PropTypes.number.isRequired,
searchTerms: PropTypes.arrayOf(PropTypes.string).isRequired,
};
// default export = container
export default connect(
state => ({
loading: state.posts.loading,
searching: state.posts.searching,
timezone: state.profiles.selectedProfile ? state.profiles.selectedProfile.timezone : '',
metrics: state.posts.posts,
startDate: state.date.startDate,
endDate: state.date.endDate,
isDropdownOpen: state.posts.isDropdownOpen,
isDescendingSelected: state.posts.isDescendingSelected,
selectedMetric: state.posts.selectedMetric,
activePostsCount: state.posts.activePostsCount,
profileService: state.profiles.selectedProfile ? state.profiles.selectedProfile.service : '',
selectedProfileId: state.profiles.selectedProfile ? state.profiles.selectedProfile.id : null,
searchTerms: state.posts.searchTerms,
}),
dispatch => ({
selectMetric: ({ metric, descending }) => dispatch(
actions.selectMetric(metric, descending),
),
toggleDropdown: () => dispatch(actions.toggleDropdown()),
handlePostsCountClick: ({ postsCount }) => dispatch(
actions.handlePostsCountClick(postsCount),
),
handlePostsSortClick: ({ isDescendingSelected }) => dispatch(
actions.handlePostsSortClick(isDescendingSelected),
),
search: (tags) => dispatch(
actions.search(tags),
),
}),
)(PostsTableWrapper);
// export reducer, actions and action types
export reducer, { actions, actionTypes } from './reducer';
export middleware from './middleware';
export { Table } from './components/PostsTable';
export Title from './components/Title';
|