From cbe17be40ed742b5f2d5192756fe40cb82ef1eba Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 22 Aug 2017 14:39:57 -0400 Subject: [PATCH] Remove unused small action component --- .../discourse/components/small-action.js.es6 | 44 ------------------- .../discourse/components/stream-item.js.es6 | 2 +- .../templates/components/small-action.hbs | 13 ------ .../widgets/post-small-action.js.es6 | 27 +++++++++++- 4 files changed, 27 insertions(+), 59 deletions(-) delete mode 100644 app/assets/javascripts/discourse/components/small-action.js.es6 delete mode 100644 app/assets/javascripts/discourse/templates/components/small-action.hbs diff --git a/app/assets/javascripts/discourse/components/small-action.js.es6 b/app/assets/javascripts/discourse/components/small-action.js.es6 deleted file mode 100644 index 114d35801c6..00000000000 --- a/app/assets/javascripts/discourse/components/small-action.js.es6 +++ /dev/null @@ -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 = `@${username}`; - } else { - who = `@${username}`; - } - } - 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')); - } - } - -}); diff --git a/app/assets/javascripts/discourse/components/stream-item.js.es6 b/app/assets/javascripts/discourse/components/stream-item.js.es6 index 26d1e6f8e5a..581b1c78769 100644 --- a/app/assets/javascripts/discourse/components/stream-item.js.es6 +++ b/app/assets/javascripts/discourse/components/stream-item.js.es6 @@ -1,5 +1,5 @@ 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({ classNameBindings: [":item", "item.hidden", "item.deleted:deleted", "moderatorAction"], diff --git a/app/assets/javascripts/discourse/templates/components/small-action.hbs b/app/assets/javascripts/discourse/templates/components/small-action.hbs deleted file mode 100644 index 852ef95abaa..00000000000 --- a/app/assets/javascripts/discourse/templates/components/small-action.hbs +++ /dev/null @@ -1,13 +0,0 @@ -
- {{#if post}} - {{#if post.can_delete}} - - {{/if}} - {{#if post.can_edit}} - - {{/if}} - - {{avatar post imageSize="small"}} - - {{/if}} -
diff --git a/app/assets/javascripts/discourse/widgets/post-small-action.js.es6 b/app/assets/javascripts/discourse/widgets/post-small-action.js.es6 index 680a6259116..a09f6df7f90 100644 --- a/app/assets/javascripts/discourse/widgets/post-small-action.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-small-action.js.es6 @@ -2,8 +2,33 @@ import { createWidget } from 'discourse/widgets/widget'; import RawHtml from 'discourse/widgets/raw-html'; import { iconNode } from 'discourse-common/lib/icon-library'; import { h } from 'virtual-dom'; -import { actionDescriptionHtml } from 'discourse/components/small-action'; 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 = `@${username}`; + } else { + who = `@${username}`; + } + } + 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 = { 'closed.enabled': 'lock',