Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
feat: Copy domain button with pass/user (#5530)
Oleg Isonenb824ab10a055
diff --git a/apps/builder/app/builder/features/topbar/domains.tsx b/apps/builder/app/builder/features/topbar/domains.tsxindex 7eb08e4ca2..210abb88c7 100644--- a/apps/builder/app/builder/features/topbar/domains.tsx+++ b/apps/builder/app/builder/features/topbar/domains.tsx@@ -13,12 +13,7 @@ import {toast,} from "@webstudio-is/design-system";import type { Project } from "@webstudio-is/project";-import {- AlertIcon,- CheckCircleIcon,- ExternalLinkIcon,- CopyIcon,-} from "@webstudio-is/icons";+import { AlertIcon, CheckCircleIcon, CopyIcon } from "@webstudio-is/icons";import { CollapsibleDomainSection } from "./collapsible-domain-section";import {Fragment,@@ -326,20 +321,14 @@ const DomainItem = ({projectDomain={projectDomain}/>- <Tooltip content={`Proceed to ${projectDomain.domain}`}>- <IconButton- type="button"- tabIndex={-1}- disabled={status !== "VERIFIED_ACTIVE"}- onClick={(event) => {- const url = new URL(`https://${projectDomain.domain}`);- window.open(url.href, "_blank");- event.preventDefault();- }}- >- <ExternalLinkIcon />+ <CopyToClipboard+ text={`https://${projectDomain.domain}`}+ copyText={`Copy link: https://${projectDomain.domain}`}+ >+ <IconButton type="button" tabIndex={-1}>+ <CopyIcon /></IconButton>- </Tooltip>+ </CopyToClipboard></Grid>}>diff --git a/apps/builder/app/builder/features/topbar/publish.tsx b/apps/builder/app/builder/features/topbar/publish.tsxindex 34f6d2a813..b60ab14e06 100644--- a/apps/builder/app/builder/features/topbar/publish.tsx+++ b/apps/builder/app/builder/features/topbar/publish.tsx@@ -59,6 +59,7 @@ import {$userPlanFeatures,$stagingUsername,$stagingPassword,+ $publisherHost,} from "~/shared/nano-states";import {$publishDialog,@@ -68,7 +69,6 @@ import { Domains, PENDING_TIMEOUT, getPublishStatusAndText } from "./domains";import { CollapsibleDomainSection } from "./collapsible-domain-section";import {CheckCircleIcon,- ExternalLinkIcon,AlertIcon,CopyIcon,GearIcon,@@ -105,6 +105,7 @@ const ChangeProjectDomain = ({const selectedPagePath = useStore($selectedPagePath);const stagingUsername = useStore($stagingUsername);const stagingPassword = useStore($stagingPassword);+ const publisherHost = useStore($publisherHost);const [domain, setDomain] = useState(project.domain);const [error, setError] = useState<string>();@@ -113,6 +114,16 @@ const ChangeProjectDomain = ({const pageUrl = new URL(publishedOrigin);pageUrl.pathname = selectedPagePath;+ // Add username:password@ for staging domains+ if (+ stagingUsername &&+ stagingPassword &&+ pageUrl.hostname.endsWith(`.${publisherHost}`)+ ) {+ pageUrl.username = stagingUsername;+ pageUrl.password = stagingPassword;+ }+const updateProjectDomain = async () => {setIsUpdateInProgress(true);const validationResult = validateProjectDomain(domain);@@ -184,25 +195,15 @@ const ChangeProjectDomain = ({)}</Flex></Tooltip>- <Tooltip- content={- <Text css={{ wordBreak: "break-all" }}>- Proceed to {pageUrl.toString()}- </Text>- }- variant="wrapped"++ <CopyToClipboard+ text={pageUrl.toString()}+ copyText={`Copy link: ${pageUrl.toString()}`}>- <IconButton- type="button"- tabIndex={-1}- onClick={(event) => {- window.open(pageUrl, "_blank");- event.preventDefault();- }}- >- <ExternalLinkIcon />+ <IconButton type="button" tabIndex={-1}>+ <CopyIcon /></IconButton>- </Tooltip>+ </CopyToClipboard></Grid>}>diff --git a/apps/builder/app/shared/copy-to-clipboard.tsx b/apps/builder/app/shared/copy-to-clipboard.tsxindex 1ea75a5b75..32ae0cd1a4 100644--- a/apps/builder/app/shared/copy-to-clipboard.tsx+++ b/apps/builder/app/shared/copy-to-clipboard.tsx@@ -8,8 +8,8 @@ export const CopyToClipboard = ({children,}: {text: string;- copyText?: string;- copiedText?: string;+ copyText?: React.ReactNode;+ copiedText?: React.ReactNode;children: React.ReactNode;}) => {const [isCopied, setIsCopied] = useState(false);@@ -17,7 +17,8 @@ export const CopyToClipboard = ({return (<divstyle={{ display: "contents" }}- onClick={() => {+ onClick={(event) => {+ event.preventDefault();navigator.clipboard.writeText(text);setIsCopied(true);}}@@ -27,6 +28,7 @@ export const CopyToClipboard = ({// Changing the key seems like a workaround to address this issue.key={isCopied ? "copied" : "copy"}disableHoverableContent+ variant="wrapped"content={isCopied ? copiedText : copyText}open={isCopied === true ? true : undefined}onOpenChange={(isOpen) => {