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

Integrate TimePeriods into DetailsTabs (Graph) #4146

Merged
merged 15 commits into from
May 27, 2024
Merged

Conversation

Noha-ElAbrouki
Copy link
Contributor

@Noha-ElAbrouki Noha-ElAbrouki commented May 20, 2024

Description: Integrate TimePeriods into DetailsTabs (Graph)

video

screen-capture.26.webm

Copy link
Contributor

coderabbitai bot commented May 20, 2024

Walkthrough

The recent updates involve refactoring imports, enhancing time period functionalities, and adjusting styling properties. Key changes include converting default exports to named exports, adding new props and interfaces, and updating component logic for better flexibility and performance. These improvements span across various files, focusing on time period management, graph rendering, and UI styling adjustments.

Changes

Files/Paths Change Summary
centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx Changed useTimeShiftZones from default to named import.
centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts Converted useTimeShiftZones function to a named export.
centreon/packages/ui/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts Adjusted styling properties for buttons and date/time containers.
centreon/packages/ui/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx Added isCondensed prop to CompactCustomTimePeriod component for conditional styling.
centreon/packages/ui/src/TimePeriods/index.tsx Introduced isCondensed prop in CustomTimePeriod component for more customization.
centreon/packages/ui/src/TimePeriods/TimePeriods.styles.ts Updated useStyles function with new styling properties.
centreon/packages/ui/src/TimePeriods/TimePeriods.tsx Added width parameter to TimePeriods component.
centreon/packages/ui/src/TimePeriods/models.ts Added new interfaces and properties for time period management.
centreon/packages/ui/src/TimePeriods/useTimePeriod.ts Updated imports and function signature to use WrapperTimePeriodProps.
centreon/packages/ui/src/utils/index.ts Added exports for helper functions related to LineChart and InteractiveComponents.
centreon/www/front_src/src/Resources/Details/models.ts Added service_id field to ResourceDetails interface.
centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx Refactored imports, added state for graphTimeParameters, and updated component logic.
centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx Added state for graphTimeParameters, refactored imports, and updated rendering logic.
centreon/www/front_src/src/Resources/Details/tabs/Graph/models.ts Introduced GraphTimeParameters interface.
centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx Added graphTimeParameters property to Props and ServiceGraphs component.
centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/GraphOptions.tsx Added Typography component and updated label text wrapping in Options component.
centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/atoms.ts Introduced updatedGraphIntervalAtom for managing updated graph intervals.
centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/index.tsx Refactored imports, removed unused functions, and updated rendering logic for performance graph.
centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/models.ts Introduced UpdatedGraphInterval interface.
centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/Zone.tsx Introduced useTimeShiftZones and updatedGraphIntervalAtom affecting time shifting and graph intervals logic.
centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/index.tsx Added end property and modified shiftTime function signature in TimeShiftContextProps interface.
centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx Refactored imports, removed unused functions, and updated interface properties and function signatures.
centreon/www/front_src/src/Resources/Graph/Performance/GraphActions.tsx Removed useAtomValue, adjusted handling of start and end properties, and updated GraphActions component.
centreon/www/front_src/src/Resources/Graph/Performance/index.tsx Refactored imports, removed unused functions, and adjusted props in PerformanceGraph component.

In fields of code where logic grows,
Refactors bring the gentle flows.
Props and states now finely tuned,
Graphs and styles in harmony crooned.
🐇✨


Tip

Early Access Features
  • gpt-4o model for chat

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Noha-ElAbrouki Noha-ElAbrouki marked this pull request as ready for review May 24, 2024 16:25
@Noha-ElAbrouki Noha-ElAbrouki requested a review from a team as a code owner May 24, 2024 16:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Outside diff range and nitpick comments (13)
centreon/packages/ui/src/TimePeriods/useTimePeriod.ts (1)

Line range hint 12-40: Ensure all dependencies are specified in the useEffect hooks to avoid issues with stale closures or missing updates.

