Skip to content

Comments

[WEB-2488] fix: only the owner of a view can publish their project views#5799

Closed
sharma01ketan wants to merge 3 commits intopreviewfrom
fix/project-view-publish
Closed

[WEB-2488] fix: only the owner of a view can publish their project views#5799
sharma01ketan wants to merge 3 commits intopreviewfrom
fix/project-view-publish

Conversation

@sharma01ketan
Copy link
Contributor

@sharma01ketan sharma01ketan commented Oct 11, 2024

[WEB-2488]

This PR changes the permission level of Project Views: Only the owner of a Project View can publish the view.

For Admin:

Screen.Recording.2024-10-11.at.1.05.46.PM.mov

For Member:

Screen.Recording.2024-10-11.at.1.06.18.PM.mov

Summary by CodeRabbit

  • New Features

    • Updated user permissions for the publish modal, now allowing only owners to open it.
    • Introduced a new check for publishing views based on user roles.
  • Bug Fixes

    • Improved control flow related to user permissions for enhanced security.

@sharma01ketan sharma01ketan added 🐛bug Something isn't working 🌐frontend labels Oct 11, 2024
@sharma01ketan sharma01ketan added this to the v0.24.0 milestone Oct 11, 2024
@sharma01ketan sharma01ketan self-assigned this Oct 11, 2024
@sharma01ketan sharma01ketan marked this pull request as ready for review October 11, 2024 08:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request focus on modifying the ViewQuickActions component located in web/core/components/views/quick-actions.tsx. A new variable, canPublishView, is introduced to check user permissions for publishing views, specifically for users with EUserPermissions.ADMIN and EUserPermissions.MEMBER at the EUserPermissionsLevel.PROJECT level. The logic for opening the publish modal is updated to only consider the isOwner condition, excluding the previous isAdmin check. The component's overall structure remains unchanged.

Changes

File Path Change Summary
web/core/components/views/quick-actions.tsx Introduced canPublishView for permission checks, updated modal opening logic to only allow owners, and adjusted rendering logic for the publish menu item.

Possibly related PRs

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • pushya22

🐰 In a garden where permissions grow,
Only owners can publish, this we know.
Admins step back, the rules are clear,
A hop for the rights, let’s give a cheer!
With a twitch of the nose, the changes are done,
In the world of quick actions, we’ve had our fun! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 50fa85b and 2b96b5b.

📒 Files selected for processing (1)
  • web/core/components/views/quick-actions.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/views/quick-actions.tsx

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 (1)
web/core/components/views/quick-actions.tsx (1)

41-41: Suggestion: Add an explanatory comment

Consider adding a comment above this line to explain the reasoning behind restricting the publish action to only the owner. This will help future developers understand the intentional permission restriction.

Example comment:

// Only the view owner can publish to ensure strict control over view publication
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2c96e04 and 50fa85b.

📒 Files selected for processing (1)
  • web/core/components/views/quick-actions.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
web/core/components/views/quick-actions.tsx (1)

41-41: Approved: Restrict publish action to view owner only

This change aligns with the PR objective of allowing only the owner to publish their view. It enhances security and control over project views.

To ensure consistency across the codebase, please run the following script:

This script will help identify any inconsistencies in publish permissions across the codebase.

✅ Verification successful

To address the issues with the previous script, please run the following updated shell scripts:


Verified: Publish actions are correctly restricted to view owners only

The shell script results confirm that there are no other instances where isAdmin controls publish permissions. This ensures that only the view owner can publish, aligning with the PR objectives and maintaining consistency across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that publish actions are restricted to view owners across the codebase

# Test 1: Search for other occurrences of useViewPublish
echo "Searching for other occurrences of useViewPublish:"
rg --type typescript --type tsx "useViewPublish\(" -C 3

# Test 2: Search for other publish-related functions or components
echo "Searching for other publish-related functions or components:"
rg --type typescript --type tsx "publish.*view" -i -C 3

# Test 3: Search for admin-related publish permissions
echo "Searching for admin-related publish permissions:"
rg --type typescript --type tsx "isAdmin.*publish" -C 3

Length of output: 627


Script:

#!/bin/bash
# Description: Verify that publish actions are restricted to view owners across the codebase

# Test 1: Search for other occurrences of useViewPublish
echo "Searching for other occurrences of useViewPublish:"
rg "useViewPublish\(" --glob "*.ts" --glob "*.tsx" -C 3

# Test 2: Search for other publish-related functions or components
echo "Searching for other publish-related functions or components:"
rg "publish.*view" -i --glob "*.ts" --glob "*.tsx" -C 3

# Test 3: Search for admin-related publish permissions
echo "Searching for admin-related publish permissions:"
rg "isAdmin.*publish" --glob "*.ts" --glob "*.tsx" -C 3

Length of output: 20824

@sharma01ketan sharma01ketan changed the title [WEB-2488] fix: only the owner can publish their publish view [WEB-2488] fix: only the owner can publish their project views Oct 11, 2024
@sharma01ketan sharma01ketan changed the title [WEB-2488] fix: only the owner can publish their project views [WEB-2488] fix: only the owner of a view can publish their project views Oct 11, 2024
@sharma01ketan sharma01ketan marked this pull request as draft October 11, 2024 13:09
@sharma01ketan sharma01ketan marked this pull request as ready for review October 22, 2024 03:10
@pushya22
Copy link
Collaborator

This change is not required.

@pushya22 pushya22 closed this Oct 24, 2024
@sriramveeraghanta sriramveeraghanta deleted the fix/project-view-publish branch May 2, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛bug Something isn't working 🌐frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants