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

refactor: add options to hide schedule #1203

Merged
merged 1 commit into from
Sep 1, 2024
Merged

refactor: add options to hide schedule #1203

merged 1 commit into from
Sep 1, 2024

Conversation

cpvalente
Copy link
Owner

Adds option to disable right section in studio clock so we only get the clock view in the center
As described in #1168

Copy link
Contributor

coderabbitai bot commented Aug 31, 2024

Warning

Rate limit exceeded

@cpvalente has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 26 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 88fb40d and 6fe0482.

Walkthrough

The changes introduce a new CSS class modifier for layout management, enhance the StudioClock component with flexible props and conditional rendering, and implement a new StudioClockSchedule component for displaying schedules. Additionally, a new option for hiding the right section of the interface is added, and a utility function for converting milliseconds to seconds is relocated. Overall, the modifications improve the functionality and configurability of the studio clock feature.

Changes

Files Change Summary
apps/client/src/features/viewers/studio/StudioClock.scss Added .hide-right CSS class modifier to adjust grid layout and hide the 'schedule' area when applied.
apps/client/src/features/viewers/studio/StudioClock.tsx Updated imports and props to use MaybeString, adjusted rendering logic to conditionally display StudioClockSchedule, and simplified control flow.
apps/client/src/features/viewers/studio/StudioClockSchedule.tsx Introduced a new component to display a schedule, filtering events and managing display based on on-air status.
apps/client/src/features/viewers/studio/studioClock.options.ts Added a new option to getStudioClockOptions to allow hiding the right section of the interface.
apps/client/src/features/viewers/studio/studioClock.utils.ts Removed secondsInMillis function and related constants, reducing utility functions available for time calculations.
packages/utils/src/date-utils/conversionUtils.ts Added a new secondsInMillis function to convert milliseconds to seconds, enhancing the utility of the module.

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using 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 do a full 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 configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

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

Outside diff range, codebase verification and nitpick comments (1)
apps/client/src/features/viewers/studio/StudioClock.tsx (1)

Line range hint 64-117: Component logic and JSX structure review.

The component logic has been significantly refactored to include conditional rendering based on the hideRight parameter. This change is well-aligned with the PR objectives and enhances the component's interactivity by allowing users to toggle the schedule display based on their preferences.

However, there are a few areas that could be improved for better maintainability and readability:

  1. Handling of Time Formatting: The logic for handling AM/PM in the clock display is somewhat convoluted and could be simplified. Consider using a dedicated utility function for this purpose to make the code cleaner and more maintainable.
  2. Conditional Rendering: The conditional rendering logic for displaying the StudioClockSchedule component is straightforward, but ensure that it is robust against all edge cases, especially when the hideRight parameter is toggled frequently.

Overall, the changes are in line with the objectives, but refining these areas could enhance the code quality further.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 81f0e61 and 88fb40d.

Files ignored due to path filters (1)
  • packages/utils/index.ts is excluded by none and included by none
Files selected for processing (6)
  • apps/client/src/features/viewers/studio/StudioClock.scss (1 hunks)
  • apps/client/src/features/viewers/studio/StudioClock.tsx (6 hunks)
  • apps/client/src/features/viewers/studio/StudioClockSchedule.tsx (1 hunks)
  • apps/client/src/features/viewers/studio/studioClock.options.ts (1 hunks)
  • apps/client/src/features/viewers/studio/studioClock.utils.ts (2 hunks)
  • packages/utils/src/date-utils/conversionUtils.ts (1 hunks)
Additional comments not posted (8)
apps/client/src/features/viewers/studio/studioClock.options.ts (1)

9-16: New option addition is well-implemented.

The addition of the hideRight option is correctly implemented and follows the established pattern for configuration options. The default value of false is appropriate, ensuring backward compatibility and user-driven customization.

apps/client/src/features/viewers/studio/studioClock.utils.ts (1)

Line range hint 1-16: Remaining function trimRundown is correctly implemented.

The function is well-documented and logically sound. It handles the trimming of event lists based on a selected ID and a limit, which is a typical use case in event management systems.

packages/utils/src/date-utils/conversionUtils.ts (1)

67-78: New function secondsInMillis is correctly implemented.

