Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ interface RootNetworkSearchPanelProps {
}

function getModificationResultsCount(results: ModificationsSearchResult[]): number {
return results.reduce((sum, node) => {
const countForNode = node.modifications.reduce((innerSum, modif) => {
return innerSum + modif.impactedEquipmentIds.length;
}, 0);
return sum + countForNode;
}, 0);
return results.reduce((sum, r) => sum + r.modifications.length, 0);
}

function getNodeResultsCount(results: string[]): number {
Expand Down Expand Up @@ -132,11 +127,14 @@ const RootNetworkSearchPanel: React.FC<RootNetworkSearchPanelProps> = ({ setIsSe
<Box sx={styles.searchField}>
<SearchBar
placeholder={intl.formatMessage({
id: 'searchPlaceholder',
})}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
placeholder={intl.formatMessage({
id: 'searchPlaceholder',
})}

remove placeholder ? the label usage is sufficient no ?

value={searchTerm}
label={intl.formatMessage({
id: isNodeTab(tabValue)
? 'rootNetwork.searchPlaceholder.nodes'
: 'rootNetwork.searchPlaceholder.modifications',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
? 'rootNetwork.searchPlaceholder.nodes'
: 'rootNetwork.searchPlaceholder.modifications',
? 'rootNetwork.searchLabel.nodes'
: 'rootNetwork.searchLabel.modifications',

})}
value={searchTerm}
onChange={handleOnChange}
onClear={leaveSearch}
/>
Expand All @@ -149,21 +147,14 @@ const RootNetworkSearchPanel: React.FC<RootNetworkSearchPanelProps> = ({ setIsSe
)}
{showResultsCount && (
<Typography variant="body2" sx={{ mt: 1, color: 'gray' }}>
{isNodeTab(tabValue) ? (
<FormattedMessage
id="rootNetwork.nodeResults"
values={{
count: getNodeResultsCount(nodesSearch.results),
}}
/>
) : (
<FormattedMessage
id="rootNetwork.modificationResults"
values={{
count: getModificationResultsCount(modificationsSearch.results),
}}
/>
)}
<FormattedMessage
id="rootNetwork.results"
values={{
count: isNodeTab(tabValue)
? getNodeResultsCount(nodesSearch.results)
: getModificationResultsCount(modificationsSearch.results),
}}
/>
</Typography>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ import React from 'react';
interface SearchBarProps {
readonly placeholder: string;
readonly value: string;
readonly label?: string;
readonly onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
readonly onClear: () => void;
}

export default function SearchBar({ placeholder, value, onChange, onClear }: SearchBarProps) {
export default function SearchBar({ placeholder, value, label, onChange, onClear }: SearchBarProps) {
return (
<>
<TextField
fullWidth
variant="outlined"
placeholder={placeholder}
value={value}
label={label}
onChange={onChange}
size="small"
InputProps={{
Expand Down
7 changes: 3 additions & 4 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1446,12 +1446,11 @@
"updateRootNetworksError": "An error occurred while updating the root network",
"visibleRootNetwork": "Visible network : ",
"rootNetwork.modificationsInfos": "Only modifications in built nodes and their parent nodes will appear in the results.",
"rootNetwork.searchPlaceholder.modifications": "Search for a modified equipment",
"rootNetwork.searchPlaceholder.nodes": "Search for a node",
"rootNetwork.searchPlaceholder.modifications": "Search equipment",
"rootNetwork.searchPlaceholder.nodes": "Search node",
"rootNetwork.modificationTab": "Modifications",
"rootNetwork.nodeTab": "Nodes",
"rootNetwork.nodeResults": "{count, plural, =0 {No result} =1 {# result} other {# results}}",
"rootNetwork.modificationResults": "{count, plural, =0 {No equipment found} =1 {# equipment found} other {# equipments found}}",
"rootNetwork.results": "{count, plural, =0 {No result} =1 {# result} other {# results}}",
"rootNetwork.loading": "Loading...",
"rootNetwork.originalNotFound": "The original case was not found",
"rootNetwork.unknownPath": "<Unknown>",
Expand Down
7 changes: 3 additions & 4 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1448,12 +1448,11 @@
"importCaseFailure": "Impossible d'importer la situation",
"modificationActivationByRootNetworkError": "Une erreur est survenue lors de l'activation / désactivation de la modification par réseau racine",
"rootNetwork.modificationsInfos": "Seules les modifications dans les nœuds réalisés et leurs nœuds parents apparaitront dans les résultats.",
"rootNetwork.searchPlaceholder.modifications": "Rechercher un ouvrage modifié…",
"rootNetwork.searchPlaceholder.nodes": "Rechercher un nœud...",
"rootNetwork.searchPlaceholder.modifications": "Rechercher un ouvrage",
"rootNetwork.searchPlaceholder.nodes": "Rechercher un nœud",
"rootNetwork.modificationTab": "Modifications",
"rootNetwork.nodeTab": "Nœuds",
"rootNetwork.nodeResults": "{count, plural, =0 {Aucun résultat} =1 {# résultat} other {# résultats}}",
"rootNetwork.modificationResults": "{count, plural, =0 {Aucun ouvrage trouvé} =1 {# ouvrage trouvé} other {# ouvrages trouvés}}",
"rootNetwork.results": "{count, plural, =0 {Aucun résultat} =1 {# résultat} other {# résultats}}",
"rootNetwork.loading": "Chargement...",
"rootNetwork.originalNotFound": "La situation d'origine est introuvable",
"rootNetwork.unknownPath": "<Inconnu>",
Expand Down
Loading