feat(driver): honor selected driver download source
This commit is contained in:
parent
1e1d424164
commit
f6ecd3c881
|
|
@ -239,6 +239,7 @@ const usageSummary = computed(() => {
|
|||
];
|
||||
});
|
||||
const canClearDownloadCache = computed(() => !clearingDownloadCache.value && installing.value === null && !upgradingAll.value && reinstallingJre.value === null && downloadCacheBytes.value > 0);
|
||||
const downloadSourceBusy = computed(() => refreshing.value || installing.value !== null || upgradingAll.value || queuedDriverInstalls.value.length > 0 || reinstallingJre.value !== null);
|
||||
const jreUsageByKey = computed(() => {
|
||||
const map = new Map<string, number>();
|
||||
for (const item of driverStoreUsage.value?.jres || []) {
|
||||
|
|
@ -330,6 +331,13 @@ async function forceRefresh() {
|
|||
}
|
||||
}
|
||||
|
||||
function setUpdateDownloadSource(value: unknown) {
|
||||
if (value !== "official" && value !== "cnb" && value !== "atomgit") return;
|
||||
if (value === settingsStore.editorSettings.updateDownloadSource) return;
|
||||
settingsStore.updateEditorSettings({ updateDownloadSource: value });
|
||||
void forceRefresh().catch(() => undefined);
|
||||
}
|
||||
|
||||
async function loadJavaRuntimeConfig() {
|
||||
const config = await api.getAgentJavaRuntimeConfig();
|
||||
javaRuntimeConfig.value = config;
|
||||
|
|
@ -1143,7 +1151,20 @@ watch(driverStoreTab, (tab) => {
|
|||
{{ t("driverStore.storageTab") }}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<div v-if="driverStoreTab !== 'storage'" class="flex items-center gap-2">
|
||||
<div v-if="driverStoreTab !== 'storage'" class="flex flex-wrap items-center gap-2">
|
||||
<div v-if="driverStoreTab === 'agent' && !isWeb" class="flex items-center gap-1.5">
|
||||
<span class="text-xs text-muted-foreground">{{ t("settings.updateDownloadSource") }}</span>
|
||||
<Select :model-value="settingsStore.editorSettings.updateDownloadSource" :disabled="downloadSourceBusy" @update:model-value="setUpdateDownloadSource">
|
||||
<SelectTrigger class="h-7 w-[160px] rounded-[6px] text-xs">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="official">{{ t("settings.updateDownloadSourceOfficial") }}</SelectItem>
|
||||
<SelectItem value="cnb">{{ t("settings.updateDownloadSourceCnb") }}</SelectItem>
|
||||
<SelectItem value="atomgit">{{ t("settings.updateDownloadSourceAtomgit") }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button variant="ghost" size="sm" class="h-7 rounded-[6px] text-xs gap-1 text-muted-foreground" :disabled="importingZip" @click="importOfflineZip">
|
||||
<FileUp class="h-3.5 w-3.5" />
|
||||
{{ importingZip ? t("driverStore.importing") : t("driverStore.importOfflinePackage") }}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { test } from "vitest";
|
||||
|
||||
function source(relativePath: string): string {
|
||||
return readFileSync(path.resolve(relativePath), "utf8");
|
||||
}
|
||||
|
||||
test("shares the configured download source with agent driver management", () => {
|
||||
const driverStore = source("apps/desktop/src/components/config/DriverStoreDialog.vue");
|
||||
const backendApi = source("apps/desktop/src/lib/backend/api.ts");
|
||||
|
||||
assert.match(driverStore, /driverStoreTab === 'agent' && !isWeb/);
|
||||
assert.match(driverStore, /:model-value="settingsStore\.editorSettings\.updateDownloadSource"/);
|
||||
assert.match(driverStore, /settingsStore\.updateEditorSettings\(\{ updateDownloadSource: value \}\)/);
|
||||
assert.match(driverStore, /void forceRefresh\(\)\.catch\(\(\) => undefined\)/);
|
||||
|
||||
assert.match(backendApi, /backend\.listInstalledAgents\(useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
|
||||
assert.match(backendApi, /backend\.installAgent\(dbType, useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
|
||||
assert.match(backendApi, /backend\.upgradeAllAgents\(useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
|
||||
assert.match(backendApi, /backend\.reinstallJre\(jreKey, useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
|
||||
});
|
||||
Loading…
Reference in New Issue