-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from dolthub/liuliu/remote-types
Web: UI for different remote types
- Loading branch information
Showing
4 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/Radios.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={css.radios}> | ||
<Radio | ||
name="DoltHub" | ||
checked={props.type === RemoteType.DoltHub} | ||
onChange={() => props.setType(RemoteType.DoltHub)} | ||
label="DoltHub" | ||
/> | ||
<Radio | ||
name="DoltLab" | ||
checked={props.type === RemoteType.DoltLab} | ||
onChange={() => props.setType(RemoteType.DoltLab)} | ||
label="DoltLab" | ||
/> | ||
<Radio | ||
name="Other" | ||
checked={props.type === RemoteType.Other} | ||
onChange={() => props.setType(RemoteType.Other)} | ||
label="Other" | ||
/> | ||
</div> | ||
); | ||
} |
76 changes: 76 additions & 0 deletions
76
web/renderer/components/pageComponents/DatabasePage/ForRemotes/AddRemotePage/RemoteUrl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<FormInput | ||
value={remoteUrl} | ||
onChangeString={setRemoteUrl} | ||
label="Add remote url" | ||
placeholder="i.e. https://url-of-remote.com" | ||
className={css.input} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<div> | ||
{type === RemoteType.DoltLab && ( | ||
<FormInput | ||
value={host} | ||
onChangeString={(s: string) => { | ||
setHost(s); | ||
setRemoteUrl(`${s}/${ownerName}/${dbName}`); | ||
}} | ||
label="Host" | ||
placeholder="Url of your host, i.e. https://doltlab.dolthub.com:50051" | ||
className={css.input} | ||
/> | ||
)} | ||
<FormInput | ||
value={ownerName} | ||
onChangeString={(s: string) => { | ||
setOwnerName(s); | ||
setRemoteUrl( | ||
`${type === RemoteType.DoltHub ? dolthubHost : host}/${s}/${dbName}`, | ||
); | ||
}} | ||
label="Owner Name" | ||
placeholder="Owner of your database, i.e. dolthub" | ||
className={css.input} | ||
/> | ||
<FormInput | ||
value={dbName} | ||
onChangeString={(s: string) => { | ||
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} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters