Skip to content

Commit d3cf0ca

Browse files
committed
Fix sonar issues
Signed-off-by: Ayoub LABIDI <[email protected]>
1 parent c703c70 commit d3cf0ca

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/components/graph/nodes/labeled-group-node.styles.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ import { type MuiStyles } from '@gridsuite/commons-ui';
99
import { colors, Theme } from '@mui/material';
1010
import { zoomStyles } from '../zoom.styles';
1111

12-
export const LABEL_BLOCK_HEIGHT = 30; // px, matches label box vertical size
12+
export const LABEL_GROUP_OFFSET = 30;
1313

14-
export const getContainerStyle = (theme: Theme, isLight: boolean) => ({
15-
...zoomStyles.labeledGroupBorder(theme),
16-
background: theme.tree?.is.minimalDetail ? (isLight ? theme.palette.grey[200] : colors.grey[700]) : 'transparent',
17-
borderColor: isLight ? colors.grey[400] : colors.grey[500],
18-
});
14+
export const getContainerStyle = (theme: Theme, isLight: boolean) => {
15+
let backgroundColor = 'transparent';
16+
if (theme.tree?.is.minimalDetail) {
17+
backgroundColor = isLight ? theme.palette.grey[200] : colors.grey[700];
18+
}
19+
20+
return {
21+
...zoomStyles.labeledGroupBorder(theme),
22+
background: backgroundColor,
23+
borderColor: isLight ? colors.grey[400] : colors.grey[500],
24+
};
25+
};
1926

2027
export const labeledGroupNodeStyles = {
2128
label: (theme) => ({

src/components/graph/nodes/labeled-group-node.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { nodeHeight as nodeLayoutHeight, nodeWidth as nodeLayoutWidth } from '..
1212
import { FormattedMessage } from 'react-intl';
1313
import { LabeledGroupNodeType } from './labeled-group-node.type';
1414
import { NODE_HEIGHT, NODE_WIDTH } from './constants';
15-
import { labeledGroupNodeStyles, getContainerStyle, LABEL_BLOCK_HEIGHT } from './labeled-group-node.styles';
15+
import { labeledGroupNodeStyles, getContainerStyle, LABEL_GROUP_OFFSET } from './labeled-group-node.styles';
1616

1717
export function LabeledGroupNode({ data }: NodeProps<LabeledGroupNodeType>) {
1818
const theme = useTheme();
@@ -23,13 +23,13 @@ export function LabeledGroupNode({ data }: NodeProps<LabeledGroupNodeType>) {
2323
const horizontalPadding = (nodeLayoutWidth - NODE_WIDTH) / 2;
2424

2525
// Adjust position and size to account for border width and label block
26-
const labeledGroupTopPosition = data.position.topLeft.row * nodeLayoutHeight - verticalPadding - LABEL_BLOCK_HEIGHT;
26+
const labeledGroupTopPosition = data.position.topLeft.row * nodeLayoutHeight - verticalPadding - LABEL_GROUP_OFFSET;
2727
const labeledGroupLeftPosition = data.position.topLeft.column * nodeLayoutWidth - horizontalPadding;
2828

2929
const labeledGroupHeight =
3030
(data.position.bottomRight.row - data.position.topLeft.row + 1) * nodeLayoutHeight -
3131
2 * verticalPadding +
32-
2 * LABEL_BLOCK_HEIGHT;
32+
2 * LABEL_GROUP_OFFSET;
3333
const labeledGroupWidth = (data.position.bottomRight.column - data.position.topLeft.column + 1) * nodeLayoutWidth;
3434

3535
const isLight = theme.palette.mode === 'light';

src/components/graph/nodes/network-modification-node.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ const NetworkModificationNode = (props: NodeProps<ModificationNode>) => {
4949
}, [props.id, selectionForCopy]);
5050

5151
const nodeOpacity = useMemo(() => {
52-
return isSelectedForCut() ? (getLocalStorageTheme() === LIGHT_THEME ? 0.3 : 0.6) : 1;
52+
if (!isSelectedForCut()) {
53+
return 1;
54+
}
55+
return getLocalStorageTheme() === LIGHT_THEME ? 0.3 : 0.6;
5356
}, [isSelectedForCut]);
5457

5558
const tooltipContent = useMemo(() => {

0 commit comments

Comments
 (0)