@@ -1837,7 +1852,7 @@ export function ConnectedSourceWorkflow({
{t(($) => $['newKnowledge.providerCredentialRequiredDescription'], {
- provider: draft.provider,
+ provider: providerDraft.provider,
})}
@@ -1851,7 +1866,7 @@ export function ConnectedSourceWorkflow({
)
}
>
- {t(($) => $['newKnowledge.connectProvider'], { provider: draft.provider })}
+ {t(($) => $['newKnowledge.connectProvider'], { provider: providerDraft.provider })}
- ) : websiteProviderOption && !websiteProviderOption.installed ? (
-
}
- provider={websiteProviderOption.label}
- onInstall={() =>
- globalThis.open(
- websiteProviderIntegrationPath(websiteProviderOption),
- '_blank',
- 'noopener,noreferrer',
- )
- }
- />
- ) : !datasourceProvider || !provider ? (
+ ) : websiteProviderOptions.length === 0 ? null : !datasourceProvider || !provider ? (
{t(($) => $['newKnowledge.providerUnavailable'])}
@@ -1118,7 +1098,7 @@ function AddSourcePageContent({
@@ -1174,7 +1154,7 @@ function AddSourcePageContent({
>
) : (
{
clearStoredSourceDraft()
@@ -1189,7 +1169,7 @@ function AddSourcePageContent({
{sourceType === 'websiteCrawl' && !websiteReady && (
diff --git a/web/features/new-rag/sources/setup/__tests__/provider-options.spec.ts b/web/features/new-rag/sources/setup/__tests__/provider-options.spec.ts
index a2802641f8e..a33d9e8722f 100644
--- a/web/features/new-rag/sources/setup/__tests__/provider-options.spec.ts
+++ b/web/features/new-rag/sources/setup/__tests__/provider-options.spec.ts
@@ -1,4 +1,22 @@
-import { sourceProviderPresentation } from '../provider-options'
+import type { SourceProviderOption } from '../provider-options'
+import { sourceDraftForProviderOption, sourceProviderPresentation } from '../provider-options'
+
+function providerOption({ key, label }: { key: string; label: string }) {
+ return {
+ datasource: {
+ parameters: [
+ {
+ default: 'new-default',
+ label: { en_US: 'Workspace' },
+ name: 'workspace',
+ type: 'string',
+ },
+ ],
+ },
+ key,
+ label,
+ } as SourceProviderOption
+}
describe('sourceProviderPresentation', () => {
it.each([
@@ -19,3 +37,51 @@ describe('sourceProviderPresentation', () => {
expect(sourceProviderPresentation('Notion Backup', 'onlineDocuments')).toBeUndefined()
})
})
+
+describe('sourceDraftForProviderOption', () => {
+ it('resets provider-specific fields when a different provider has the same label', () => {
+ const draft = {
+ parameters: { oldWorkspace: 'stale-value' },
+ provider: 'Docs',
+ providerKey: 'onlineDocuments:old-provider',
+ sourceName: 'Existing source',
+ sourceType: 'onlineDocuments' as const,
+ syncPolicy: 'daily' as const,
+ }
+
+ expect(
+ sourceDraftForProviderOption(
+ draft,
+ providerOption({ key: 'onlineDocuments:new-provider', label: 'Docs' }),
+ ),
+ ).toEqual({
+ parameters: { workspace: 'new-default' },
+ provider: 'Docs',
+ providerKey: 'onlineDocuments:new-provider',
+ sourceName: '',
+ sourceType: 'onlineDocuments',
+ syncPolicy: 'daily',
+ })
+ })
+
+ it('preserves provider fields when the stable provider key matches after a label change', () => {
+ const draft = {
+ parameters: { workspace: 'saved-workspace' },
+ provider: 'Old Docs Name',
+ providerKey: 'onlineDocuments:provider',
+ sourceName: 'Existing source',
+ sourceType: 'onlineDocuments' as const,
+ syncPolicy: 'daily' as const,
+ }
+
+ expect(
+ sourceDraftForProviderOption(
+ draft,
+ providerOption({ key: 'onlineDocuments:provider', label: 'New Docs Name' }),
+ ),
+ ).toEqual({
+ ...draft,
+ provider: 'New Docs Name',
+ })
+ })
+})
diff --git a/web/features/new-rag/sources/setup/fields.tsx b/web/features/new-rag/sources/setup/fields.tsx
index fa04e049595..6fefdd9af08 100644
--- a/web/features/new-rag/sources/setup/fields.tsx
+++ b/web/features/new-rag/sources/setup/fields.tsx
@@ -128,6 +128,26 @@ export function SourceProviderRadioGroup({
)
}
+export function SourceProviderEmptyState({ className }: { className?: string }) {
+ const { t } = useTranslation('plugin')
+
+ return (
+
+
+
+
+ {t(($) => $['list.notFound'])}
+
+ )
+}
+
type SourceProviderIconValue =
| InstalledSourceProviderOption['datasource']['identity']['icon']
| InstalledSourceProviderOption['plugin']['declaration']['identity']['icon']
@@ -174,6 +194,7 @@ export function SourceProviderSelector({
layout = 'grid-three',
options,
providerKey,
+ showEmptyState = false,
onChange,
}: {
appearance?: 'embedded' | 'page'
@@ -181,6 +202,7 @@ export function SourceProviderSelector({
layout?: 'grid-four' | 'grid-three'
options: SourceProviderOption[]
providerKey: string
+ showEmptyState?: boolean
onChange: (providerKey: string) => void
}) {
const { t } = useTranslation('dataset')
@@ -213,28 +235,28 @@ export function SourceProviderSelector({