diff --git a/apps/dashboard/src/components/contract-components/contract-deploy-form/drawer.tsx b/apps/dashboard/src/components/contract-components/contract-deploy-form/drawer.tsx deleted file mode 100644 index 8bcbdaa8ca9..00000000000 --- a/apps/dashboard/src/components/contract-components/contract-deploy-form/drawer.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { Box, Flex, Icon, Tooltip, useDisclosure } from "@chakra-ui/react"; -import { useTrack } from "hooks/analytics/useTrack"; -import { BiRocket } from "react-icons/bi"; -import { FiChevronsRight } from "react-icons/fi"; -import { Button, Drawer } from "tw-components"; -import { ContractDeployForm } from "."; -import type { ContractId } from "../types"; - -interface DeployFormDrawerProps { - contractId: ContractId; - version?: string; - chainId?: number; - onSuccessCallback?: (contractAddress: string) => void; - onDrawerVisibilityChanged?: (isVisible: boolean) => void; - isImplementationDeploy?: true; - onlyIcon?: boolean; -} - -export const DeployFormDrawer: React.FC = ({ - contractId, - version, - chainId, - onSuccessCallback, - onDrawerVisibilityChanged, - isImplementationDeploy, - onlyIcon = false, -}) => { - const { isOpen, onOpen, onClose } = useDisclosure(); - - const trackEvent = useTrack(); - return ( - <> - - { - onDrawerVisibilityChanged?.(false); - onClose(); - }} - onCloseComplete={() => { - onDrawerVisibilityChanged?.(false); - }} - isOpen={isOpen} - trapFocus={false} - blockScrollOnMount={false} - > - - { - onSuccessCallback(address); - onDrawerVisibilityChanged?.(false); - onClose(); - } - : undefined - } - /> - - - - ); -}; diff --git a/apps/dashboard/src/components/pages/publish.tsx b/apps/dashboard/src/components/pages/publish.tsx index 80566716481..8bc7b5e0a8f 100644 --- a/apps/dashboard/src/components/pages/publish.tsx +++ b/apps/dashboard/src/components/pages/publish.tsx @@ -9,26 +9,33 @@ import { SimpleGrid, Skeleton, } from "@chakra-ui/react"; -import { DeployFormDrawer } from "components/contract-components/contract-deploy-form/drawer"; import { useAllVersions, useEns } from "components/contract-components/hooks"; import { PublishedContract } from "components/contract-components/published-contract"; import { useTrack } from "hooks/analytics/useTrack"; import { replaceIpfsUrl } from "lib/sdk"; +import { ChevronsRightIcon, ExternalLinkIcon } from "lucide-react"; +import Link from "next/link"; import { useRouter } from "next/router"; import { useMemo } from "react"; import { FiChevronLeft, FiImage } from "react-icons/fi"; -import { Heading, Link, Text, TrackedIconButton } from "tw-components"; +import { Heading, Text, TrackedIconButton } from "tw-components"; +import { Spinner } from "../../@/components/ui/Spinner/Spinner"; +import { Button } from "../../@/components/ui/button"; +import { ContractDeployForm } from "../contract-components/contract-deploy-form"; +import { ShareButton } from "../share-buttom"; export interface PublishWithVersionPageProps { author: string; contractName: string; version: string; + isDeploy: boolean; } export const PublishWithVersionPage: React.FC = ({ author, contractName, version, + isDeploy, }) => { const trackEvent = useTrack(); const ensQuery = useEns(author); @@ -53,113 +60,162 @@ export const PublishWithVersionPage: React.FC = ({ ); const availableVersions = allVersions.data?.map(({ version: v }) => v) || []; + const contractNameDisplay = + publishedContract?.displayName || publishedContract?.name; - return ( - - - - - } - category="release" - label="back_button" - aria-label="Back" + const header = ( + + + + } + category="release" + label="back_button" + aria-label="Back" + /> + + {publishedContract?.logo ? ( + {publishedContract.name} + ) : ( +
+ +
+ )} - {publishedContract?.logo ? ( - {publishedContract.name} - ) : ( -
- -
- )} - - - - - {publishedContract?.displayName || publishedContract?.name} - - - {publishedContract?.description} - - - -
-
- - - { + const val = e.target.value; + if (availableVersions.includes(val)) { + trackEvent({ + category: "release-selector", + action: "click", + version_selected: val, + }); + + const pathName = + val === allVersions.data?.[0].version + ? `/${author}/${contractName}` + : `/${author}/${contractName}/${val}`; + if (isDeploy) { + router.push(`${pathName}/deploy`); + } else { router.push(pathName); } - }} - value={version} - > - {availableVersions.map((v, idx) => ( - - ))} - - {deployContractId && ( - - )} - - -
+ } + }} + value={version} + > + {availableVersions.map((v, idx) => ( + + ))} + + {isDeploy ? ( + <> + + + + + ) : ( + <> + {deployContractId && ( + + )} + + )} +
+
+
+ ); + + if (isDeploy) { + if (!deployContractId || !publishedContract) { + return ( +
+ +
+ ); + } + + return ( +
+
{header}
+
+ +
+
+ ); + } + + return ( + + {header} diff --git a/apps/dashboard/src/components/selects/NetworkSelectorButton.tsx b/apps/dashboard/src/components/selects/NetworkSelectorButton.tsx index 74a34635736..225ee2714ae 100644 --- a/apps/dashboard/src/components/selects/NetworkSelectorButton.tsx +++ b/apps/dashboard/src/components/selects/NetworkSelectorButton.tsx @@ -18,6 +18,7 @@ import { useNetworkSwitcherModal } from "thirdweb/react"; import { Button } from "tw-components"; import { thirdwebClient } from "../../@/constants/client"; import { useFavoriteChains } from "../../@3rdweb-sdk/react/hooks/useFavoriteChains"; +import { getSDKTheme } from "../../app/components/sdk-component-theme"; import { mapStoredChainTov5Chain } from "../../contexts/map-chains"; import { useActiveChainAsDashboardChain } from "../../lib/v5-adapter"; @@ -120,7 +121,7 @@ export const NetworkSelectorButton: React.FC = ({ }} onClick={() => { networkSwitcherModal.open({ - theme: theme === "dark" ? "dark" : "light", + theme: getSDKTheme(theme === "light" ? "light" : "dark"), sections: [ { label: "Recently Used", diff --git a/apps/dashboard/src/components/share-buttom/index.tsx b/apps/dashboard/src/components/share-buttom/index.tsx index 71e10e9f5bd..909b97c2f7d 100644 --- a/apps/dashboard/src/components/share-buttom/index.tsx +++ b/apps/dashboard/src/components/share-buttom/index.tsx @@ -2,9 +2,10 @@ import { Icon, useClipboard, useToast } from "@chakra-ui/react"; import { FiCheck, FiShare2 } from "react-icons/fi"; import { TrackedIconButton } from "tw-components"; -export const ShareButton: React.FC>> = ( - shareData, -) => { +export const ShareButton: React.FC = (props) => { + const url = + props.url || typeof window !== "undefined" ? window.location.href : ""; + const shareData = { ...props, url }; const { onCopy, hasCopied } = useClipboard(shareData.url); const toast = useToast(); @@ -34,21 +35,19 @@ export const ShareButton: React.FC>> = ( }; return ( - <> - - } - category="released-contract" - label="copy-url" - onClick={onShareClick} - /> - + + } + category="released-contract" + label="copy-url" + onClick={onShareClick} + /> ); }; diff --git a/apps/dashboard/src/pages/publish/[...paths].tsx b/apps/dashboard/src/pages/publish/[...paths].tsx index 7e36070cd00..7b9dfd89182 100644 --- a/apps/dashboard/src/pages/publish/[...paths].tsx +++ b/apps/dashboard/src/pages/publish/[...paths].tsx @@ -36,6 +36,7 @@ const PublishPage: ThirdwebNextPage = (props: PublishPageProps) => { author={props.author} contractName={props.contractName} version={props.version} + isDeploy={props.isDeploy} /> ); @@ -59,7 +60,17 @@ export default PublishPage; export const getStaticProps: GetStaticProps = async (ctx) => { const paths = ctx.params?.paths as string[]; - const [authorAddress, contractName, version = ""] = paths; + const [authorAddress, contractName, versionOrDeploy = "", deployStr] = paths; + let version = ""; + let isDeploy = false; + + if (versionOrDeploy === "deploy") { + isDeploy = true; + version = ""; + } else if (versionOrDeploy && deployStr === "deploy") { + version = versionOrDeploy; + isDeploy = true; + } if (!contractName) { return { @@ -133,6 +144,7 @@ export const getStaticProps: GetStaticProps = async (ctx) => { author: checksummedAddress, contractName, version, + isDeploy, }; return {