Skip to content

Commit

Permalink
[frontend] view user's confidence level (#4304)
Browse files Browse the repository at this point in the history
  • Loading branch information
labo-flg committed Dec 28, 2023
1 parent 0b11112 commit 7fad1bd
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -527,11 +535,18 @@ const User: FunctionComponent<UserProps> = ({ data }) => {
</List>
</FieldOrEmpty>
</Grid>
<Grid item={true} xs={12}>
<Grid item={true} xs={6}>
<HiddenTypesChipList
hiddenTypes={user.default_hidden_types ?? []}
/>
</Grid>
<Grid item={true} xs={6}>

<Typography variant="h3" gutterBottom={true}>
{t('Max Confidence Level')}
</Typography>
<UserConfidenceLevelField userConfidenceLevel={user.user_confidence_level}/>
</Grid>
</Grid>
</Paper>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<UserConfidenceLevelFieldProps> = ({ userConfidenceLevel }) => {
const { t } = useFormatter();

const overrides = userConfidenceLevel.overrides
.map(({ entity_type, max_confidence }) => `${t(`entity_${entity_type}`)}: ${max_confidence}`)
.join('\n');

return (
<>
<div style={{ float: 'left', marginRight: 5 }}>
{`${userConfidenceLevel.max_confidence ?? '-'}`}
</div>
<div>
{
userConfidenceLevel?.overrides.length > 0 && (
<Tooltip title={
<div style={{ whiteSpace: 'pre-line' }}>
{`${t('This value is overridden for the following entity types')}\n\n${overrides}`}
</div>
}
>
<InfoOutlined
fontSize="small"
color="warning"
/>
</Tooltip>
)
}
</div>
</>
);
};

export default UserConfidenceLevelField;
9 changes: 8 additions & 1 deletion opencti-platform/opencti-front/src/utils/Localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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': '組織に隠れて',
Expand Down Expand Up @@ -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': '隐藏在组织中',
Expand Down

0 comments on commit 7fad1bd

Please sign in to comment.