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

feat(docs): add cuHacking Google calendar #81

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AquaShotRyan
Copy link
Contributor

@AquaShotRyan AquaShotRyan commented Aug 31, 2024

Screenshot 2024-08-31 154631
Screenshot 2024-08-31 154636
Screenshot 2024-08-31 154640
Screenshot 2024-08-31 154645
Screenshot 2024-08-31 154649
Screenshot 2024-08-31 154654

Summary by Sourcery

Add a Google Calendar integration to the documentation site using FullCalendar, allowing users to view events in different formats. Update the build configuration to include necessary dependencies and embed the calendar in the documentation index page.

New Features:

  • Integrate a Google Calendar into the documentation site using the FullCalendar library, allowing users to view events in various formats such as week, month, and list views.

Enhancements:

  • Add a new Calendar component to the documentation site, which utilizes environment variables for Google Calendar API integration.

Build:

  • Update pnpm-lock.yaml to include new dependencies for FullCalendar plugins and Preact.

Documentation:

  • Embed the new Calendar component into the documentation index page, providing users with a visual calendar interface.

Summary by CodeRabbit

  • New Features

    • Introduced a calendar component that allows users to view and manage events from Google Calendar.
    • Added customizable calendar views, including day grid, time grid, and list view.
  • Style

    • Implemented new CSS styles for tables within prose elements to enhance visual presentation.
  • Documentation

    • Updated documentation to include the new calendar component, providing users with integration details for Google Calendar.
  • Chores

    • Added necessary dependencies for FullCalendar functionality to the project.

@AquaShotRyan AquaShotRyan added the documentation Improvements or additions to documentation label Aug 31, 2024
@AquaShotRyan AquaShotRyan self-assigned this Aug 31, 2024
@AquaShotRyan AquaShotRyan linked an issue Aug 31, 2024 that may be closed by this pull request
Copy link

sourcery-ai bot commented Aug 31, 2024

Reviewer's Guide by Sourcery

This pull request adds a Google Calendar integration to the documentation site using the FullCalendar library. The implementation focuses on embedding a calendar component that displays cuHacking events, with various view options and plugins for enhanced functionality.

File-Level Changes

Change Details Files
Integrate FullCalendar library with Google Calendar
  • Add FullCalendar and its plugins as dependencies
  • Create a new Calendar component using FullCalendar
  • Configure FullCalendar with various plugins and view options
  • Set up Google Calendar API integration
pnpm-lock.yaml
apps/docs/src/components/Calendar.tsx
Embed calendar component in the documentation index page
  • Import the Calendar component
  • Add the Calendar component to the index page
  • Pass the Google Calendar ID as a prop to the Calendar component
apps/docs/src/content/docs/index.mdx

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

netlify bot commented Aug 31, 2024

Deploy Preview for cuhacking-portal-dev failed. Why did it fail? →

Name Link
🔨 Latest commit 95a214f
🔍 Latest deploy log https://app.netlify.com/sites/cuhacking-portal-dev/deploys/66e454b6967b8f0007b1ad1e

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @AquaShotRyan - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Potential hard-coded Google Calendar ID found. (link)

Overall Comments:

  • Please ensure the Google Calendar API key is stored securely as an environment variable before merging this PR. Leaving it empty in the code could lead to security issues.
  • Consider implementing lazy loading for the Calendar component to optimize initial page load times, especially if it's not needed on every page of the documentation.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🔴 Security: 1 blocking issue, 1 other issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

apps/docs/src/components/Calendar.tsx Outdated Show resolved Hide resolved
import googleCalendarPlugin from '@fullcalendar/google-calendar'

// cuHacking calendar
const GOOGLE_CALENDAR_ID = 'fcdba3f354d4e01552e2495d743105bd9efce4e1076cda3c1ec1454d0f5faa73@group.calendar.google.com'
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider making the calendar ID configurable.

Making the calendar ID a prop or configuration option would increase the component's flexibility and reusability.

interface CalendarProps {
  calendarId: string;
}

const Calendar: React.FC<CalendarProps> = ({ calendarId }) => {
  // Use calendarId prop instead of constant
  // Rest of the component logic...
};

export default Calendar;

apps/docs/src/components/Calendar.tsx Outdated Show resolved Hide resolved
@MFarabi619
Copy link
Member

MFarabi619 commented Aug 31, 2024

For dependencies you can do:

  • chore(deps): add @fullcalendar/daygrid
  • chore(deps): add @fullcalendar/...
  • chore(deps): add ....

If this convention is missing from the docs, feel free to add it

apps/docs/src/components/Calendar.tsx Outdated Show resolved Hide resolved
apps/docs/src/components/Calendar.tsx Outdated Show resolved Hide resolved
@@ -0,0 +1,41 @@
'use client'
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to remove this and render the component server-side? Then we can move all of the dependencies to dev dependencies, and the bundle size will be much smaller for the client.

