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}}
  • {{ user_type }}
  • {{/if}} +
  • Joined {{date_joined}}
  • {{#if is_me}} @@ -100,82 +101,86 @@ {{/if}} -
    - {{#if show_user_profile}} -
  • - - {{#if is_me}} - {{#tr}}View your profile{{/tr}} - {{else}} - {{#tr}}View full profile{{/tr}} - {{/if}} - -
  • - {{/if}} - {{#if is_active}} - {{#unless is_me}} + {{#if spectator_view}} + {{else}} + +
    + {{#if show_user_profile}}
  • - - {{#tr}}Send private message{{/tr}} {{#if is_sender_popover}}(R){{/if}} + + {{#if is_me}} + {{#tr}}View your profile{{/tr}} + {{else}} + {{#tr}}View full profile{{/tr}} + {{/if}}
  • - {{/unless}} - {{/if}} - {{#unless is_me}} -
  • - {{#if has_message_context}} - - - {{#tr}}Reply mentioning user{{/tr}} - {{#if is_sender_popover}}(@){{/if}} - - {{else}} - - - {{#tr}}Copy mention syntax{{/tr}} - {{#if is_sender_popover}}(@){{/if}} - {{/if}} -
  • - {{/unless}} - {{#if is_me}} -
  • - - {{#tr}}Edit your profile{{/tr}} - -
  • - {{/if}} -
    -
  • - - - {{#if is_me}} - {{#tr}}View private messages to myself{{/tr}} + {{#if is_active}} + {{#unless is_me}} +
  • + + {{#tr}}Send private message{{/tr}} {{#if is_sender_popover}}(R){{/if}} + +
  • + {{/unless}} + {{/if}} + {{#unless is_me}} +
  • + {{#if has_message_context}} + + + {{#tr}}Reply mentioning user{{/tr}} + {{#if is_sender_popover}}(@){{/if}} + {{else}} - {{#tr}}View private messages{{/tr}} + + + {{#tr}}Copy mention syntax{{/tr}} + {{#if is_sender_popover}}(@){{/if}} + {{/if}} - -
  • -
  • - - {{#tr}}View messages sent{{/tr}} - -
  • + + {{/unless}} + {{#if is_me}} +
  • + + {{#tr}}Edit your profile{{/tr}} + +
  • + {{/if}} +
    +
  • + + + {{#if is_me}} + {{#tr}}View private messages to myself{{/tr}} + {{else}} + {{#tr}}View private messages{{/tr}} + {{/if}} + +
  • +
  • + + {{#tr}}View messages sent{{/tr}} + +
  • - {{#if can_mute }} -
    -
  • - - {{#tr}}Mute this user{{/tr}} - -
  • - {{/if}} - {{#if can_unmute}} -
    -
  • - - {{#tr}}Unmute this user{{/tr}} - -
  • + {{#if can_mute }} +
    +
  • + + {{#tr}}Mute this user{{/tr}} + +
  • + {{/if}} + {{#if can_unmute}} +
    +
  • + + {{#tr}}Unmute this user{{/tr}} + +
  • + {{/if}} {{/if}}