-  }, [adjustTimePeriodData?.start, adjustTimePeriodData?.end]);
+  }, [adjustTimePeriodData, adjustTimeTimePeriod, adjustTimePeriodData?.start, adjustTimePeriodData?.end]);

-  }, [customTimePeriod.start, customTimePeriod.end, selectedTimePeriod]);
+  }, [customTimePeriod, getCurrentEndStartInterval, getParameters, selectedTimePeriod]);

-  }, [errorTimePeriod]);
+  }, [errorTimePeriod, getIsError]);
centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts (1)

Line range hint 14-52: Refactor the useEffect dependencies to include getShiftedDate and ensure graphInterval is used correctly.

-  }, [graphInterval.end, graphInterval.start, direction]);
+  }, [getShiftedDate, graphInterval, direction]);
centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/GraphOptions.tsx (1)

Line range hint 9-10: Consider using import type for imports that are only used for type annotations to prevent them from being included in the JavaScript bundle.

- import { GraphOption, GraphOptions } from '../../../Details/models';
+ import type { GraphOption, GraphOptions } from '../../../Details/models';
centreon/www/front_src/src/Resources/Details/models.ts (1)

Line range hint 1-12: Consider using import type for imports that are only used for type annotations to prevent them from being included in the JavaScript bundle.

- import { AcknowledgementDetails, Downtime, NamedEntity, Parent, ResourceLinks, ResourceShortType, ResourceType, Severity, Status } from '../models';
+ import type { AcknowledgementDetails, Downtime, NamedEntity, Parent, ResourceLinks, ResourceShortType, ResourceType, Severity, Status } from '../models';

- import { CustomTimePeriod, TimePeriodId } from './tabs/Graph/models';
+ import type { CustomTimePeriod, TimePeriodId } from './tabs/Graph/models';

Also applies to: 13-14

centreon/www/front_src/src/Resources/Listing/columns/Graph.tsx (3)

Line range hint 13-14: Consider using TypeScript's import type for imports that are only used as types to clarify their usage and potentially improve build performance.

- import { ComponentColumnProps } from '@centreon/ui';
+ import type { ComponentColumnProps } from '@centreon/ui';

Line range hint 20-21: Imports from @mui/icons-material/BarChart and @mui/material/Paper are only used as types. Use import type to make this explicit.

- import IconGraph from '@mui/icons-material/BarChart';
- import { Paper } from '@mui/material';
+ import type IconGraph from '@mui/icons-material/BarChart';
+ import type { Paper } from '@mui/material';

Line range hint 62-62: The useEffect hook is missing dependencies. To avoid potential bugs, include all variables used inside the hook in its dependency array.

-  }, []);
+  }, [setIsListingGraphOpen, changeMousePositionAndTimeValue]);
centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/index.tsx (1)

Line range hint 142-142: The useEffect hooks are either missing dependencies or specifying more than necessary. Ensure that all variables used inside the hook are included in its dependency array, and remove unnecessary dependencies.

-  }, [endpoint, displayEventAnnotations, end, start]);
+  }, [endpoint, retrieveTimeline]);

-  }, []);
+  }, [setElement]);

-  }, [details, end, start]);
+  }, [endpoint, end, start]);

Also applies to: 150-150, 154-154

centreon/www/front_src/src/Resources/decoders.ts (1)

Line range hint 2-8: Imports from various directories are only used as types. Use import type to make this explicit.

- import { JsonDecoder } from 'ts.data.json';
- import { Category, Group, ResourceDetails, Sensitivity } from './Details/models';
- import { AcknowledgementDetails, Downtime, Icon, Notes, Parent, Resource, ResourceEndpoints, ResourceExternals, ResourceLinks, ResourceShortType, ResourceType, ResourceUris, Severity, Status } from './models';
+ import type { JsonDecoder } from 'ts.data.json';
+ import type { Category, Group, ResourceDetails, Sensitivity, AcknowledgementDetails, Downtime, Icon, Notes, Parent, Resource, ResourceEndpoints, ResourceExternals, ResourceLinks, ResourceShortType, ResourceType, ResourceUris, Severity, Status } from './models';

