Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/elementSearch/elementItem/EquipmentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import parse from 'autosuggest-highlight/parse';
import clsx from 'clsx';
import { FormattedMessage } from 'react-intl';
import { Box, SxProps, Theme } from '@mui/material';
import { EQUIPMENT_TYPE, EquipmentInfos } from '../../../utils/types/equipmentType';
import { EquipmentInfos, SEARCH_TAG_EQUIPMENT_TYPES } from '../../../utils/types/equipmentType';
import { TagRenderer } from '../tagRenderer/TagRenderer';
import { OverflowableText } from '../../overflowableText';
import { mergeSx } from '../../../utils/styles';
Expand Down Expand Up @@ -57,7 +57,7 @@ export function EquipmentItem({
className={clsx(props.classes?.equipmentTag, props.classes?.equipmentTypeTag)}
sx={mergeSx(props.styles?.equipmentTag, props.styles?.equipmentTypeTag)}
>
<FormattedMessage id={EQUIPMENT_TYPE[element.type]?.tagLabel} />
<FormattedMessage id={SEARCH_TAG_EQUIPMENT_TYPES[element.type]?.tagLabel} />
</Box>
)}
<OverflowableText
Expand Down
4 changes: 2 additions & 2 deletions src/components/elementSearch/tagRenderer/TagRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import clsx from 'clsx';
import { SxProps, Theme } from '@mui/material';
import { OverflowableText } from '../../overflowableText';
import { EQUIPMENT_TYPE, EquipmentInfos } from '../../../utils/types/equipmentType';
import { EquipmentInfos, EquipmentType } from '../../../utils/types/equipmentType';
import { mergeSx } from '../../../utils/styles';

export interface TagRendererProps {
Expand All @@ -23,7 +23,7 @@ export interface TagRendererProps {
}

export function TagRenderer({ element, ...props }: TagRendererProps) {
if (element.type !== EQUIPMENT_TYPE.SUBSTATION?.name && element.type !== EQUIPMENT_TYPE.VOLTAGE_LEVEL?.name) {
if (element.type !== EquipmentType.SUBSTATION && element.type !== EquipmentType.VOLTAGE_LEVEL) {
return (
<OverflowableText
text={element.voltageLevelLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { NumericEditor } from '../../inputs/reactHookForm/agGridTable/cellEditor
import { InputWithPopupConfirmation } from '../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation';
import { toFloatOrNullValue } from '../../inputs/reactHookForm/utils/functions';
import { DISTRIBUTION_KEY, FilterType } from '../constants/FilterConstants';
import { FILTER_EQUIPMENTS } from '../utils/filterFormUtils';
import { FILTER_EQUIPMENT_TYPES } from '../utils/filterFormUtils';
import { useSnackMessage } from '../../../hooks/useSnackMessage';
import { ElementType } from '../../../utils/types/elementType';
import { ModifyElementSelection } from '../../dialogs/modifyElementSelection/ModifyElementSelection';
Expand Down Expand Up @@ -108,7 +108,7 @@ export function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversi
});

useEffect(() => {
if (watchEquipmentType && !((watchEquipmentType as EquipmentType) in FILTER_EQUIPMENTS)) {
if (watchEquipmentType && !((watchEquipmentType as EquipmentType) in FILTER_EQUIPMENT_TYPES)) {
snackError({
headerId: 'obsoleteFilter',
});
Expand Down Expand Up @@ -216,7 +216,7 @@ export function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversi
<InputWithPopupConfirmation
Input={SelectInput}
name={FieldConstants.EQUIPMENT_TYPE}
options={Object.values(FILTER_EQUIPMENTS)}
options={Object.values(FILTER_EQUIPMENT_TYPES)}
disabled={!!sourceFilterForExplicitNamingConversion}
label="equipmentType"
shouldOpenPopup={openConfirmationPopup}
Expand Down
110 changes: 29 additions & 81 deletions src/components/filter/utils/filterFormUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { FunctionComponent } from 'react';
import { FieldConstants } from '../../../utils/constants/fieldConstants';
import { RangeInput } from '../../inputs/reactHookForm/numbers/RangeInput';
import { CountriesInput } from '../../inputs/reactHookForm/selectInputs/CountriesInput';
import { SelectInput } from '../../inputs/reactHookForm/selectInputs/SelectInput';
import { EquipmentType } from '../../../utils/types/equipmentType';
import { BASE_INFOS_EQUIPMENT_TYPES, EquipmentType } from '../../../utils/types/equipmentType';

const countries = {
renderer: CountriesInput,
Expand Down Expand Up @@ -60,21 +59,6 @@ const nominalVoltage3 = {
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.NOMINAL_VOLTAGE_3}`,
},
};
const energySource = {
renderer: SelectInput,
props: {
label: 'EnergySourceText',
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.ENERGY_SOURCE}`,
options: [
{ id: 'HYDRO', label: 'Hydro' },
{ id: 'NUCLEAR', label: 'Nuclear' },
{ id: 'WIND', label: 'Wind' },
{ id: 'THERMAL', label: 'Thermal' },
{ id: 'SOLAR', label: 'Solar' },
{ id: 'OTHER', label: 'Other' },
],
},
};
export type FormField = {
renderer: FunctionComponent<any>;
props: {
Expand Down Expand Up @@ -158,79 +142,43 @@ export const CONTINGENCY_LIST_EQUIPMENTS: Record<
fields: [countries, nominalVoltage],
},
};
export const FILTER_EQUIPMENTS: Record<
| EquipmentType.SUBSTATION
| EquipmentType.VOLTAGE_LEVEL
| EquipmentType.LINE
| EquipmentType.TWO_WINDINGS_TRANSFORMER
| EquipmentType.THREE_WINDINGS_TRANSFORMER
| EquipmentType.GENERATOR
| EquipmentType.BATTERY
| EquipmentType.LOAD
| EquipmentType.SHUNT_COMPENSATOR
| EquipmentType.STATIC_VAR_COMPENSATOR
| EquipmentType.HVDC_LINE
| EquipmentType.DANGLING_LINE,
FormEquipment
> = {
SUBSTATION: {
id: 'SUBSTATION',
label: 'Substations',
fields: [countries],
},
VOLTAGE_LEVEL: {
id: 'VOLTAGE_LEVEL',
label: 'VoltageLevels',
fields: [countries, nominalVoltage],

// order is important
export const FILTER_EQUIPMENT_TYPES: Partial<Record<EquipmentType, { label?: string }>> = {
[EquipmentType.SUBSTATION]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.SUBSTATION],
},
LINE: {
id: 'LINE',
label: 'Lines',
fields: [countries1, countries2, nominalVoltage1, nominalVoltage2],
[EquipmentType.VOLTAGE_LEVEL]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.VOLTAGE_LEVEL],
},
TWO_WINDINGS_TRANSFORMER: {
id: 'TWO_WINDINGS_TRANSFORMER',
label: 'TwoWindingsTransformers',
fields: [countries, nominalVoltage1, nominalVoltage2],
[EquipmentType.LINE]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.LINE],
},
THREE_WINDINGS_TRANSFORMER: {
id: 'THREE_WINDINGS_TRANSFORMER',
label: 'ThreeWindingsTransformers',
fields: [countries, nominalVoltage1, nominalVoltage2, nominalVoltage3],
[EquipmentType.TWO_WINDINGS_TRANSFORMER]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.TWO_WINDINGS_TRANSFORMER],
},
GENERATOR: {
id: 'GENERATOR',
label: 'Generators',
fields: [countries, energySource, nominalVoltage],
[EquipmentType.THREE_WINDINGS_TRANSFORMER]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.THREE_WINDINGS_TRANSFORMER],
},
BATTERY: {
id: 'BATTERY',
label: 'Batteries',
fields: [countries, nominalVoltage],
[EquipmentType.GENERATOR]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.GENERATOR],
},
LOAD: {
id: 'LOAD',
label: 'Loads',
fields: [countries, nominalVoltage],
[EquipmentType.BATTERY]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.BATTERY],
},
SHUNT_COMPENSATOR: {
id: 'SHUNT_COMPENSATOR',
label: 'ShuntCompensators',
fields: [countries, nominalVoltage],
[EquipmentType.LOAD]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.LOAD],
},
STATIC_VAR_COMPENSATOR: {
id: 'STATIC_VAR_COMPENSATOR',
label: 'StaticVarCompensators',
fields: [countries, nominalVoltage],
[EquipmentType.SHUNT_COMPENSATOR]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.SHUNT_COMPENSATOR],
},
HVDC_LINE: {
id: 'HVDC_LINE',
label: 'Hvdc',
fields: [countries1, countries2, nominalVoltage],
[EquipmentType.STATIC_VAR_COMPENSATOR]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.STATIC_VAR_COMPENSATOR],
},
DANGLING_LINE: {
id: 'DANGLING_LINE',
label: 'DanglingLines',
fields: [countries, nominalVoltage],
[EquipmentType.DANGLING_LINE]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.DANGLING_LINE],
},
[EquipmentType.HVDC_LINE]: {
...BASE_INFOS_EQUIPMENT_TYPES[EquipmentType.HVDC_LINE],
},
};
4 changes: 2 additions & 2 deletions src/hooks/useModificationLabelComputer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useIntl } from 'react-intl';
import { useCallback } from 'react';
import { UUID } from 'crypto';
import { MODIFICATION_TYPES } from '../utils/types/modificationType';
import { EQUIPMENT_TYPE } from '../utils/types/equipmentType';
import { EquipmentType } from '../utils/types/equipmentType';

