From 43c0bbb6a4e5cea9f6766c663b77d959d8979133 Mon Sep 17 00:00:00 2001 From: Andrei Prigorshnev Date: Wed, 13 Jul 2022 16:02:59 +0400 Subject: [PATCH] FEATURE: show status in the tooltip on the status bubble on the user menu (#17451) --- .../javascripts/discourse/app/widgets/header.js | 6 +----- .../discourse/app/widgets/user-status-bubble.js | 11 ++++++++++- config/locales/client.en.yml | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js index 1b9d584ea93..c131e2c6b9a 100644 --- a/app/assets/javascripts/discourse/app/widgets/header.js +++ b/app/assets/javascripts/discourse/app/widgets/header.js @@ -69,11 +69,7 @@ createWidget("header-notifications", { ]; if (this.currentUser.status) { - contents.push( - this.attach("user-status-bubble", { - emoji: this.currentUser.status.emoji, - }) - ); + contents.push(this.attach("user-status-bubble", this.currentUser.status)); } if (user.isInDoNotDisturb()) { diff --git a/app/assets/javascripts/discourse/app/widgets/user-status-bubble.js b/app/assets/javascripts/discourse/app/widgets/user-status-bubble.js index 31fad4cba55..d2cc0be9a8e 100644 --- a/app/assets/javascripts/discourse/app/widgets/user-status-bubble.js +++ b/app/assets/javascripts/discourse/app/widgets/user-status-bubble.js @@ -1,9 +1,18 @@ import { createWidget } from "discourse/widgets/widget"; +import I18n from "I18n"; export default createWidget("user-status-bubble", { tagName: "div.user-status-background", html(attrs) { - return this.attach("emoji", { name: attrs.emoji }); + let title = attrs.description; + if (attrs.ends_at) { + const until = moment + .tz(attrs.ends_at, this.currentUser.timezone) + .format(I18n.t("dates.long_date_without_year")); + title += `\n${I18n.t("user_status.until")} ${until}`; + } + + return this.attach("emoji", { name: attrs.emoji, title }); }, }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 906835112f3..e5da978e931 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1800,6 +1800,7 @@ en: set_custom_status: "Set custom status" what_are_you_doing: "What are you doing?" remove_status: "Remove status" + until: "Until:" loading: "Loading..." errors: