forked from VulcanJS/Vulcan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostsViews.jsx
61 lines (51 loc) · 1.76 KB
/
PostsViews.jsx
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
import { registerComponent, withCurrentUser } from 'meteor/nova:core';
import React, { PropTypes, Component } from 'react';
import { FormattedMessage, intlShape } from 'react-intl';
import { DropdownButton, MenuItem } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';
import { withRouter } from 'react-router'
import Users from 'meteor/nova:users';
const PostsViews = (props, context) => {
let views = ["main", "top", "new", "best"];
const adminViews = ["pending", "rejected", "scheduled"];
if (Users.canDo(props.currentUser, "posts.edit.all")) {
views = views.concat(adminViews);
}
const query = _.clone(props.router.location.query);
return (
<div className="posts-views">
<DropdownButton
bsStyle="default"
className="views btn-secondary"
title={context.intl.formatMessage({id: "posts.view"})}
id="views-dropdown"
>
{views.map(view =>
<LinkContainer key={view} to={{pathname: "/", query: {...query, view: view}}} className="dropdown-item">
<MenuItem>
<FormattedMessage id={"posts."+view}/>
</MenuItem>
</LinkContainer>
)}
<LinkContainer to={"/daily"} className="dropdown-item">
<MenuItem className={"bar"}>
<FormattedMessage id="posts.daily"/>
</MenuItem>
</LinkContainer>
</DropdownButton>
</div>
)
}
PostsViews.propTypes = {
currentUser: React.PropTypes.object,
defaultView: React.PropTypes.string
};
PostsViews.defaultProps = {
defaultView: "main"
};
PostsViews.contextTypes = {
currentRoute: React.PropTypes.object,
intl: intlShape
};
PostsViews.displayName = "PostsViews";
registerComponent('PostsViews', PostsViews, withCurrentUser, withRouter);