Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translate voltagelevel with substation creation modification label #699

15 changes: 15 additions & 0 deletions src/hooks/useModificationLabelComputer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { UUID } from 'crypto';
import { MODIFICATION_TYPES } from '../utils/types/modificationType';
import { EQUIPMENT_TYPE } from '../utils/types/equipmentType';

export const format = (text: string, bold: boolean) => {
return bold ? <strong>{text}</strong> : { text };
};

export interface NetworkModificationMetadata {
uuid: UUID;
type: string;
Expand All @@ -27,6 +31,8 @@ interface ModificationValues {
energizedVoltageLevelId: string;
equipmentAttributeName: string;
equipmentAttributeValue: string;
voltageLevelEquipmentId: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already said it in the back but I think equipmentId is enough and should be used for the main equipment id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use voltageLevelEquipmentId to be coherent with the new VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION type

substationEquipmentId: string;
}

const getOperatingStatusModificationValues = (modification: ModificationValues, formatBold: boolean) => {
Expand All @@ -45,6 +51,13 @@ const getEquipmentAttributeModificationValues = (modification: ModificationValue
};
};

const getVoltageLevelWithSubstationModificationValues = (modification: ModificationValues, formatBold: boolean) => {
return {
voltageLevelEquipmentId: format(modification.voltageLevelEquipmentId, formatBold),
substationEquipmentId: format(modification.substationEquipmentId, formatBold),
};
};

export const useModificationLabelComputer = () => {
const intl = useIntl();

Expand Down Expand Up @@ -94,6 +107,8 @@ export const useModificationLabelComputer = () => {
return getOperatingStatusModificationValues(modificationValues, formatBold);
case MODIFICATION_TYPES.EQUIPMENT_ATTRIBUTE_MODIFICATION.type:
return getEquipmentAttributeModificationValues(modificationValues, formatBold);
case MODIFICATION_TYPES.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION.type:
return getVoltageLevelWithSubstationModificationValues(modificationValues, formatBold);
default:
return { computedLabel: formatBold ? <strong>{getLabel(modif)}</strong> : getLabel(modif) };
}
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en/networkModificationsEn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ export const networkModificationsEn = {
'network_modifications.tabular.GENERATOR_CREATION': 'generator creations',
'network_modifications.LCC_CREATION': 'Creating HVDC (LCC) {computedLabel}',
'network_modifications.STATIC_VAR_COMPENSATOR_CREATION': 'Creating static var compensator {computedLabel}',
'network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION':
'Creating voltage level {voltageLevelEquipmentId} and substation {substationEquipmentId}',
};
2 changes: 2 additions & 0 deletions src/translations/fr/networkModificationsFr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ export const networkModificationsFr = {
'network_modifications.tabular.GENERATOR_CREATION': 'créations de générateurs',
'network_modifications.LCC_CREATION': 'Création de la HVDC (LCC) {computedLabel}',
'network_modifications.STATIC_VAR_COMPENSATOR_CREATION': 'Création de CSPR {computedLabel}',
'network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION':
'Création du poste {voltageLevelEquipmentId} et du site {substationEquipmentId}',
};
3 changes: 3 additions & 0 deletions src/utils/types/modificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,7 @@ export const MODIFICATION_TYPES = {
LCC_CREATION: {
type: ModificationType.LCC_CREATION,
},
VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION: {
type: 'VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION',
},
};
Loading