diff --git a/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/AddRemoteForm.tsx b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/AddRemoteForm.tsx index 7eaddec7..c9125eb1 100644 --- a/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/AddRemoteForm.tsx +++ b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/AddRemoteForm.tsx @@ -21,6 +21,8 @@ import { getDatabaseType } from "@components/DatabaseTypeLabel"; import DoltLink from "@components/links/DoltLink"; import DoltgresLink from "@components/links/DoltgresLink"; import css from "./index.module.css"; +import Radios, { RemoteType } from "./Radios"; +import RemoteUrl from "./RemoteUrl"; type Props = { params: DatabaseParams; @@ -30,11 +32,10 @@ export default function AddRemoteForm(props: Props): JSX.Element { const router = useRouter(); const { data: databaseDetails, loading: databaseDetailsLoading } = useDoltDatabaseDetailsQuery(); - const { dbLink, urlPlaceHolder } = getDbNameAndLink( - databaseDetails?.doltDatabaseDetails, - ); + const dbLink = getDbLink(databaseDetails?.doltDatabaseDetails); const [remoteName, setRemoteName] = useState(""); const [remoteUrl, setRemoteUrl] = useState(""); + const [type, setType] = useState(RemoteType.DoltHub); const { mutateFn: addRemote, err, @@ -73,12 +74,13 @@ export default function AddRemoteForm(props: Props): JSX.Element { placeholder="i.e. origin" className={css.input} /> - Remote type + + , - urlPlaceHolder: "i.e. https://doltremoteapi.dolthub.com/owner/repo", - }; + return ; } if (type === "DoltgreSQL") { - return { dbLink: , urlPlaceHolder: universalUrl }; + return ; } - return { dbLink: {type}, urlPlaceHolder: universalUrl }; + return {type}; } diff --git a/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/Radios.tsx b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/Radios.tsx new file mode 100644 index 00000000..84d14818 --- /dev/null +++ b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/Radios.tsx @@ -0,0 +1,38 @@ +import { Radio } from "@dolthub/react-components"; +import css from "./index.module.css"; + +export enum RemoteType { + DoltHub, + DoltLab, + Other, +} + +type Props = { + type: RemoteType; + setType: (t: RemoteType) => void; +}; + +export default function Radios(props: Props) { + return ( +
+ props.setType(RemoteType.DoltHub)} + label="DoltHub" + /> + props.setType(RemoteType.DoltLab)} + label="DoltLab" + /> + props.setType(RemoteType.Other)} + label="Other" + /> +
+ ); +} diff --git a/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/RemoteUrl.tsx b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/RemoteUrl.tsx new file mode 100644 index 00000000..145a2fac --- /dev/null +++ b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/RemoteUrl.tsx @@ -0,0 +1,76 @@ +import { FormInput } from "@dolthub/react-components"; +import { useState } from "react"; +import { RemoteType } from "./Radios"; +import css from "./index.module.css"; + +type Props = { + type: RemoteType; + remoteUrl: string; + setRemoteUrl: (t: string) => void; + currentDbName: string; +}; + +const dolthubHost = "https://doltremoteapi.dolthub.com"; + +export default function RemoteUrl({ + type, + remoteUrl, + setRemoteUrl, + currentDbName, +}: Props) { + const [ownerName, setOwnerName] = useState(""); + const [dbName, setDbName] = useState(currentDbName); + const [host, setHost] = useState(""); + if (type === RemoteType.Other) { + return ( + + ); + } + + return ( +
+ {type === RemoteType.DoltLab && ( + { + setHost(s); + setRemoteUrl(`${s}/${ownerName}/${dbName}`); + }} + label="Host" + placeholder="Url of your host, i.e. https://doltlab.dolthub.com:50051" + className={css.input} + /> + )} + { + setOwnerName(s); + setRemoteUrl( + `${type === RemoteType.DoltHub ? dolthubHost : host}/${s}/${dbName}`, + ); + }} + label="Owner Name" + placeholder="Owner of your database, i.e. dolthub" + className={css.input} + /> + { + setDbName(s); + setRemoteUrl( + `${type === RemoteType.DoltHub ? dolthubHost : host}/${ownerName}/${s}`, + ); + }} + label="Database Name" + placeholder="Name of your database, i.e. example-db" + className={css.input} + /> +
+ ); +} diff --git a/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/index.module.css b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/index.module.css index df39b339..0f7db138 100644 --- a/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/index.module.css +++ b/web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/index.module.css @@ -6,6 +6,10 @@ @apply max-w-2xl mx-auto; } +.label { + @apply text-base font-semibold py-2; +} + .input { @apply mt-4 px-0; input { @@ -20,3 +24,7 @@ .text { @apply text-sm text-stone-500 mb-5 max-w-xl mt-4; } + +.radios { + @apply flex justify-between w-72 mt-2; +}