Skip to content

Commit

Permalink
Right-click to bookmark share link
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Apr 14, 2023
1 parent c155f5c commit 29a779b
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions products/jbrowse-web/src/ShareButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
RadioGroup,
TextField,
Typography,
Link,
} from '@mui/material'
import copy from 'copy-to-clipboard'

Expand Down Expand Up @@ -147,6 +148,24 @@ function InfoDialog(props: { open: boolean; onClose: Function }) {
</Dialog>
)
}
function LinkField({ url }: { url: string }) {
return (
<>
<TextField
label="URL"
value={url}
InputProps={{ readOnly: true }}
variant="filled"
style={{ width: '100%' }}
onClick={event => {
const target = event.target as HTMLTextAreaElement
target.select()
}}
/>
<Link href={url}>Link for bookmarking</Link>
</>
)
}

const ShareDialog = observer(function ({
handleClose,
Expand Down Expand Up @@ -239,40 +258,16 @@ const ShareDialog = observer(function ({
) : loading ? (
<Typography>Generating short URL...</Typography>
) : (
<TextField
label="URL"
value={shortUrl}
InputProps={{
readOnly: true,
}}
variant="filled"
style={{ width: '100%' }}
onClick={event => {
const target = event.target as HTMLTextAreaElement
target.select()
}}
/>
<LinkField url={shortUrl} />
)
) : (
<TextField
label="URL"
value={longUrl}
InputProps={{
readOnly: true,
}}
variant="filled"
style={{ width: '100%' }}
onClick={event => {
const target = event.target as HTMLTextAreaElement
target.select()
}}
/>
<LinkField url={longUrl} />
)}
</DialogContent>
<DialogActions>
<Button
onClick={() => {
copy(shortUrl || longUrl.toString())
copy(shortUrl || longUrl)
session.notify('Copied to clipboard', 'success')
}}
color="primary"
Expand Down

0 comments on commit 29a779b

Please sign in to comment.