Skip to content

fix: sidebar new issue button paper cuts#5863

Closed
kidonng wants to merge 1 commit intomakeplane:previewfrom
kidonng:fix/sidebar-new-issue
Closed

fix: sidebar new issue button paper cuts#5863
kidonng wants to merge 1 commit intomakeplane:previewfrom
kidonng:fix/sidebar-new-issue

Conversation

@kidonng
Copy link

@kidonng kidonng commented Oct 18, 2024

The "New issue" button in the sidebar is deceptively larger than its actually clickable area:

CleanShot 2024-10-18 at 11 47 04@2x

I have encountered this paper cut bug several times, hence this proposed fix.

CleanShot.2024-10-18.at.11.45.08.mp4

Summary by CodeRabbit

  • New Features

    • Enhanced the sidebar quick actions with a new button for creating issues, now responsive to user permissions and project membership.
  • Bug Fixes

    • Improved button interaction by directly managing the disabled state to prevent unauthorized actions.
  • Chores

    • Cleaned up the code by removing commented-out sections, streamlining the component.

@CLAassistant
Copy link

CLAassistant commented Oct 18, 2024

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

The changes in this pull request modify the SidebarQuickActions component in quick-actions.tsx. A new click handler is introduced for the main button to open the issue creation modal, incorporating checks for user permissions and project membership. The previous click handler is removed, and the button's disabled property is set directly based on these conditions. Additionally, commented-out code related to the last drafted issue is removed, while the component's overall structure, hover effects, and layout remain unchanged.

Changes

File Path Change Summary
web/core/components/workspace/sidebar/quick-actions.tsx Added a new click handler for the main button, removed the previous handler, set button's disabled property directly, and cleaned up commented-out code.

Possibly related PRs

  • [WEB-2344] fix: quick action hover #5449: The changes in this PR focus on improving the hover behavior of quick actions, which is directly related to the modifications made in the SidebarQuickActions component in the main PR, enhancing user interaction with quick action elements.

Suggested labels

🐛bug, 🌐frontend, 🎨UI / UX

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐇 In the sidebar where quick actions play,
A button now checks if it’s okay.
With permissions in sight,
It opens just right,
For issues to draft and convey! ✨


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 (3)
web/core/components/workspace/sidebar/quick-actions.tsx (3)

86-93: Improved click handler implementation. Consider adding a comment for clarity.

The new click handler for the "New issue" button is well-implemented. It correctly checks the disabled state before proceeding, which prevents unintended actions when the button should be inactive. The use of setTrackElement for analytics and toggleCreateIssueModal to open the modal are appropriate.

Consider adding a brief comment explaining the purpose of the disabled check, especially since the button's visual state is controlled separately. This could improve code readability:

 onClick={() => {
   if (disabled) {
+    // Prevent action if user doesn't have permission or no projects are available
     return;
   }

   setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
   toggleCreateIssueModal(true);
 }}

Line range hint 1-150: Consider cleaning up unused variables and functions

Now that the draft issue functionality has been removed, there are some unused variables and functions that could be cleaned up to improve code maintainability:

Consider removing or commenting out the following unused elements:

  1. isDraftIssueModalOpen state and its setter
  2. CreateUpdateIssueModal component (if it's not used elsewhere in this file)
  3. removeWorkspaceDraftIssue function
  4. workspaceDraftIssue variable
  5. Any unused imports related to these removed elements

Here's a partial example of the cleanup:

- const [isDraftIssueModalOpen, setIsDraftIssueModalOpen] = useState(false);
- const workspaceDraftIssue = workspaceSlug ? (storedValue?.[workspaceSlug] ?? undefined) : undefined;

- const removeWorkspaceDraftIssue = () => {
-   const draftIssues = storedValue ?? {};
-   if (workspaceSlug && draftIssues[workspaceSlug]) delete draftIssues[workspaceSlug];
-   setValue(draftIssues);
-   return Promise.resolve();
- };

  return (
    <>
-     <CreateUpdateIssueModal
-       isOpen={isDraftIssueModalOpen}
-       onClose={() => setIsDraftIssueModalOpen(false)}
-       data={workspaceDraftIssue ?? {}}
-       onSubmit={() => removeWorkspaceDraftIssue()}
-       isDraft
-     />
      <div
        className={cn("flex items-center justify-between gap-1 cursor-pointer", {
          "flex-col gap-0": isSidebarCollapsed,
        })}
      >
        {/* ... rest of the component ... */}
      </div>
    </>
  );

After making these changes, be sure to remove any unused imports at the top of the file.


Remaining references to draft issues detected in the codebase.

Multiple instances of draftIssues are still present, suggesting that draft issue functionality is active. Please verify whether the removal of the commented-out code impacts these areas or if additional cleanup is necessary.

  • web/core/store/issue/helpers/base-issues.store.ts
  • web/core/store/issue/root.store.ts
  • web/core/store/issue/draft/issue.store.ts
  • web/core/components/issues/issue-modal/base.tsx
  • web/core/components/workspace/sidebar/quick-actions.tsx
  • web/core/components/workspace/sidebar/user-menu.tsx
  • web/core/hooks/use-issues-actions.tsx
  • web/core/hooks/store/use-issues.ts
  • web/core/constants/empty-state.ts
  • web/app/[workspaceSlug]/(projects)/drafts/header.tsx
🔗 Analysis chain

Line range hint 1-150: Approval for removing commented-out code. Verify if functionality is needed elsewhere.

The removal of the large block of commented-out code related to draft issues is a good practice. It improves code readability and maintainability by eliminating unused code.

Please confirm that the draft issue functionality has been intentionally removed or relocated. If it's still needed, ensure it's implemented elsewhere in the codebase.

To verify this, you can run the following command to search for any remaining references to draft issues:

If the functionality is indeed no longer needed, consider removing any related unused imports, state variables, or functions (e.g., removeWorkspaceDraftIssue) to keep the code clean and efficient.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to draft issues in the codebase
rg --type typescript --type tsx 'draftIssue|draft issue|lastDraftedIssue'

Length of output: 110


Script:

#!/bin/bash
# Search for references to draft issues in .ts and .tsx files
rg 'draftIssue|draft issue|lastDraftedIssue' --glob '**/*.ts' --glob '**/*.tsx'

Length of output: 3797

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9530884 and 078f468.

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

@SatishGandham
Copy link
Contributor

Hello @kidonng , thats a poor UX. Thanks for pointing it out, and raising the PR.
Having on click event on a div is semantically in correct in this context. We should expand the button, probably by moving the styling from the div to the button.
Can you make this change? If not someone from our team will pick it up.

@SatishGandham
Copy link
Contributor

This is handled in this PR. Thanks for reporting it, and taking time to submit a PR.

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.

3 participants