Skip to content

Commit 18ac940

Browse files
authored
fix: cannot delete endpoint URL (#318)
fixes: #284
1 parent 38f2ecc commit 18ac940

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

package-lock.json

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/features/providers/components/provider-form.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ interface Props {
1717
export function ProviderForm({ provider, setProvider }: Props) {
1818
const providerAuthType =
1919
provider.auth_type || getProviderAuthByType(provider.provider_type)
20-
const providerEndpoint =
21-
provider.endpoint || getProviderEndpointByAuthType(provider.provider_type)
2220

2321
const handleProviderType = (provider: AddProviderEndpointRequest) => {
2422
setProvider({
@@ -87,7 +85,7 @@ export function ProviderForm({ provider, setProvider }: Props) {
8785
onChange={(endpoint) => setProvider({ ...provider, endpoint })}
8886
>
8987
<Label>Endpoint</Label>
90-
<Input placeholder="Provider endpoint" value={providerEndpoint} />
88+
<Input placeholder="Provider endpoint" value={provider.endpoint} />
9189
</TextField>
9290
</div>
9391
<div className="py-3">

src/routes/route-provider-create.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ProviderDialog } from '@/features/providers/components/provider-dialog'
77
import { ProviderDialogFooter } from '@/features/providers/components/provider-dialog-footer'
88
import { ProviderForm } from '@/features/providers/components/provider-form'
99
import { useMutationCreateProvider } from '@/features/providers/hooks/use-mutation-create-provider'
10+
import { getProviderEndpointByAuthType } from '@/features/providers/lib/utils'
1011
import { DialogContent, Form } from '@stacklok/ui-kit'
1112
import { useState } from 'react'
1213

@@ -20,9 +21,13 @@ const DEFAULT_PROVIDER_STATE = {
2021
}
2122

2223
export function RouteProviderCreate() {
23-
const [provider, setProvider] = useState<AddProviderEndpointRequest>(
24-
DEFAULT_PROVIDER_STATE
25-
)
24+
const [provider, setProvider] = useState<AddProviderEndpointRequest>({
25+
...DEFAULT_PROVIDER_STATE,
26+
endpoint: getProviderEndpointByAuthType(
27+
DEFAULT_PROVIDER_STATE.provider_type
28+
),
29+
})
30+
2631
const { mutateAsync } = useMutationCreateProvider()
2732

2833
const handleSubmit = (event: React.FormEvent) => {

0 commit comments

Comments
 (0)