From b1dae4a27718113b62b8408d52e80ee5bd03ac03 Mon Sep 17 00:00:00 2001 From: Alexander Burmatov Date: Thu, 14 Nov 2024 01:25:47 +0300 Subject: [PATCH] Fix a bug --- public/locales/en/translation.json | 7 +++-- public/locales/ru/translation.json | 6 ++-- .../vulnerabilityAndSignatureCheck.jsx | 27 +++++++++++++++++- .../vulnerabilityAndSignatureComponents.jsx | 28 ++++++++++++++----- 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 89c3dedb..e8582ec7 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -155,7 +155,9 @@ "low": "Low", "lowShort": "L", "unknown": "Unknown", - "unknownShort": "U" + "unknownShort": "U", + "no": "No", + "none": "None" }, "vulnerabilityPackageSection": { "packagePath": "Package Path", @@ -222,7 +224,8 @@ "starredRepositories": "Starred Repositories" }, "vulnerabilityAndSignatureComponents": { - "failed2scan": "Failed to scan" + "failed2scan": "Failed to scan", + "unverifiedSign": "Unverified Signature" }, "alert": { "newScheme": "In the near future (11/15/2024), it is planned to change the structure of image placement. ", diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 15b5d8a0..bfd867d4 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -155,7 +155,8 @@ "low": "Небольших", "lowShort": "Н", "unknown": "Неизвестных", - "unknownShort": "Не" + "unknownShort": "Не", + "no": "Нет" }, "vulnerabilityPackageSection": { "packagePath": "Путь пакета", @@ -222,7 +223,8 @@ "starredRepositories": "Понравившиеся" }, "vulnerabilityAndSignatureComponents": { - "failed2scan": "Не удалось выполнить сканирование" + "failed2scan": "Не удалось выполнить сканирование", + "unverifiedSign": "Непроверенная подпись" }, "alert": { "newScheme": "В скором времени (15.11.2024) планируется смена структуры размещения образов. ", diff --git a/src/utilities/vulnerabilityAndSignatureCheck.jsx b/src/utilities/vulnerabilityAndSignatureCheck.jsx index dff55ef0..c66b594e 100644 --- a/src/utilities/vulnerabilityAndSignatureCheck.jsx +++ b/src/utilities/vulnerabilityAndSignatureCheck.jsx @@ -1,5 +1,6 @@ import { isEmpty } from 'lodash'; import React from 'react'; +import { useTranslation } from 'react-i18next'; import { NoneVulnerabilityIcon, LowVulnerabilityIcon, @@ -35,13 +36,37 @@ const getAllAuthorsOfSignatures = (signatureInfo) => { const VulnerabilityIconCheck = ({ vulnerabilitySeverity }) => { let result; + + const { t } = useTranslation(); + let vulnerabilityStringTitle = ''; if (vulnerabilitySeverity) { vulnerabilityStringTitle = vulnerabilitySeverity.charAt(0) + vulnerabilitySeverity.substring(1).toLowerCase(); + switch (vulnerabilityStringTitle) { + case 'None': + vulnerabilityStringTitle = 'vulnerabilityCountCard.no'; + break; + case 'Low': + vulnerabilityStringTitle = 'vulnerabilityCountCard.low'; + break; + case 'Medium': + vulnerabilityStringTitle = 'vulnerabilityCountCard.medium'; + break; + case 'High': + vulnerabilityStringTitle = 'vulnerabilityCountCard.high'; + break; + case 'Critical': + vulnerabilityStringTitle = 'vulnerabilityCountCard.critical'; + break; + case 'Unknown': + vulnerabilityStringTitle = 'vulnerabilityCountCard.unknown'; + break; + } + vulnerabilityStringTitle = t(vulnerabilityStringTitle); } switch (vulnerabilitySeverity) { case 'NONE': - result = ; + result = ; break; case 'LOW': result = ; diff --git a/src/utilities/vulnerabilityAndSignatureComponents.jsx b/src/utilities/vulnerabilityAndSignatureComponents.jsx index 21c47173..eb464de4 100644 --- a/src/utilities/vulnerabilityAndSignatureComponents.jsx +++ b/src/utilities/vulnerabilityAndSignatureComponents.jsx @@ -151,9 +151,11 @@ const CriticalVulnerabilityIcon = ({ vulnerabilityStringTitle }) => { ); }; const NoneVulnerabilityChip = () => { + const { t } = useTranslation(); + return ( } @@ -162,9 +164,11 @@ const NoneVulnerabilityChip = () => { ); }; const UnknownVulnerabilityChip = () => { + const { t } = useTranslation(); + return ( } @@ -186,9 +190,11 @@ const FailedScanChip = () => { ); }; const LowVulnerabilityChip = () => { + const { t } = useTranslation(); + return ( } @@ -197,9 +203,11 @@ const LowVulnerabilityChip = () => { ); }; const MediumVulnerabilityChip = () => { + const { t } = useTranslation(); + return ( } @@ -208,9 +216,11 @@ const MediumVulnerabilityChip = () => { ); }; const HighVulnerabilityChip = () => { + const { t } = useTranslation(); + return ( } @@ -219,9 +229,11 @@ const HighVulnerabilityChip = () => { ); }; const CriticalVulnerabilityChip = () => { + const { t } = useTranslation(); + return ( } @@ -366,9 +378,11 @@ const VerifiedSignatureIcon = ({ signatureInfo }) => { }; const UnverifiedSignatureChip = () => { + const { t } = useTranslation(); + return ( {