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

Network map viewer built with Vite #267

Merged
merged 4 commits into from
Dec 18, 2023
Merged

Network map viewer built with Vite #267

merged 4 commits into from
Dec 18, 2023

Conversation

CBiasuzzi
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

Alternative build tool used for the network-map-viewer component.

Same context as the one in PR #263
(please refer to it for details).
The component's code has not changed, with respect to the branch referenced in PR #263
The difference lies in the building phase, for which Vite is used, instead of Webpack
(compared to Webpack Vite offers some advantages, such as simpler configurations).

@capyq
Copy link

capyq commented Nov 15, 2023

Globaly, it would be better to switch to typescript it will reveal a lot of bug.
I notice to much confusion between "null" and "undefined".
it's not a javaScript way to handle Object by using the class Map. it's better to use JSON Object.

network-map-viewer/.npmrc Outdated Show resolved Hide resolved
network-map-viewer/demo/.npmrc Outdated Show resolved Hide resolved
network-map-viewer/demo/package.json Outdated Show resolved Hide resolved
network-map-viewer/demo/package.json Outdated Show resolved Hide resolved
network-map-viewer/demo/package.json Outdated Show resolved Hide resolved
Comment on lines 128 to 132
substation.voltageLevels.find((v) =>
props.filteredNominalVoltages.includes(
v.nominalVoltage
)
) !== undefined
Copy link

Choose a reason for hiding this comment

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

separate in two lines we don't understand what should not be undefined

[useName]
);

const getUseNameParameterKey = useCallback(() => {
Copy link

Choose a reason for hiding this comment

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

this method is never used

Comment on lines 13 to 19
if (infos != null) {
const name = infos.name;
return useName && name != null && name.trim() !== ''
? name
: infos?.id;
}
return null;
Copy link

Choose a reason for hiding this comment

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

you are mixing null and undefined
1 - if infos is undefined you also should return null (or undefined) => if (!infos){...}
2 - why testing infos?.id but not infos.name ?

Comment on lines 9 to 23
if (nominalVoltage >= 300) {
return [255, 0, 0];
} else if (nominalVoltage >= 170 && nominalVoltage < 300) {
return [34, 139, 34];
} else if (nominalVoltage >= 120 && nominalVoltage < 170) {
return [1, 175, 175];
} else if (nominalVoltage >= 70 && nominalVoltage < 120) {
return [204, 85, 0];
} else if (nominalVoltage >= 50 && nominalVoltage < 70) {
return [160, 32, 240];
} else if (nominalVoltage >= 30 && nominalVoltage < 50) {
return [255, 130, 144];
} else {
return [171, 175, 40];
}
Copy link

Choose a reason for hiding this comment

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

those are not else if but only if and you don't need else case because you return each statement

@@ -0,0 +1,4 @@
{
"tabWidth": 4,
Copy link

Choose a reason for hiding this comment

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

you shouldn't use tabWith : 4 with the linewith 80.
so many line goes to 2 lines or more

@@ -457,16 +426,14 @@ const NetworkMap = (props) => {
};

const renderOverlay = () => (
Copy link

Choose a reason for hiding this comment

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

It's not a good practice to use variable to store component React doesn't tag this as react component and re-render it more than needed.

@flo-dup
Copy link
Contributor

flo-dup commented Dec 12, 2023

@capyq, could you confirm that all the comments you wrote about the packaging were answered by @CBiasuzzi ? So that we can merge this pull request, or modify further on those aspects if the changes are not satisfying.

For the other comments, I'll create an issue in this repository, but I'd prefer that we do not touch the gridsuite code at all before they integrate the viewer, I mean before gridsuite/gridstudy-app#1323 is merged. Indeed any changes here in the viewer code would be annoying when updating the viewer with latest changes from gridsuite. Or we should apply all those changes both on the viewer here and on the gridsuite repository, which also doubles the work.

@capyq
Copy link

capyq commented Dec 12, 2023

@capyq, could you confirm that all the comments you wrote about the packaging were answered by @CBiasuzzi ? So that we can merge this pull request, or modify further on those aspects if the changes are not satisfying.

For the other comments, I'll create an issue in this repository, but I'd prefer that we do not touch the gridsuite code at all before they integrate the viewer, I mean before gridsuite/gridstudy-app#1323 is merged. Indeed any changes here in the viewer code would be annoying when updating the viewer with latest changes from gridsuite. Or we should apply all those changes both on the viewer here and on the gridsuite repository, which also doubles the work.

Ok for me.

Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
…uilt with vite; removes unused dependencies

Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
Copy link

sonarcloud bot commented Dec 18, 2023

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@flo-dup
Copy link
Contributor

flo-dup commented Dec 18, 2023

As mentioned above, the remaining comments are on the code extracted from github.com/gridsuite/gridstudy-app and will be considered when the extracted component will be integrated there. An issue (#268) has been created to track down those comments.

@flo-dup flo-dup merged commit f535583 into main Dec 18, 2023
6 checks passed
@flo-dup flo-dup deleted the network_map_viewer_vitejs branch December 18, 2023 15:06
flo-dup added a commit that referenced this pull request Apr 15, 2024
This reverts commit f535583.

Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
flo-dup added a commit that referenced this pull request Apr 15, 2024
* Revert "Network map viewer built with Vite (#267)": This reverts commit f535583.
* Revert "network-map-viewer react component (extracted from gridsuite' gridstudy-app) (#263)": This reverts commit 58f6214.

Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants