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

Added helper_link and link seeder. #496

Merged

Conversation

MandeepPaul
Copy link
Collaborator

Describe your changes

Added helper_link and link seeder. The target element for the hints is set to '.element' for now.

Issue number

#495

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Walkthrough

The changes in the seeders file enhance the database initialization process by introducing new bulk insert operations. The modifications focus on populating the "hints", "helper_link", and "link" tables with predefined data. The seeder now adds more comprehensive initial data, including details like action URLs, colors, and related link information, which will help set up a more structured initial database state.

Changes

File Change Summary
backend/seeders/seeders.js - Added bulk insert for "hints" table with multiple fields
- Introduced bulk insert for "helper_link" table
- Created bulk insert for "link" table with links referencing helper links

Sequence Diagram

sequenceDiagram
    participant DB as Database
    participant Seeder as Seeder Script
    
    Seeder->>DB: Insert Hints
    Seeder->>DB: Insert Helper Links
    Seeder->>DB: Retrieve Helper Link ID
    Seeder->>DB: Insert Links with Helper Link References
Loading

The sequence diagram illustrates the order of database insertions, showing how the seeder populates different tables sequentially, with each step building upon the previous one by using retrieved IDs for referential integrity.

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94ecbf4 and a9fff3b.

📒 Files selected for processing (1)
  • backend/seeders/seeders.js (2 hunks)

Comment on lines 100 to 105
const links = [
{ title: 'GuideFox Website', url: 'http://localhost:4173https://guidefox-demo.bluewavelabs.ca', target: true, helperId: helperLink.id },
{ title: 'GuideFox Repo', url: 'https://github.com/bluewave-labs/guidefox', target: false, helperId: helperLink.id },
];

await queryInterface.bulkInsert('link', links, {});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Knees weak, arms heavy! That URL is looking sketchy! 🍝

There are several issues in the links array:

  1. The first URL is malformed: 'http://localhost:4173https://guidefox-demo.bluewavelabs.ca'
  2. Mixing different environment URLs (localhost, demo, and production)
  3. The target boolean's purpose isn't documented (is it for target="_blank"?)

Here's the fix:

+ const { environments } = require('../config/environments');

  const links = [
    { 
      title: 'GuideFox Website', 
-     url: 'http://localhost:4173https://guidefox-demo.bluewavelabs.ca',
+     url: environments.DEMO_URL,
      target: true, // Opens in new tab
      helperId: helperLink.id 
    },
    { 
      title: 'GuideFox Repo', 
      url: 'https://github.com/bluewave-labs/guidefox', 
      target: false, // Opens in same tab
      helperId: helperLink.id 
    },
  ];

Consider adding JSDoc comments to document the schema:

/**
 * @typedef {Object} Link
 * @property {string} title - The display text for the link
 * @property {string} url - The destination URL
 * @property {boolean} target - Whether to open in new tab
 * @property {number} helperId - Reference to helper_link.id
 */

Comment on lines 22 to 44
await queryInterface.bulkInsert(
'hints',
[
{
action: 'open url',
url: 'https://guidefox-demo.bluewavelabs.ca',
actionButtonUrl: 'https://guidefox.io/',
actionButtonText: 'Take me to GuideFox page',
targetElement: '.element',
tooltipPlacement: 'right',
hintContent:
'Guidefox helps app owners build knowledge and user-experience oriented apps. It includes the following features: welcome tours, popups, banners, helper links, hints',
header: 'GuideFox Intro',
headerBackgroundColor: '#FFFFFF',
headerColor: '#101828',
textColor: '#101828',
buttonBackgroundColor: '#7F56D9',
buttonTextColor: '#FFFFFF',
createdBy: 1,
},
],
{}
);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Yo dawg, these hardcoded values are making me nervous! 🍝

The hint seeder's got some issues that need fixin':

  1. The URLs are all over the place - mixing demo and production environments
  2. Those color codes ain't coming from the theme (PR objectives mentioned this)
  3. No validation on those hex color codes

