-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix/prevent re-render reports menu #1252
base: master
Are you sure you want to change the base?
Conversation
const ReportsLayout = () => ( | ||
<PageLayout | ||
menu={<ReportsMenu />} | ||
breadcrumbs={['reportTitle', 'reportCombined']} |
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.
The breadcrumbs is different per report.
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.
@@ -154,7 +155,7 @@ const Navigation = () => { | |||
<Route path="user" element={<UserPage />} /> | |||
</Route> | |||
|
|||
<Route path="reports"> | |||
<Route path="reports" element={<ReportsLayout />}> |
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.
Should we do the same thing for settings?
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.
It seems to me that yes, in the components that have the same design.
It would be necessary to analyze it because I do not see that the state update generated by the socket is rendering the settings menu.
I apologize for any translation errors, my language is Spanish and I am using a translator.
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.
Can you please update settings as well, so we have consistent codebase.
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.
Of course, let me see what I can do.
Can you please clarify how this fixes the problem. |
Response to comment #1252 (comment) Child components are affected by the rendering of the parent or container component. |
'/reports/combined': ['reportTitle', 'reportCombined'], | ||
'/reports/route': ['reportTitle', 'reportRoute'], | ||
'/reports/event': ['reportTitle', 'reportEvents'], | ||
'/reports/trip': ['reportTitle', 'reportTrips'], | ||
'/reports/stop': ['reportTitle', 'reportStops'], | ||
'/reports/summary': ['reportTitle', 'reportSummary'], | ||
'/reports/chart': ['reportTitle', 'reportChart'], | ||
'/reports/logs': ['reportTitle', 'statisticsTitle'], | ||
'/reports/scheduled': ['settingsTitle', 'reportScheduled'], | ||
'/reports/statistics': ['reportTitle', 'statisticsTitle'], |
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.
You probably don't need to duplicate 'reportTitle'
everywhere. Just the second part is different.
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.
I made this change, what do you think? 395ada3
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.
I found that being part was different-> '/reports/scheduled': ['settingsTitle', 'reportScheduled'],
traccar-web/src/reports/ScheduledPage.jsx
Line 65 in 66b964c
<PageLayout menu={<ReportsMenu />} breadcrumbs={['settingsTitle', 'reportScheduled']}> |
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.
This is probably a mistake. All of them should be under reports.
import ReportsMenu from './ReportsMenu'; | ||
|
||
const routes = { | ||
reports: { |
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.
Why do we need a nested JSON here. I think reports
property should be removed. This is only reports anyway.
const commondBreadcrumb = 'settingsTitle'; | ||
|
||
const routes = { | ||
settings: { |
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.
Same here
}, | ||
}; | ||
|
||
const compoundRoutes = { |
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.
This looks really complicated. Why do we need all of these? I think you should be able to split it by path segements.
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.
What do you think of this alternative?
https://gist.github.com/jorgeart81/6140d1afeab31ae690b11eedf8dca106
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.
Seems like it's still overcomplicated. Why can't we just append to an array? Something like:
let breadcrumbs = ['settingsTitle'];
if (length >= 2) {
breadcrumbs.add(routes[pathSegmets[1]);
}
if (length >= 3) {
switch ...
}
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.
The other PR looks promising, if it works as expected. Commented there.
Create a ReportLayout so that the ReportsMenu is not affected by the status update.
Ref -> PR/1251
Video
2024-06-28.18-54-18.mp4