mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 07:42:48 +08:00
Merge pull request #2867 from flarum/as/1.0-qa-fixes
Assorted 1.0 QA fixes
This commit is contained in:
commit
9b76c8f611
|
@ -2,7 +2,7 @@ import SettingsModal from './SettingsModal';
|
|||
|
||||
export default class EditCustomCssModal extends SettingsModal {
|
||||
className() {
|
||||
return 'EditCustomCssModal Modal--large';
|
||||
return 'EditCustomCssModal TextareaCodeModal Modal--large';
|
||||
}
|
||||
|
||||
title() {
|
||||
|
|
|
@ -2,7 +2,7 @@ import SettingsModal from './SettingsModal';
|
|||
|
||||
export default class EditCustomFooterModal extends SettingsModal {
|
||||
className() {
|
||||
return 'EditCustomFooterModal Modal--large';
|
||||
return 'EditCustomFooterModal TextareaCodeModal Modal--large';
|
||||
}
|
||||
|
||||
title() {
|
||||
|
|
|
@ -2,7 +2,7 @@ import SettingsModal from './SettingsModal';
|
|||
|
||||
export default class EditCustomHeaderModal extends SettingsModal {
|
||||
className() {
|
||||
return 'EditCustomHeaderModal Modal--large';
|
||||
return 'EditCustomHeaderModal TextareaCodeModal Modal--large';
|
||||
}
|
||||
|
||||
title() {
|
||||
|
|
|
@ -12,7 +12,6 @@ import Discussion from '../../common/models/Discussion';
|
|||
export default class NotificationList extends Component {
|
||||
view() {
|
||||
const state = this.attrs.state;
|
||||
const pages = state.getPages();
|
||||
|
||||
return (
|
||||
<div className="NotificationList">
|
||||
|
@ -29,72 +28,73 @@ export default class NotificationList extends Component {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="NotificationList-content">
|
||||
{state.hasItems()
|
||||
? pages.map((page) => {
|
||||
const groups = [];
|
||||
const discussions = {};
|
||||
|
||||
page.items.forEach((notification) => {
|
||||
const subject = notification.subject();
|
||||
|
||||
if (typeof subject === 'undefined') return;
|
||||
|
||||
// Get the discussion that this notification is related to. If it's not
|
||||
// directly related to a discussion, it may be related to a post or
|
||||
// other entity which is related to a discussion.
|
||||
let discussion = null;
|
||||
if (subject instanceof Discussion) discussion = subject;
|
||||
else if (subject && subject.discussion) discussion = subject.discussion();
|
||||
|
||||
// If the notification is not related to a discussion directly or
|
||||
// indirectly, then we will assign it to a neutral group.
|
||||
const key = discussion ? discussion.id() : 0;
|
||||
discussions[key] = discussions[key] || { discussion: discussion, notifications: [] };
|
||||
discussions[key].notifications.push(notification);
|
||||
|
||||
if (groups.indexOf(discussions[key]) === -1) {
|
||||
groups.push(discussions[key]);
|
||||
}
|
||||
});
|
||||
|
||||
return groups.map((group) => {
|
||||
const badges = group.discussion && group.discussion.badges().toArray();
|
||||
|
||||
return (
|
||||
<div className="NotificationGroup">
|
||||
{group.discussion ? (
|
||||
<Link className="NotificationGroup-header" href={app.route.discussion(group.discussion)}>
|
||||
{badges && badges.length && <ul className="NotificationGroup-badges badges">{listItems(badges)}</ul>}
|
||||
<span>{group.discussion.title()}</span>
|
||||
</Link>
|
||||
) : (
|
||||
<div className="NotificationGroup-header">{app.forum.attribute('title')}</div>
|
||||
)}
|
||||
|
||||
<ul className="NotificationGroup-content">
|
||||
{group.notifications.map((notification) => {
|
||||
const NotificationComponent = app.notificationComponents[notification.contentType()];
|
||||
return NotificationComponent ? <li>{NotificationComponent.component({ notification })}</li> : '';
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
})
|
||||
: ''}
|
||||
{state.isLoading() ? (
|
||||
<LoadingIndicator className="LoadingIndicator--block" />
|
||||
) : pages.length ? (
|
||||
''
|
||||
) : (
|
||||
<div className="NotificationList-empty">{app.translator.trans('core.forum.notifications.empty_text')}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="NotificationList-content">{this.content(state)}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
content(state) {
|
||||
if (state.isLoading()) {
|
||||
return <LoadingIndicator className="LoadingIndicator--block" />;
|
||||
}
|
||||
|
||||
if (state.hasItems()) {
|
||||
return state.getPages().map((page) => {
|
||||
const groups = [];
|
||||
const discussions = {};
|
||||
|
||||
page.items.forEach((notification) => {
|
||||
const subject = notification.subject();
|
||||
|
||||
if (typeof subject === 'undefined') return;
|
||||
|
||||
// Get the discussion that this notification is related to. If it's not
|
||||
// directly related to a discussion, it may be related to a post or
|
||||
// other entity which is related to a discussion.
|
||||
let discussion = null;
|
||||
if (subject instanceof Discussion) discussion = subject;
|
||||
else if (subject && subject.discussion) discussion = subject.discussion();
|
||||
|
||||
// If the notification is not related to a discussion directly or
|
||||
// indirectly, then we will assign it to a neutral group.
|
||||
const key = discussion ? discussion.id() : 0;
|
||||
discussions[key] = discussions[key] || { discussion: discussion, notifications: [] };
|
||||
discussions[key].notifications.push(notification);
|
||||
|
||||
if (groups.indexOf(discussions[key]) === -1) {
|
||||
groups.push(discussions[key]);
|
||||
}
|
||||
});
|
||||
|
||||
return groups.map((group) => {
|
||||
const badges = group.discussion && group.discussion.badges().toArray();
|
||||
|
||||
return (
|
||||
<div className="NotificationGroup">
|
||||
{group.discussion ? (
|
||||
<Link className="NotificationGroup-header" href={app.route.discussion(group.discussion)}>
|
||||
{badges && !!badges.length && <ul className="NotificationGroup-badges badges">{listItems(badges)}</ul>}
|
||||
<span>{group.discussion.title()}</span>
|
||||
</Link>
|
||||
) : (
|
||||
<div className="NotificationGroup-header">{app.forum.attribute('title')}</div>
|
||||
)}
|
||||
|
||||
<ul className="NotificationGroup-content">
|
||||
{group.notifications.map((notification) => {
|
||||
const NotificationComponent = app.notificationComponents[notification.contentType()];
|
||||
return NotificationComponent ? <li>{NotificationComponent.component({ notification })}</li> : '';
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return <div className="NotificationList-empty">{app.translator.trans('core.forum.notifications.empty_text')}</div>;
|
||||
}
|
||||
|
||||
oncreate(vnode) {
|
||||
super.oncreate(vnode);
|
||||
|
||||
|
|
|
@ -104,7 +104,9 @@ export default class KeyboardNavigatable {
|
|||
* Provide a callback that determines whether keyboard input should be handled.
|
||||
*/
|
||||
when(callback: ShouldHandle): KeyboardNavigatable {
|
||||
return { ...this, whenCallback: callback };
|
||||
this.whenCallback = callback;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.EditCustomCssModal, .EditCustomHeaderModal {
|
||||
.TextareaCodeModal {
|
||||
textarea {
|
||||
font-family: monospace;
|
||||
line-height: 1;
|
||||
|
|
|
@ -130,6 +130,7 @@ class EditUserHandler
|
|||
|
||||
$user->afterSave(function (User $user) use ($newGroupIds) {
|
||||
$user->groups()->sync($newGroupIds);
|
||||
$user->unsetRelation('groups');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user