From bc66abf19c764eed9b779011c845110e03ab420e Mon Sep 17 00:00:00 2001 From: Yuval Yaron Date: Mon, 6 Feb 2023 16:50:38 +0000 Subject: [PATCH] add tooltip to copy SAS URL button --- .../airlock/AirlockRequestFilesSection.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/app/src/components/shared/airlock/AirlockRequestFilesSection.tsx b/ui/app/src/components/shared/airlock/AirlockRequestFilesSection.tsx index 9c7daabce4..4c48074320 100644 --- a/ui/app/src/components/shared/airlock/AirlockRequestFilesSection.tsx +++ b/ui/app/src/components/shared/airlock/AirlockRequestFilesSection.tsx @@ -1,4 +1,4 @@ -import { MessageBar, MessageBarType, Pivot, PivotItem, PrimaryButton, Stack, TextField } from "@fluentui/react"; +import { MessageBar, MessageBarType, Pivot, PivotItem, PrimaryButton, Stack, TextField, TooltipHost } from "@fluentui/react"; import React, { useCallback, useEffect, useState } from "react"; import { HttpMethod, useAuthApiCall } from "../../../hooks/useAuthApiCall"; import { AirlockRequest, AirlockRequestStatus } from "../../../models/airlock"; @@ -14,7 +14,11 @@ interface AirlockRequestFilesSectionProps { export const AirlockRequestFilesSection: React.FunctionComponent = (props: AirlockRequestFilesSectionProps) => { + const COPY_TOOL_TIP_DEFAULT_MESSAGE = "Copy to clipboard" + + const [copyToolTipMessage, setCopyToolTipMessage] = useState(COPY_TOOL_TIP_DEFAULT_MESSAGE); const [sasUrl, setSasUrl] = useState(); + const [sasUrlError, setSasUrlError] = useState(false); const [apiSasUrlError, setApiSasUrlError] = useState({} as APIError); @@ -50,6 +54,15 @@ export const AirlockRequestFilesSection: React.FunctionComponent { + if (!sasUrl) { + return; + } + navigator.clipboard.writeText(sasUrl); + setCopyToolTipMessage("Copied") + setTimeout(() => setCopyToolTipMessage(COPY_TOOL_TIP_DEFAULT_MESSAGE), 3000); + } + const getAzureCliCommand = (sasUrl: string) => { let containerDetails = parseSasUrl(sasUrl) if (!containerDetails) { @@ -85,13 +98,13 @@ export const AirlockRequestFilesSection: React.FunctionComponent - { + { sasUrl && navigator.clipboard.writeText(sasUrl) }} + onClick={() => { handleCopySasUrl() }} /> - } + {