-
Notifications
You must be signed in to change notification settings - Fork 7
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
Tech - Nettoyage des states redux #3687
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4e0b5fb
Fix redux serialize issues and few warnings
louptheron b012198
Remove monitorenvApi from observed actions
louptheron d388e35
Fix few cypress tests
louptheron 081b9a7
Fix non-serializable measurement objects stored in redux
louptheron 5a411b2
Use persistor to use localstorage and fix deletion of measurement
louptheron d18720f
Refactor and fix measurement layer
louptheron 5e2f5ce
Prefix styled component prop in InfractionsSummary
ivangabriele bce24ff
Fix cloning of object
louptheron 748aaab
Add ADR
louptheron 2eb8883
Update ADR
louptheron 2802037
Update ADR
louptheron d520eda
Update 0007-side_window_rework.md
louptheron 3428112
Update 0007-side_window_rework.md
louptheron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Refonte de la deuxième fenêtre (`SideWindow`) | ||
|
||
Date: 2024-09-25 | ||
|
||
## Statut | ||
|
||
Résolu | ||
|
||
## Contexte | ||
|
||
Nous utilisons la libairie react-new-window dans monitor-ui. | ||
|
||
Le ticket [#3211](https://github.com/MTES-MCT/monitorfish/issues/3211) est impactant pour les utilisateurs : il empêche le clic dans un `<Select/>` après avoir scrollé dans une liste. | ||
|
||
Le bug est reproductible seulement dans `window.open()`, avec notre implémentation de `NewWindow`. | ||
|
||
Il provient de la librairie `react-window`, utilisée par `rsuite`: [`react-window` désactive `pointer-events` lors du scroll](https://github.com/bvaughn/react-window/issues/128) | ||
|
||
> Les portals semblent plus adaptés aux scénarios simples dans un seul contexte DOM, tandis que l'approche avec BroadcastChannel et une nouvelle URL semble plus robuste pour des interfaces complexes réparties sur plusieurs fenêtres. | ||
|
||
## Option 1 - React portal | ||
|
||
Nous avions copié la libairie `react-new-window` dans [monitor-ui](https://github.com/MTES-MCT/monitor-ui/blob/d1294389097d528637c481ada8ea9ad1514f2640/src/components/NewWindow.tsx#L44) : | ||
- Utilise `ReactDOM.createPortal()` | ||
- Copie de tous les styles à la main | ||
|
||
Avantages : | ||
1. Chargement rapide: Un React Portal vous permet d'injecter un composant dans une autre partie du DOM sans quitter l'application principale, ce qui permet de ne pas re-charger les assets de l'application. | ||
2. Sans communication interfenêtres : Pas besoin d'utiliser des mécanismes complexes de synchronisation, tout se passe dans la même instance de React. | ||
|
||
Inconvénients : | ||
1. Il y a des bugs d'affichages (notamment sur des `<Select />` contenant beaucoup d'éléments) | ||
2. Si la première fenêtre est supprimée, la deuxième est orpheline (clic impossible) | ||
|
||
## Option 2 - Nouvelle fenêtre synchronisée avec `BroadcastChannel` | ||
|
||
Implémentation dans cette PR : https://github.com/MTES-MCT/monitorfish/pull/3668 | ||
|
||
Avantages : | ||
1. Séparation claire des responsabilités : Chaque fenêtre a son propre cycle de vie et son propre DOM, ce qui rend la gestion des deux interfaces plus propre et modulaire. | ||
2. Communication efficace : BroadcastChannel est conçu pour la synchronisation des états entre différentes fenêtres, ce qui permet une synchronisation rapide et efficace sans prop drilling ou complexité supplémentaire. | ||
|
||
Inconvénients : | ||
1. Complexité de la gestion de l’état : Il est nécessaire de gérer la logique de synchronisation entre les fenêtres manuellement, ce qui peut introduire des erreurs si les états deviennent désynchronisés. | ||
2. Temps de chargement : Ouvrir une nouvelle URL nécessite un chargement complet d’une nouvelle page, ce qui augmente le temps de réponse initial par rapport à un React Portal. | ||
3. `RTK Query` ne peut pas être synchronisé avec `BroadcastChannel`, à cause des objets passés non-sérialisables. Cela induit: | ||
- Une multiplication des requêtes APIs (dans la side window et main window) lorsqu'il y a un refraichissement demander par une action redux | ||
- Une dé-synchronisation des states RTK lorsque des refaichissement passent directement par des hooks RTK et non pas par des actions redux | ||
4. Il faut limiter le nombre de fenêtres pour éviter: | ||
- Une deuxième fenêtre MainWindow peut penser avoir un état (stocké dans redux), mais n'a pas l'état RTK correspondant | ||
- Une troisième fenêtre SideWindow ne sera pas synchronisée avec la deuxième fenêtre SideWindow ; cela peut avoir des impacts lors de modifications par APIs | ||
|
||
## Décision | ||
|
||
Nous allons rester sur l'option 1 et fixer le bug avec : https://github.com/MTES-MCT/monitor-ui/pull/1382 | ||
|
||
## Conséquences | ||
|
||
Nous n'allons pas changer de méthode pour lancer une side-window. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module version="4"> | ||
<component name="NewModuleRootManager"> | ||
<content url="file://$MODULE_DIR$" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
frontend/src/domain/use_cases/measurement/saveMeasurement.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bien vu, sauf pour les 1er point point : ça ne change pas les tests d'interactions avec Cypress selon moi (sauf si j'ai raté quelque chose ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah non c'est moi qui ait sûrement mal compris, je pensais qu'on pouvait tester plusieurs tabs ouverts simultanément en utilisant Cypress.