Skip to content

Com 20 updates#241

Merged
7yntax merged 4 commits into
mainfrom
COM-20-Updates
Apr 2, 2025
Merged

Com 20 updates#241
7yntax merged 4 commits into
mainfrom
COM-20-Updates

Conversation

@7yntax
Copy link
Copy Markdown
Contributor

@7yntax 7yntax commented Apr 2, 2025

Summary by CodeRabbit

  • New Features
    • The dashboard now conditionally presents an onboarding interface when no test results are found, guiding new users with relevant content.
    • The onboarding experience has been refined to display an actionable prompt only when available, ensuring a cleaner UI.
    • A new cloud security testing section has been added to the onboarding material, featuring informative content and FAQs to help users understand cloud testing options.

@linear
Copy link
Copy Markdown

linear Bot commented Apr 2, 2025

COM-20 Cloud Tests

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2025 4:41pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
comp-portal ⬜️ Skipped (Inspect) Apr 2, 2025 4:41pm

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2025

Walkthrough

The changes add a new asynchronous function getTestsOverview in the dashboard layout to fetch test results using the authenticated user's organization ID with caching. The layout now conditionally renders an onboarding UI via the AppOnboarding component (wrapped in a Suspense for loading) when no tests are found, while continuing with the regular layout when tests are present. Additionally, the AppOnboarding component now only renders the CTA button if a corresponding prop is provided, and a new cloud_tests section is added to the onboarding localization for cloud security testing.

Changes

File(s) Change Summary
apps/app/src/app/[locale]/.../tests/all/layout.tsx Added an asynchronous getTestsOverview function with caching and integrated conditional rendering to show an onboarding UI (via AppOnboarding in Suspense) if no tests are returned.
apps/app/src/components/app-onboarding.tsx Updated the AppOnboarding component to conditionally render the Button inside CardFooter depending on the presence of the cta prop.
apps/app/src/locales/onboarding/app-onboarding.ts Introduced a new cloud_tests section in the onboarding localization with a title, description, CTA, and FAQ entries related to cloud security testing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Layout
    participant DB
    participant AppOnboarding
    User->>Layout: Request dashboard view
    Layout->>DB: Call getTestsOverview(orgId)
    DB-->>Layout: Return test results
    alt No tests found
        Layout->>AppOnboarding: Render onboarding UI wrapped in Suspense
    else Tests exist
        Layout->>Layout: Render SecondaryMenu and child components
    end
Loading
sequenceDiagram
    participant AppOnboarding
    participant CardFooter
    participant Button
    AppOnboarding->>CardFooter: Prepare CardFooter
    alt CTA prop provided
        CardFooter->>Button: Render Button component
    else CTA prop absent
        CardFooter-->>AppOnboarding: Do not render Button
    end
Loading

Possibly related PRs

  • Lewis/pol #164: The changes in the main PR are related to the AppOnboarding component, which is used in the main PR's Layout component, as it conditionally renders the onboarding UI based on the presence of test results.
  • SSR Settings + Loading UI #147: The changes in the main PR are related to the modifications in the AppOnboarding component, as both involve enhancements to the onboarding experience, specifically through the introduction of new functionalities and conditional rendering that improve user interaction.

Poem

Oh, what a hop, a bounce so bright,
CodeRabbit's changes take flight at night.
New functions spring like fresh carrots in the ground,
Conditionally rendering joy all around.
With each line of code, our UI is light,
A rabbit's delight in every byte! 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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>, please review it.
    • 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 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown

@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

🧹 Nitpick comments (3)
apps/app/src/components/app-onboarding.tsx (1)

16-24: Make cta prop optional to match conditional rendering

Since the component now conditionally renders the button based on the existence of the cta prop, the prop should be marked as optional in the type definition.

type Props = {
  title: string;
  description: string;
-  cta: string;
+  cta?: string;
  imageSrc: string;
  imageAlt: string;
  faqs?: FAQ[];
  sheetName: string;
};
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (2)

17-17: Remove console.log statement

Debug statements should be removed before pushing to production.

const tests = await getTestsOverview();
- console.log(tests);

22-22: Improve Suspense fallback for better UX

The current fallback is very basic. Consider using a skeleton loader or a more styled loading indicator.

- <Suspense fallback={<div>Loading...</div>}>
+ <Suspense fallback={
+   <div className="mt-8 flex items-center justify-center p-6 bg-accent/10 rounded-lg">
+     <div className="flex flex-col items-center gap-2">
+       <div className="h-8 w-8 animate-spin rounded-full border-b-2 border-primary"></div>
+       <p className="text-sm text-muted-foreground">Loading tests...</p>
+     </div>
+   </div>
+ }>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78783a4 and 773223d.

⛔ Files ignored due to path filters (1)
  • apps/app/public/onboarding/cloud-tests.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (3 hunks)
  • apps/app/src/components/app-onboarding.tsx (1 hunks)
  • apps/app/src/locales/onboarding/app-onboarding.ts (1 hunks)
🔇 Additional comments (3)
apps/app/src/components/app-onboarding.tsx (1)

71-77: LGTM: Improved conditional rendering

Good improvement to conditionally render the button only when the cta prop is provided, making the component more flexible.

