Skip to content

Commit 830d580

Browse files
committed
fix sonar
1 parent 8a61a28 commit 830d580

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

src/components/dialogs/limits/limits-constants.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
*/
77

88
export enum LimitsPropertyName {
9-
LIMITS_TYPE = 'LimitsType',
10-
ASSOCIATION = 'association',
11-
ORIGIN = 'origin',
9+
LIMITS_TYPE = 'Limit type',
1210
}
1311

1412
export function getPropertyAvatar(type: string): string {
1513
const transformedType: LimitsPropertyName | undefined = type as LimitsPropertyName;
1614

1715
const descriptions: Record<LimitsPropertyName, string> = {
1816
[LimitsPropertyName.LIMITS_TYPE]: 'Ty',
19-
[LimitsPropertyName.ASSOCIATION]: 'As',
20-
[LimitsPropertyName.ORIGIN]: 'Pr',
2117
};
2218

2319
return descriptions[transformedType] ?? transformedType.substring(0, 2);

src/components/dialogs/limits/limits-pane-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export const combineFormAndMapServerLimitsGroups = (
268268
}
269269

270270
// adds all the operational limits groups from mapServerBranch THAT ARE NOT DELETED by the netmod
271-
mapServerBranch.currentLimits?.forEach((currentLimit: CurrentLimitsData) => {
271+
for (const currentLimit of mapServerBranch.currentLimits) {
272272
const equivalentFromNetMod = updatedOpLG.find(
273273
(opLG: OperationalLimitsGroupFormInfos) =>
274274
currentLimit.id === opLG.name && currentLimit.applicability === opLG[APPLICABIlITY]
@@ -286,7 +286,7 @@ export const combineFormAndMapServerLimitsGroups = (
286286
},
287287
});
288288
}
289-
});
289+
}
290290

291291
return updatedOpLG;
292292
};

src/components/dialogs/limits/limits-properties-side-stack.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
3636
}
3737
if (!limitsProperties?.length) {
3838
setValue(formName, [{ name: propertyName, value: propertyValue }]);
39-
} else if (limitsProperties.find((l) => l.name === propertyName)) {
40-
setEditorError(intl.formatMessage({ id: 'UsedPropertyName' }));
39+
} else if (limitsProperties.some((l) => l.name === propertyName)) {
40+
setEditorError(intl.formatMessage({ id: 'NameUnique' }));
4141
return;
4242
} else {
4343
setValue(formName, [...limitsProperties, { name: propertyName, value: propertyValue }]);
@@ -74,7 +74,7 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
7474
disabled={disabled}
7575
/>
7676
))}
77-
{!isEditing ? (
77+
{!isEditing && (
7878
<IconButton
7979
color="primary"
8080
sx={{ verticalAlign: 'center' }}
@@ -83,8 +83,6 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
8383
>
8484
<AddCircle />
8585
</IconButton>
86-
) : (
87-
''
8886
)}
8987
</Stack>
9088
{isEditing && !disabled ? (
@@ -117,12 +115,18 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
117115
<TextField
118116
size="small"
119117
label={intl.formatMessage({ id: 'PropertyValue' })}
120-
sx={{ flex: 1 }}
118+
sx={{ flex: 1, verticalAlign: 'center' }}
121119
onKeyDown={handleKeyPress}
122120
onChange={(event) => setPropertyValue(event.target.value)}
123121
/>
124122
{hovered && (
125-
<IconButton sx={{ verticalAlign: 'center' }} onClick={() => setIsEditing(false)}>
123+
<IconButton
124+
sx={{ verticalAlign: 'center' }}
125+
onClick={() => {
126+
setIsEditing(false);
127+
setEditorError('');
128+
}}
129+
>
126130
<Delete />
127131
</IconButton>
128132
)}

src/components/utils/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const formatToTemporaryLimitsFormInfos = (temporaryLimits: TemporaryLimit
155155
export const formatCompleteCurrentLimit = (completeLimitsGroups: CurrentLimitsData[]) => {
156156
const formattedCompleteLimitsGroups: OperationalLimitsGroup[] = [];
157157
if (completeLimitsGroups) {
158-
completeLimitsGroups.forEach((elt: CurrentLimitsData) => {
158+
for (const elt of completeLimitsGroups) {
159159
if (isNotBlankOrEmpty(elt.id)) {
160160
formattedCompleteLimitsGroups.push({
161161
[ID]: elt.id + elt.applicability,
@@ -169,7 +169,7 @@ export const formatCompleteCurrentLimit = (completeLimitsGroups: CurrentLimitsDa
169169
},
170170
});
171171
}
172-
});
172+
}
173173
}
174174
return formattedCompleteLimitsGroups;
175175
};

src/services/network-modification-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export interface CurrentLimitsData {
306306
applicability?: string;
307307
limitsProperties?: LimitsProperty[];
308308
permanentLimit: number | null;
309-
temporaryLimits: TemporaryLimit[]; // TODO : not exactly the right type Limit is more convenient
309+
temporaryLimits: TemporaryLimit[];
310310
}
311311

312312
export interface SubstationModificationInfo {

src/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@
916916
"SelectedOperationalLimitGroup": "Active limit set",
917917
"SelectedOperationalLimitGroups": "Active limit sets",
918918
"Applicability": "Applicability",
919-
"UsedPropertyName": "Property name already used",
919+
"NameUnique": "Name should be unique",
920920

921921
"CreateTwoWindingsTransformer": "Create a 2 windings transformer",
922922
"ModifyTwoWindingsTransformer": "Modify a 2 windings transformer",

src/translations/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@
901901
"operationalLimitsGroup1WithProperties": "Jeu de limites actif côté 1 ayant la propriété",
902902
"operationalLimitsGroup2WithProperties": "Jeu de limites actif côté 2 ayant la propriété",
903903
"Applicability": "Applicable sur",
904-
"UsedPropertyName": "Nom de propriété déjà utilisé",
904+
"NameUnique": "Le nom doit être unique",
905905

906906
"qMaxAtNominalVMustBeGreaterThanZero": "La valeur Q installée à tension nominale doit être supérieure à 0",
907907
"powerFactorMaxValueError": "La valeur du coefficient Q/P doit être inférieure à 1",

0 commit comments

Comments
 (0)