Also applies to: 8-24

centreon/www/front_src/src/Resources/Graph/Performance/index.tsx (2)

Line range hint 1-7: Several imports are only used as types. Use import type to make this explicit.

- import { MutableRefObject, ReactNode, useEffect, useRef, useState } from 'react';
- import { Skeleton, Typography } from '@mui/material';
- import { getData, ParentSize, timeFormat, useLocaleDateTimeFormat, useRequest } from '@centreon/ui';
- import { CommentParameters } from '../../Actions/api';
- import { selectedResourcesDetailsAtom } from '../../Details/detailsAtoms';
- import { ResourceDetails, TimelineEvent, Resource } from '../../Details/models';
+ import type { MutableRefObject, ReactNode };
+ import type { Skeleton, Typography };
+ import type { getData, ParentSize, timeFormat, useLocaleDateTimeFormat, useRequest };
+ import type { CommentParameters };
+ import type { selectedResourcesDetailsAtom };
+ import type { ResourceDetails, TimelineEvent, Resource };
+ import { useEffect, useRef, useState } from 'react';

Also applies to: 38-39, 40-41, 41-42, 42-43, 52-60


Line range hint 191-191: The useEffect hooks are either missing dependencies or specifying more than necessary. Ensure that all variables used inside the hook are included in its dependency array, and remove unnecessary dependencies.

-  }, [endpoint]);
+  }, [endpoint, sendGetGraphDataRequest, lineData]);

-  }, [selectedResource?.resourceId]);
+  }, [selectedResource?.resourceId, lineData]);

-  }, [performanceGraphRef]);
+  }, [getPerformanceGraphRef]);

Also applies to: 221-221, 235-235

centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx (2)

Line range hint 490-495: The tooltip title element should not be empty. Provide a meaningful title or remove the tooltip if it's not necessary.

- <Tooltip title={commentTitle}>
+ <Tooltip title={commentTitle || "Default Tooltip Title"}>

Line range hint 280-280: The useEffect hook for adding and removing the event listener does not specify all of its dependencies. Include hideAddCommentTooltipOnEspcapePress in the dependency array to ensure it captures the latest changes.