The function is well-documented and efficiently handles the conversion of milliseconds to seconds, considering edge cases like falsy values. This utility function is a valuable addition to the module.

apps/client/src/features/viewers/studio/StudioClockSchedule.tsx (2)

1-8: Imports are well-organized and relevant.

The imports in this file are well-organized and directly relevant to the functionality of the StudioClockSchedule component. This helps in maintaining clarity and ensuring that all dependencies are correctly managed.


10-15: Interface StudioClockScheduleProps is well-defined.

The interface StudioClockScheduleProps is clearly defined and includes all necessary properties (rundown, selectedId, nextId, onAir) that the component requires to function properly. This ensures strong typing and helps in maintaining the integrity of data passed to the component.

apps/client/src/features/viewers/studio/StudioClock.scss (1)

45-48: CSS changes for .hide-right class are appropriate.

The addition of the .hide-right class to adjust the grid layout is well-implemented. It correctly sets the grid-template-columns and grid-template-areas to focus solely on the clock area when the schedule is not needed. This change aligns with the PR objectives to allow users to disable the right section of the studio clock interface for a more streamlined view.

Ensure to verify the visual impact in different screen sizes and configurations to confirm that the layout behaves as expected across all devices.

Consider adding screenshots or conducting a visual regression test to ensure that the changes appear as intended across all supported devices and resolutions.

apps/client/src/features/viewers/studio/StudioClock.tsx (2)

Line range hint 1-16: Imports are well-organized and relevant.

The imports in this file are well-organized and directly relevant to the functionality of the StudioClock component. This helps in maintaining clarity and ensuring that all dependencies are correctly managed.


25-26: Changes to StudioClockProps interface are appropriate.

The update of selectedId and nextId properties from string | null to MaybeString in the StudioClockProps interface is a positive change. It enhances the flexibility in handling these properties and aligns with the use of MaybeString across other components. This change should help in managing optional string values more effectively.

Comment on lines +20 to +50
export default function StudioClockSchedule(props: StudioClockScheduleProps) {
const { rundown, selectedId, nextId, onAir } = props;

const delayed = rundown.filter((event) => isOntimeEvent(event)) as OntimeEvent[];
const trimmedRundown = trimRundown(delayed, selectedId, MAX_TITLES);

return (
<div className='schedule-container'>
<div className={onAir ? 'onAir' : 'onAir onAir--idle'} data-testid={onAir ? 'on-air-enabled' : 'on-air-disabled'}>
ON AIR
</div>
<ul className='schedule'>
{trimmedRundown.map((event) => {
const start = formatTime(event.timeStart + (event?.delay ?? 0), { format12: 'h:mm a', format24: 'HH:mm' });
const isSelected = event.id === selectedId;
const isNext = event.id === nextId;
const classes = `schedule__item schedule__item${isSelected ? '--now' : isNext ? '--next' : '--future'}`;
return (
<li key={event.id} className={classes}>
<span className='event'>
<span className='event__colour' style={{ backgroundColor: `${event.colour}` }} />
<SuperscriptTime time={start} />
</span>
<span>{event.title}</span>
</li>
);
})}
</ul>
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Component logic and JSX structure review.

The component logic is mostly clear and functional. However, there are a few areas that could be improved:

  1. Conditional Class Application: The way CSS classes are applied based on the onAir prop could be simplified for better readability. Consider using a utility function to handle class names based on conditions.
  2. Event Filtering: The filtering of events to check if they are OntimeEvent instances is crucial. Ensure that this logic is robust and consider adding error handling if the data structure is not as expected.
  3. TODO Comment: The TODO comment about fitting titles on the screen suggests that there might be UI issues with long titles. It would be beneficial to address this or at least track it in your project management tool.

Overall, the component does what it is supposed to do but consider refining these areas to enhance maintainability and readability.

Copy link
Collaborator

@alex-Arc alex-Arc left a comment

Choose a reason for hiding this comment

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

Works as expected 👍🏽

@cpvalente cpvalente merged commit 7b932ef into master Sep 1, 2024
3 checks passed
@cpvalente cpvalente deleted the studio-options branch September 1, 2024 08:41
@coderabbitai coderabbitai bot mentioned this pull request Sep 18, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 6, 2024
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