fix(updates): show why a plugin update was blocked
This commit is contained in:
3 files changed
+63
-8
No files matched your search
@@ -131,7 +131,7 @@ describe("useComponentUpdates", () => {
|
||||
expect(mocks.installJdbcPlugin).toHaveBeenCalledOnce();
|
||||
expect(mocks.installMcpServer).toHaveBeenCalledOnce();
|
||||
expect(mocks.installMarketplacePlugin).toHaveBeenCalledWith({ repositoryId: "official", pluginId: "example", version: "1.1.0" });
|
||||
expect(result).toEqual({ drivers: 1, jdbc: true, mcp: true, plugins: 1, skippedDrivers: 0, failed: [] });
|
||||
expect(result).toEqual({ drivers: 1, jdbc: true, mcp: true, plugins: 1, skippedDrivers: 0, failed: [], blockedPlugins: [] });
|
||||
});
|
||||
|
||||
it("shares one update operation between automatic and manual callers", async () => {
|
||||
@@ -172,7 +172,7 @@ describe("useComponentUpdates", () => {
|
||||
expect(mocks.installJdbcPlugin).not.toHaveBeenCalled();
|
||||
expect(mocks.installMcpServer).not.toHaveBeenCalled();
|
||||
expect(mocks.installMarketplacePlugin).not.toHaveBeenCalled();
|
||||
expect(result).toEqual({ drivers: 0, jdbc: false, mcp: false, plugins: 0, skippedDrivers: 0, failed: [] });
|
||||
expect(result).toEqual({ drivers: 0, jdbc: false, mcp: false, plugins: 0, skippedDrivers: 0, failed: [], blockedPlugins: [] });
|
||||
});
|
||||
|
||||
it("installs every manually selected category when no DBX update exists and automatic updates are disabled", async () => {
|
||||
@@ -190,7 +190,7 @@ describe("useComponentUpdates", () => {
|
||||
expect(mocks.installJdbcPlugin).toHaveBeenCalledOnce();
|
||||
expect(mocks.installMcpServer).toHaveBeenCalledOnce();
|
||||
expect(mocks.installMarketplacePlugin).toHaveBeenCalledOnce();
|
||||
expect(result).toEqual({ drivers: 1, jdbc: true, mcp: true, plugins: 1, skippedDrivers: 0, failed: [] });
|
||||
expect(result).toEqual({ drivers: 1, jdbc: true, mcp: true, plugins: 1, skippedDrivers: 0, failed: [], blockedPlugins: [] });
|
||||
});
|
||||
|
||||
it("resumes a persisted manual update-all plan after restart while automatic updates are disabled", async () => {
|
||||
@@ -213,7 +213,7 @@ describe("useComponentUpdates", () => {
|
||||
expect(mocks.installJdbcPlugin).toHaveBeenCalledOnce();
|
||||
expect(mocks.installMcpServer).toHaveBeenCalledOnce();
|
||||
expect(mocks.installMarketplacePlugin).toHaveBeenCalledOnce();
|
||||
expect(result).toEqual({ drivers: 1, jdbc: true, mcp: true, plugins: 1, skippedDrivers: 0, failed: [] });
|
||||
expect(result).toEqual({ drivers: 1, jdbc: true, mcp: true, plugins: 1, skippedDrivers: 0, failed: [], blockedPlugins: [] });
|
||||
});
|
||||
|
||||
it("keeps the toolbar update action hidden while a persisted restart plan is still installing", async () => {
|
||||
@@ -302,6 +302,32 @@ describe("useComponentUpdates", () => {
|
||||
const result = await updates.installCategory("jdbc");
|
||||
|
||||
expect(mocks.installJdbcPlugin).toHaveBeenCalledOnce();
|
||||
expect(result).toEqual({ drivers: 0, jdbc: true, mcp: false, plugins: 0, skippedDrivers: 0, failed: [] });
|
||||
expect(result).toEqual({ drivers: 0, jdbc: true, mcp: false, plugins: 0, skippedDrivers: 0, failed: [], blockedPlugins: [] });
|
||||
});
|
||||
|
||||
it("reports the blocking connections when a K8S plugin update cannot start", async () => {
|
||||
mocks.buildMarketplacePluginListings.mockReturnValue([
|
||||
{
|
||||
...pluginUpdate,
|
||||
plugin: { id: "io.dbx.k8s", latestVersion: "0.1.3" },
|
||||
name: "Kubernetes 管理",
|
||||
},
|
||||
]);
|
||||
mocks.installMarketplacePlugin.mockRejectedValue(new Error("Plugin update blocked by active connections: market测试环境"));
|
||||
const updates = useComponentUpdates({ isDesktop: true });
|
||||
|
||||
const result = await updates.installCategory("plugins");
|
||||
|
||||
expect(result.blockedPlugins).toEqual([{ pluginName: "Kubernetes 管理", reason: "connections", connections: "market测试环境" }]);
|
||||
expect(result.failed).toEqual(["Kubernetes 管理: Plugin update blocked by active connections: market测试环境"]);
|
||||
});
|
||||
|
||||
it("reports active operations separately from connections", async () => {
|
||||
mocks.installMarketplacePlugin.mockRejectedValue(new Error("Plugin update blocked by active operations. Please wait for them to finish."));
|
||||
const updates = useComponentUpdates({ isDesktop: true });
|
||||
|
||||
const result = await updates.installCategory("plugins");
|
||||
|
||||
expect(result.blockedPlugins).toEqual([{ pluginName: "Example plugin", reason: "operations" }]);
|
||||
});
|
||||
});
|
||||
@@ -11,6 +11,8 @@ import type { JdbcPluginStatus } from "@/types/database";
|
||||
|
||||
export type { ComponentUpdateCategory } from "@/lib/updates/componentUpdateOrchestration";
|
||||
|
||||
export type PluginUpdateBlock = { pluginName: string; reason: "connections"; connections: string } | { pluginName: string; reason: "operations" | "inProgress" };
|
||||
|
||||
export interface ComponentUpdateResult {
|
||||
drivers: number;
|
||||
jdbc: boolean;
|
||||
@@ -18,6 +20,7 @@ export interface ComponentUpdateResult {
|
||||
plugins: number;
|
||||
skippedDrivers: number;
|
||||
failed: string[];
|
||||
blockedPlugins: PluginUpdateBlock[];
|
||||
}
|
||||
|
||||
interface ComponentUpdateRefreshOptions {
|
||||
@@ -25,7 +28,21 @@ interface ComponentUpdateRefreshOptions {
|
||||
}
|
||||
|
||||
function emptyResult(): ComponentUpdateResult {
|
||||
return { drivers: 0, jdbc: false, mcp: false, plugins: 0, skippedDrivers: 0, failed: [] };
|
||||
return { drivers: 0, jdbc: false, mcp: false, plugins: 0, skippedDrivers: 0, failed: [], blockedPlugins: [] };
|
||||
}
|
||||
|
||||
function pluginUpdateBlock(pluginName: string, message: string): PluginUpdateBlock | null {
|
||||
const connectionsPrefix = "Plugin update blocked by active connections: ";
|
||||
if (message.startsWith(connectionsPrefix)) {
|
||||
return { pluginName, reason: "connections", connections: message.slice(connectionsPrefix.length) };
|
||||
}
|
||||
if (message === "Plugin update blocked by active operations. Please wait for them to finish.") {
|
||||
return { pluginName, reason: "operations" };
|
||||
}
|
||||
if (message === "Plugin update is in progress. Please try again after it finishes.") {
|
||||
return { pluginName, reason: "inProgress" };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function useComponentUpdates(options: { isDesktop: boolean }) {
|
||||
@@ -167,7 +184,10 @@ export function useComponentUpdates(options: { isDesktop: boolean }) {
|
||||
});
|
||||
result.plugins += 1;
|
||||
} catch (error) {
|
||||
result.failed.push(`${listing.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const block = pluginUpdateBlock(listing.name, message);
|
||||
if (block) result.blockedPlugins.push(block);
|
||||
result.failed.push(`${listing.name}: ${message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user