Frontend School

Resource Activity Timeline Component

Machine Coding
medium

Resource Activity Timeline Component

Medium
UI
React
Component
Timeline
Data Visualization

Overview

Oracle Cloud Infrastructure (OCI) provides granular monitoring and auditing capabilities for its vast array of cloud resources. For operations teams, a clear and concise timeline of resource activities is critical for debugging, auditing, and understanding resource lifecycle. This problem asks you to build a React component to visualize these historical events, enabling administrators to quickly grasp a resource's history at a glance.

What you need to do / Task

Your primary goal is to implement a Timeline React component that displays a series of resource activity events.

  1. Render Timeline Events: Display all provided TimelineEvent objects in chronological order, showing their timestamp, type, and description.
  2. Implement Event Grouping: Group consecutive events of the same type that occur within a 5-minute window into a single, collapsible timeline entry.
  3. Group Header Display: For grouped events, the header should show the time range (earliest to latest event timestamp within the group), the common event type, and the total count of events in that group.
  4. Collapsible Groups: Allow users to expand and collapse these grouped entries to reveal or hide the individual events contained within.
  5. Visual Distinction: Visually differentiate between different EventTypes (e.g., using distinct colors or icons for the timeline markers).

UI/UX expectations

  • Layout: The timeline should be presented vertically, with events ordered from oldest at the top to newest at the bottom.
  • Timeline Axis: Each event (or group header) should have a clear visual indicator (e.g., a dot or line segment) aligned along a central vertical axis.
  • Interactions: Group headers should be clickable to toggle their expanded/collapsed state. A clear visual cue (e.g., an arrow icon or text like 'Expand'/'Collapse') should indicate the current state.
  • Clarity: Ensure event details (timestamp, type, description) are clearly legible for both individual and grouped events.

Acceptance criteria

  • The Timeline component renders all provided TimelineEvent data.
  • Events are always displayed in strict chronological order.
  • Consecutive events of the same EventType occurring within a 5-minute (300,000 milliseconds) window are correctly grouped.
  • Each group header accurately displays the aggregated time range (from the first event's timestamp to the last event's timestamp in the group), the common EventType, and the total number of events in the group.
  • Group headers are interactive and correctly toggle the visibility of their contained individual events.
  • Individual events within an expanded group are rendered correctly, displaying their specific timestamp, type, and description.
  • Different EventTypes are visually distinguishable (e.g., via distinct colors for their timeline markers/dots).

Constraints

Constraints & assumptions

  • The input events array will always be sorted by timestamp in ascending order.
  • The time window for grouping consecutive events of the same type is exactly 5 minutes (300,000 milliseconds).
  • The maximum number of events for this exercise will be around 50-100.
  • You must use React for building the UI component.
  • No external UI component libraries (e.g., Material UI, Ant Design, Bootstrap) are allowed. Build components using native HTML elements and CSS.
  • Basic styling is provided in styles.css to give a starting point for the timeline layout and visual distinction; feel free to enhance it.

Out of scope

  • Complex date/time formatting libraries (e.g., Moment.js, date-fns) – basic Date.toLocaleString() is sufficient.
  • Advanced accessibility features beyond semantic HTML elements for clickable areas.
  • Pagination, infinite scrolling, or lazy loading of events.
  • Real-time updates or polling for new events.

What interviewers evaluate

  • Component Design & Structure: Modularity, separation of concerns, and appropriate use of React hooks and patterns.
  • State Management: Correct handling of UI state, particularly for managing group expansion/collapse.
  • Logic & Algorithms: Accurate implementation of the event grouping algorithm based on the specified criteria.
  • UI/UX Implementation: Fidelity to the described layout and interactive behaviors, along with basic styling for visual clarity.

Loading editor...