From 44dde44bf17f5f491584b2bf4bf4326c6d8a07a0 Mon Sep 17 00:00:00 2001 From: Laurent Bonnet Date: Thu, 21 Dec 2023 17:56:44 +0100 Subject: [PATCH] [frontend] view user's confidence level (#4304) --- .../src/private/components/Error.jsx | 2 +- .../components/settings/users/User.tsx | 17 ++++++- .../users/UserConfidenceLevelField.tsx | 44 +++++++++++++++++++ .../opencti-front/src/utils/Localization.js | 9 +++- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 opencti-platform/opencti-front/src/private/components/settings/users/UserConfidenceLevelField.tsx diff --git a/opencti-platform/opencti-front/src/private/components/Error.jsx b/opencti-platform/opencti-front/src/private/components/Error.jsx index f83883a83196..1f375a1c8ad5 100644 --- a/opencti-platform/opencti-front/src/private/components/Error.jsx +++ b/opencti-platform/opencti-front/src/private/components/Error.jsx @@ -86,7 +86,7 @@ export const BoundaryRoute = (props) => { }; BoundaryRoute.propTypes = { - component: PropTypes.func, + component: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), display: PropTypes.object, exact: PropTypes.bool, path: PropTypes.string, diff --git a/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx b/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx index 579992d789f0..0ce48fa993c6 100644 --- a/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx +++ b/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx @@ -20,6 +20,7 @@ import { useTheme } from '@mui/styles'; import makeStyles from '@mui/styles/makeStyles'; import { ApexOptions } from 'apexcharts'; import { SimplePaletteColorOptions } from '@mui/material/styles/createPalette'; +import UserConfidenceLevelField from '@components/settings/users/UserConfidenceLevelField'; import FieldOrEmpty from '../../../../components/FieldOrEmpty'; import { useFormatter } from '../../../../components/i18n'; import UserEdition from './UserEdition'; @@ -154,6 +155,13 @@ const UserFragment = graphql` } } default_hidden_types + user_confidence_level { + max_confidence + overrides { + entity_type + max_confidence + } + } objectOrganization( orderBy: $organizationsOrderBy orderMode: $organizationsOrderMode @@ -527,11 +535,18 @@ const User: FunctionComponent = ({ data }) => { - + + + + + {t('Max Confidence Level')} + + + diff --git a/opencti-platform/opencti-front/src/private/components/settings/users/UserConfidenceLevelField.tsx b/opencti-platform/opencti-front/src/private/components/settings/users/UserConfidenceLevelField.tsx new file mode 100644 index 000000000000..730ee42336fb --- /dev/null +++ b/opencti-platform/opencti-front/src/private/components/settings/users/UserConfidenceLevelField.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { User_user$data } from '@components/settings/users/__generated__/User_user.graphql'; +import { InfoOutlined } from '@mui/icons-material'; +import Tooltip from '@mui/material/Tooltip'; +import { useFormatter } from '../../../../components/i18n'; + +type UserConfidenceLevelFieldProps = { + userConfidenceLevel: User_user$data['user_confidence_level'] +}; + +const UserConfidenceLevelField: React.FC = ({ userConfidenceLevel }) => { + const { t } = useFormatter(); + + const overrides = userConfidenceLevel.overrides + .map(({ entity_type, max_confidence }) => `${t(`entity_${entity_type}`)}: ${max_confidence}`) + .join('\n'); + + return ( + <> +
+ {`${userConfidenceLevel.max_confidence ?? '-'}`} +
+
+ { + userConfidenceLevel?.overrides.length > 0 && ( + + {`${t('This value is overridden for the following entity types')}\n\n${overrides}`} +
+ } + > + + + ) + } + + + ); +}; + +export default UserConfidenceLevelField; diff --git a/opencti-platform/opencti-front/src/utils/Localization.js b/opencti-platform/opencti-front/src/utils/Localization.js index 1d4777b8c266..4caa429b9908 100644 --- a/opencti-platform/opencti-front/src/utils/Localization.js +++ b/opencti-platform/opencti-front/src/utils/Localization.js @@ -275,6 +275,8 @@ const i18n = { 'This configuration is not available for this entity type': 'Esta configuración no está disponible para este tipo de entidad', 'Hidden entity types': 'Tipos de entidad ocultos', + 'Max Confidence Level': 'Nivel Máximo de Confianza', + 'This value is overridden for the following entity types': 'Este valor está anulado para los siguientes tipos de entidad', 'Hidden in ': 'Oculto en ', 'Hidden in groups': 'Oculto en grupos', 'Hidden in organizations': 'Oculto en las organizaciones', @@ -2674,7 +2676,8 @@ const i18n = { Language: 'Langue', 'This configuration is not available for this entity type': "Cette configuration n'est pas disponible pour ce type d'entité", - 'Hidden entity types': "Types d'entité cachés", + 'Max Confidence Level': 'Niveau de Confiance Max', + 'This value is overridden for the following entity types': "Cette valeur est remplacée pour les types d'entités suivants", 'Hidden in ': 'Caché dans ', 'Hidden in groups': 'Caché dans les groupes', 'Hidden in organizations': 'Caché dans les organisations', @@ -5009,6 +5012,8 @@ const i18n = { 'This configuration is not available for this entity type': 'この構成は、このエンティティ タイプでは使用できません', 'Hidden entity types': '非表示のエンティティ種別', + 'Max Confidence Level': '最大信頼レベル', + 'This value is overridden for the following entity types': 'この値は、次のエンティティタイプに対して上書きされています', 'Hidden in ': 'に隠されています', 'Hidden in groups': 'グループに隠れている', 'Hidden in organizations': '組織に隠れて', @@ -7253,6 +7258,8 @@ const i18n = { 'This configuration is not available for this entity type': '此配置不适用于此实体类型', 'Hidden entity types': '隐藏的实体类型', + 'Max Confidence Level': '最大信心水平', + 'This value is overridden for the following entity types': '此值已覆盖以下实体类型', 'Hidden in ': '隐藏在', 'Hidden in groups': '隐藏在群体中', 'Hidden in organizations': '隐藏在组织中',