feat(jdbc): show plugin update notice
This commit is contained in:
1 parent
ea5e15612f
commit
73cb490189
13 files changed
+200
-12
No files matched your search
@@ -11,7 +11,7 @@ import DriverInstallProgressCircle from "@/components/config/DriverInstallProgre
|
||||
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import { isTauriRuntime } from "@/lib/tauriRuntime";
|
||||
import { countAvailableAgentDriverUpdates } from "@/lib/agentDriverUpdateBadge";
|
||||
import { countAvailableDriverUpdates } from "@/lib/agentDriverUpdateBadge";
|
||||
import type { JdbcDriverInfo, JdbcPluginStatus } from "@/types/database";
|
||||
import * as api from "@/lib/api";
|
||||
import type { AgentDriverInfo, JavaRuntimeConfig } from "@/lib/api";
|
||||
@@ -84,7 +84,11 @@ const updatableCount = computed(() => drivers.value.filter((d) => d.update_avail
|
||||
|
||||
function updateAgentDrivers(nextDrivers: AgentDriverInfo[]) {
|
||||
drivers.value = nextDrivers;
|
||||
emit("update-count-change", countAvailableAgentDriverUpdates(nextDrivers));
|
||||
emitDriverUpdateCount();
|
||||
}
|
||||
|
||||
function emitDriverUpdateCount() {
|
||||
emit("update-count-change", countAvailableDriverUpdates(drivers.value, jdbcPluginStatus.value));
|
||||
}
|
||||
|
||||
function isDriverProgressActive(dbType: string): boolean {
|
||||
@@ -299,6 +303,7 @@ async function loadJdbcPluginStatus() {
|
||||
if (isWeb) return;
|
||||
try {
|
||||
jdbcPluginStatus.value = await api.jdbcPluginStatus();
|
||||
emitDriverUpdateCount();
|
||||
} catch (e: any) {
|
||||
toast(String(e?.message || e), 5000);
|
||||
}
|
||||
@@ -309,6 +314,7 @@ async function installJdbcPlugin() {
|
||||
isInstallingJdbcPlugin.value = true;
|
||||
try {
|
||||
jdbcPluginStatus.value = await api.installJdbcPlugin();
|
||||
emitDriverUpdateCount();
|
||||
toast(t("settings.jdbcPluginInstallSuccess"));
|
||||
await loadJdbcDrivers();
|
||||
} catch (e: any) {
|
||||
@@ -330,6 +336,7 @@ async function installJdbcPluginLocal() {
|
||||
isInstallingJdbcPlugin.value = true;
|
||||
try {
|
||||
jdbcPluginStatus.value = await api.installJdbcPluginLocal(selected);
|
||||
emitDriverUpdateCount();
|
||||
toast(t("settings.jdbcPluginInstallSuccess"));
|
||||
await loadJdbcDrivers();
|
||||
} catch (e: any) {
|
||||
@@ -344,6 +351,7 @@ async function uninstallJdbcPlugin() {
|
||||
isUninstallingJdbcPlugin.value = true;
|
||||
try {
|
||||
jdbcPluginStatus.value = await api.uninstallJdbcPlugin();
|
||||
emitDriverUpdateCount();
|
||||
toast(t("settings.jdbcPluginUninstallSuccess"));
|
||||
await loadJdbcDrivers();
|
||||
} catch (e: any) {
|
||||
@@ -702,6 +710,20 @@ onUnmounted(() => {
|
||||
: t("settings.jdbcPluginIncompatible")
|
||||
}}
|
||||
</span>
|
||||
<span
|
||||
v-if="jdbcPluginStatus?.installed && jdbcPluginStatus.update_available"
|
||||
class="rounded-full bg-amber-500/15 px-2 py-0.5 text-[11px] text-amber-600"
|
||||
>→ v{{ jdbcPluginStatus.latest_version }}</span
|
||||
>
|
||||
<Button
|
||||
v-if="jdbcPluginStatus?.installed && jdbcPluginStatus.update_available"
|
||||
type="button"
|
||||
variant="outline"
|
||||
:disabled="isInstallingJdbcPlugin"
|
||||
@click="installJdbcPlugin"
|
||||
>
|
||||
{{ isInstallingJdbcPlugin ? t("common.loading") : t("settings.jdbcPluginUpdate") }}
|
||||
</Button>
|
||||
<Button
|
||||
v-if="jdbcPluginStatus?.installed"
|
||||
type="button"
|
||||
|
||||
@@ -1154,6 +1154,7 @@ export default {
|
||||
jdbcPlugin: "DBX JDBC plugin",
|
||||
jdbcPluginInstall: "Install JDBC plugin",
|
||||
jdbcPluginInstallSuccess: "JDBC plugin installed",
|
||||
jdbcPluginUpdate: "Update",
|
||||
jdbcPluginUninstall: "Uninstall",
|
||||
jdbcPluginUninstallSuccess: "JDBC plugin uninstalled",
|
||||
jdbcPluginInstalled: "Installed: v{version}",
|
||||
|
||||
@@ -1059,6 +1059,7 @@ export default {
|
||||
jdbcPlugin: "Plugin JDBC de DBX",
|
||||
jdbcPluginInstall: "Instalar plugin JDBC",
|
||||
jdbcPluginInstallSuccess: "Plugin JDBC instalado",
|
||||
jdbcPluginUpdate: "Actualizar",
|
||||
jdbcPluginUninstall: "Desinstalar",
|
||||
jdbcPluginUninstallSuccess: "Plugin JDBC desinstalado",
|
||||
jdbcPluginInstalled: "Instalado: v{version}",
|
||||
|
||||
@@ -1131,6 +1131,7 @@ export default {
|
||||
jdbcPlugin: "DBX JDBC 插件",
|
||||
jdbcPluginInstall: "安装 JDBC 插件",
|
||||
jdbcPluginInstallSuccess: "JDBC 插件已安装",
|
||||
jdbcPluginUpdate: "更新",
|
||||
jdbcPluginUninstall: "卸载",
|
||||
jdbcPluginUninstallSuccess: "JDBC 插件已卸载",
|
||||
jdbcPluginInstalled: "已安装:v{version}",
|
||||
|
||||
@@ -5,3 +5,14 @@ export interface AgentDriverUpdateBadgeState {
|
||||
export function countAvailableAgentDriverUpdates(drivers: readonly AgentDriverUpdateBadgeState[]): number {
|
||||
return drivers.filter((driver) => driver.update_available).length;
|
||||
}
|
||||
|
||||
export interface JdbcPluginUpdateBadgeState {
|
||||
update_available?: boolean | null;
|
||||
}
|
||||
|
||||
export function countAvailableDriverUpdates(
|
||||
drivers: readonly AgentDriverUpdateBadgeState[],
|
||||
jdbcPlugin?: JdbcPluginUpdateBadgeState | null,
|
||||
): number {
|
||||
return countAvailableAgentDriverUpdates(drivers) + (jdbcPlugin?.update_available ? 1 : 0);
|
||||
}
|
||||
@@ -121,19 +121,28 @@ export async function deleteJdbcDriver(_path: string): Promise<JdbcDriverInfo[]>
|
||||
}
|
||||
|
||||
export async function jdbcPluginStatus(): Promise<JdbcPluginStatus> {
|
||||
return { installed: false, version: null, protocol_version: null, compatible: true, path: "" };
|
||||
return {
|
||||
installed: false,
|
||||
version: null,
|
||||
protocol_version: null,
|
||||
compatible: true,
|
||||
latest_version: null,
|
||||
latest_protocol_version: null,
|
||||
update_available: false,
|
||||
path: "",
|
||||
};
|
||||
}
|
||||
|
||||
export async function installJdbcPlugin(): Promise<JdbcPluginStatus> {
|
||||
return { installed: false, version: null, protocol_version: null, compatible: true, path: "" };
|
||||
return jdbcPluginStatus();
|
||||
}
|
||||
|
||||
export async function installJdbcPluginLocal(_path: string): Promise<JdbcPluginStatus> {
|
||||
return { installed: false, version: null, protocol_version: null, compatible: true, path: "" };
|
||||
return jdbcPluginStatus();
|
||||
}
|
||||
|
||||
export async function uninstallJdbcPlugin(): Promise<JdbcPluginStatus> {
|
||||
return { installed: false, version: null, protocol_version: null, compatible: true, path: "" };
|
||||
return jdbcPluginStatus();
|
||||
}
|
||||
|
||||
export async function listInstalledAgentsLocal(): Promise<AgentDriverInfo[]> {
|
||||
|
||||
@@ -110,6 +110,9 @@ export interface JdbcPluginStatus {
|
||||
version?: string | null;
|
||||
protocol_version?: number | null;
|
||||
compatible: boolean;
|
||||
latest_version?: string | null;
|
||||
latest_protocol_version?: number | null;
|
||||
update_available: boolean;
|
||||
path: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user