fix(updates): keep toolbar update entry hidden during component updates
This commit is contained in:
4 files changed
+80
-4
No files matched your search
+32
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { driverStoreUpdateBadgeCount, showMcpUpdateBadge } from "@/lib/updates/updateBadges";
|
||||
import { driverStoreUpdateBadgeCount, showMcpUpdateBadge, showToolbarUpdateAction } from "@/lib/updates/updateBadges";
|
||||
|
||||
describe("component update entry badges", () => {
|
||||
it("hides separate driver and JDBC badges while their automatic updates are enabled", () => {
|
||||
@@ -17,4 +17,35 @@ describe("component update entry badges", () => {
|
||||
expect(showMcpUpdateBadge(false, true)).toBe(true);
|
||||
expect(showMcpUpdateBadge(false, false)).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the toolbar update action hidden while component updates are still running", () => {
|
||||
expect(
|
||||
showToolbarUpdateAction({
|
||||
appUpdateAvailable: false,
|
||||
driverUpdateCount: 1,
|
||||
jdbcUpdateAvailable: true,
|
||||
mcpUpdateAvailable: true,
|
||||
pluginUpdateCount: 1,
|
||||
componentUpdatesRunning: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("shows the toolbar update action for remaining updates after component updating stops", () => {
|
||||
const base = {
|
||||
appUpdateAvailable: false,
|
||||
driverUpdateCount: 0,
|
||||
jdbcUpdateAvailable: false,
|
||||
mcpUpdateAvailable: false,
|
||||
pluginUpdateCount: 0,
|
||||
componentUpdatesRunning: false,
|
||||
};
|
||||
|
||||
expect(showToolbarUpdateAction(base)).toBe(false);
|
||||
expect(showToolbarUpdateAction({ ...base, appUpdateAvailable: true })).toBe(true);
|
||||
expect(showToolbarUpdateAction({ ...base, driverUpdateCount: 1 })).toBe(true);
|
||||
expect(showToolbarUpdateAction({ ...base, jdbcUpdateAvailable: true })).toBe(true);
|
||||
expect(showToolbarUpdateAction({ ...base, mcpUpdateAvailable: true })).toBe(true);
|
||||
expect(showToolbarUpdateAction({ ...base, pluginUpdateCount: 1 })).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -5,3 +5,9 @@ export function driverStoreUpdateBadgeCount(autoUpdateDrivers: boolean, autoUpda
|
||||
export function showMcpUpdateBadge(autoUpdateMcp: boolean, mcpUpdateAvailable: boolean): boolean {
|
||||
return !autoUpdateMcp && mcpUpdateAvailable;
|
||||
}
|
||||
|
||||
export function showToolbarUpdateAction(options: { appUpdateAvailable: boolean; driverUpdateCount: number; jdbcUpdateAvailable: boolean; mcpUpdateAvailable: boolean; pluginUpdateCount: number; componentUpdatesRunning: boolean }): boolean {
|
||||
// Installation refreshes before replacing components, so discovery can report pending entries mid-operation.
|
||||
if (options.componentUpdatesRunning) return false;
|
||||
return options.appUpdateAvailable || options.driverUpdateCount > 0 || options.jdbcUpdateAvailable || options.mcpUpdateAvailable || options.pluginUpdateCount > 0;
|
||||
}
|
||||
Reference in new issue
Block a user