-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide ability to copy URL to access an internally accessible resour…
…ce (#3420) * ui-changes * Fix Resource Card * Update workspaceService.ts * Update workspaceService.ts * bump ui version * bump ui version * Update workspaceService.ts * Update workspaceService.ts --------- Co-authored-by: Anat Balzam <> Co-authored-by: anatbal <anatbal@example.com>
- Loading branch information
Showing
7 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
ui/app/src/components/shared/ConfirmCopyUrlToClipboard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Dialog, PrimaryButton, DialogType, Stack, TooltipHost, TextField } from '@fluentui/react'; | ||
import React, { useState } from 'react'; | ||
import { Resource } from '../../models/resource'; | ||
|
||
interface ConfirmCopyUrlToClipboardProps { | ||
resource: Resource, | ||
onDismiss: () => void | ||
} | ||
|
||
// show a explanation about why connect is disabled, and show a copy to clipboard tool tip | ||
export const ConfirmCopyUrlToClipboard: React.FunctionComponent<ConfirmCopyUrlToClipboardProps> = (props: ConfirmCopyUrlToClipboardProps) => { | ||
const COPY_TOOL_TIP_DEFAULT_MESSAGE = "Copy to clipboard" | ||
|
||
const [copyToolTipMessage, setCopyToolTipMessage] = useState<string>(COPY_TOOL_TIP_DEFAULT_MESSAGE); | ||
|
||
const copyUrlToClipboardProps = { | ||
type: DialogType.normal, | ||
title: 'Access a Protected Endpoint', | ||
closeButtonAriaLabel: 'Close', | ||
subText: `Copy the link below, paste it and use it from a workspace virtual machine`, | ||
}; | ||
|
||
const dialogStyles = { main: { maxWidth: 450 } }; | ||
const modalProps = { | ||
titleAriaId: 'labelId', | ||
subtitleAriaId: 'subTextId', | ||
isBlocking: true, | ||
styles: dialogStyles | ||
}; | ||
|
||
const handleCopyUrl = () => { | ||
navigator.clipboard.writeText(props.resource.properties.connection_uri); | ||
setCopyToolTipMessage("Copied") | ||
setTimeout(() => setCopyToolTipMessage(COPY_TOOL_TIP_DEFAULT_MESSAGE), 3000); | ||
} | ||
|
||
return (<> | ||
<Dialog | ||
hidden={false} | ||
onDismiss={() => props.onDismiss()} | ||
dialogContentProps={copyUrlToClipboardProps} | ||
modalProps={modalProps} | ||
> | ||
<Stack horizontal styles={{ root: { alignItems: 'center', paddingTop: '7px' } }}> | ||
<Stack.Item grow> | ||
<TextField readOnly value={props.resource.properties.connection_uri} /> | ||
</Stack.Item> | ||
<TooltipHost content={copyToolTipMessage}> | ||
<PrimaryButton | ||
iconProps={{ iconName: 'copy' }} | ||
styles={{ root: { minWidth: '40px' } }} | ||
onClick={() => { handleCopyUrl() }} | ||
/> | ||
</TooltipHost> | ||
</Stack> | ||
</Dialog> | ||
|
||
</>); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters