diff --git a/src/components/Apps/AppViewer.tsx b/src/components/Apps/AppViewer.tsx index bc89875..77ec0e4 100644 --- a/src/components/Apps/AppViewer.tsx +++ b/src/components/Apps/AppViewer.tsx @@ -53,6 +53,35 @@ export const AppViewer = React.forwardRef(({ app , hide, isDevMode}, iframeRef) }; }, [app, path, isDevMode]); + const removeTrailingSlash = (str) => str.replace(/\/$/, ''); + const copyLinkFunc = (e) => { + const {tabId} = e.detail + if(tabId === app?.tabId){ + let link = 'qortal://' + app?.service + '/' + app?.name + if(path && path.startsWith('/')){ + link = link + removeTrailingSlash(path) + } + if(path && !path.startsWith('/')){ + link = link + '/' + removeTrailingSlash(path) + } + navigator.clipboard.writeText(link) + .then(() => { + console.log("Path copied to clipboard:", path); + }) + .catch((error) => { + console.error("Failed to copy path:", error); + }); + } + }; + + useEffect(() => { + subscribeToEvent("copyLink", copyLinkFunc); + + return () => { + unsubscribeFromEvent("copyLink", copyLinkFunc); + }; + }, [app, path]); + // Function to navigate back in iframe const navigateBackInIframe = async () => { if (iframeRef.current && iframeRef.current.contentWindow && history?.currentIndex > 0) { diff --git a/src/components/Apps/AppsNavBarDesktop.tsx b/src/components/Apps/AppsNavBarDesktop.tsx index 253cb98..c23fd93 100644 --- a/src/components/Apps/AppsNavBarDesktop.tsx +++ b/src/components/Apps/AppsNavBarDesktop.tsx @@ -7,6 +7,7 @@ import { import NavBack from "../../assets/svgs/NavBack.svg"; import NavAdd from "../../assets/svgs/NavAdd.svg"; import NavMoreMenu from "../../assets/svgs/NavMoreMenu.svg"; +import ContentCopyIcon from '@mui/icons-material/ContentCopy'; import { ButtonBase, ListItemIcon, @@ -366,6 +367,38 @@ export const AppsNavBarDesktop = () => { primary="Refresh" /> + { + executeEvent("copyLink", { + tabId: selectedTab?.tabId, + }); + handleClose(); + }} + > + + + + + );