mirror of
https://github.com/flarum/core.git
synced 2025-05-12 02:15:21 +02:00
Show login modal if replying as guest; disable button if no permission
Also hide the first item in dropdown-split menus
This commit is contained in:
parent
538784744c
commit
ae2930dc35
@ -13,10 +13,11 @@ export default class DropdownSplit extends Component {
|
|||||||
var firstItem = this.props.items[0];
|
var firstItem = this.props.items[0];
|
||||||
var items = listItems(this.props.items);
|
var items = listItems(this.props.items);
|
||||||
|
|
||||||
var buttonProps = { className: this.props.buttonClass || 'btn btn-default' };
|
var buttonProps = {};
|
||||||
for (var i in firstItem.props) {
|
for (var i in firstItem.props) {
|
||||||
buttonProps[i] = firstItem.props[i];
|
buttonProps[i] = firstItem.props[i];
|
||||||
}
|
}
|
||||||
|
buttonProps.className = (buttonProps.className || '')+' '+(this.props.buttonClass || 'btn btn-default');
|
||||||
|
|
||||||
return m('div', {className: 'dropdown dropdown-split btn-group item-count-'+(items.length)+' '+this.props.className}, [
|
return m('div', {className: 'dropdown dropdown-split btn-group item-count-'+(items.length)+' '+this.props.className}, [
|
||||||
ActionButton.component(buttonProps),
|
ActionButton.component(buttonProps),
|
||||||
|
@ -5,6 +5,7 @@ import DiscussionPage from 'flarum/components/discussion-page';
|
|||||||
import ActionButton from 'flarum/components/action-button';
|
import ActionButton from 'flarum/components/action-button';
|
||||||
import Separator from 'flarum/components/separator';
|
import Separator from 'flarum/components/separator';
|
||||||
import ComposerReply from 'flarum/components/composer-reply';
|
import ComposerReply from 'flarum/components/composer-reply';
|
||||||
|
import LoginModal from 'flarum/components/login-modal';
|
||||||
|
|
||||||
class Discussion extends Model {
|
class Discussion extends Model {
|
||||||
unreadCount() {
|
unreadCount() {
|
||||||
@ -23,7 +24,10 @@ class Discussion extends Model {
|
|||||||
var items = new ItemList();
|
var items = new ItemList();
|
||||||
|
|
||||||
if (context instanceof DiscussionPage) {
|
if (context instanceof DiscussionPage) {
|
||||||
items.add('reply', ActionButton.component({ icon: 'reply', label: 'Reply', onclick: this.replyAction.bind(this) }));
|
items.add('reply', !app.session.user() || this.canReply()
|
||||||
|
? ActionButton.component({ icon: 'reply', label: app.session.user() ? 'Reply' : 'Log In to Reply', onclick: this.replyAction.bind(this) })
|
||||||
|
: ActionButton.component({ icon: 'reply', label: 'Can\'t Reply', className: 'disabled', title: 'You don\'t have permission to reply to this discussion.' })
|
||||||
|
);
|
||||||
|
|
||||||
items.add('separator', Separator.component());
|
items.add('separator', Separator.component());
|
||||||
}
|
}
|
||||||
@ -40,7 +44,7 @@ class Discussion extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replyAction() {
|
replyAction() {
|
||||||
if (app.session.user()) {
|
if (app.session.user() && this.canReply()) {
|
||||||
if (app.current.discussion && app.current.discussion().id() === this.id()) {
|
if (app.current.discussion && app.current.discussion().id() === this.id()) {
|
||||||
app.current.streamContent.goToLast();
|
app.current.streamContent.goToLast();
|
||||||
}
|
}
|
||||||
@ -49,8 +53,11 @@ class Discussion extends Model {
|
|||||||
discussion: this
|
discussion: this
|
||||||
}));
|
}));
|
||||||
app.composer.show();
|
app.composer.show();
|
||||||
} else {
|
} else if (!app.session.user()) {
|
||||||
// signup
|
app.modal.show(new LoginModal({
|
||||||
|
message: 'You must be logged in to do that.',
|
||||||
|
callback: this.replyAction.bind(this)
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,15 @@
|
|||||||
color: @fl-body-color;
|
color: @fl-body-color;
|
||||||
background-color: @fl-body-control-bg;
|
background-color: @fl-body-control-bg;
|
||||||
}
|
}
|
||||||
|
&.disabled {
|
||||||
|
color: #aaa;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
&:hover, &:focus {
|
||||||
|
color: #aaa;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
& .icon {
|
& .icon {
|
||||||
float: left;
|
float: left;
|
||||||
margin-left: -25px;
|
margin-left: -25px;
|
||||||
@ -31,12 +40,22 @@
|
|||||||
background-color: @fl-body-control-bg;
|
background-color: @fl-body-control-bg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.dropdown-split.item-count-1 {
|
@media @tablet, @desktop, @desktop-hd {
|
||||||
& .btn {
|
.dropdown-split {
|
||||||
border-radius: @border-radius-base !important;
|
&.item-count-1 {
|
||||||
}
|
& .btn {
|
||||||
& .dropdown-toggle {
|
border-radius: @border-radius-base !important;
|
||||||
display: none;
|
}
|
||||||
|
& .dropdown-toggle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& .dropdown-menu li:first-child {
|
||||||
|
&, & + li.divider {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user