Skip to content

Conversation

@jorgeart81
Copy link
Contributor

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

const ReportsLayout = () => (
<PageLayout
menu={<ReportsMenu />}
breadcrumbs={['reportTitle', 'reportCombined']}
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's true, I hadn't noticed it.
I made these changes to fix it.

</Route>

<Route path="reports">
<Route path="reports" element={<ReportsLayout />}>
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@tananaev
Copy link
Member

Can you please clarify how this fixes the problem.

@jorgeart81
Copy link
Contributor Author

jorgeart81 commented Jun 29, 2024

Response to comment #1252 (comment)

Child components are affected by the rendering of the parent or container component.
In this case, when converting <PageLayout menu={<ReportsMenu />} Breadcrumbs={['reportTitle', 'reportCombined']}> to the parent container, the change of state of the children only affects their content, therefore the component main (Layout) is not affected.

Comment on lines 7 to 16
'/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'],
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

@jorgeart81 jorgeart81 Jun 29, 2024

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'],

<PageLayout menu={<ReportsMenu />} breadcrumbs={['settingsTitle', 'reportScheduled']}>

Copy link
Member

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: {
Copy link
Member

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: {
Copy link
Member

Choose a reason for hiding this comment

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

Same here

},
};

const compoundRoutes = {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

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 ...
}

Copy link
Contributor Author

@jorgeart81 jorgeart81 Jul 2, 2024

Choose a reason for hiding this comment

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

I understand your points of view. I think that although it works for the current context, using push would not be correct because push is used to add elements to an array, every time it is called.

I propose another solution so as not to affect the structure of your code too much. PR -> #1253

Copy link
Member

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.

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.

2 participants