From 4ee515a2450b50321833e869b29485fd5921075a Mon Sep 17 00:00:00 2001 From: Hardik Dharmani Date: Mon, 18 Sep 2023 13:20:39 +0530 Subject: [PATCH] user_profile_modal: Abbrevate long URLs of custom fields. Abbreviated long URL for custom field in the user profile modal and user card popover. Added a copy-to-clipboard icon at the end of the URL. When hovering over the copy button, it displays a tippy tooltip with the text `Copy URL`. Clicking the copy button displays a `Copied` tippy tooltip for 1 second. Fixes #21680 --- web/src/user_card_popover.js | 11 +++++++ web/styles/popovers.css | 30 ++++++++++++++++++++ web/templates/user_custom_profile_fields.hbs | 7 ++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/web/src/user_card_popover.js b/web/src/user_card_popover.js index 0dba6f70b9..b56bcbd021 100644 --- a/web/src/user_card_popover.js +++ b/web/src/user_card_popover.js @@ -29,6 +29,7 @@ import * as rows from "./rows"; import * as settings_config from "./settings_config"; import * as sidebar_ui from "./sidebar_ui"; import * as timerender from "./timerender"; +import {show_copied_confirmation} from "./tippyjs"; import * as ui_report from "./ui_report"; import * as ui_util from "./ui_util"; import * as user_deactivation_ui from "./user_deactivation_ui"; @@ -830,6 +831,16 @@ function register_click_handlers() { const user = people.get_by_user_id(user_id); toggle_user_card_popover_manage_menu(e.target, user); }); + new ClipboardJS(".copy-custom-field-url", { + text(trigger) { + return $(trigger) + .closest(".custom-user-url-field") + .find(".custom-profile-fields-link") + .attr("href"); + }, + }).on("success", (e) => { + show_copied_confirmation(e.trigger); + }); } export function initialize() { diff --git a/web/styles/popovers.css b/web/styles/popovers.css index fc191b5155..4f918ad5c3 100644 --- a/web/styles/popovers.css +++ b/web/styles/popovers.css @@ -146,6 +146,36 @@ } } +.custom-user-url-field { + display: flex; + overflow: hidden; + + .custom-profile-fields-link { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + .copy-custom-field-url { + background-color: transparent; + border: 0; + padding: 0; + + #clipboard_image { + /* Adjust margin to align the copy icon */ + margin: -2px 0 0 6px; + + &:hover path { + fill: hsl(204deg 100% 40%); + } + } + + &:focus { + outline: none; + } + } +} + .user-card-popover-actions .user-card-popover-manage-menu-btn { opacity: 0.8; diff --git a/web/templates/user_custom_profile_fields.hbs b/web/templates/user_custom_profile_fields.hbs index f0c7786aa0..df2be0929a 100644 --- a/web/templates/user_custom_profile_fields.hbs +++ b/web/templates/user_custom_profile_fields.hbs @@ -4,7 +4,12 @@
{{this.name}}
{{/unless}} {{#if this.is_link}} - {{this.value}} +
+ {{this.value}} + +
{{else if this.is_external_account}} {{#if (eq this.subtype "github") }}