Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/config/__tests__/importExport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe("importExport", () => {
setValues: jest.fn(),
setValue: jest.fn(),
export: jest.fn().mockImplementation(() => Promise.resolve({})),
setProviderSettings: jest.fn(),
} as unknown as jest.Mocked<ContextProxy>

// Setup customModesManager mock
Expand Down
17 changes: 15 additions & 2 deletions src/core/config/importExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as vscode from "vscode"
import { z } from "zod"

import { globalSettingsSchema } from "../../schemas"

import { ProviderSettingsManager, providerProfilesSchema } from "./ProviderSettingsManager"
import { ContextProxy } from "./ContextProxy"
import { CustomModesManager } from "./CustomModesManager"
Expand Down Expand Up @@ -38,6 +39,7 @@ export const importSettings = async ({ providerSettingsManager, contextProxy, cu

try {
const previousProviderProfiles = await providerSettingsManager.export()

const { providerProfiles: newProviderProfiles, globalSettings } = schema.parse(
JSON.parse(await fs.readFile(uris[0].fsPath, "utf-8")),
)
Expand All @@ -59,9 +61,20 @@ export const importSettings = async ({ providerSettingsManager, contextProxy, cu
)

await providerSettingsManager.import(newProviderProfiles)

await contextProxy.setValues(globalSettings)
contextProxy.setValue("currentApiConfigName", providerProfiles.currentApiConfigName)

// Set the current provider.
const currentProviderName = providerProfiles.currentApiConfigName
const currentProvider = providerProfiles.apiConfigs[currentProviderName]
contextProxy.setValue("currentApiConfigName", currentProviderName)

// TODO: It seems like we don't need to have the provider settings in
// the proxy; we can just use providerSettingsManager as the source of
// truth.
if (currentProvider) {
contextProxy.setProviderSettings(currentProvider)
}

contextProxy.setValue("listApiConfigMeta", await providerSettingsManager.listConfig())

return { providerProfiles, globalSettings, success: true }
Expand Down
13 changes: 12 additions & 1 deletion webview-ui/src/components/welcome/WelcomeView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useState } from "react"
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import { useExtensionState } from "@src/context/ExtensionStateContext"
import { validateApiConfiguration } from "@src/utils/validate"
import { vscode } from "@src/utils/vscode"
Expand Down Expand Up @@ -114,6 +114,17 @@ const WelcomeView = () => {
</TabContent>
<div className="sticky bottom-0 bg-vscode-sideBar-background p-5">
<div className="flex flex-col gap-1">
<div className="flex justify-end">
<VSCodeLink
href="#"
onClick={(e) => {
e.preventDefault()
vscode.postMessage({ type: "importSettings" })
}}
className="text-sm">
{t("welcome:importSettings")}
</VSCodeLink>
</div>
<VSCodeButton onClick={handleSubmit} appearance="primary">
{t("welcome:start")}
</VSCodeButton>
Expand Down
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ca/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Permetre",
"deny": "Denegar"
},
"or": "o"
"or": "o",
"importSettings": "Importar configuració"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/de/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Erlauben",
"deny": "Ablehnen"
},
"or": "oder"
"or": "oder",
"importSettings": "Einstellungen importieren"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/en/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Allow",
"deny": "Deny"
},
"or": "or"
"or": "or",
"importSettings": "Import Settings"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/es/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Permitir",
"deny": "Denegar"
},
"or": "o"
"or": "o",
"importSettings": "Importar configuración"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/fr/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Autoriser",
"deny": "Refuser"
},
"or": "ou"
"or": "ou",
"importSettings": "Importer les paramètres"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/hi/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "अनुमति दें",
"deny": "अस्वीकार करें"
},
"or": "या"
"or": "या",
"importSettings": "सेटिंग्स आयात करें"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/it/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Consenti",
"deny": "Nega"
},
"or": "o"
"or": "o",
"importSettings": "Importa impostazioni"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ja/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "許可",
"deny": "拒否"
},
"or": "または"
"or": "または",
"importSettings": "設定をインポート"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ko/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "허용",
"deny": "거부"
},
"or": "또는"
"or": "또는",
"importSettings": "설정 가져오기"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/pl/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Zezwól",
"deny": "Odmów"
},
"or": "lub"
"or": "lub",
"importSettings": "Importuj ustawienia"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/pt-BR/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Permitir",
"deny": "Negar"
},
"or": "ou"
"or": "ou",
"importSettings": "Importar configurações"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ru/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Разрешить",
"deny": "Запретить"
},
"or": "или"
"or": "или",
"importSettings": "Импорт настроек"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/tr/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "İzin Ver",
"deny": "Reddet"
},
"or": "veya"
"or": "veya",
"importSettings": "Ayarları İçe Aktar"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/vi/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "Cho phép",
"deny": "Từ chối"
},
"or": "hoặc"
"or": "hoặc",
"importSettings": "Nhập cài đặt"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/zh-CN/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "允许",
"deny": "拒绝"
},
"or": "或"
"or": "或",
"importSettings": "导入设置"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/zh-TW/welcome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"allow": "允許",
"deny": "拒絕"
},
"or": "或是"
"or": "或是",
"importSettings": "匯入設定"
}
Loading