apps/app/src/locales/onboarding/app-onboarding.ts (1)

63-76: LGTM: Well-structured localization for cloud tests

The new cloud_tests section follows the established pattern and provides clear, informative content for users.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (1)

69-80: LGTM: Well-implemented cached data fetching

Good implementation of the data fetching function with appropriate caching and authentication.

Comment on lines +24 to +43
<AppOnboarding
title={t("app_onboarding.cloud_tests.title")}
description={t("app_onboarding.cloud_tests.description")}
imageSrc="/onboarding/cloud-tests.png"
imageAlt="Cloud Security Testing"
faqs={[
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_1"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_1"),
},
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_2"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_2"),
},
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_3"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_3"),
},
]}
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing required sheetName prop

The AppOnboarding component requires a sheetName prop but it's missing in this implementation. The sheetName is used with useQueryState inside the component to manage the component's open state.

<AppOnboarding
  title={t("app_onboarding.cloud_tests.title")}
  description={t("app_onboarding.cloud_tests.description")}
+ cta={t("app_onboarding.cloud_tests.cta")}
  imageSrc="/onboarding/cloud-tests.png"
  imageAlt="Cloud Security Testing"
+ sheetName="cloud_tests"
  faqs={[
    {
      questionKey: t("app_onboarding.cloud_tests.faqs.question_1"),
      answerKey: t("app_onboarding.cloud_tests.faqs.answer_1"),
    },
    {
      questionKey: t("app_onboarding.cloud_tests.faqs.question_2"),
      answerKey: t("app_onboarding.cloud_tests.faqs.answer_2"),
    },
    {
      questionKey: t("app_onboarding.cloud_tests.faqs.question_3"),
      answerKey: t("app_onboarding.cloud_tests.faqs.answer_3"),
    },
  ]}
/>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<AppOnboarding
title={t("app_onboarding.cloud_tests.title")}
description={t("app_onboarding.cloud_tests.description")}
imageSrc="/onboarding/cloud-tests.png"
imageAlt="Cloud Security Testing"
faqs={[
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_1"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_1"),
},
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_2"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_2"),
},
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_3"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_3"),
},
]}
/>
<AppOnboarding
title={t("app_onboarding.cloud_tests.title")}
description={t("app_onboarding.cloud_tests.description")}
cta={t("app_onboarding.cloud_tests.cta")}
imageSrc="/onboarding/cloud-tests.png"
imageAlt="Cloud Security Testing"
sheetName="cloud_tests"
faqs={[
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_1"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_1"),
},
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_2"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_2"),
},
{
questionKey: t("app_onboarding.cloud_tests.faqs.question_3"),
answerKey: t("app_onboarding.cloud_tests.faqs.answer_3"),
},
]}
/>

@vercel vercel Bot temporarily deployed to Preview – comp-portal April 2, 2025 16:38 Inactive
Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (1)

16-17: Remove debugging logs in production

Consider removing or converting console.log(tests) into a more formal logging mechanism to avoid cluttering production logs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 773223d and 2ce7e92.

📒 Files selected for processing (1)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (3 hunks)
🔇 Additional comments (3)
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (3)

4-6: New imports look good

No concerns introducing the AppOnboarding, db, and cache/Suspense modules.


24-45: Set valid props for the Onboarding component

  1. CTA property: If you don’t intend to display a call-to-action, remove the cta prop. Otherwise, specify meaningful text to guide users.
  2. sheetName: Setting this to an empty string effectively disables the component’s internal state handling. A previous review advised providing a proper name (e.g., "cloud_tests") so the component can manage its open state via useQueryState.
- cta=""
- sheetName=""
+ cta={t("app_onboarding.cloud_tests.cta")}
+ sheetName="cloud_tests"

70-82:

Details

❓ Verification inconclusive

Confirm behavior for missing session or orgId

Currently, if session or organizationId is undefined, the query returns an empty array, triggering the onboarding flow. Verify that this is desired or if you need to handle anonymous access differently.


🏁 Script executed:

#!/bin/bash
# Description: Look for any error handling or fallback code for missing orgId or session in the repository.
ast-grep --pattern $'if (session?.user?.organizationId == null) { $$$ }'

Length of output: 73


Review Comment Verification Outcome:
After running the search, no explicit conditional checks (e.g., if (session?.user?.organizationId == null) { … }) or alternative error-handling logic were found in the repository. In the current implementation, if either session or organizationId is missing, the database query will execute with an undefined condition and ultimately return an empty array—thereby triggering the onboarding flow.

  • Location: apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/tests/all/layout.tsx (Lines 70–82)
  • Code Snippet:
    const getTestsOverview = cache(async () => {
    	const session = await auth();
    	const orgId = session?.user.organizationId;
    
    	const tests = await db.organizationIntegrationResults.findMany({
    		where: {
    			organizationId: orgId,
    		},
    	});
    
    	return tests;
    });

Please confirm that returning an empty array in cases where the session or organization ID is missing is indeed the intended behavior for triggering the onboarding flow. If a different handling (e.g., explicit error messaging or separate logic for anonymous access) is required, then adjustments should be made accordingly.

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