diff --git a/packages/web-ui/src/pages/Settings.tsx b/packages/web-ui/src/pages/Settings.tsx index c17285cd9..1aa232588 100644 --- a/packages/web-ui/src/pages/Settings.tsx +++ b/packages/web-ui/src/pages/Settings.tsx @@ -43,6 +43,8 @@ import {useConnectionCapabilities} from '@/hooks/useConnectionCapabilities'; import {useAvailableUpdates} from '@/hooks/useAvailableUpdates'; import {UpdateBadge} from '@/components/ui/UpdateBadge'; import {UpdateTooltip} from '@/components/ui/UpdateTooltip'; +import {Chip} from '@/components/ui/Chip'; +import type {DeprecationInfo} from '@/types/plugins'; type SettingsTab = | 'general' @@ -159,7 +161,10 @@ export const Settings = () => { [refreshDrivers], ); - const pluginSettingItems = new Map(); + const pluginSettingItems = new Map< + string, + {id: string; name: string; deprecated?: DeprecationInfo} + >(); for (const driver of allDrivers) { const hasSettings = (driver.settings?.length ?? 0) > 0; @@ -168,6 +173,7 @@ export const Settings = () => { pluginSettingItems.set(driver.id, { id: driver.id, name: driver.name, + deprecated: driver.deprecated, }); } @@ -259,19 +265,44 @@ export const Settings = () => {
{pluginTabs.map((plugin) => { const pluginTabId = `plugin:${plugin.id}` as const; + const deprecation = plugin.deprecated; + const deprecatedTitle = deprecation + ? deprecation.removal_date + ? t('settings.plugins.deprecatedTooltipDate', { + replacement: deprecation.replacement_id ?? '', + date: deprecation.removal_date, + }) + : t('settings.plugins.deprecatedTooltip', { + replacement: deprecation.replacement_id ?? '', + }) + : undefined; return ( ); })} diff --git a/packages/web-ui/tests/pages/Settings.test.tsx b/packages/web-ui/tests/pages/Settings.test.tsx index b8640ba09..e408ed7d6 100644 --- a/packages/web-ui/tests/pages/Settings.test.tsx +++ b/packages/web-ui/tests/pages/Settings.test.tsx @@ -1,7 +1,7 @@ import {StrictMode} from 'react'; import {act, fireEvent, render, screen, waitFor, within} from '@testing-library/react'; import {MemoryRouter, Route, Routes, useSearchParams} from 'react-router-dom'; -import {beforeEach, describe, expect, it, vi} from 'vitest'; +import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import {createInstance} from 'i18next'; import en from '@/i18n/locales/en.json'; import itLocale from '@/i18n/locales/it.json'; @@ -34,17 +34,25 @@ vi.mock('@/hooks/useUpdate', () => ({useUpdate: vi.fn()})); vi.mock('@/hooks/useSettings', () => ({ useSettings: () => ({settings: {}, isLoading: false, updateSetting: vi.fn()}), })); +const driversMock = vi.hoisted(() => { + const defaultDrivers = [ + { + id: 'mysql', + name: 'MySQL', + is_builtin: true, + settings: [{key: 'pool'}], + }, + ]; + return { + defaultDrivers, + allDrivers: defaultDrivers as Array>, + installedPlugins: [] as Array>, + }; +}); vi.mock('@/hooks/useDrivers', () => ({ useDrivers: () => ({ - allDrivers: [ - { - id: 'mysql', - name: 'MySQL', - is_builtin: true, - settings: [{key: 'pool'}], - }, - ], - installedPlugins: [], + allDrivers: driversMock.allDrivers, + installedPlugins: driversMock.installedPlugins, refresh: vi.fn(), }), })); @@ -380,3 +388,67 @@ describe('managed connections', () => { expect(screen.getByText('SshTab')).toBeInTheDocument(); }); }); + +describe('plugin sidebar with a deprecated built-in driver', () => { + beforeEach(() => { + vi.clearAllMocks(); + vi.mocked(usePluginRegistry).mockReturnValue({ + plugins: [], + updates: [], + loading: false, + error: null, + refresh: vi.fn(), + }); + vi.mocked(useUpdate).mockReturnValue({ + updateInfo: null, + availableUpdate: null, + isChecking: false, + isDownloading: false, + downloadProgress: 0, + checkForUpdates: vi.fn(), + downloadAndInstall: vi.fn(), + dismissUpdate: vi.fn(), + error: null, + isUpToDate: true, + installationSource: null, + }); + driversMock.allDrivers = [ + ...driversMock.defaultDrivers, + { + id: 'postgres', + name: 'PostgreSQL', + is_builtin: true, + settings: [{key: 'pool'}], + deprecated: {replacement_id: 'postgresql', removal_date: '2026-10-05'}, + }, + {id: 'postgresql', name: 'PostgreSQL', is_builtin: false, settings: []}, + ]; + driversMock.installedPlugins = [{id: 'postgresql', name: 'PostgreSQL'}]; + }); + + afterEach(() => { + driversMock.allDrivers = driversMock.defaultDrivers; + driversMock.installedPlugins = []; + }); + + it('marks the deprecated built-in entry so it can be told apart from its plugin replacement', () => { + renderApp(); + + const entries = screen.getAllByRole('button', {name: /^PostgreSQL/}); + expect(entries).toHaveLength(2); + const [builtin, replacement] = entries; + expect(builtin).toHaveTextContent('Deprecato'); + expect(builtin).toHaveAttribute( + 'title', + expect.stringContaining('viene sostituito dal plugin postgresql'), + ); + expect(replacement).toHaveAccessibleName('PostgreSQL'); + expect(replacement).not.toHaveTextContent('Deprecato'); + }); + + it('leaves non-deprecated entries unchanged', () => { + renderApp(); + + expect(screen.getByRole('button', {name: 'MySQL'})).not.toHaveTextContent('Deprecato'); + }); +});