Here's how we can clean this up:

+ const { themeColors } = require('../config/theme');
+ const { environments } = require('../config/environments');

  await queryInterface.bulkInsert(
    'hints',
    [{
      action: 'open url',
-     url: 'https://guidefox-demo.bluewavelabs.ca',
+     url: environments.DEMO_URL,
      actionButtonUrl: 'https://guidefox.io/',
      actionButtonText: 'Take me to GuideFox page',
      targetElement: '.element',
      tooltipPlacement: 'right',
      hintContent:
        'Guidefox helps app owners build knowledge and user-experience oriented apps. It includes the following features: welcome tours, popups, banners, helper links, hints',
      header: 'GuideFox Intro',
-     headerBackgroundColor: '#FFFFFF',
-     headerColor: '#101828',
-     textColor: '#101828',
-     buttonBackgroundColor: '#7F56D9',
-     buttonTextColor: '#FFFFFF',
+     headerBackgroundColor: themeColors.background.primary,
+     headerColor: themeColors.text.primary,
+     textColor: themeColors.text.primary,
+     buttonBackgroundColor: themeColors.button.primary,
+     buttonTextColor: themeColors.button.text,
      createdBy: 1,
    }],
    {}
  );

Committable suggestion skipped: line range outside the PR's diff.

@MandeepPaul MandeepPaul requested a review from erenfn January 16, 2025 15:53
url: 'https://guidefox-demo.bluewavelabs.ca',
actionButtonUrl: 'https://guidefox.io/',
actionButtonText: 'Take me to GuideFox page',
targetElement: '.element',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this targetElement really exist in the actual website?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I see! I was a bit confused earlier. I will update it to use an element from the actual website.

So, to confirm, we are showcasing hints, banners, etc., on this website: https://guidefox-demo.bluewavelabs.ca/, for demonstration purposes?

Copy link
Collaborator

@erenfn erenfn left a comment

Choose a reason for hiding this comment

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

Try duplicating the helper link from frontend, it gives an error, suggesting that it may not have been set up successfully

@MandeepPaul
Copy link
Collaborator Author

MandeepPaul commented Jan 17, 2025

Try duplicating the helper link from frontend, it gives an error, suggesting that it may not have been set up successfully

I was doing the same thing, for example: first creating a helperLink, then populating the link table using helperLink.id as the foreign key.
image
image

And its populating the db and displaying it correctly
imageScreenshot 2025-01-17 050229

Copy link
Collaborator

@erenfn erenfn left a comment

Choose a reason for hiding this comment

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

{"errors":["Invalid value for link URLs"]}

image

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: 0

♻️ Duplicate comments (2)
backend/seeders/seeders.js (2)

35-39: 🛠️ Refactor suggestion

Mom's spaghetti alert! These hardcoded colors are making me nervous! 🍝

These color values should be coming from the theme as mentioned in the PR objectives:

  • #FFFFFF for header background
  • #101828 for header and text
  • #7F56D9 for button background
  • #FFFFFF for button text

Import and use theme colors:

+ const { themeColors } = require('../config/theme');

  {
-   headerBackgroundColor: '#FFFFFF',
-   headerColor: '#101828',
-   textColor: '#101828',
-   buttonBackgroundColor: '#7F56D9',
-   buttonTextColor: '#FFFFFF',
+   headerBackgroundColor: themeColors.background.primary,
+   headerColor: themeColors.text.primary,
+   textColor: themeColors.text.primary,
+   buttonBackgroundColor: themeColors.button.primary,
+   buttonTextColor: themeColors.button.text,
  }

91-93: 🛠️ Refactor suggestion

More hardcoded colors! My sweater's getting heavy! 🍝

These color values should also come from the theme:

  • #adb2f5 for header background
  • #344054 for link font
  • #7F56D9 for icon

Import and use theme colors:

