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

Fix (temp): Wrap Integrations beforeLoad in Try/Catch and RenderBannerGuard if order #3115

Merged

Conversation

scott-ray-wilson
Copy link
Contributor

@scott-ray-wilson scott-ray-wilson commented Feb 13, 2025

Description 📣

This PR wraps the beforeLoad on the integrations list page in a try/catch to handle permission failure (temporary). Also adjusts if statements in permission banner guard to properly display

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

Summary by CodeRabbit

  • Refactor

    • Streamlined the logic for displaying an access warning, ensuring that users without permission are notified immediately.
  • New Features

    • Updated the secret management interface to enforce refined access controls on the Secret Syncs tab.
  • Bug Fixes

    • Enhanced error handling during data retrieval, ensuring smooth redirections in case of data load issues.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

The changes update the permission handling and error management logic across multiple components. In the permission component, the conditional check for displaying the guard banner is moved to the top of the logic flow, removing redundancy. In the secret manager pages, the permission prop for the Secret Syncs tab has been updated to use a specialized permission action and the pass-through prop removed. The route file now uses type annotations and try-catch blocks to capture data fetching errors, redirecting as needed.

Changes

File(s) Change Summary
frontend/.../ProjectPermissionCan.tsx Moved the guard banner check (renderGuardBanner & isAllowed) to the top, removing redundant checks and streamlining tooltip rendering logic.
frontend/.../IntegrationsListPage.tsx
frontend/.../route.tsx
Updated the IntegrationsListPage to use ProjectPermissionSecretSyncActions.Read instead of ProjectPermissionActions.Read for the Secret Syncs tab (removing the passThrough prop), and modified the route’s beforeLoad function to include type annotations and try-catch error handling for fetching integrations and secret syncs.

Suggested Reviewers

  • vmatsiiako
  • maidul98

Poem

I'm a rabbit hopping through the code,
Guard banners lighting my secret node.
Permissions dance like carrots in sight,
Errors caught in my try-catch flight.
With every update I nibble and roam,
Coding magic makes this garden my home!
🐇✨


🪧 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. (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.

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

@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 (2)
frontend/src/components/permissions/ProjectPermissionCan.tsx (1)

60-62: LGTM! Improved conditional flow.

Moving the guard banner check to the top of the logic flow improves code clarity and efficiency by prioritizing access restriction handling.

Consider adding a comment explaining the order-dependent nature of these conditions for future maintainers:

+        // Check access restriction first to prioritize guard banner display
         if (!isAllowed && renderGuardBanner) {
           return <ProjectPermissionGuardBanner />;
         }
frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx (1)

55-69: Consider reducing code duplication in redirect logic.

The redirect logic is duplicated across multiple catch blocks. Consider extracting it into a helper function.

+const redirectToIntegrations = (projectId: string, selectedTab: IntegrationsListPageTabs) => {
+  throw redirect({
+    to: "/secret-manager/$projectId/integrations",
+    params: { projectId },
+    search: { selectedTab }
+  });
+};

 let integrations: TIntegration[];
 try {
   integrations = await context.queryClient.ensureQueryData({
     queryKey: workspaceKeys.getWorkspaceIntegrations(projectId),
     queryFn: () => fetchWorkspaceIntegrations(projectId)
   });
 } catch {
-  throw redirect({
-    to: "/secret-manager/$projectId/integrations",
-    params: {
-      projectId
-    },
-    search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
-  });
+  redirectToIntegrations(projectId, IntegrationsListPageTabs.SecretSyncs);
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 93912da and ec12d57.

📒 Files selected for processing (3)
  • frontend/src/components/permissions/ProjectPermissionCan.tsx (1 hunks)
  • frontend/src/pages/secret-manager/IntegrationsListPage/IntegrationsListPage.tsx (2 hunks)
  • frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Check Frontend Type and Lint check
🔇 Additional comments (3)
frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx (2)

6-11: LGTM! Improved type safety.

Added proper type imports for better type checking and code maintainability.


28-43: LGTM! Enhanced error handling for secret syncs.

Added proper try/catch block to handle permission failures gracefully with redirects.

frontend/src/pages/secret-manager/IntegrationsListPage/IntegrationsListPage.tsx (1)

102-108: LGTM! Improved permission handling for secret syncs.

Updated to use the specialized ProjectPermissionSecretSyncActions.Read permission for better access control granularity.

@scott-ray-wilson scott-ray-wilson merged commit b269bb8 into main Feb 13, 2025
5 checks passed
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