Skip to content

Commit ece2235

Browse files
committed
fix : replication endpoint remove prefix
1 parent 18f9b48 commit ece2235

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

components/replication/new-form.tsx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function ReplicationNewForm({ open, onOpenChange, bucketName, onSuccess }
3232
const { setRemoteReplicationTarget, putBucketReplication, getBucketReplication } = useBucket()
3333

3434
const [level, setLevel] = useState("1")
35-
const [endpoint, setEndpoint] = useState("http://")
35+
const [endpoint, setEndpoint] = useState("")
3636
const [tls, setTls] = useState(false)
3737
const [accessKey, setAccessKey] = useState("")
3838
const [secretKey, setSecretKey] = useState("")
@@ -66,25 +66,9 @@ export function ReplicationNewForm({ open, onOpenChange, bucketName, onSuccess }
6666
[],
6767
)
6868

69-
useEffect(() => {
70-
if (tls) {
71-
if (endpoint.startsWith("http://")) {
72-
setEndpoint(endpoint.replace("http://", "https://"))
73-
} else if (!endpoint.startsWith("https://")) {
74-
setEndpoint("https://" + endpoint)
75-
}
76-
} else {
77-
if (endpoint.startsWith("https://")) {
78-
setEndpoint(endpoint.replace("https://", "http://"))
79-
} else if (!endpoint.startsWith("http://")) {
80-
setEndpoint("http://" + endpoint)
81-
}
82-
}
83-
}, [tls, endpoint])
84-
8569
const resetForm = useCallback(() => {
8670
setLevel("1")
87-
setEndpoint("http://")
71+
setEndpoint("")
8872
setTls(false)
8973
setAccessKey("")
9074
setSecretKey("")
@@ -309,11 +293,17 @@ export function ReplicationNewForm({ open, onOpenChange, bucketName, onSuccess }
309293
<Field>
310294
<FieldLabel>{t("Endpoint")}</FieldLabel>
311295
<FieldContent>
312-
<Input
313-
value={endpoint}
314-
onChange={(e) => setEndpoint(e.target.value)}
315-
placeholder={t("Please enter endpoint")}
316-
/>
296+
<div className="flex items-center gap-2">
297+
<div className="flex h-10 items-center whitespace-nowrap rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground">
298+
{tls ? "https://" : "http://"}
299+
</div>
300+
<Input
301+
className="flex-1"
302+
value={endpoint}
303+
onChange={(e) => setEndpoint(e.target.value)}
304+
placeholder={t("Please enter endpoint")}
305+
/>
306+
</div>
317307
</FieldContent>
318308
</Field>
319309
<Field>

0 commit comments

Comments
 (0)