Revert "feat: show connected providers in /connect dialog (#8351)"
This reverts commit a57c8669b6.
This commit is contained in:
@@ -26,82 +26,67 @@ export function createDialogProviderOptions() {
|
|||||||
const sync = useSync()
|
const sync = useSync()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const connected = createMemo(() => new Set(sync.data.provider_next.connected))
|
|
||||||
const options = createMemo(() => {
|
const options = createMemo(() => {
|
||||||
return pipe(
|
return pipe(
|
||||||
sync.data.provider_next.all,
|
sync.data.provider_next.all,
|
||||||
sortBy((x) => PROVIDER_PRIORITY[x.id] ?? 99),
|
sortBy((x) => PROVIDER_PRIORITY[x.id] ?? 99),
|
||||||
map((provider) => {
|
map((provider) => ({
|
||||||
const isConnected = connected().has(provider.id)
|
title: provider.name,
|
||||||
return {
|
value: provider.id,
|
||||||
title: provider.name,
|
description: {
|
||||||
value: provider.id,
|
opencode: "(Recommended)",
|
||||||
description: {
|
anthropic: "(Claude Max or API key)",
|
||||||
opencode: "(Recommended)",
|
openai: "(ChatGPT Plus/Pro or API key)",
|
||||||
anthropic: "(Claude Max or API key)",
|
}[provider.id],
|
||||||
openai: "(ChatGPT Plus/Pro or API key)",
|
category: provider.id in PROVIDER_PRIORITY ? "Popular" : "Other",
|
||||||
}[provider.id],
|
async onSelect() {
|
||||||
category: provider.id in PROVIDER_PRIORITY ? "Popular" : "Other",
|
const methods = sync.data.provider_auth[provider.id] ?? [
|
||||||
footer: isConnected ? "Connected" : undefined,
|
{
|
||||||
async onSelect() {
|
type: "api",
|
||||||
const methods = sync.data.provider_auth[provider.id] ?? [
|
label: "API key",
|
||||||
{
|
},
|
||||||
type: "api",
|
]
|
||||||
label: "API key",
|
let index: number | null = 0
|
||||||
},
|
if (methods.length > 1) {
|
||||||
]
|
index = await new Promise<number | null>((resolve) => {
|
||||||
let index: number | null = 0
|
dialog.replace(
|
||||||
if (methods.length > 1) {
|
() => (
|
||||||
index = await new Promise<number | null>((resolve) => {
|
<DialogSelect
|
||||||
dialog.replace(
|
title="Select auth method"
|
||||||
() => (
|
options={methods.map((x, index) => ({
|
||||||
<DialogSelect
|
title: x.label,
|
||||||
title="Select auth method"
|
value: index,
|
||||||
options={methods.map((x, index) => ({
|
}))}
|
||||||
title: x.label,
|
onSelect={(option) => resolve(option.value)}
|
||||||
value: index,
|
|
||||||
}))}
|
|
||||||
onSelect={(option) => resolve(option.value)}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
() => resolve(null),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (index == null) return
|
|
||||||
const method = methods[index]
|
|
||||||
if (method.type === "oauth") {
|
|
||||||
const result = await sdk.client.provider.oauth.authorize({
|
|
||||||
providerID: provider.id,
|
|
||||||
method: index,
|
|
||||||
})
|
|
||||||
if (result.data?.method === "code") {
|
|
||||||
dialog.replace(() => (
|
|
||||||
<CodeMethod
|
|
||||||
providerID={provider.id}
|
|
||||||
title={method.label}
|
|
||||||
index={index}
|
|
||||||
authorization={result.data!}
|
|
||||||
/>
|
/>
|
||||||
))
|
),
|
||||||
}
|
() => resolve(null),
|
||||||
if (result.data?.method === "auto") {
|
)
|
||||||
dialog.replace(() => (
|
})
|
||||||
<AutoMethod
|
}
|
||||||
providerID={provider.id}
|
if (index == null) return
|
||||||
title={method.label}
|
const method = methods[index]
|
||||||
index={index}
|
if (method.type === "oauth") {
|
||||||
authorization={result.data!}
|
const result = await sdk.client.provider.oauth.authorize({
|
||||||
/>
|
providerID: provider.id,
|
||||||
))
|
method: index,
|
||||||
}
|
})
|
||||||
|
if (result.data?.method === "code") {
|
||||||
|
dialog.replace(() => (
|
||||||
|
<CodeMethod providerID={provider.id} title={method.label} index={index} authorization={result.data!} />
|
||||||
|
))
|
||||||
}
|
}
|
||||||
if (method.type === "api") {
|
if (result.data?.method === "auto") {
|
||||||
return dialog.replace(() => <ApiMethod providerID={provider.id} title={method.label} />)
|
dialog.replace(() => (
|
||||||
|
<AutoMethod providerID={provider.id} title={method.label} index={index} authorization={result.data!} />
|
||||||
|
))
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
if (method.type === "api") {
|
||||||
}),
|
return dialog.replace(() => <ApiMethod providerID={provider.id} title={method.label} />)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return options
|
return options
|
||||||
|
|||||||
Reference in New Issue
Block a user