mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 14:13:37 +08:00
Rename JS sub-components so that descriptors are before the noun, not after
To be consistent with the naming in PHP world. e.g. ReplyComposer instead of ComposerReply
This commit is contained in:
parent
6bdf36253c
commit
58adcfa3c4
|
@ -1,38 +0,0 @@
|
|||
import Component from 'flarum/component';
|
||||
import humanTime from 'flarum/helpers/human-time';
|
||||
import avatar from 'flarum/helpers/avatar';
|
||||
import listItems from 'flarum/helpers/list-items';
|
||||
import ItemList from 'flarum/utils/item-list';
|
||||
|
||||
export default class ActivityPost extends Component {
|
||||
view() {
|
||||
var activity = this.props.activity;
|
||||
var user = activity.user();
|
||||
var post = activity.post();
|
||||
var discussion = post.discussion();
|
||||
|
||||
return m('div', [
|
||||
avatar(user, {className: 'activity-icon'}),
|
||||
m('div.activity-info', [
|
||||
m('strong', post.number() == 1 ? 'Started a discussion' : 'Posted a reply'),
|
||||
humanTime(activity.time())
|
||||
]),
|
||||
m('a.activity-content.activity-post', {href: app.route('discussion.near', {
|
||||
id: discussion.id(),
|
||||
slug: discussion.slug(),
|
||||
near: post.number()
|
||||
}), config: m.route}, [
|
||||
m('ul.list-inline', listItems(this.headerItems().toArray())),
|
||||
m('div.body', m.trust(post.contentHtml()))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
headerItems() {
|
||||
var items = new ItemList();
|
||||
|
||||
items.add('title', m('h3.title', this.props.activity.post().discussion().title()));
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import PostHeaderUser from 'flarum/components/post-header-user';
|
|||
import PostHeaderMeta from 'flarum/components/post-header-meta';
|
||||
import PostHeaderEdited from 'flarum/components/post-header-edited';
|
||||
import PostHeaderToggle from 'flarum/components/post-header-toggle';
|
||||
import ComposerEdit from 'flarum/components/composer-edit';
|
||||
import EditComposer from 'flarum/components/edit-composer';
|
||||
import Composer from 'flarum/components/composer';
|
||||
import ItemList from 'flarum/utils/item-list';
|
||||
import listItems from 'flarum/helpers/list-items';
|
||||
|
@ -14,7 +14,7 @@ import listItems from 'flarum/helpers/list-items';
|
|||
(controls, header, and footer) surrounding the post's HTML content. Allows
|
||||
the post to be edited with the composer, hidden, or restored.
|
||||
*/
|
||||
export default class PostComment extends Post {
|
||||
export default class CommentPost extends Post {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
|
@ -32,11 +32,11 @@ export default class PostComment extends Post {
|
|||
m('aside.post-actions', m('ul', listItems(this.actionItems().toArray())))
|
||||
], {
|
||||
className: classList({
|
||||
'post-comment': true,
|
||||
'comment-post': true,
|
||||
'is-hidden': post.isHidden(),
|
||||
'is-edited': post.isEdited(),
|
||||
'reveal-content': this.revealContent,
|
||||
'editing': app.composer.component instanceof ComposerEdit &&
|
||||
'editing': app.composer.component instanceof EditComposer &&
|
||||
app.composer.component.props.post === this.props.post &&
|
||||
app.composer.position() !== Composer.PositionEnum.MINIMIZED
|
||||
})
|
|
@ -8,7 +8,7 @@ import ActionButton from 'flarum/components/action-button';
|
|||
control so the user can enter the title of their discussion. Also overrides
|
||||
the `submit` and `willExit` actions to account for the title.
|
||||
*/
|
||||
export default class ComposerDiscussion extends ComposerBody {
|
||||
export default class DiscussionComposer extends ComposerBody {
|
||||
constructor(props) {
|
||||
props.placeholder = props.placeholder || 'Write a post...';
|
||||
props.submitLabel = props.submitLabel || 'Post Discussion';
|
|
@ -5,7 +5,7 @@ import DiscussionList from 'flarum/components/discussion-list';
|
|||
import DiscussionHero from 'flarum/components/discussion-hero';
|
||||
import StreamContent from 'flarum/components/stream-content';
|
||||
import StreamScrubber from 'flarum/components/stream-scrubber';
|
||||
import ComposerReply from 'flarum/components/composer-reply';
|
||||
import ReplyComposer from 'flarum/components/reply-composer';
|
||||
import ActionButton from 'flarum/components/action-button';
|
||||
import LoadingIndicator from 'flarum/components/loading-indicator';
|
||||
import DropdownSplit from 'flarum/components/dropdown-split';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Notification from 'flarum/components/notification';
|
||||
import username from 'flarum/helpers/username';
|
||||
|
||||
export default class NotificationDiscussionRenamed extends Notification {
|
||||
export default class DiscussionRenamedNotification extends Notification {
|
||||
view() {
|
||||
var notification = this.props.notification;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import PostActivity from 'flarum/components/post-activity';
|
||||
import EventPost from 'flarum/components/event-post';
|
||||
|
||||
export default class PostDiscussionRenamed extends PostActivity {
|
||||
export default class DiscussionRenamedPost extends EventPost {
|
||||
view() {
|
||||
var post = this.props.post;
|
||||
var oldTitle = post.content()[0];
|
|
@ -8,7 +8,7 @@ import ActionButton from 'flarum/components/action-button';
|
|||
content of the post that is being edited, and adds a title control to
|
||||
indicate which post is being edited.
|
||||
*/
|
||||
export default class ComposerEdit extends ComposerBody {
|
||||
export default class EditComposer extends ComposerBody {
|
||||
constructor(props) {
|
||||
props.submitLabel = props.submitLabel || 'Save Changes';
|
||||
props.confirmExit = props.confirmExit || 'You have not saved your changes. Do you wish to discard them?';
|
|
@ -4,20 +4,20 @@ import icon from 'flarum/helpers/icon';
|
|||
import humanTime from 'flarum/utils/human-time';
|
||||
import { dasherize } from 'flarum/utils/string';
|
||||
|
||||
export default class PostActivity extends Post {
|
||||
export default class EventPost extends Post {
|
||||
view(iconName, content, attrs) {
|
||||
var post = this.props.post;
|
||||
|
||||
attrs = attrs || {};
|
||||
attrs.className = 'post-activity post-'+dasherize(post.contentType())+' '+(attrs.className || '');
|
||||
attrs.className = 'event-post post-'+dasherize(post.contentType())+' '+(attrs.className || '');
|
||||
|
||||
return super.view([
|
||||
icon(iconName+' post-icon'),
|
||||
m('div.post-activity-info', [
|
||||
m('div.event-post-info', [
|
||||
m('a.post-user', {href: app.route('user', { username: post.user().username() }), config: m.route}, username(post.user())), ' ',
|
||||
content
|
||||
]),
|
||||
m('div.post-activity-time', humanTime(post.time()))
|
||||
m('div.event-post-time', humanTime(post.time()))
|
||||
], attrs);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import mixin from 'flarum/utils/mixin';
|
|||
|
||||
import DiscussionList from 'flarum/components/discussion-list';
|
||||
import WelcomeHero from 'flarum/components/welcome-hero';
|
||||
import ComposerDiscussion from 'flarum/components/composer-discussion';
|
||||
import DiscussionComposer from 'flarum/components/discussion-composer';
|
||||
import LoginModal from 'flarum/components/login-modal';
|
||||
import DiscussionPage from 'flarum/components/discussion-page';
|
||||
|
||||
|
@ -148,7 +148,7 @@ export default class IndexPage extends Component {
|
|||
|
||||
newDiscussion() {
|
||||
if (app.session.user()) {
|
||||
app.composer.load(new ComposerDiscussion({ user: app.session.user() }));
|
||||
app.composer.load(new DiscussionComposer({ user: app.session.user() }));
|
||||
app.composer.show();
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@ import Component from 'flarum/component';
|
|||
import humanTime from 'flarum/helpers/human-time';
|
||||
import avatar from 'flarum/helpers/avatar';
|
||||
|
||||
export default class ActivityJoin extends Component {
|
||||
export default class JoinActivity extends Component {
|
||||
view() {
|
||||
var activity = this.props.activity;
|
||||
var user = activity.user();
|
|
@ -4,7 +4,7 @@ import Alert from 'flarum/components/alert';
|
|||
import ActionButton from 'flarum/components/action-button';
|
||||
import Composer from 'flarum/components/composer';
|
||||
|
||||
export default class ComposerReply extends ComposerBody {
|
||||
export default class ReplyComposer extends ComposerBody {
|
||||
constructor(props) {
|
||||
props.placeholder = props.placeholder || 'Write your reply...';
|
||||
props.submitLabel = props.submitLabel || 'Post Reply';
|
||||
|
@ -14,7 +14,7 @@ export default class ComposerReply extends ComposerBody {
|
|||
}
|
||||
|
||||
view() {
|
||||
return super.view('composer-reply');
|
||||
return super.view('reply-composer');
|
||||
}
|
||||
|
||||
headerItems() {
|
|
@ -5,7 +5,7 @@ import DiscussionList from 'flarum/components/discussion-list';
|
|||
import StreamContent from 'flarum/components/stream-content';
|
||||
import StreamScrubber from 'flarum/components/stream-scrubber';
|
||||
import UserCard from 'flarum/components/user-card';
|
||||
import ComposerReply from 'flarum/components/composer-reply';
|
||||
import ReplyComposer from 'flarum/components/reply-composer';
|
||||
import ActionButton from 'flarum/components/action-button';
|
||||
import LoadingIndicator from 'flarum/components/loading-indicator';
|
||||
import DropdownSplit from 'flarum/components/dropdown-split';
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import PostComment from 'flarum/components/post-comment';
|
||||
import PostDiscussionRenamed from 'flarum/components/post-discussion-renamed';
|
||||
import ActivityPost from 'flarum/components/activity-post';
|
||||
import ActivityJoin from 'flarum/components/activity-join';
|
||||
import NotificationDiscussionRenamed from 'flarum/components/notification-discussion-renamed';
|
||||
import CommentPost from 'flarum/components/comment-post';
|
||||
import DiscussionRenamedPost from 'flarum/components/discussion-renamed-post';
|
||||
import PostActivity from 'flarum/components/post-activity';
|
||||
import JoinActivity from 'flarum/components/join-activity';
|
||||
import DiscussionRenamedNotification from 'flarum/components/discussion-renamed-notification';
|
||||
|
||||
export default function(app) {
|
||||
app.postComponentRegistry = {
|
||||
comment: PostComment,
|
||||
discussionRenamed: PostDiscussionRenamed
|
||||
comment: CommentPost,
|
||||
discussionRenamed: DiscussionRenamedPost
|
||||
};
|
||||
|
||||
app.activityComponentRegistry = {
|
||||
post: ActivityPost,
|
||||
join: ActivityJoin
|
||||
post: PostActivity,
|
||||
join: JoinActivity
|
||||
};
|
||||
|
||||
app.notificationComponentRegistry = {
|
||||
discussionRenamed: NotificationDiscussionRenamed
|
||||
discussionRenamed: DiscussionRenamedNotification
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Discussion from 'flarum/models/discussion';
|
||||
import DiscussionPage from 'flarum/components/discussion-page';
|
||||
import ComposerReply from 'flarum/components/composer-reply';
|
||||
import ReplyComposer from 'flarum/components/reply-composer';
|
||||
import LoginModal from 'flarum/components/login-modal';
|
||||
import ActionButton from 'flarum/components/action-button';
|
||||
import Separator from 'flarum/components/separator';
|
||||
|
@ -13,8 +13,8 @@ export default function(app) {
|
|||
app.current.streamContent.goToLast();
|
||||
}
|
||||
var component = app.composer.component;
|
||||
if (!(component instanceof ComposerReply) || component.props.discussion !== this || component.props.user !== app.session.user() || forceRefresh) {
|
||||
component = new ComposerReply({
|
||||
if (!(component instanceof ReplyComposer) || component.props.discussion !== this || component.props.user !== app.session.user() || forceRefresh) {
|
||||
component = new ReplyComposer({
|
||||
user: app.session.user(),
|
||||
discussion: this
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import Post from 'flarum/models/post';
|
||||
import DiscussionPage from 'flarum/components/discussion-page';
|
||||
import ComposerEdit from 'flarum/components/composer-edit';
|
||||
import EditComposer from 'flarum/components/edit-composer';
|
||||
import ActionButton from 'flarum/components/action-button';
|
||||
import Separator from 'flarum/components/separator';
|
||||
import ItemList from 'flarum/utils/item-list';
|
||||
|
||||
export default function(app) {
|
||||
function editAction() {
|
||||
app.composer.load(new ComposerEdit({ post: this }));
|
||||
app.composer.load(new EditComposer({ post: this }));
|
||||
app.composer.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@
|
|||
.post-icon {
|
||||
float: left;
|
||||
}
|
||||
.post-activity {
|
||||
.event-post {
|
||||
&, & a {
|
||||
color: @fl-body-muted-color;
|
||||
}
|
||||
|
@ -337,11 +337,11 @@
|
|||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
.post-activity-info {
|
||||
.event-post-info {
|
||||
font-size: 15px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.post-discussion-renamed {
|
||||
.discussion-renamed-post {
|
||||
& .old-title, & .new-title {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
|
@ -439,7 +439,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.post-activity {
|
||||
.event-post {
|
||||
padding-left: 30px;
|
||||
}
|
||||
.post-icon {
|
||||
|
|
|
@ -162,7 +162,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.activity-post {
|
||||
.post-activity {
|
||||
overflow: hidden;
|
||||
|
||||
& .title {
|
||||
|
|
Loading…
Reference in New Issue
Block a user