import { Alert, AlertVariant } from '../../../components/ui/Alert';
import DismissableAlert from '../../../components/ui/DismissableAlert';
import SystemUpgradeButton from '../../../components/upgrade/SystemUpgradeButton';
-import { sortUpgrades, UpdateUseCase } from '../../../components/upgrade/utils';
+import { UpdateUseCase, sortUpgrades } from '../../../components/upgrade/utils';
+import { now, parseDate } from '../../../helpers/dates';
import { translate } from '../../../helpers/l10n';
import { hasGlobalPermission } from '../../../helpers/users';
import { AppState } from '../../../types/appstate';
const { upgrades, latestLTS } = await getSystemUpgrades();
- if (isEmpty(upgrades)) {
+ if (isEmpty(upgrades) && parseDate(this.props.appState.versionEOL) > now()) {
// No new upgrades
this.noPromptToShow();
return;
let useCase = UpdateUseCase.NewMinorVersion;
- if (this.isPreviousLTSUpdate(parsedVersion, latestLTS, systemUpgrades)) {
+ if (parseDate(this.props.appState.versionEOL) <= now()) {
+ useCase = UpdateUseCase.PreviousLTS;
+ } else if (this.isPreviousLTSUpdate(parsedVersion, latestLTS, systemUpgrades)) {
useCase = UpdateUseCase.PreviousLTS;
} else if (this.isPreLTSUpdate(parsedVersion, latestLTS)) {
useCase = UpdateUseCase.PreLTS;
new Date(upgrade1.releaseDate || '').getTime()
)[0];
- const dismissKey = useCase + latest.version;
+ const dismissKey = useCase + latest?.version;
if (this.mounted) {
this.setState({
it('should render correctly', async () => {
let wrapper = shallowRender({
- appState: mockAppState({ version: '9.0' }),
+ appState: mockAppState({ version: '9.0', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot('default');
wrapper = shallowRender({
- appState: mockAppState({ version: '9.0' }),
+ appState: mockAppState({ version: '9.0', versionEOL: '2026-01-01' }),
currentUser: mockCurrentUser(),
});
expect(wrapper.type()).toBeNull();
});
it('should not show prompt when no current version', async () => {
- const wrapper = shallowRender({ appState: mockAppState({ version: 'NOVERSION' }) });
+ const wrapper = shallowRender({
+ appState: mockAppState({ version: 'NOVERSION', versionEOL: '2026-01-01' }),
+ });
await waitAndUpdate(wrapper);
expect(wrapper.type()).toBeNull();
});
it('should not show prompt when no upgrade', async () => {
(getSystemUpgrades as jest.Mock).mockResolvedValueOnce({ upgrades: [], latestLTS: '8.9' });
const wrapper = shallowRender({
- appState: mockAppState({ version: '9.1' }),
+ appState: mockAppState({ version: '9.1', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
latestLTS: '8.9',
});
const wrapper = shallowRender({
- appState: mockAppState({ version: '8.1' }),
+ appState: mockAppState({ version: '8.1', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
latestLTS: '8.9',
});
const wrapper = shallowRender({
- appState: mockAppState({ version: '9.1' }),
+ appState: mockAppState({ version: '9.1', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
latestLTS: '8.9',
});
const wrapper = shallowRender({
- appState: mockAppState({ version: '9.1' }),
+ appState: mockAppState({ version: '9.1', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
latestLTS: '8.9',
});
const wrapper = shallowRender({
- appState: mockAppState({ version: '8.8' }),
+ appState: mockAppState({ version: '8.8', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
latestLTS: '8.9',
});
const wrapper = shallowRender({
- appState: mockAppState({ version: '8.8' }),
+ appState: mockAppState({ version: '8.8', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
latestLTS: '8.9',
});
const wrapper = shallowRender({
- appState: mockAppState({ version: '8.8' }),
+ appState: mockAppState({ version: '8.8', versionEOL: '2026-01-01' }),
currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
});
await waitAndUpdate(wrapper);
expect(wrapper.find(Alert).type).toBeDefined();
});
+it('should show alert if version has reached eol, but there are no upgrades', async () => {
+ (getSystemUpgrades as jest.Mock).mockResolvedValueOnce({ upgrades: [], latestLTS: '9.9' });
+ const wrapper = shallowRender({
+ appState: mockAppState({ version: '9.9', versionEOL: '2020-01-01' }),
+ currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Admin] } }),
+ });
+ await waitAndUpdate(wrapper);
+ expect(wrapper.contains('admin_notification.update.previous_lts')).toBe(true);
+});
+
function shallowRender(props: Partial<UpdateNotification['props']> = {}) {
return shallow(
<UpdateNotification