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

[WEB-2543] chore: workspace inbox guest permission #5695

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Sep 25, 2024

Changes:

This PR updates the workspace inbox permissions for guest users.

Reference:

[WEB-2543]

Summary by CodeRabbit

  • New Features

    • Expanded access to notification methods (list, mark unread, archive, unarchive, create) for guest users.
    • Added guest user access to the "Inbox" menu item in the user menu.
  • Improvements

    • Updated rendering logic in the IssueView component to prioritize error states over loading states, enhancing user experience during data retrieval.
    • Modified cross-origin policy to improve resource sharing capabilities.

Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces several modifications to user role access across different components of the application. Specifically, the ROLE.GUEST has been added to the access permissions for various methods in the apiserver/plane/app/views/notification/base.py file, allowing guest users to perform actions previously restricted to admin and member roles. Additionally, the web/core/constants/dashboard.ts file has been updated to include guest permissions for the "Inbox" menu item. Changes to the IssueView component's rendering logic prioritize error handling over loading states.

Changes

Files Change Summary
apiserver/plane/app/views/notification/base.py Expanded allowed_roles to include ROLE.GUEST for methods: list, mark_unread, archive, unarchive, and create in MarkAllReadNotificationViewSet.
web/core/constants/dashboard.ts Updated access for SIDEBAR_USER_MENU_ITEMS to include EUserPermissions.GUEST, allowing guest users to access the "Inbox" menu item.
web/core/components/issues/peek-overview/view.tsx Modified conditional rendering logic in IssueView to prioritize displaying error states over loading states.

Possibly related PRs

Suggested labels

⚙️backend

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • rahulramesha
  • pablohashescobar

Poem

In the meadow where rabbits play,
New roles for guests have come to stay.
With open doors and hearts so wide,
Everyone's welcome, come inside!
Hopping with joy, we celebrate,
A friendly change that feels just great! 🐇✨


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>, 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 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
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

🧹 Outside diff range and nitpick comments (2)
web/core/components/issues/peek-overview/view.tsx (1)

148-153: Approve with suggestion: Simplify the conditional rendering logic.

The changes improve the readability of the code by using if-else statements instead of nested ternary operators, which is good. Prioritizing the error state check is also a good practice. However, the logic can be further simplified.

Consider simplifying the logic as follows:

-            {isError ? (
+            {isError && (
               <div className="relative h-screen w-full overflow-hidden">
                 <IssuePeekOverviewError removeRoutePeekId={removeRoutePeekId} />
               </div>
-            ) : (
-              isLoading && <IssuePeekOverviewLoader removeRoutePeekId={removeRoutePeekId} />
-            )}
+            )}
+            {!isError && isLoading && <IssuePeekOverviewLoader removeRoutePeekId={removeRoutePeekId} />}

This change maintains the priority of error state checking while simplifying the overall structure.

apiserver/plane/app/views/notification/base.py (1)

289-289: LGTM with a performance consideration: Guest role added to allowed roles for marking all notifications as read

This change is consistent with the previous updates and aligns with the PR objectives. It allows guest users to mark all their notifications as read, which is a useful functionality. The method maintains security by filtering notifications based on the authenticated user.

However, it's worth noting that this method performs a bulk update operation. While this is generally efficient, it could potentially impact performance if a user has a very large number of notifications. Consider implementing a limit on the number of notifications that can be marked as read in a single operation, or adding pagination to process notifications in batches for users with a high volume of notifications.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 85f7483 and 370e1bd.

📒 Files selected for processing (3)
  • apiserver/plane/app/views/notification/base.py (5 hunks)
  • web/core/components/issues/peek-overview/view.tsx (1 hunks)
  • web/core/constants/dashboard.ts (1 hunks)
🔇 Additional comments not posted (6)
web/core/constants/dashboard.ts (1)

328-328: LGTM! Verify backend permissions and update documentation.

The change to include EUserPermissions.GUEST in the access array for the "Inbox" item is correct and aligns with the PR objectives. This will allow guest users to see and access the "Inbox" feature in the sidebar.

To ensure full functionality, please verify that the backend permissions have been updated to allow guest users to access the inbox. Run the following script to check for any backend permission changes:

Consider updating any relevant documentation or user guides to reflect this new capability for guest users. This will ensure that all stakeholders are aware of the change in guest user permissions.

apiserver/plane/app/views/notification/base.py (5)

44-44: LGTM: Guest role added to allowed roles for listing notifications

This change aligns with the PR objective of updating workspace inbox permissions for guest users. It allows guests to list their notifications, which is appropriate for basic functionality. The security seems maintained as the method only retrieves notifications for the authenticated user.


210-210: LGTM: Guest role added to allowed roles for marking notifications as unread

This change is consistent with the updates to the list method and aligns with the PR objectives. It allows guest users to mark their notifications as unread, which is a reasonable functionality to provide. The method maintains security by checking if the notification belongs to the authenticated user.


222-222: LGTM: Guest role added to allowed roles for archiving notifications

This change is consistent with the previous updates and aligns with the PR objectives. It allows guest users to archive their notifications, which is a reasonable functionality to provide. The method maintains security by checking if the notification belongs to the authenticated user.


234-234: LGTM: Guest role added to allowed roles for unarchiving notifications

This change is consistent with the previous updates and aligns with the PR objectives. It allows guest users to unarchive their notifications, which complements the archiving functionality. The method maintains security by checking if the notification belongs to the authenticated user.


Line range hint 1-389: Summary: Comprehensive update of guest permissions for notification handling

This PR successfully updates the workspace inbox permissions for guest users across various notification-related operations. The changes are consistent and align well with the stated PR objectives. Here's a summary of the updates:

  1. Guests can now list their notifications
  2. Guests can mark notifications as unread
  3. Guests can archive and unarchive notifications
  4. Guests can mark all their notifications as read

Security is maintained throughout these changes as all methods appropriately filter or check notifications based on the authenticated user. This ensures that guests can only interact with their own notifications.

The only potential concern is the performance of the bulk update operation in the MarkAllReadNotificationViewSet, especially for users with a large number of notifications. Consider implementing a limit or pagination for this operation to ensure optimal performance for all users.

Overall, these changes provide a more inclusive experience for guest users while maintaining the necessary security measures.

@SatishGandham SatishGandham merged commit 22623fa into preview Sep 25, 2024
9 of 12 checks passed
@SatishGandham SatishGandham deleted the chore-workspace-inbox-guest-permission branch September 25, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants