From cddcd742f651bab3aa20c7ca513ab3cf0f98615e Mon Sep 17 00:00:00 2001 From: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com> Date: Thu, 27 Oct 2022 02:42:25 +0530 Subject: [PATCH] Add: copy link option (#5236) * add: new item and local var * add: copy link func Co-authored-by: root Co-authored-by: alannnc --- apps/web/public/static/locales/en/common.json | 1 + packages/ui/v2/core/Shell.tsx | 38 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 5a2ae2448b..f1fa89331d 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -140,6 +140,7 @@ "slide_zoom_drag_instructions": "Slide to zoom, drag to reposition", "view_notifications": "View notifications", "view_public_page": "View public page", + "copy_public_page_link":"Copy public page link", "sign_out": "Sign out", "add_another": "Add another", "install_another": "Install another", diff --git a/packages/ui/v2/core/Shell.tsx b/packages/ui/v2/core/Shell.tsx index 6c25e8faf0..abbf53e120 100644 --- a/packages/ui/v2/core/Shell.tsx +++ b/packages/ui/v2/core/Shell.tsx @@ -30,6 +30,7 @@ import Dropdown, { import { Icon } from "@calcom/ui/Icon"; import TimezoneChangeDialog from "@calcom/ui/TimezoneChangeDialog"; import Button from "@calcom/ui/v2/core/Button"; +import showToast from "@calcom/ui/v2/core/notifications"; /* TODO: Get this from endpoint */ import pkg from "../../../../apps/web/package.json"; @@ -314,16 +315,33 @@ function UserDropdown({ small }: { small?: boolean }) { {user.username && ( - - - {" "} - {t("view_public_page")} - - + <> + + + {" "} + {t("view_public_page")} + + + + { + e.preventDefault(); + navigator.clipboard.writeText( + `${process.env.NEXT_PUBLIC_WEBSITE_URL}/${user.username}` + ); + showToast(t("link_copied"), "success"); + }} + className="flex items-center px-4 py-2 text-sm text-gray-700"> + {" "} + {t("copy_public_page_link")} + + + )}