123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- /* jshint ignore:start */
- import React from 'react';
- import modal from 'misago/services/modal';
- import * as moderation from './actions';
- import MoveModal from './move';
- import SplitModal from './split';
- export default function(props) {
- return (
- <ul className="dropdown-menu">
- <Approve {...props} />
- <Merge {...props} />
- <Move {...props} />
- <Split {...props} />
- <Protect {...props} />
- <Unprotect {...props} />
- <Hide {...props} />
- <Unhide {...props} />
- <Delete {...props} />
- </ul>
- );
- }
- export class Approve extends React.Component {
- onClick = () => {
- moderation.approve(this.props);
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_approve;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Approve")}
- </button>
- </li>
- );
- }
- }
- export class Merge extends React.Component {
- onClick = () => {
- moderation.merge(this.props);
- };
- render() {
- if (this.props.selection.length < 2 || !this.props.thread.acl.can_merge_posts) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Merge")}
- </button>
- </li>
- );
- }
- }
- export class Move extends React.Component {
- onClick = () => {
- modal.show(
- <MoveModal {...this.props} />
- );
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_move;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Move")}
- </button>
- </li>
- );
- }
- }
- export class Split extends React.Component {
- onClick = () => {
- modal.show(
- <SplitModal {...this.props} />
- );
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_move;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Split")}
- </button>
- </li>
- );
- }
- }
- export class Protect extends React.Component {
- onClick = () => {
- moderation.protect(this.props);
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_protect;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Protect")}
- </button>
- </li>
- );
- }
- }
- export class Unprotect extends React.Component {
- onClick = () => {
- moderation.unprotect(this.props);
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_protect;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Unprotect")}
- </button>
- </li>
- );
- }
- }
- export class Hide extends React.Component {
- onClick = () => {
- moderation.hide(this.props);
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_hide;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Hide")}
- </button>
- </li>
- );
- }
- }
- export class Unhide extends React.Component {
- onClick = () => {
- moderation.unhide(this.props);
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_unhide;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Unhide")}
- </button>
- </li>
- );
- }
- }
- export class Delete extends React.Component {
- onClick = () => {
- moderation.remove(this.props);
- };
- render() {
- const isVisible = this.props.selection.find((post) => {
- return post.acl.can_delete;
- });
- if (!isVisible) {
- return null;
- }
- return (
- <li>
- <button type="button" className="btn btn-link" onClick={this.onClick}>
- {gettext("Delete")}
- </button>
- </li>
- );
- }
- }
|