export interface NetworkModificationMetadata {
uuid: UUID;
Expand Down Expand Up @@ -70,7 +70,7 @@ export const useModificationLabelComputer = () => {
case MODIFICATION_TYPES.BY_FILTER_DELETION.type:
return intl.formatMessage({
id:
modificationMetadata.equipmentType === EQUIPMENT_TYPE.HVDC_LINE
modificationMetadata.equipmentType === EquipmentType.HVDC_LINE
? 'Hvdc'
: modificationMetadata.equipmentType,
});
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en/equipmentSearchEn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const equipmentSearchEn = {
'equipment_search/shuntTag': 'SHUNT',
'equipment_search/svcTag': 'SVC',
'equipment_search/hvdcLineTag': 'HVDC LINE',
'equipment_search/hvdcLineVscTag': 'HVDC LINE (VSC)',
'equipment_search/hvdcLineLccTag': 'HVDC LINE (LCC)',
'equipment_search/hvdcStationTag': 'HVDC STATION',
'equipment_search/voltageLevelTag': 'VOLTAGE LEVEL',
'equipment_search/substationTag': 'SUBSTATION',
Expand Down
2 changes: 2 additions & 0 deletions src/translations/fr/equipmentSearchFr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const equipmentSearchFr = {
'equipment_search/shuntTag': 'MCS',
'equipment_search/svcTag': 'CSPR',
'equipment_search/hvdcLineTag': 'LIGNE HVDC',
'equipment_search/hvdcLineVscTag': 'LIGNE HVDC (VSC)',
'equipment_search/hvdcLineLccTag': 'LIGNE HVDC (LCC)',
'equipment_search/hvdcStationTag': 'STATION HVDC',
'equipment_search/voltageLevelTag': 'POSTE',
'equipment_search/substationTag': 'SITE',
Expand Down
Loading
Loading