diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx
index 7ac884429e6fd..45cdfe9327ed0 100644
--- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx
+++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx
@@ -28,6 +28,18 @@ describe('PerconaUpdateVersion', () => {
});
it('should render modal with one update', async () => {
+ const changeLogsAPIResponse = {
+ last_check: '',
+ updates: [
+ {
+ version: 'PMM 3.0.1',
+ tag: 'string',
+ timestamp: '2024-09-24T09:12:31.488Z',
+ release_notes_url: 'http://localhost:3000',
+ release_notes_text: 'text1',
+ },
+ ],
+ };
const state = {
updates: {
isLoading: false,
@@ -48,9 +60,7 @@ describe('PerconaUpdateVersion', () => {
},
},
};
- jest
- .spyOn(UpdatesService, 'getUpdatesChangelogs')
- .mockReturnValue(Promise.resolve({ ...state.updates.changeLogs }));
+ jest.spyOn(UpdatesService, 'getUpdatesChangelogs').mockReturnValue(Promise.resolve({ changeLogsAPIResponse }));
const defaultState = configureStore().getState();
const store = configureStore({
@@ -70,6 +80,25 @@ describe('PerconaUpdateVersion', () => {
});
it('should render modal with multiple updates', async () => {
+ const changeLogsAPIResponse = {
+ last_check: '',
+ updates: [
+ {
+ version: 'PMM 3.0.1',
+ tag: 'string',
+ timestamp: '2024-09-24T09:12:31.488Z',
+ release_notes_url: 'http://localhost:3000',
+ release_notes_text: 'text1',
+ },
+ {
+ version: 'PMM 3.0.2',
+ tag: 'string',
+ timestamp: '2024-09-24T09:12:31.488Z',
+ release_notes_url: 'http://localhost:3000',
+ release_notes_text: 'text2',
+ },
+ ],
+ };
const state = {
updates: {
isLoading: false,
@@ -97,9 +126,7 @@ describe('PerconaUpdateVersion', () => {
},
},
};
- jest
- .spyOn(UpdatesService, 'getUpdatesChangelogs')
- .mockReturnValue(Promise.resolve({ ...state.updates.changeLogs }));
+ jest.spyOn(UpdatesService, 'getUpdatesChangelogs').mockReturnValue(Promise.resolve({ changeLogsAPIResponse }));
const defaultState = configureStore().getState();
const store = configureStore({
diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx
index 0c18661120e03..a955b58106f8c 100644
--- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx
+++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx
@@ -2,7 +2,7 @@ import React, { FC, useEffect, useState } from 'react';
import { dateTimeFormat } from '@grafana/data';
import { Modal, useStyles2, Button } from '@grafana/ui';
-import { checkUpdatesChangeLogs, UpdatesChangelogs } from 'app/percona/shared/core/reducers/updates';
+import { checkUpdatesChangeLogs, UpdatesChangeLogs } from 'app/percona/shared/core/reducers/updates';
import { getPerconaUser, getUpdatesInfo } from 'app/percona/shared/core/selectors';
import { useAppDispatch } from 'app/store/store';
import { useSelector } from 'app/types';
@@ -89,7 +89,7 @@ const PerconaUpdateVersion: FC = () => {
{Messages.newVersions}
- {changeLogs?.updates.map((update: UpdatesChangelogs) => (
+ {changeLogs?.updates.map((update: UpdatesChangeLogs) => (
-
{update.version}, {dateTimeFormat(update.timestamp, { format: 'MMM DD, YYYY' })}
diff --git a/public/app/percona/shared/core/reducers/updates/updates.ts b/public/app/percona/shared/core/reducers/updates/updates.ts
index 6e66d835066fb..a01e839699030 100644
--- a/public/app/percona/shared/core/reducers/updates/updates.ts
+++ b/public/app/percona/shared/core/reducers/updates/updates.ts
@@ -3,7 +3,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import { UpdatesService } from 'app/percona/shared/services/updates';
import { CheckUpdatesPayload, UpdatesState } from './updates.types';
-import { responseToPayload } from './updates.utils';
+import { mapUpdatesChangeLogs, responseToPayload } from './updates.utils';
const initialState: UpdatesState = {
isLoading: false,
@@ -54,7 +54,7 @@ export const checkUpdatesAction = createAsyncThunk('percona/checkUpdates', async
});
export const checkUpdatesChangeLogs = createAsyncThunk('percona/checkUpdatesChangelogs', async () => {
- return await UpdatesService.getUpdatesChangelogs();
+ return mapUpdatesChangeLogs(await UpdatesService.getUpdatesChangelogs());
});
export default updatesSlice.reducer;
diff --git a/public/app/percona/shared/core/reducers/updates/updates.types.ts b/public/app/percona/shared/core/reducers/updates/updates.types.ts
index 7df4454687e34..08e0baae3308a 100644
--- a/public/app/percona/shared/core/reducers/updates/updates.types.ts
+++ b/public/app/percona/shared/core/reducers/updates/updates.types.ts
@@ -17,8 +17,7 @@ export interface UpdatesState {
latest?: LatestInformation;
latestNewsUrl?: string;
lastChecked?: string;
- changeLogs?: CheckUpdatesChangeLogsResponse;
- snoozeCurrentVersion?: SnoozePayloadResponse;
+ changeLogs?: CheckUpdatesChangeLogs;
}
export interface CheckUpdatesPayload {
@@ -29,7 +28,15 @@ export interface CheckUpdatesPayload {
updateAvailable: boolean;
}
-export interface UpdatesChangelogs {
+export interface UpdatesChangeLogsResponse {
+ version: string;
+ tag: string;
+ timestamp: string;
+ release_notes_url: string;
+ release_notes_text: string;
+}
+
+export interface UpdatesChangeLogs {
version: string;
tag: string;
timestamp: string;
@@ -37,20 +44,12 @@ export interface UpdatesChangelogs {
releaseNotesText: string;
}
-export interface CheckUpdatesChangeLogsResponse {
- updates: UpdatesChangelogs[];
+export interface CheckUpdatesChangeLogs {
+ updates: UpdatesChangeLogs[];
lastCheck: string;
}
-export interface SnoozePayloadBody {
- productTourCompleted: boolean;
- alertingTourCompleted: boolean;
- snoozedPmmVersion: string;
-}
-
-export interface SnoozePayloadResponse {
- userId: number;
- productTourCompleted: boolean;
- alertingTourCompleted: boolean;
- snoozedPmmVersion: string;
+export interface CheckUpdatesChangeLogsResponse {
+ updates: UpdatesChangeLogsResponse[];
+ last_check: string;
}
diff --git a/public/app/percona/shared/core/reducers/updates/updates.utils.ts b/public/app/percona/shared/core/reducers/updates/updates.utils.ts
index 10dd6c6756a7d..caa6477514755 100644
--- a/public/app/percona/shared/core/reducers/updates/updates.utils.ts
+++ b/public/app/percona/shared/core/reducers/updates/updates.utils.ts
@@ -1,6 +1,6 @@
import { CheckUpdatesResponse } from 'app/percona/shared/services/updates/Updates.types';
-import { CheckUpdatesPayload } from './updates.types';
+import { CheckUpdatesPayload, CheckUpdatesChangeLogs, CheckUpdatesChangeLogsResponse } from './updates.types';
export const responseToPayload = (response: CheckUpdatesResponse): CheckUpdatesPayload => ({
installed: response.installed
@@ -21,3 +21,17 @@ export const responseToPayload = (response: CheckUpdatesResponse): CheckUpdatesP
latestNewsUrl: response.latest_news_url,
updateAvailable: !!response.update_available,
});
+
+export const mapUpdatesChangeLogs = (response: CheckUpdatesChangeLogsResponse): CheckUpdatesChangeLogs => {
+ let responseMapping = response.updates.map((item) => ({
+ version: item.version,
+ tag: item.tag,
+ timestamp: item.timestamp,
+ releaseNotesUrl: item.release_notes_url,
+ releaseNotesText: item.release_notes_text,
+ }));
+ return {
+ lastCheck: response.last_check,
+ updates: responseMapping,
+ };
+};