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 Jan 17, 2024
1 parent 5442ba3 commit 27550e4
Show file tree
Hide file tree
Showing 4 changed files with 9,741 additions and 2 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 UserConfidenceLevel from '@components/settings/users/UserConfidenceLevel';
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,17 @@ 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>
<UserConfidenceLevel 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 UserConfidenceLevel: 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 UserConfidenceLevel;
Loading

0 comments on commit 27550e4

Please sign in to comment.