What would be the other tradeoffs? Does this calendar update real-time?

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 removed it and it gave me this error:
image
I did some research online and there doesn't seem to be a way to render it server-side, at least as a React component. I think it needs to be client side in order to be interactive.

Copy link
Member

Choose a reason for hiding this comment

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

Okay sounds good

@HasithDeAlwis HasithDeAlwis marked this pull request as draft August 31, 2024 22:14
@AquaShotRyan AquaShotRyan force-pushed the rtran/feat/80-welcome-to-docs-add-cuhacking-google-calendar branch from 5bee7af to 56192b6 Compare September 3, 2024 12:42
@AquaShotRyan
Copy link
Contributor Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @AquaShotRyan - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider moving the Google Calendar API key and Calendar ID to a server-side environment or using a more secure method to protect these sensitive values.
  • Ensure that the calendar component renders correctly in both client and server environments, and consider adding error handling and loading states for a better user experience.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -0,0 +1,41 @@
'use client'
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): Consider moving environment variable access to server-side

The use of 'process.env' to access environment variables on the client-side can be problematic as these values are typically not available in the browser. Consider moving this logic to a server-side component or API route, and pass the necessary values as props to the Calendar component.

'use client'

import FullCalendar from '@fullcalendar/react'
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlugin from '@fullcalendar/timegrid'
import listPlugin from '@fullcalendar/list'
import googleCalendarPlugin from '@fullcalendar/google-calendar'

interface CalendarProps {
  calendarId: string
  googleCalendarApiKey: string
}

export const Calendar: React.FC<CalendarProps> = ({ calendarId, googleCalendarApiKey }) => {

dayGridMonth: {},
listWeek: {},
}}
eventColor="red"
Copy link

Choose a reason for hiding this comment

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

suggestion: Make event color configurable

Consider making the event color configurable, either through a prop or a theme setting. This would allow for more flexibility in customizing the calendar's appearance.

eventColor={props.eventColor || theme.calendar.eventColor || "red"}

Copy link
Member

@MFarabi619 MFarabi619 Sep 4, 2024

Choose a reason for hiding this comment

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

Amazing PR reviews @sourcery-ai

Copy link

Choose a reason for hiding this comment

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

Thank you, @MFarabi619! I'm glad you found the review helpful. If you have any questions or need further clarification on any of the suggestions, feel free to ask. I'm here to help!

@AquaShotRyan AquaShotRyan force-pushed the rtran/feat/80-welcome-to-docs-add-cuhacking-google-calendar branch from 56192b6 to 0401d7c Compare September 3, 2024 12:53
@AquaShotRyan AquaShotRyan force-pushed the rtran/feat/80-welcome-to-docs-add-cuhacking-google-calendar branch from 0401d7c to 95a214f Compare September 13, 2024 15:05
Copy link

coderabbitai bot commented Sep 13, 2024

Walkthrough

Walkthrough

The changes introduce a new Calendar component built with React, utilizing the FullCalendar library for enhanced scheduling capabilities. It supports various views and integrates with Google Calendar through specified API keys and calendar IDs. Additionally, CSS styles for tables within prose contexts are defined, and several FullCalendar-related dependencies are added to the project. Documentation is updated to include the new calendar feature, ensuring a seamless integration into the existing application structure.

Changes

File Change Summary
apps/docs/src/components/calendar/Calendar.tsx Introduced Calendar component with Google Calendar integration and defined CalendarProps interface.
apps/docs/src/components/calendar/calendar-styles.css Added CSS rules for table styling within .prose class.
apps/docs/src/content/docs/index.mdx Added import for Calendar component and instantiated it with environment variables for Google API.
package.json Added FullCalendar dependencies: @fullcalendar/daygrid, @fullcalendar/google-calendar, @fullcalendar/list, @fullcalendar/react, @fullcalendar/timegrid, all at version ^6.1.15.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Docs
    participant Calendar
    participant GoogleCalendarAPI

    User->>Docs: Open documentation page
    Docs->>Calendar: Render Calendar component
    Calendar->>GoogleCalendarAPI: Fetch events using googleApiKey and calendarId
    GoogleCalendarAPI-->>Calendar: Return events data
    Calendar-->>Docs: Display events in calendar view
Loading

Poem

🐰 In a meadow bright, the calendar hops,
With events to share, it never stops!
From Google it fetches, a view so neat,
A schedule of joy, a planning treat!
With styles so fine, it dances with glee,
Oh, what a wonder, come play with me! 🌼

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 333617b and 95a214f.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (4)
  • apps/docs/src/components/calendar/Calendar.tsx (1 hunks)
  • apps/docs/src/components/calendar/calendar-styles.css (1 hunks)
  • apps/docs/src/content/docs/index.mdx (1 hunks)
  • package.json (1 hunks)