+ const { themeColors } = require('../config/theme');

  {
-   headerBackgroundColor: '#adb2f5',
-   linkFontColor: '#344054',
-   iconColor: '#7F56D9',
+   headerBackgroundColor: themeColors.background.secondary,
+   linkFontColor: themeColors.text.link,
+   iconColor: themeColors.icon.primary,
  }
🧹 Nitpick comments (1)
backend/seeders/seeders.js (1)

100-103: Knees weak, documentation's heavy! Let's make it better! 🍝

The target boolean's purpose isn't immediately clear. Let's add JSDoc comments to document the schema:

+ /**
+  * @typedef {Object} Link
+  * @property {string} title - The display text for the link
+  * @property {string} url - The destination URL
+  * @property {boolean} target - Whether to open in new tab (true) or same tab (false)
+  * @property {number} helperId - Reference to helper_link.id
+  */

  const links = [
    { title: 'GuideFox Website', url: 'https://guidefox-demo.bluewavelabs.ca', target: true, helperId: helperLink.id },
    { title: 'GuideFox Repo', url: 'https://github.com/bluewave-labs/guidefox', target: false, helperId: helperLink.id },
  ];
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9fff3b and e1b219d.

📒 Files selected for processing (1)
  • backend/seeders/seeders.js (2 hunks)
🔇 Additional comments (2)
backend/seeders/seeders.js (2)

30-30: Yo dawg, that target element is looking sus! 🍝

Based on the previous discussion, .element doesn't exist on the actual website. We need to update this to target a real element from https://guidefox-demo.bluewavelabs.ca/.

Let's verify what elements are available on the demo site:

#!/bin/bash
# Description: Check for commonly used elements in the codebase that might be present on the demo site

rg -g '*.{jsx,tsx,vue,html}' 'class=|className=' --no-filename | sort -u

27-28: 🛠️ Refactor suggestion

These URLs are all over the place! Let's clean up this spaghetti! 🍝

We're mixing demo and production URLs. Let's use environment configuration for consistency:

+ const { environments } = require('../config/environments');

  {
-   url: 'https://guidefox-demo.bluewavelabs.ca',
-   actionButtonUrl: 'https://guidefox.io/',
+   url: environments.DEMO_URL,
+   actionButtonUrl: environments.PRODUCTION_URL,
  }

Likely invalid or redundant comment.

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: 2

🧹 Nitpick comments (1)
backend/seeders/seeders.js (1)

100-103: Knees weak, arms heavy! This links array needs some love! 🍝

  1. The target boolean's purpose isn't documented
  2. Links are tightly coupled with the helper link

Let's add some JSDoc and improve the structure:

+ /** @type {Array<{
+  *   title: string,
+  *   url: string,
+  *   target: boolean, // When true, opens in new tab
+  *   helperId: number
+  * }>} */
  const links = [
    { 
      title: 'GuideFox Website', 
      url: 'https://guidefox-demo.bluewavelabs.ca', 
      target: true, // Opens in new tab
      helperId: helperLink.id 
    },
    // ... other links
  ];

Consider moving the links to a separate configuration file for better maintainability:

// config/seed-data/links.js
module.exports = {
  guidefoxLinks: [
    {
      title: 'GuideFox Website',
      url: 'https://guidefox-demo.bluewavelabs.ca',
      target: true,
    },
    // ... other links
  ]
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1b219d and 28c5e8e.

📒 Files selected for processing (1)
  • backend/seeders/seeders.js (2 hunks)
🔇 Additional comments (2)
backend/seeders/seeders.js (2)

35-39: These hardcoded colors are making me nervous! 🍝

Previous review already flagged this - we still need to use theme colors here.


91-93: Mom's spaghetti alert! More hardcoded colors! 🍝

Previous review already flagged this - we still need to use theme colors here.

@MandeepPaul MandeepPaul requested a review from erenfn January 17, 2025 13:07
@erenfn erenfn merged commit 9e85c9a into demo-server Jan 18, 2025
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 30, 2025
9 tasks
@erenfn erenfn deleted the 495-add-a-helper-link-and-hint-seeder-to-demo-server-branch branch March 5, 2025 21:08
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