diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js index 26976efcf5..f71bfb3fb0 100644 --- a/frontend_tests/node_tests/popovers.js +++ b/frontend_tests/node_tests/popovers.js @@ -52,6 +52,7 @@ const alice = { is_guest: false, is_admin: false, role: 400, + date_joined: "2021-11-01T16:32:16.458735+00:00", }; const me = { @@ -111,6 +112,7 @@ function test_ui(label, f) { } test_ui("sender_hover", ({override, mock_template}) => { + page_params.is_spectator = false; override($.fn, "popover", noop); override(emoji, "get_emoji_details_by_name", noop); @@ -196,6 +198,8 @@ test_ui("sender_hover", ({override, mock_template}) => { status_text: "on the beach", status_emoji_info, user_mention_syntax: "@**Alice Smith**", + date_joined: undefined, + spectator_view: false, }); return "content-html"; }); diff --git a/static/js/popovers.js b/static/js/popovers.js index f9cf845c90..01fab3ea13 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -1,5 +1,5 @@ import ClipboardJS from "clipboard"; -import {add, formatISO, set} from "date-fns"; +import {add, formatISO, parseISO, set} from "date-fns"; import ConfirmDatePlugin from "flatpickr/dist/plugins/confirmDate/confirmDate"; import $ from "jquery"; import tippy, {hideAll} from "tippy.js"; @@ -208,6 +208,13 @@ function render_user_info_popover( const status_text = user_status.get_status_text(user.user_id); const status_emoji_info = user_status.get_status_emoji(user.user_id); + const spectator_view = page_params.is_spectator; + let date_joined; + if (spectator_view) { + const dateFormat = new Intl.DateTimeFormat("default", {dateStyle: "long"}); + date_joined = dateFormat.format(parseISO(user.date_joined)); + } + const args = { can_revoke_away, can_set_away, @@ -234,6 +241,8 @@ function render_user_info_popover( status_text, status_emoji_info, user_mention_syntax: people.get_mention_syntax(user.full_name, user.user_id), + date_joined, + spectator_view, }; if (user.is_bot) { diff --git a/static/templates/user_info_popover_content.hbs b/static/templates/user_info_popover_content.hbs index dbdd6e8027..9ca96bd2e8 100644 --- a/static/templates/user_info_popover_content.hbs +++ b/static/templates/user_info_popover_content.hbs @@ -7,7 +7,7 @@ {{#if is_bot}} {{else}} - + {{/if}} {{/if}} @@ -49,6 +49,7 @@ {{else}}