-  }, []);
+  }, [hideAddCommentTooltipOnEspcapePress]);
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between c8515ab and 5296c7f.
Files selected for processing (26)
  • centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx (1 hunks)
  • centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts (2 hunks)
  • centreon/packages/ui/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts (3 hunks)
  • centreon/packages/ui/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx (1 hunks)
  • centreon/packages/ui/src/TimePeriods/CustomTimePeriod/index.tsx (2 hunks)
  • centreon/packages/ui/src/TimePeriods/TimePeriods.styles.ts (1 hunks)
  • centreon/packages/ui/src/TimePeriods/TimePeriods.tsx (1 hunks)
  • centreon/packages/ui/src/TimePeriods/index.tsx (2 hunks)
  • centreon/packages/ui/src/TimePeriods/models.ts (2 hunks)
  • centreon/packages/ui/src/TimePeriods/useTimePeriod.ts (1 hunks)
  • centreon/packages/ui/src/utils/index.ts (1 hunks)
  • centreon/www/front_src/src/Resources/Details/models.ts (1 hunks)
  • centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx (3 hunks)
  • centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx (3 hunks)
  • centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx (3 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/GraphOptions.tsx (2 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/atoms.ts (1 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/index.tsx (10 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/models.ts (1 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/Zone.tsx (3 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/index.tsx (1 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx (8 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/GraphActions.tsx (8 hunks)
  • centreon/www/front_src/src/Resources/Graph/Performance/index.tsx (10 hunks)
  • centreon/www/front_src/src/Resources/Listing/columns/Graph.tsx (1 hunks)
  • centreon/www/front_src/src/Resources/decoders.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/models.ts
Additional Context Used
Biome (77)
centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx (2)

1-1: All these imports are only used as types.


8-9: All these imports are only used as types.

centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts (6)

4-5: Some named imports are only used as types.


6-7: Some named imports are only used as types.


52-52: This hook specifies a dependency more specific that its captures: graphInterval.start


52-52: This hook does not specify all of its dependencies: getShiftedDate


52-52: This hook specifies a dependency more specific that its captures: graphInterval.start


52-52: This hook does not specify all of its dependencies: graphInterval

centreon/packages/ui/src/TimePeriods/CustomTimePeriod/index.tsx (1)

1-1: Some named imports are only used as types.

centreon/packages/ui/src/TimePeriods/TimePeriods.tsx (2)

11-12: Some named imports are only used as types.


17-18: All these imports are only used as types.

centreon/packages/ui/src/TimePeriods/index.tsx (1)

12-13: All these imports are only used as types.

centreon/packages/ui/src/TimePeriods/models.ts (1)

1-1: All these imports are only used as types.

centreon/packages/ui/src/TimePeriods/useTimePeriod.ts (9)

11-12: All these imports are only used as types.


25-25: This hook specifies a dependency more specific that its captures: adjustTimePeriodData?.end


25-25: This hook does not specify all of its dependencies: adjustTimePeriodData


25-25: This hook specifies a dependency more specific that its captures: adjustTimePeriodData?.end


25-25: This hook does not specify all of its dependencies: adjustTimeTimePeriod


33-33: This hook does not specify all of its dependencies: getCurrentEndStartInterval


33-33: This hook does not specify all of its dependencies: getParameters


33-33: This hook specifies more dependencies than necessary: customTimePeriod.start, customTimePeriod.end


40-40: This hook does not specify all of its dependencies: getIsError

centreon/www/front_src/src/Resources/Details/models.ts (2)

1-12: All these imports are only used as types.


13-14: All these imports are only used as types.

centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx (2)

8-9: All these imports are only used as types.


12-13: All these imports are only used as types.

centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx (2)

6-7: All these imports are only used as types.


10-11: All these imports are only used as types.

centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx (3)

1-1: All these imports are only used as types.


5-6: All these imports are only used as types.


7-8: All these imports are only used as types.

centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/GraphOptions.tsx (1)

9-10: All these imports are only used as types.

centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/atoms.ts (1)

2-3: All these imports are only used as types.

centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/index.tsx (11)

1-8: Some named imports are only used as types.


13-14: Some named imports are only used as types.


21-22: All these imports are only used as types.


24-25: All these imports are only used as types.


25-26: All these imports are only used as types.


27-33: Some named imports are only used as types.


142-142: This hook does not specify all of its dependencies: retrieveTimeline


142-142: This hook specifies more dependencies than necessary: displayEventAnnotations, end, start


150-150: This hook does not specify all of its dependencies: setElement


154-154: This hook does not specify all of its dependencies: endpoint


154-154: This hook specifies more dependencies than necessary: details

centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/index.tsx (1)

14-14: This enum declaration contains members that are implicitly initialized.

centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx (11)

490-495: Alternative text title element cannot be empty


1-9: Some named imports are only used as types.


10-11: All these imports are only used as types.


36-37: All these imports are only used as types.


38-39: All these imports are only used as types.


39-40: All these imports are only used as types.


40-41: All these imports are only used as types.


47-48: All these imports are only used as types.


66-72: Some named imports are only used as types.


280-280: This hook does not specify all of its dependencies: hideAddCommentTooltipOnEspcapePress


589-589: This hook specifies more dependencies than necessary: margin

centreon/www/front_src/src/Resources/Graph/Performance/GraphActions.tsx (4)

1-1: Some named imports are only used as types.


18-19: All these imports are only used as types.


19-20: All these imports are only used as types.


21-22: All these imports are only used as types.

centreon/www/front_src/src/Resources/Graph/Performance/index.tsx (11)

1-7: Some named imports are only used as types.


38-39: All these imports are only used as types.


40-41: All these imports are only used as types.


41-42: All these imports are only used as types.


42-43: All these imports are only used as types.


52-60: All these imports are only used as types.


191-191: This hook does not specify all of its dependencies: lineData


191-191: This hook does not specify all of its dependencies: sendGetGraphDataRequest


221-221: This hook does not specify all of its dependencies: lineData


235-235: This hook does not specify all of its dependencies: getPerformanceGraphRef


235-235: This hook specifies more dependencies than necessary: performanceGraphRef

centreon/www/front_src/src/Resources/Listing/columns/Graph.tsx (4)

13-14: All these imports are only used as types.


20-21: All these imports are only used as types.


62-62: This hook does not specify all of its dependencies: changeMousePositionAndTimeValue


62-62: This hook does not specify all of its dependencies: setIsListingGraphOpen

centreon/www/front_src/src/Resources/decoders.ts (2)

2-8: All these imports are only used as types.


8-24: Some named imports are only used as types.

Additional comments not posted (21)
centreon/packages/ui/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts (1)

Line range hint 5-46: The new styles for the condensed layout are well-defined and follow the theme's spacing conventions.

centreon/packages/ui/src/utils/index.ts (1)

26-27: The new exports for helper functions related to LineChart and InteractiveComponents are correctly added and organized.

centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx (2)

34-35: Ensure graphTimeParameters is utilized correctly within the component logic.


55-55: LGTM! The graphTimeParameters prop is passed correctly to the ExportableGraphWithTimeline component.

centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx (1)

12-12: Correctly updated the import to reflect the named export change in useTimeShiftZones.

centreon/packages/ui/src/TimePeriods/CustomTimePeriod/index.tsx (2)

17-17: Added isCondensed prop to allow conditional rendering based on the component's condensed state.


49-49: Properly passed the isCondensed prop to the CompactCustomTimePeriod component.

centreon/packages/ui/src/TimePeriods/TimePeriods.tsx (1)

25-57: Ensure the new width prop is utilized correctly and integrates well with the responsive design logic.

centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/Zone.tsx (1)

Line range hint 36-67: Refactored to use the useTimeShiftZones hook and useSetAtom for state management, improving the component's reactivity and maintainability.

centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/index.tsx (1)

21-27: LGTM! The addition of start and end properties to TimeShiftContextProps supports enhanced time period management.

centreon/www/front_src/src/Resources/Graph/Performance/ExportableGraphWithTimeline/GraphOptions.tsx (1)

6-6: LGTM! Using Typography for labels enhances UI consistency and accessibility.

Also applies to: 72-72

centreon/www/front_src/src/Resources/Details/models.ts (1)

61-61: LGTM! The addition of service_id to ResourceDetails enhances linking resources with services, supporting detailed management and reporting.

centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx (1)

1-1: LGTM! The integration of TimePeriods with dynamic props and the use of state management hooks enhance the graph's functionality with flexible time period adjustments.

Also applies to: 7-7, 10-11, 19-20, 25-26, 52-54, 56-58, 63-69, 79-79

centreon/packages/ui/src/TimePeriods/models.ts (1)

101-112: LGTM! The addition of the Parameters interface and its integration into WrapperTimePeriodProps enhances the flexibility and configurability of time period management.

centreon/packages/ui/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx (1)

20-20: LGTM! The addition of the isCondensed prop and its usage in conditional rendering enhances the component's flexibility and maintainability.

Also applies to: 26-27, 49-51, 54-56, 78-80

centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx (6)

46-46: Ensure that the import of updatedGraphIntervalAtom is used appropriately in the component.


73-73: The import of TimeShiftZones and TimeShiftContext is correctly placed and used in the rendering logic.


Line range hint 195-207: The addition of end and start props to manage time boundaries is a good enhancement for handling time shifts in graphs.

Also applies to: 239-241


267-268: The use of useSetAtom for updatedGraphIntervalAtom is appropriate for managing state changes related to graph intervals.


592-607: The useMemo hook is used to optimize the rendering of TimeShiftZones. The dependencies listed are appropriate, ensuring that the component only re-renders when necessary.


400-400: The logic to update the graph interval based on zoom boundaries is correctly implemented. However, ensure that the updatedGraphInterval function is called with the correct context.

Verification successful

The search results indicate multiple instances of updatedGraphInterval being used across different files. To ensure that the function is called with the correct context, we need to examine these instances more closely.


The extracted context shows that the updatedGraphInterval function is used in various files and appears to be correctly implemented with the appropriate context. Here are the key observations:

  • In centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx, updatedGraphInterval is called with the zoom boundaries to update the graph interval.
  • In centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/Zone.tsx, setGraphInterval is used to set the new interval based on time shift zones.
  • In centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx and centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx, updatedGraphInterval is used to get the current graph interval and update it accordingly.

These usages indicate that the function is being called with the correct context and parameters.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `updatedGraphInterval` function is used correctly across the application.

# Test: Search for the function usage. Expect: Correct usage in context.
rg --type typescript $'updatedGraphInterval'

Length of output: 78



Script:

#!/bin/bash
# Description: Verify that the `updatedGraphInterval` function is used correctly across the application.

# Test: Search for the function usage. Expect: Correct usage in context.
rg --type ts 'updatedGraphInterval'

Length of output: 2063



Script:

#!/bin/bash
# Description: Extract the context of `updatedGraphInterval` usage to verify correct implementation.

# Extract lines around the usage in centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx
rg --context 5 'updatedGraphInterval' centreon/www/front_src/src/Resources/Graph/Performance/Graph/index.tsx

# Extract lines around the usage in centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/Zone.tsx
rg --context 5 'updatedGraphInterval' centreon/www/front_src/src/Resources/Graph/Performance/Graph/TimeShiftZones/Zone.tsx

# Extract lines around the usage in centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx
rg --context 5 'updatedGraphInterval' centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx

# Extract lines around the usage in centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx
rg --context 5 'updatedGraphInterval' centreon/www/front_src/src/Resources/Details/tabs/Graph/HostGraph.tsx

Length of output: 4656

Copy link

Code coverage report for centreon-packages-ui component 🚀

Coverage after merging MON-81801 into develop will be
72.56%
Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
centreon/packages/ui/src/Graph/LineChart/InteractiveComponents/TimeShiftZones
   TimeShiftZone.tsx85.71%100%75%90%49
   useTimeShiftZones.ts81.82%70%100%85%28–29, 38–39, 65–66
centreon/packages/ui/src/TimePeriods
   TimePeriods.styles.ts100%100%100%100%
   TimePeriods.tsx100%100%100%100%
   index.tsx100%100%100%100%
   models.ts100%100%100%100%
   useTimePeriod.ts84%50%100%88.24%26, 30, 41, 44
centreon/packages/ui/src/TimePeriods/CustomTimePeriod
   CompactCustomTimePeriod.styles.ts100%100%100%100%
   CompactCustomTimePeriod.tsx100%100%100%100%
   index.tsx57.14%100%25%70%31, 38, 42
centreon/packages/ui/src/utils
   index.ts100%100%100%100%

Copy link

Code coverage report for centreon component 🚀

Coverage after merging MON-81801 into develop will be
91.91%
Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
centreon/www/front_src/src/Resources
   decoders.ts100%100%100%100%
centreon/www/front_src/src/Resources/Details/tabs/Graph
   models.ts60%100%40%62.50%59, 68, 78
centreon/www/front_src/src/Resources/Listing/columns
   Graph.tsx56.36%77.78%46.15%54.55%142, 148, 148, 152, 156–157, 52–54, 58, 62–63, 65–67, 71, 83

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5296c7f and 65c86bf.
Files selected for processing (3)
  • centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx (3 hunks)
  • centreon/www/front_src/src/Resources/Details/tabs/Graph/models.ts (1 hunks)
  • centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx (3 hunks)
Additional Context Used
Biome (7)
centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx (3)

6-7: All these imports are only used as types.


10-11: All these imports are only used as types.


21-22: All these imports are only used as types.

centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx (4)

1-1: All these imports are only used as types.


5-6: All these imports are only used as types.


7-8: All these imports are only used as types.


8-9: All these imports are only used as types.

Additional comments not posted (8)
centreon/www/front_src/src/Resources/Details/tabs/Services/Graphs.tsx (3)

12-12: The Props interface now includes graphTimeParameters. Ensure that all usages of this prop are consistent with its definition in Graph/models.ts.


36-36: Ensure that graphTimeParameters is correctly passed to ExportableGraphWithTimeline and that its type aligns with the expected interface.


56-56: The graphTimeParameters prop is used here. Verify that the ExportableGraphWithTimeline component properly handles this prop, especially since it's a critical part of the graph rendering logic.

centreon/www/front_src/src/Resources/Details/tabs/Graph/models.ts (1)

82-86: The new GraphTimeParameters interface is well-defined and aligns with the requirements for managing graph time parameters. Ensure that all components using this interface are updated to handle the new fields correctly.

centreon/www/front_src/src/Resources/Details/tabs/Graph/index.tsx (4)

1-1: The use of useState is appropriate for managing state in this component. Ensure that the state initialization and updates are handled correctly throughout the component lifecycle.


50-52: The state graphTimeParameters is initialized here. Ensure that the default state aligns with the expected structure of GraphTimeParameters.


73-75: This function getTimePeriodsParameters correctly updates the state. Ensure that it is used appropriately wherever time period parameters need to be updated.


122-125: The TimePeriods component is used here with the newGraphInterval and getTimePeriodsParameters. Verify that these props are handled correctly in the TimePeriods component to ensure proper functionality.

Verification successful

The TimePeriods component is defined in centreon/packages/ui/src/TimePeriods/TimePeriods.tsx. The props adjustTimePeriodData and getParameters are handled within this component. Specifically, the useTimePeriod hook is used to manage these props, ensuring that adjustTimePeriodData is applied and getParameters is called with the appropriate parameters.

  • adjustTimePeriodData is used within a useEffect hook to adjust the time period.
  • getParameters is called within another useEffect hook to pass the start and end dates.

These implementations confirm that the TimePeriods component correctly handles the newGraphInterval and getTimePeriodsParameters props.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `TimePeriods` handles `newGraphInterval` and `getTimePeriodsParameters` correctly.

# Test: Search for the component usage and its props handling.
rg --type typescript $'TimePeriods' --files-with-matches | xargs cat | grep -A 10 'TimePeriods'

Length of output: 127



Script:

#!/bin/bash
# Description: Verify that `TimePeriods` handles `newGraphInterval` and `getTimePeriodsParameters` correctly.

# Test: Search for the component definition and its props handling.
rg --type tsx 'TimePeriods' | xargs -I {} sh -c 'echo "File: {}"; cat {}' | grep -A 20 'TimePeriods'

Length of output: 128



Script:

#!/bin/bash
# Description: Verify that `TimePeriods` handles `newGraphInterval` and `getTimePeriodsParameters` correctly.

# Step 1: Find all TypeScript files.
fd -e ts -e tsx > ts_files.txt

# Step 2: Search for the `TimePeriods` component definition and its props handling within those files.
xargs -a ts_files.txt grep -H -A 20 'TimePeriods' 

Length of output: 64383

@Noha-ElAbrouki Noha-ElAbrouki merged commit 7f7ea0e into develop May 27, 2024
206 checks passed
@Noha-ElAbrouki Noha-ElAbrouki deleted the MON-81801 branch May 27, 2024 12:27
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.

None yet

3 participants