Skip to content

Conversation

@carhartlewis
Copy link
Contributor

@carhartlewis carhartlewis commented Mar 17, 2025

…ayout and risk pages; change login redirects to /auth for improved user experience

Summary by CodeRabbit

  • Bug Fixes
    • Revised the authentication flow so unauthenticated users are now directed to the updated sign-in page.
  • Chores
    • Upgraded several system dependencies to enhance overall performance and stability.
  • Style
    • Improved code formatting and indentation across multiple components for better readability.
  • New Features
    • Enhanced the SecondaryMenu styling to prevent text selection on specific elements.

…ayout and risk pages; change login redirects to /auth for improved user experience
@vercel
Copy link

vercel bot commented Mar 17, 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 Mar 17, 2025 5:12pm
comp-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2025 5:12pm

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2025

Walkthrough

This pull request updates the authentication flow and code formatting across several dashboard and risk-related components. The redirect path for unauthenticated users has been changed from /login to /auth in multiple files, and there are several indentation and formatting adjustments to improve code clarity. Additionally, dependency versions in the database package have been upgraded.

Changes

File(s) Change Summary
apps/app/src/app/[locale]/(app)/(dashboard)/(home)/layout.tsx
apps/app/src/app/[locale]/(app)/(dashboard)/risk/**
Adjusted formatting and indentation; updated authentication redirect from /login to /auth for unauthenticated accesses in layout and risk-related pages.
packages/db/package.json Upgraded dependencies: updated versions for @auth/prisma-adapter, @prisma/adapter-neon, @prisma/client, prisma, and typescript to newer releases.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant AppServer

    Browser->>AppServer: Request Page
    AppServer->>AppServer: Check session & organization ID
    alt Session invalid/missing organization ID
      AppServer->>Browser: Redirect to /auth
    else Session valid
      AppServer->>Browser: Render requested page with layout and components
    end
Loading

Possibly Related PRs

  • Refactor Risk Management and RisksByStatus components for improved re… #137: The changes in the main PR and the retrieved PR are related through the modification of the redirect path from "/login" to "/auth" for unauthenticated users, which affects the control flow in both the Layout and RiskPage functions.
  • Mariano/stuff #45: The changes in the main PR and the retrieved PR are related through the modification of the redirect path from "/login" to "/auth" in both the Layout function and the RiskPage function, indicating a shared logic for user authentication handling.
  • Clean up (metadata) + fixes #51: The changes in the main PR and the retrieved PR are related through the modification of the redirect path for unauthenticated users, specifically changing it from "/login" to "/auth" in both the Layout and RiskPage functions.

Poem

I'm just a rabbit, hopping through the code,
Redirects now lead to /auth on the road.
Formatting and spacing, neat and refined,
Dependencies upgraded, neatly aligned.
With a bounce in my step and a hop full of cheer,
The code's now merry and bright, oh dear!
🐰✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ 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 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.

…y; update styling to remove unnecessary classes and ensure select-none is applied where appropriate.
Copy link

@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 (3)
apps/app/src/app/[locale]/(app)/(dashboard)/policies/all/(overview)/actions/get-policies.ts (3)

47-111: Consider extracting duplicate WHERE condition

The WHERE condition is duplicated between the findMany and count queries. This could be extracted to a variable to improve maintainability.

 try {
   const skip = (page - 1) * pageSize;
   const [column, order] = sort?.split(":") ?? [];

   let orderByClause: any = { updatedAt: "desc" };

   if (column) {
     // ...existing orderByClause logic...
   }

+  const whereCondition = {
+    organizationId: user.organizationId,
+    AND: [
+      search
+        ? {
+            policy: {
+              OR: [
+                { name: { contains: search, mode: "insensitive" } },
+                {
+                  description: {
+                    contains: search,
+                    mode: "insensitive",
+                  },
+                },
+              ],
+            },
+          }
+        : {},
+      status ? { status: status as any } : {},
+    ],
+  };
+
   const [policies, total] = await Promise.all([
     db.organizationPolicy.findMany({
-      where: {
-        organizationId: user.organizationId,
-        AND: [
-          search
-            ? {
-                policy: {
-                  OR: [
-                    { name: { contains: search, mode: "insensitive" } },
-                    {
-                      description: {
-                        contains: search,
-                        mode: "insensitive",
-                      },
-                    },
-                  ],
-                },
-              }
-            : {},
-          status ? { status: status as any } : {},
-        ],
-      },
+      where: whereCondition,
       select: {
         // ...existing select...
       },
       skip,
       take: pageSize,
       orderBy: orderByClause,
     }),
     db.organizationPolicy.count({
-      where: {
-        organizationId: user.organizationId,
-        AND: [
-          search
-            ? {
-                policy: {
-                  OR: [
-                    { name: { contains: search, mode: "insensitive" } },
-                    {
-                      description: {
-                        contains: search,
-                        mode: "insensitive",
-                      },
-                    },
-                  ],
-                },
-              }
-            : {},
-          status ? { status: status as any } : {},
-        ],
-      },
+      where: whereCondition,
     }),
   ]);

67-67: Consider using proper type for status

The code uses status as any which bypasses TypeScript's type checking. If possible, define a proper type for the status field to maintain type safety.

- status ? { status: status as any } : {},
+ status ? { status } : {},

If the status parameter has a different type than the database field, consider properly typing and transforming it:

- status ? { status: status as any } : {},
+ status ? { status: status as PolicyStatus } : {},

Where PolicyStatus would be the appropriate enum or type.


31-31: Consider type safety improvement for orderByClause

orderByClause is typed as any which bypasses TypeScript's type checking. If possible, define a proper type for better maintainability.

- let orderByClause: any = { updatedAt: "desc" };
+ let orderByClause: Prisma.OrganizationPolicyOrderByWithRelationInput = { updatedAt: "desc" };

This would require importing the appropriate Prisma type:

import { Prisma } from "@bubba/db";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f037576 and 805e10a.

📒 Files selected for processing (6)
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworkProgress.tsx (2 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksGrid.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksOverview.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/RequirementStatusChart.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/policies/all/(overview)/actions/get-policies.ts (1 hunks)
  • packages/ui/src/components/secondary-menu.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (5)
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworkProgress.tsx
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksOverview.tsx
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksGrid.tsx
  • apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/RequirementStatusChart.tsx
  • packages/ui/src/components/secondary-menu.tsx
🔇 Additional comments (3)
apps/app/src/app/[locale]/(app)/(dashboard)/policies/all/(overview)/actions/get-policies.ts (3)

7-16: LGTM: Improved architecture with AuthActionClient

The refactored implementation now properly leverages the authActionClient pattern with schema validation and metadata tracking. This is a better approach than the previous caching mechanism via unstable_cache as it provides more consistent authentication handling.


17-25: Good authentication check

Validating the presence of user.organizationId early in the function and returning a clear error message ensures proper access control and prevents unauthorized data access.


113-116: Response structure improvement

The simplified response structure with success flag and either data or error field makes error handling more consistent on the client side.

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