mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Feat: Add a new button to import settings on the welcome screen (#2811)
This commit is contained in:
parent
a3d8c0e3f6
commit
04fa72eebe
19 changed files with 60 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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")),
|
||||
)
|
||||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Permetre",
|
||||
"deny": "Denegar"
|
||||
},
|
||||
"or": "o"
|
||||
"or": "o",
|
||||
"importSettings": "Importar configuració"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Erlauben",
|
||||
"deny": "Ablehnen"
|
||||
},
|
||||
"or": "oder"
|
||||
"or": "oder",
|
||||
"importSettings": "Einstellungen importieren"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Allow",
|
||||
"deny": "Deny"
|
||||
},
|
||||
"or": "or"
|
||||
"or": "or",
|
||||
"importSettings": "Import Settings"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Permitir",
|
||||
"deny": "Denegar"
|
||||
},
|
||||
"or": "o"
|
||||
"or": "o",
|
||||
"importSettings": "Importar configuración"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Autoriser",
|
||||
"deny": "Refuser"
|
||||
},
|
||||
"or": "ou"
|
||||
"or": "ou",
|
||||
"importSettings": "Importer les paramètres"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "अनुमति दें",
|
||||
"deny": "अस्वीकार करें"
|
||||
},
|
||||
"or": "या"
|
||||
"or": "या",
|
||||
"importSettings": "सेटिंग्स आयात करें"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Consenti",
|
||||
"deny": "Nega"
|
||||
},
|
||||
"or": "o"
|
||||
"or": "o",
|
||||
"importSettings": "Importa impostazioni"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "許可",
|
||||
"deny": "拒否"
|
||||
},
|
||||
"or": "または"
|
||||
"or": "または",
|
||||
"importSettings": "設定をインポート"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "허용",
|
||||
"deny": "거부"
|
||||
},
|
||||
"or": "또는"
|
||||
"or": "또는",
|
||||
"importSettings": "설정 가져오기"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Zezwól",
|
||||
"deny": "Odmów"
|
||||
},
|
||||
"or": "lub"
|
||||
"or": "lub",
|
||||
"importSettings": "Importuj ustawienia"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Permitir",
|
||||
"deny": "Negar"
|
||||
},
|
||||
"or": "ou"
|
||||
"or": "ou",
|
||||
"importSettings": "Importar configurações"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Разрешить",
|
||||
"deny": "Запретить"
|
||||
},
|
||||
"or": "или"
|
||||
"or": "или",
|
||||
"importSettings": "Импорт настроек"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "İzin Ver",
|
||||
"deny": "Reddet"
|
||||
},
|
||||
"or": "veya"
|
||||
"or": "veya",
|
||||
"importSettings": "Ayarları İçe Aktar"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "Cho phép",
|
||||
"deny": "Từ chối"
|
||||
},
|
||||
"or": "hoặc"
|
||||
"or": "hoặc",
|
||||
"importSettings": "Nhập cài đặt"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "允许",
|
||||
"deny": "拒绝"
|
||||
},
|
||||
"or": "或"
|
||||
"or": "或",
|
||||
"importSettings": "导入设置"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
"allow": "允許",
|
||||
"deny": "拒絕"
|
||||
},
|
||||
"or": "或是"
|
||||
"or": "或是",
|
||||
"importSettings": "匯入設定"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue