Remove unused small action component
This commit is contained in:
parent
7e8766cee8
commit
cbe17be40e
|
@ -1,44 +0,0 @@
|
||||||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
|
||||||
import { userPath } from 'discourse/lib/url';
|
|
||||||
|
|
||||||
export function actionDescriptionHtml(actionCode, createdAt, username) {
|
|
||||||
const dt = new Date(createdAt);
|
|
||||||
const when = autoUpdatingRelativeAge(dt, { format: 'medium-with-ago' });
|
|
||||||
|
|
||||||
var who = "";
|
|
||||||
if (username) {
|
|
||||||
if (actionCode === "invited_group" || actionCode === "removed_group") {
|
|
||||||
who = `<a class="mention-group" href="/groups/${username}">@${username}</a>`;
|
|
||||||
} else {
|
|
||||||
who = `<a class="mention" href="${userPath(username)}">@${username}</a>`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return I18n.t(`action_codes.${actionCode}`, { who, when }).htmlSafe();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function actionDescription(actionCode, createdAt, username) {
|
|
||||||
return function() {
|
|
||||||
const ac = this.get(actionCode);
|
|
||||||
if (ac) {
|
|
||||||
return actionDescriptionHtml(ac, this.get(createdAt), this.get(username));
|
|
||||||
}
|
|
||||||
}.property(actionCode, createdAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
|
||||||
layoutName: 'components/small-action', // needed because `time-gap` inherits from this
|
|
||||||
classNames: ['small-action'],
|
|
||||||
|
|
||||||
description: actionDescription('actionCode', 'post.created_at', 'post.action_code_who'),
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
edit() {
|
|
||||||
this.sendAction('editPost', this.get('post'));
|
|
||||||
},
|
|
||||||
|
|
||||||
delete() {
|
|
||||||
this.sendAction('deletePost', this.get('post'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { propertyEqual } from 'discourse/lib/computed';
|
import { propertyEqual } from 'discourse/lib/computed';
|
||||||
import { actionDescription } from "discourse/components/small-action";
|
import { actionDescription } from "discourse/widgets/post-small-action";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNameBindings: [":item", "item.hidden", "item.deleted:deleted", "moderatorAction"],
|
classNameBindings: [":item", "item.hidden", "item.deleted:deleted", "moderatorAction"],
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
<div class='small-action-desc'>
|
|
||||||
{{#if post}}
|
|
||||||
{{#if post.can_delete}}
|
|
||||||
<button {{action "delete"}} title={{i18n "post.controls.delete"}}>{{d-icon "times"}}</button>
|
|
||||||
{{/if}}
|
|
||||||
{{#if post.can_edit}}
|
|
||||||
<button {{action "edit"}} title={{i18n "post.controls.edit"}}>{{d-icon "pencil"}}</button>
|
|
||||||
{{/if}}
|
|
||||||
<a href={{post.usernameUrl}} data-user-card={{post.username}}>
|
|
||||||
{{avatar post imageSize="small"}}
|
|
||||||
</a>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
|
@ -2,8 +2,33 @@ import { createWidget } from 'discourse/widgets/widget';
|
||||||
import RawHtml from 'discourse/widgets/raw-html';
|
import RawHtml from 'discourse/widgets/raw-html';
|
||||||
import { iconNode } from 'discourse-common/lib/icon-library';
|
import { iconNode } from 'discourse-common/lib/icon-library';
|
||||||
import { h } from 'virtual-dom';
|
import { h } from 'virtual-dom';
|
||||||
import { actionDescriptionHtml } from 'discourse/components/small-action';
|
|
||||||
import { avatarFor } from 'discourse/widgets/post';
|
import { avatarFor } from 'discourse/widgets/post';
|
||||||
|
import { userPath } from 'discourse/lib/url';
|
||||||
|
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||||
|
|
||||||
|
export function actionDescriptionHtml(actionCode, createdAt, username) {
|
||||||
|
const dt = new Date(createdAt);
|
||||||
|
const when = autoUpdatingRelativeAge(dt, { format: 'medium-with-ago' });
|
||||||
|
|
||||||
|
var who = "";
|
||||||
|
if (username) {
|
||||||
|
if (actionCode === "invited_group" || actionCode === "removed_group") {
|
||||||
|
who = `<a class="mention-group" href="/groups/${username}">@${username}</a>`;
|
||||||
|
} else {
|
||||||
|
who = `<a class="mention" href="${userPath(username)}">@${username}</a>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return I18n.t(`action_codes.${actionCode}`, { who, when }).htmlSafe();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function actionDescription(actionCode, createdAt, username) {
|
||||||
|
return function() {
|
||||||
|
const ac = this.get(actionCode);
|
||||||
|
if (ac) {
|
||||||
|
return actionDescriptionHtml(ac, this.get(createdAt), this.get(username));
|
||||||
|
}
|
||||||
|
}.property(actionCode, createdAt);
|
||||||
|
}
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
'closed.enabled': 'lock',
|
'closed.enabled': 'lock',
|
||||||
|
|
Loading…
Reference in New Issue