From 8189eaa49f4e2f3873e64fe795f6c5c554e7f1da Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 16 Jan 2024 20:59:37 -0800 Subject: Show share link in a dialog --- modern/src/common/components/StatusCard.jsx | 27 ++++++++++++++++----------- modern/src/resources/l10n/en.json | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'modern/src') diff --git a/modern/src/common/components/StatusCard.jsx b/modern/src/common/components/StatusCard.jsx index c6eec3ca..0b5d4148 100644 --- a/modern/src/common/components/StatusCard.jsx +++ b/modern/src/common/components/StatusCard.jsx @@ -16,7 +16,11 @@ import { Menu, MenuItem, CardMedia, - Snackbar, + Dialog, + TextField, + DialogActions, + DialogContent, + Button, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import CloseIcon from '@mui/icons-material/Close'; @@ -34,7 +38,6 @@ import usePositionAttributes from '../attributes/usePositionAttributes'; import { devicesActions } from '../../store'; import { useCatch, useCatchCallback } from '../../reactHelper'; import { useAttributePreference } from '../util/preferences'; -import { snackBarDurationShortMs } from '../util/duration'; const useStyles = makeStyles((theme) => ({ card: { @@ -134,7 +137,7 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin const [anchorEl, setAnchorEl] = useState(null); const [removing, setRemoving] = useState(false); - const [shared, setShared] = useState(false); + const [shared, setShared] = useState(null); const handleRemove = useCatch(async (removed) => { if (removed) { @@ -182,8 +185,7 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin }); if (response.ok) { const token = await response.text(); - navigator.clipboard.writeText(`${window.location.origin}?token=${token}`); - setShared(true); + setShared(`${window.location.origin}?token=${token}`); } else { throw Error(await response.text()); } @@ -299,12 +301,15 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin itemId={deviceId} onResult={(removed) => handleRemove(removed)} /> - setShared(false)} - autoHideDuration={snackBarDurationShortMs} - message={t('sharedLinkCopied')} - /> + setShared(null)}> + + e.target.select()} /> + + + + + + ); }; diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index 8ba25991..01f3b560 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -5,6 +5,7 @@ "sharedUpload": "Upload", "sharedSet": "Set", "sharedCancel": "Cancel", + "sharedCopy": "Copy", "sharedAdd": "Add", "sharedEdit": "Edit", "sharedRemove": "Remove", @@ -99,7 +100,6 @@ "sharedImport": "Import", "sharedColumns": "Columns", "sharedDropzoneText": "Drag and drop a file here or click", - "sharedLinkCopied": "Link copied", "sharedLogs": "Logs", "calendarSimple": "Simple", "calendarRecurrence": "Recurrence", -- cgit v1.2.3