■ ■ ■ ■ ■ ■
opencti-platform/opencti-front/src/private/components/locations/countries/CountryLine.js
opencti-platform/opencti-front/src/private/components/locations/countries/CountryLine.tsx
1 - import React, { Component } from 'react'; 2 - import * as PropTypes from 'prop-types'; 1 + import React, { FunctionComponent } from 'react'; 3 2 import { Link } from 'react-router-dom'; 4 - import withStyles from '@mui/styles/withStyles'; 5 3 import ListItem from '@mui/material/ListItem'; 6 4 import ListItemIcon from '@mui/material/ListItemIcon'; 7 5 import ListItemText from '@mui/material/ListItemText'; 8 6 import { KeyboardArrowRightOutlined, FlagOutlined } from '@mui/icons-material'; 9 - import { compose } from 'ramda'; 10 7 import Skeleton from '@mui/material/Skeleton'; 11 8 import { createFragmentContainer, graphql } from 'react-relay'; 12 - import inject18n from '../../../../components/i18n'; 9 + import makeStyles from '@mui/styles/makeStyles'; 10 + import { Theme } from '@mui/material/styles/createTheme'; 11 + import { useFormatter } from '../../../../components/i18n'; 12 + import { CountryLine_node$data } from './__generated__/CountryLine_node.graphql'; 13 + import { DataColumns } from '../../../../components/list_lines'; 13 14 14 - const styles = (theme) => ({ 15 + const useStyles = makeStyles < Theme > ( (theme) => ({ 15 16 item: { 16 17 paddingLeft: theme.spacing(8), 17 18 }, skipped 15 lines 33 34 height: '1em', 34 35 backgroundColor: theme.palette.grey[700], 35 36 }, 36 - }); 37 + })) ; 37 38 38 - class CountryLineComponent extends Component { 39 - render() { 40 - const { classes, node } = this.props; 41 - return ( 42 - <ListItem 43 - classes={{ root: classes.item }} 44 - divider={true} 45 - button={true} 46 - component={Link} 47 - to={`/dashboard/locations/countries/${node.id}`} 48 - > 49 - <ListItemIcon classes={{ root: classes.itemIcon }}> 50 - <FlagOutlined /> 51 - </ListItemIcon> 52 - <ListItemText classes={{ primary: classes.text }} primary={node.name} /> 53 - <ListItemIcon classes={{ root: classes.goIcon }}> 54 - <KeyboardArrowRightOutlined /> 55 - </ListItemIcon> 56 - </ListItem> 57 - ); 58 - } 39 + interface CountryLineProps { 40 + node: CountryLine_node$data 41 + dataColumns: DataColumns 59 42 } 43 + const classes = useStyles(); 60 44 61 - CountryLineComponent.propTypes = { 62 - node: PropTypes.object, 63 - classes: PropTypes.object, 64 - fd: PropTypes.func, 45 + const CountryLineComponent: FunctionComponent<CountryLineProps> = ({ node }) => { 46 + const { fd } = useFormatter(); 47 + 48 + return ( 49 + <ListItem 50 + classes={{ root: classes.item }} 51 + divider={true} 52 + button={true} 53 + component={Link} 54 + to={`/dashboard/locations/countries/${node.id}`} 55 + > 56 + <ListItemIcon classes={{ root: classes.itemIcon }}> 57 + <FlagOutlined /> 58 + </ListItemIcon> 59 + <ListItemText classes={{ primary: classes.text }} primary={node.name} /> 60 + <ListItemIcon classes={{ root: classes.goIcon }}> 61 + <KeyboardArrowRightOutlined /> 62 + </ListItemIcon> 63 + </ListItem> 64 + ); 65 65 }; 66 66 67 67 const CountryLineFragment = createFragmentContainer(CountryLineComponent, { skipped 7 lines 75 75 `, 76 76 }); 77 77 78 - export const CountryLine = compose( 79 - inject18n, 80 - withStyles(styles), 81 - )(CountryLineComponent); 82 - 83 - class CountryLineDummyComponent extends Component { 84 - render() { 85 - const { classes, dataColumns } = this.props; 86 - return ( 78 + const CountryLineDummyComponent: FunctionComponent<CountryLineProps> = ({ dataColumns }) => { 79 + return ( 87 80 <ListItem classes={{ root: classes.item }} divider={true}> 88 81 <ListItemIcon classes={{ root: classes.itemIcon }}> 89 82 <Skeleton skipped 7 lines 97 90 primary={ 98 91 <div> 99 92 <div 100 - className={classes.bodyItem } 93 + className={classes.item } 101 94 style={{ width: dataColumns.name.width }} 102 95 > 103 96 <Skeleton skipped 4 lines 108 101 /> 109 102 </div> 110 103 <div 111 - className={classes.bodyItem } 104 + className={classes.item } 112 105 style={{ width: dataColumns.created.width }} 113 106 > 114 107 <Skeleton skipped 4 lines 119 112 /> 120 113 </div> 121 114 <div 122 - className={classes.bodyItem } 115 + className={classes.item } 123 116 style={{ width: dataColumns.modified.width }} 124 117 > 125 118 <Skeleton skipped 10 lines 136 129 <KeyboardArrowRightOutlined /> 137 130 </ListItemIcon> 138 131 </ListItem> 139 - );140 - } 141 - } 142 - 143 - CountryLineDummyComponent.propTypes = { 144 - dataColumns: PropTypes.object, 145 - classes: PropTypes.object, 132 + ); 146 133 }; 147 134 148 - export const CountryLineDummy = compose( 149 - inject18n, 150 - withStyles(styles), 151 - )(CountryLineDummyComponent); 135 + export default { CountryLineComponent, CountryLineDummyComponent }; 152 136