Additional comments not posted (14)
apps/docs/src/components/calendar/calendar-styles.css (1)

1-8: LGTM!

The CSS styles for tables within the prose context are well-defined and appropriately scoped. The styles enhance the visual appearance and readability of tables while avoiding unintended effects on tables outside the prose context or those explicitly marked with not-prose classes.

apps/docs/src/components/calendar/Calendar.tsx (5)

1-2: LGTM!

The usage of the 'use client' directive is correct for a component that requires client-side rendering.


3-7: LGTM!

The imports for the FullCalendar plugins are correctly specified and match the plugins used in the component configuration.


9-9: Verify the existence and contents of the CSS file.

Please ensure that the calendar-styles.css file exists and contains the necessary styles for the Calendar component.


11-14: LGTM!

The CalendarProps interface correctly defines the props expected by the Calendar component, with appropriate names and types for Google Calendar integration.


16-41: LGTM!

The Calendar component is well-implemented and follows best practices. It correctly uses the FullCalendar component with appropriate props and configuration options. The integration with the Google Calendar API is properly set up using the provided API key and calendar ID.

apps/docs/src/content/docs/index.mdx (3)

9-9: LGTM!

The import statement for the Calendar component looks good. The import path is relative to the current file and points to a TypeScript file with a .tsx extension, which is the expected file type for a React component written in TypeScript.


5-5: Verify the usage of the process module.

Importing the process module from Node.js in a React component is not a common practice. Please ensure that the component is running in a Node.js environment and that using the process module is compatible with the application's architecture and deployment strategy.

Run the following script to verify the application's environment:

Verification successful

Usage of process module is appropriate in this context

The import of process from 'node:process' in apps/docs/src/content/docs/index.mdx is justified. This project appears to be using Next.js, which supports server-side rendering and static site generation. In this environment, using the process module to access environment variables (e.g., process.env.GOOGLE_CALENDAR_API_KEY) is a common and necessary practice.

The usage of process is consistent with:

  • Next.js configuration (next.config.js)
  • Environment variable handling (src/env.js)
  • End-to-end test configurations

These are all typical use cases for a Node.js-based application using a framework like Next.js. The process module is being used appropriately for its intended purpose in a server-side or build-time context.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the application's environment and the usage of the `process` module.

# Test: Search for the usage of the `process` module in the codebase.
# Expect: The `process` module is used in a Node.js environment, such as a server-side rendered application or a static site generator.
rg --type typescript --type javascript --type mdx $'process\.(env|argv|exit|cwd)' -g '!node_modules'

Length of output: 136


Script:

#!/bin/bash
# Description: Verify the usage of the `process` module and determine the application type.

# Search for any usage of `process`
echo "Searching for 'process' usage:"
rg 'process' -g '!node_modules' -g '!*.json' -g '!*.lock'

# Look for configuration files
echo -e "\nChecking for configuration files:"
fd -e js -e json -e yaml -e yml '(next\.config|gatsby-config|astro\.config|nuxt\.config)'

# Check for imports of process
echo -e "\nChecking for 'process' imports:"
rg 'import.*process' -g '!node_modules'

Length of output: 7020


11-11: Verify the environment variables and handle missing or invalid values.

Using environment variables to store the Google Calendar API key and calendar ID is a good practice to keep sensitive information out of the codebase. However, please ensure that:

  1. The GOOGLE_CALENDAR_API_KEY and GOOGLE_CALENDAR_ID environment variables are set in the application's runtime environment or build process.
  2. The Calendar component handles the case when the environment variables are not set or have invalid values to avoid runtime errors.

Run the following script to verify the existence and validity of the environment variables:

package.json (5)

22-22: LGTM!

The @fullcalendar/daygrid dependency is correctly added with a valid semver range. It will provide a day grid view for the calendar in the application.


23-23: LGTM!

The @fullcalendar/google-calendar dependency is correctly added with a valid semver range. It will enable integration with Google Calendar events in the application's calendar.


24-24: LGTM!

The @fullcalendar/list dependency is correctly added with a valid semver range. It will provide a list view for the events in the application's calendar.


25-25: LGTM!

The @fullcalendar/react dependency is correctly added with a valid semver range. It will provide React components for rendering the FullCalendar in the application.


26-26: LGTM!

The @fullcalendar/timegrid dependency is correctly added with a valid semver range. It will provide a time grid view for the calendar in the application.


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.

@AquaShotRyan
Copy link
Contributor Author

In the process of learning of split commits (i.e. split the commit for installing dependencies) and adding more styles to the calendar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: 🏃 In Progress
Development

Successfully merging this pull request may close these issues.

docs(welcome-to-docs): add cuHacking Google calendar
2 participants