From 01782b32c3dfd33d8ed8785b33ff415a5f162046 Mon Sep 17 00:00:00 2001
From: DoraCretu594118 <103416234+doracretu3pillar@users.noreply.github.com>
Date: Tue, 1 Oct 2024 15:37:26 +0300
Subject: [PATCH] Fixes after PR reviews
---
.../PerconaUpdateVersion.styles.ts | 2 -
.../PerconaUpdateVersion.test.tsx | 5 +-
.../PerconaUpdateVersion.tsx | 39 ++++++---------
.../shared/core/reducers/updates/updates.ts | 49 +------------------
.../percona/shared/core/reducers/user/user.ts | 11 +++++
.../shared/core/reducers/user/user.types.ts | 1 +
.../shared/core/reducers/user/user.utils.ts | 1 +
public/app/percona/shared/core/selectors.ts | 2 +-
.../services/updates/Updates.service.ts | 11 +----
.../shared/services/user/User.service.ts | 4 ++
.../shared/services/user/User.types.ts | 2 +
11 files changed, 40 insertions(+), 87 deletions(-)
diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts
index 5a5880027273..e7a912f8031e 100644
--- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts
+++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.styles.ts
@@ -17,8 +17,6 @@ export const getStyles = ({ v1: { spacing, colors } }: GrafanaTheme2) => ({
color: ${colors.textBlue};
}
`,
- howToUpdateTitle: css``,
- howToUpdateDescription: css``,
newVersionsTitle: css`
font-weight: 500;
font-size: 16px;
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 ddaa88e1db98..a294a60b3c8c 100644
--- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx
+++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.test.tsx
@@ -13,13 +13,12 @@ import { EnhancedStore } from '@reduxjs/toolkit';
const checkUpdatesChangeLogsSpy = jest.spyOn(GrafanaUpdates, 'checkUpdatesChangeLogs');
describe('PerconaUpdateVersion', () => {
- function setup(store: EnhancedStore) {
- return render(
+ const setup = (store: EnhancedStore) =>
+ render(
);
- }
beforeEach(() => {
jest.clearAllMocks();
diff --git a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx
index c14ae8ba3213..f8c5962445f6 100644
--- a/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx
+++ b/public/app/percona/shared/components/PerconaBootstrapper/PerconaUpdateVersion/PerconaUpdateVersion.tsx
@@ -2,38 +2,31 @@ import React, { FC, useEffect, useState } from 'react';
import { dateTimeFormat } from '@grafana/data';
import { Modal, useStyles2, Button } from '@grafana/ui';
-import {
- checkUpdatesChangeLogs,
- getSnoozeCurrentVersion,
- setSnoozeCurrentUpdate,
- UpdatesChangelogs,
-} from 'app/percona/shared/core/reducers/updates';
-import { getUpdatesInfo } from 'app/percona/shared/core/selectors';
+import { checkUpdatesChangeLogs, UpdatesChangelogs } from 'app/percona/shared/core/reducers/updates';
+import { getTour, getUpdatesInfo } from 'app/percona/shared/core/selectors';
import { useAppDispatch } from 'app/store/store';
import { useSelector } from 'app/types';
import { Messages } from './PerconaUpdateVersion.constants';
import { getStyles } from './PerconaUpdateVersion.styles';
import { PMM_UPDATES_LINK } from 'app/percona/shared/components/PerconaBootstrapper/PerconaNavigation';
+import { setSnoozedVersion } from 'app/percona/shared/core/reducers/user/user';
const PerconaUpdateVersion: FC = () => {
- const { updateAvailable, installed, latest, changeLogs, lastChecked, snoozeCurrentVersion } =
- useSelector(getUpdatesInfo);
-
+ const { updateAvailable, installed, latest, changeLogs, lastChecked } = useSelector(getUpdatesInfo);
+ const { snoozeCurrentVersion } = useSelector(getTour);
const [showUpdate, setShowUpdate] = useState(false);
const dispatch = useAppDispatch();
const styles = useStyles2(getStyles);
useEffect(() => {
-
const prepareModal = async () => {
if (!snoozeCurrentVersion) {
- await dispatch(getSnoozeCurrentVersion());
+ await dispatch(fetchUserDetailsAction());
}
if (
- (installed?.version !== latest?.version &&
- snoozeCurrentVersion?.snoozedPmmVersion !== latest?.version) ||
+ (installed?.version !== latest?.version && snoozeCurrentVersion?.snoozedPmmVersion !== latest?.version) ||
!lastChecked
) {
setShowUpdate(true);
@@ -49,11 +42,9 @@ const PerconaUpdateVersion: FC = () => {
const snoozeUpdate = async () => {
if (latest && latest.version) {
const payload = {
- productTourCompleted: snoozeCurrentVersion?.productTourCompleted || true,
- alertingTourCompleted: snoozeCurrentVersion?.alertingTourCompleted || true,
- snoozedPmmVersion: latest.version,
+ version: latest.version.toString(),
};
- await dispatch(setSnoozeCurrentUpdate(payload));
+ await dispatch(setSnoozedVersion(payload));
}
setShowUpdate(false);
};
@@ -66,7 +57,7 @@ const PerconaUpdateVersion: FC = () => {
setShowUpdate(false);
const baseUrl = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`;
window.location.href = baseUrl + PMM_UPDATES_LINK.url;
- }
+ };
return (
<>
@@ -79,10 +70,12 @@ const PerconaUpdateVersion: FC = () => {
{changeLogs?.updates[0]?.version || ''}
- {Messages.fullReleaseNotes}
+
+ {Messages.fullReleaseNotes}
+
-
{Messages.howToUpdate}
-
{Messages.howToUpdateDescription}
+
{Messages.howToUpdate}
+
{Messages.howToUpdateDescription}