From 03d2d7eabb6346352b4ada78f4818100d1c704d9 Mon Sep 17 00:00:00 2001 From: IanM <16573496+imorland@users.noreply.github.com> Date: Tue, 17 Jan 2023 19:47:02 +0000 Subject: [PATCH] feat: expose {time} to eventPost data, fix renamed tooltip (#3698) --- extensions/lock/locale/en.yml | 4 ++-- extensions/sticky/locale/en.yml | 4 ++-- extensions/tags/locale/en.yml | 6 +++--- .../js/src/forum/components/DiscussionRenamedPost.js | 11 +++++++---- framework/core/js/src/forum/components/EventPost.js | 2 ++ framework/core/locale/core.yml | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/extensions/lock/locale/en.yml b/extensions/lock/locale/en.yml index 2f80ec264..ed13f3bb8 100644 --- a/extensions/lock/locale/en.yml +++ b/extensions/lock/locale/en.yml @@ -29,8 +29,8 @@ flarum-lock: # These translations are displayed between posts in the post stream. post_stream: - discussion_locked_text: "{username} locked the discussion." - discussion_unlocked_text: "{username} unlocked the discussion." + discussion_locked_text: "{username} locked the discussion {time}." + discussion_unlocked_text: "{username} unlocked the discussion {time}." # These translations are used in the Settings page. settings: diff --git a/extensions/sticky/locale/en.yml b/extensions/sticky/locale/en.yml index 850bc88bf..414c04a88 100644 --- a/extensions/sticky/locale/en.yml +++ b/extensions/sticky/locale/en.yml @@ -25,8 +25,8 @@ flarum-sticky: # These translations are displayed between posts in the post stream. post_stream: - discussion_stickied_text: "{username} stickied the discussion." - discussion_unstickied_text: "{username} unstickied the discussion." + discussion_stickied_text: "{username} stickied the discussion {time}." + discussion_unstickied_text: "{username} unstickied the discussion {time}." ## # REUSED TRANSLATIONS - These keys should not be used directly in code! diff --git a/extensions/tags/locale/en.yml b/extensions/tags/locale/en.yml index 2ede1863a..3890539d2 100644 --- a/extensions/tags/locale/en.yml +++ b/extensions/tags/locale/en.yml @@ -92,9 +92,9 @@ flarum-tags: # These translations are displayed between posts in the post stream. post_stream: - added_and_removed_tags_text: "{username} added the {tagsAdded} and removed the {tagsRemoved}." - added_tags_text: "{username} added the {tagsAdded}." - removed_tags_text: "{username} removed the {tagsRemoved}." + added_and_removed_tags_text: "{username} added the {tagsAdded} and removed the {tagsRemoved} {time}." + added_tags_text: "{username} added the {tagsAdded} {time}." + removed_tags_text: "{username} removed the {tagsRemoved} {time}." tags_text: "{count, plural, one {{tags} tag} other {{tags} tags}}" # These translations are used when visiting a single tag's discussion list. diff --git a/framework/core/js/src/forum/components/DiscussionRenamedPost.js b/framework/core/js/src/forum/components/DiscussionRenamedPost.js index 80aaa04f2..479352249 100644 --- a/framework/core/js/src/forum/components/DiscussionRenamedPost.js +++ b/framework/core/js/src/forum/components/DiscussionRenamedPost.js @@ -1,6 +1,7 @@ import app from '../../forum/app'; import EventPost from './EventPost'; import extractText from '../../common/utils/extractText'; +import Tooltip from '../../common/components/Tooltip'; /** * The `DiscussionRenamedPost` component displays a discussion event post @@ -17,9 +18,8 @@ export default class DiscussionRenamedPost extends EventPost { description(data) { const renamed = app.translator.trans('core.forum.post_stream.discussion_renamed_text', data); - const oldName = app.translator.trans('core.forum.post_stream.discussion_renamed_old_tooltip', data); - return {renamed}; + return {renamed}; } descriptionData() { @@ -28,8 +28,11 @@ export default class DiscussionRenamedPost extends EventPost { const newTitle = post.content()[1]; return { - old: oldTitle, - new: {newTitle}, + new: ( + + {newTitle} + + ), }; } } diff --git a/framework/core/js/src/forum/components/EventPost.js b/framework/core/js/src/forum/components/EventPost.js index e39984c7b..b201ab3e7 100644 --- a/framework/core/js/src/forum/components/EventPost.js +++ b/framework/core/js/src/forum/components/EventPost.js @@ -4,6 +4,7 @@ import { ucfirst } from '../../common/utils/string'; import usernameHelper from '../../common/helpers/username'; import icon from '../../common/helpers/icon'; import Link from '../../common/components/Link'; +import humanTime from '../../common/helpers/humanTime'; /** * The `EventPost` component displays a post which indicating a discussion @@ -37,6 +38,7 @@ export default class EventPost extends Post { ) : ( username ), + time: humanTime(this.attrs.post.createdAt()), }); return super.content().concat([icon(this.icon(), { className: 'EventPost-icon' }),
{this.description(data)}
]); diff --git a/framework/core/locale/core.yml b/framework/core/locale/core.yml index 1eacfe5d0..997afb4dd 100644 --- a/framework/core/locale/core.yml +++ b/framework/core/locale/core.yml @@ -446,7 +446,7 @@ core: # These translations are displayed between posts in the post stream. post_stream: discussion_renamed_old_tooltip: 'The old title was: "{old}"' - discussion_renamed_text: "{username} changed the title to {new}." + discussion_renamed_text: "{username} changed the title to {new} {time}." load_more_button: => core.ref.load_more reply_placeholder: => core.ref.write_a_reply time_lapsed_text: "{period} later"