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:
Toby Zerner 2015-05-18 18:50:24 +09:30
parent 6bdf36253c
commit 58adcfa3c4
17 changed files with 40 additions and 78 deletions

View File

@ -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;
}
}

View File

@ -4,7 +4,7 @@ import PostHeaderUser from 'flarum/components/post-header-user';
import PostHeaderMeta from 'flarum/components/post-header-meta'; import PostHeaderMeta from 'flarum/components/post-header-meta';
import PostHeaderEdited from 'flarum/components/post-header-edited'; import PostHeaderEdited from 'flarum/components/post-header-edited';
import PostHeaderToggle from 'flarum/components/post-header-toggle'; 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 Composer from 'flarum/components/composer';
import ItemList from 'flarum/utils/item-list'; import ItemList from 'flarum/utils/item-list';
import listItems from 'flarum/helpers/list-items'; 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 (controls, header, and footer) surrounding the post's HTML content. Allows
the post to be edited with the composer, hidden, or restored. 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) { constructor(props) {
super(props); super(props);
@ -32,11 +32,11 @@ export default class PostComment extends Post {
m('aside.post-actions', m('ul', listItems(this.actionItems().toArray()))) m('aside.post-actions', m('ul', listItems(this.actionItems().toArray())))
], { ], {
className: classList({ className: classList({
'post-comment': true, 'comment-post': true,
'is-hidden': post.isHidden(), 'is-hidden': post.isHidden(),
'is-edited': post.isEdited(), 'is-edited': post.isEdited(),
'reveal-content': this.revealContent, '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.component.props.post === this.props.post &&
app.composer.position() !== Composer.PositionEnum.MINIMIZED app.composer.position() !== Composer.PositionEnum.MINIMIZED
}) })

View File

@ -8,7 +8,7 @@ import ActionButton from 'flarum/components/action-button';
control so the user can enter the title of their discussion. Also overrides control so the user can enter the title of their discussion. Also overrides
the `submit` and `willExit` actions to account for the title. the `submit` and `willExit` actions to account for the title.
*/ */
export default class ComposerDiscussion extends ComposerBody { export default class DiscussionComposer extends ComposerBody {
constructor(props) { constructor(props) {
props.placeholder = props.placeholder || 'Write a post...'; props.placeholder = props.placeholder || 'Write a post...';
props.submitLabel = props.submitLabel || 'Post Discussion'; props.submitLabel = props.submitLabel || 'Post Discussion';

View File

@ -5,7 +5,7 @@ import DiscussionList from 'flarum/components/discussion-list';
import DiscussionHero from 'flarum/components/discussion-hero'; import DiscussionHero from 'flarum/components/discussion-hero';
import StreamContent from 'flarum/components/stream-content'; import StreamContent from 'flarum/components/stream-content';
import StreamScrubber from 'flarum/components/stream-scrubber'; 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 ActionButton from 'flarum/components/action-button';
import LoadingIndicator from 'flarum/components/loading-indicator'; import LoadingIndicator from 'flarum/components/loading-indicator';
import DropdownSplit from 'flarum/components/dropdown-split'; import DropdownSplit from 'flarum/components/dropdown-split';

View File

@ -1,7 +1,7 @@
import Notification from 'flarum/components/notification'; import Notification from 'flarum/components/notification';
import username from 'flarum/helpers/username'; import username from 'flarum/helpers/username';
export default class NotificationDiscussionRenamed extends Notification { export default class DiscussionRenamedNotification extends Notification {
view() { view() {
var notification = this.props.notification; var notification = this.props.notification;

View File

@ -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() { view() {
var post = this.props.post; var post = this.props.post;
var oldTitle = post.content()[0]; var oldTitle = post.content()[0];

View File

@ -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 content of the post that is being edited, and adds a title control to
indicate which post is being edited. indicate which post is being edited.
*/ */
export default class ComposerEdit extends ComposerBody { export default class EditComposer extends ComposerBody {
constructor(props) { constructor(props) {
props.submitLabel = props.submitLabel || 'Save Changes'; props.submitLabel = props.submitLabel || 'Save Changes';
props.confirmExit = props.confirmExit || 'You have not saved your changes. Do you wish to discard them?'; props.confirmExit = props.confirmExit || 'You have not saved your changes. Do you wish to discard them?';

View File

@ -4,20 +4,20 @@ import icon from 'flarum/helpers/icon';
import humanTime from 'flarum/utils/human-time'; import humanTime from 'flarum/utils/human-time';
import { dasherize } from 'flarum/utils/string'; import { dasherize } from 'flarum/utils/string';
export default class PostActivity extends Post { export default class EventPost extends Post {
view(iconName, content, attrs) { view(iconName, content, attrs) {
var post = this.props.post; var post = this.props.post;
attrs = attrs || {}; 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([ return super.view([
icon(iconName+' post-icon'), 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())), ' ', m('a.post-user', {href: app.route('user', { username: post.user().username() }), config: m.route}, username(post.user())), ' ',
content content
]), ]),
m('div.post-activity-time', humanTime(post.time())) m('div.event-post-time', humanTime(post.time()))
], attrs); ], attrs);
} }
} }

View File

@ -6,7 +6,7 @@ import mixin from 'flarum/utils/mixin';
import DiscussionList from 'flarum/components/discussion-list'; import DiscussionList from 'flarum/components/discussion-list';
import WelcomeHero from 'flarum/components/welcome-hero'; 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 LoginModal from 'flarum/components/login-modal';
import DiscussionPage from 'flarum/components/discussion-page'; import DiscussionPage from 'flarum/components/discussion-page';
@ -148,7 +148,7 @@ export default class IndexPage extends Component {
newDiscussion() { newDiscussion() {
if (app.session.user()) { 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(); app.composer.show();
return true; return true;
} else { } else {

View File

@ -2,7 +2,7 @@ import Component from 'flarum/component';
import humanTime from 'flarum/helpers/human-time'; import humanTime from 'flarum/helpers/human-time';
import avatar from 'flarum/helpers/avatar'; import avatar from 'flarum/helpers/avatar';
export default class ActivityJoin extends Component { export default class JoinActivity extends Component {
view() { view() {
var activity = this.props.activity; var activity = this.props.activity;
var user = activity.user(); var user = activity.user();

View File

@ -4,7 +4,7 @@ import Alert from 'flarum/components/alert';
import ActionButton from 'flarum/components/action-button'; import ActionButton from 'flarum/components/action-button';
import Composer from 'flarum/components/composer'; import Composer from 'flarum/components/composer';
export default class ComposerReply extends ComposerBody { export default class ReplyComposer extends ComposerBody {
constructor(props) { constructor(props) {
props.placeholder = props.placeholder || 'Write your reply...'; props.placeholder = props.placeholder || 'Write your reply...';
props.submitLabel = props.submitLabel || 'Post Reply'; props.submitLabel = props.submitLabel || 'Post Reply';
@ -14,7 +14,7 @@ export default class ComposerReply extends ComposerBody {
} }
view() { view() {
return super.view('composer-reply'); return super.view('reply-composer');
} }
headerItems() { headerItems() {

View File

@ -5,7 +5,7 @@ import DiscussionList from 'flarum/components/discussion-list';
import StreamContent from 'flarum/components/stream-content'; import StreamContent from 'flarum/components/stream-content';
import StreamScrubber from 'flarum/components/stream-scrubber'; import StreamScrubber from 'flarum/components/stream-scrubber';
import UserCard from 'flarum/components/user-card'; 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 ActionButton from 'flarum/components/action-button';
import LoadingIndicator from 'flarum/components/loading-indicator'; import LoadingIndicator from 'flarum/components/loading-indicator';
import DropdownSplit from 'flarum/components/dropdown-split'; import DropdownSplit from 'flarum/components/dropdown-split';

View File

@ -1,21 +1,21 @@
import PostComment from 'flarum/components/post-comment'; import CommentPost from 'flarum/components/comment-post';
import PostDiscussionRenamed from 'flarum/components/post-discussion-renamed'; import DiscussionRenamedPost from 'flarum/components/discussion-renamed-post';
import ActivityPost from 'flarum/components/activity-post'; import PostActivity from 'flarum/components/post-activity';
import ActivityJoin from 'flarum/components/activity-join'; import JoinActivity from 'flarum/components/join-activity';
import NotificationDiscussionRenamed from 'flarum/components/notification-discussion-renamed'; import DiscussionRenamedNotification from 'flarum/components/discussion-renamed-notification';
export default function(app) { export default function(app) {
app.postComponentRegistry = { app.postComponentRegistry = {
comment: PostComment, comment: CommentPost,
discussionRenamed: PostDiscussionRenamed discussionRenamed: DiscussionRenamedPost
}; };
app.activityComponentRegistry = { app.activityComponentRegistry = {
post: ActivityPost, post: PostActivity,
join: ActivityJoin join: JoinActivity
}; };
app.notificationComponentRegistry = { app.notificationComponentRegistry = {
discussionRenamed: NotificationDiscussionRenamed discussionRenamed: DiscussionRenamedNotification
}; };
} }

View File

@ -1,6 +1,6 @@
import Discussion from 'flarum/models/discussion'; import Discussion from 'flarum/models/discussion';
import DiscussionPage from 'flarum/components/discussion-page'; 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 LoginModal from 'flarum/components/login-modal';
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';
@ -13,8 +13,8 @@ export default function(app) {
app.current.streamContent.goToLast(); app.current.streamContent.goToLast();
} }
var component = app.composer.component; var component = app.composer.component;
if (!(component instanceof ComposerReply) || component.props.discussion !== this || component.props.user !== app.session.user() || forceRefresh) { if (!(component instanceof ReplyComposer) || component.props.discussion !== this || component.props.user !== app.session.user() || forceRefresh) {
component = new ComposerReply({ component = new ReplyComposer({
user: app.session.user(), user: app.session.user(),
discussion: this discussion: this
}); });

View File

@ -1,13 +1,13 @@
import Post from 'flarum/models/post'; import Post from 'flarum/models/post';
import DiscussionPage from 'flarum/components/discussion-page'; 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 ActionButton from 'flarum/components/action-button';
import Separator from 'flarum/components/separator'; import Separator from 'flarum/components/separator';
import ItemList from 'flarum/utils/item-list'; import ItemList from 'flarum/utils/item-list';
export default function(app) { export default function(app) {
function editAction() { function editAction() {
app.composer.load(new ComposerEdit({ post: this })); app.composer.load(new EditComposer({ post: this }));
app.composer.show(); app.composer.show();
} }

View File

@ -329,7 +329,7 @@
.post-icon { .post-icon {
float: left; float: left;
} }
.post-activity { .event-post {
&, & a { &, & a {
color: @fl-body-muted-color; color: @fl-body-muted-color;
} }
@ -337,11 +337,11 @@
font-weight: bold; font-weight: bold;
} }
} }
.post-activity-info { .event-post-info {
font-size: 15px; font-size: 15px;
margin-bottom: 5px; margin-bottom: 5px;
} }
.post-discussion-renamed { .discussion-renamed-post {
& .old-title, & .new-title { & .old-title, & .new-title {
font-weight: normal; font-weight: normal;
font-style: italic; font-style: italic;
@ -439,7 +439,7 @@
} }
} }
} }
.post-activity { .event-post {
padding-left: 30px; padding-left: 30px;
} }
.post-icon { .post-icon {

View File

@ -162,7 +162,7 @@
} }
} }
} }
.activity-post { .post-activity {
overflow: hidden; overflow: hidden;
& .title { & .title {