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-2613] chore: open parent and sibling issue in new tab from peek-overview/ issue detail page. #5819

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

prateekshourya29
Copy link
Collaborator

@prateekshourya29 prateekshourya29 commented Oct 14, 2024

Issue link: WEB-2613

Summary by CodeRabbit

  • New Features

    • Links in the Issue Parent Detail and Sibling Item components now open in a new tab for improved navigation.
  • Bug Fixes

    • No bug fixes were included in this release.
  • Documentation

    • No documentation updates were made in this release.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes involve updates to the IssueParentDetail and IssueParentSiblingItem components, specifically modifying the Link component to include the target="_blank" attribute. This change allows links to open in a new tab when clicked. The overall structure and functionality of both components remain unchanged, including how they handle parent issue details and render sibling issues.

Changes

File Path Change Summary
web/core/components/issues/issue-detail/parent/root.tsx Updated Link component to include target="_blank" for new tab functionality.
web/core/components/issues/issue-detail/parent/sibling-item.tsx Updated Link component to include target="_blank" for new tab functionality.

Possibly related PRs

Suggested labels

🌐frontend, 🧹chore, 🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐇 In the meadow, links now gleam,
With a click, they open, a new tab dream.
Parent details, siblings too,
All stay intact, just a change or two.
Hopping through code, we make it bright,
A simple tweak, oh what a delight! 🌼


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/issues/issue-detail/parent/sibling-item.tsx (1)

36-36: Approve with suggestions: Add security attribute and consider UX improvement

The addition of target="_blank" successfully implements the desired functionality of opening parent and sibling issues in a new tab, aligning with the PR objectives. However, I have two suggestions for improvement:

  1. For security reasons, when using target="_blank", it's recommended to also include rel="noopener noreferrer". This prevents potential vulnerabilities related to tabnabbing.

  2. Consider adding a visual indicator (e.g., an icon) to show users that the link will open in a new tab, improving the user experience.

Here's a suggested improvement:

<Link
  href={`/${workspaceSlug}/projects/${issueDetail?.project_id as string}/issues/${issueDetail.id}`}
- target="_blank"
+ target="_blank" rel="noopener noreferrer"
  className="flex items-center gap-2 py-0.5"
>
  {issueDetail.project_id && projectDetails?.identifier && (
    <>
      <IssueIdentifier
        projectId={issueDetail.project_id}
        issueTypeId={issueDetail.type_id}
        projectIdentifier={projectDetails?.identifier}
        issueSequenceId={issueDetail.sequence_id}
        textContainerClassName="text-xs"
      />
+     <span className="text-xs">↗️</span> {/* or use an appropriate icon from your UI library */}
    </>
  )}
</Link>

This change adds the security attribute and a simple visual indicator for the new tab behavior.

web/core/components/issues/issue-detail/parent/root.tsx (2)

45-45: Approved with a security suggestion.

The addition of target="_blank" successfully implements the desired functionality of opening parent issues in a new tab. This aligns with the PR objectives and can improve user experience.

However, for security reasons, it's recommended to add rel="noopener noreferrer" when using target="_blank". This prevents potential vulnerabilities where the new page could access the original page's JavaScript context.

Consider updating the Link component as follows:

-        <Link href={`/${workspaceSlug}/projects/${parentIssue?.project_id}/issues/${parentIssue.id}`} target="_blank">
+        <Link href={`/${workspaceSlug}/projects/${parentIssue?.project_id}/issues/${parentIssue.id}`} target="_blank" rel="noopener noreferrer">

This change maintains the desired functionality while enhancing security.


Action Required: Update <Link> Components to Include target="_blank"

The following <Link> components are missing the target="_blank" attribute. Updating them will ensure consistency and enhance security by properly handling external links.

  • space/helpers/authentication.helper.tsx

    <Link className="underline underline-offset-4 font-medium hover:font-bold transition-all" href={`/admin`}>
      Sign In
    </Link>
  • space/core/lib/instance-provider.tsx

    <Link href={`${SPACE_BASE_PATH}/`} className="h-[30px] w-[133px]">
      <Image src={logo} alt="Plane logo" />
    </Link>
  • space/core/components/views/auth.tsx

    <Link href={`${SPACE_BASE_PATH}/`} className="h-[30px] w-[133px]">
      <Image src={logo} alt="Plane logo" />
    </Link>
  • web/app/sign-up/page.tsx

    <Link href={`/`} className="h-[30px] w-[133px]">
      <Image src={logo} alt="Plane logo" />
    </Link>
  • web/app/profile/sidebar.tsx

    <Link href={`/${redirectWorkspaceSlug}`} onClick={handleItemClick}>
      <div className={`flex flex-shrink-0 items-center gap-2 truncate px-4 pt-4 ${sidebarCollapsed ? "justify-center" : ""}`}>
        {/* ... */}
      </div>
    </Link>
  • web/app/page.tsx

    <Link href={`/`} className="h-[30px] w-[133px]">
      <Image src={logo} alt="Plane logo" />
    </Link>
  • web/app/not-found.tsx

    <Link href="/">
      <span className="flex justify-center">
        <Button variant="neutral-primary" size="md">
          Go to Home
        </Button>
      </span>
    </Link>
  • web/app/invitations/page.tsx

    <Link href={`/${redirectWorkspaceSlug}`}>
      <span>
        <Button variant="neutral-primary" size="md">
          Go Home
        </Button>
      </span>
    </Link>
  • web/core/components/workspace/sidebar/user-menu.tsx

    <Link key={link.key} href={getHref(link)} onClick={() => handleLinkClick(link.key)}>
      <SidebarNavItem
        className={`${sidebarCollapsed ? "p-0 size-8 aspect-square justify-center mx-auto" : ""}`}
        isActive={link.highlight(pathname, `/${workspaceSlug}`, { userId: currentUser?.id })}
      />
    </Link>
  • web/core/layouts/auth-layout/workspace-wrapper.tsx

    <Link href="/">
      <Button>Go Home</Button>
    </Link>

Please review and update these components to include target="_blank" where appropriate to maintain consistency and improve user experience.

🔗 Analysis chain

Line range hint 1-78: Overall assessment: Functionality implemented with a minor security enhancement suggested.

The change successfully implements the PR objective of opening parent issues in a new tab. The modification is minimal and focused, which is good for maintainability.

To ensure consistency across the codebase, it would be beneficial to check if similar changes are needed in other components, particularly in the IssueParentSiblings component mentioned in this file. Run the following script to find other potential locations where this change might be applicable:

This will help identify other Link components that might benefit from the same update for consistency across the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find other potential locations where target="_blank" might be needed for consistency.

# Test: Search for Link components that might need the target="_blank" attribute.
rg --type typescript --type typescriptreact 'import.*Link.*from.*next/link' -A 10 | rg '<Link' -A 3

Length of output: 136


Script:

#!/bin/bash
# Description: Find other potential locations where target="_blank" might be needed for consistency.

# Test: Search for Link components that might need the target="_blank" attribute.
rg --type ts --type tsx 'import.*Link.*from.*next/link' -A 10 | rg '<Link' -A 3

Length of output: 109


Script:

#!/bin/bash
# Description: Find other potential locations where target="_blank" might be needed for consistency.

# Test: Search for Link components that might need the target="_blank" attribute in .ts and .tsx files.
rg 'import.*Link.*from.*next/link' --glob '*.ts' --glob '*.tsx' -A 10 | rg '<Link' -A 3

Length of output: 347


Script:

#!/bin/bash
# Description: Identify <Link> components missing the target="_blank" attribute for consistency.

# Search for Link components in .ts and .tsx files
# and list those that do not have target="_blank" specified.
rg '<Link\b(?![^>]*\btarget=["'\'']_blank["'\''])[^>]*>' --glob '*.ts' --glob '*.tsx' --context 3

Length of output: 355


Script:

#!/bin/bash
# Description: Identify <Link> components missing the target="_blank" attribute for consistency.

# Search for Link components in .ts and .tsx files
# and list those that do not have target="_blank" specified.
rg --pcre2 '<Link\b(?![^>]*\btarget=["'\'']_blank["'\''])[^>]*>' --glob '*.ts' --glob '*.tsx' --context 3

Length of output: 59426

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 701af73 and c4925a6.

📒 Files selected for processing (2)
  • web/core/components/issues/issue-detail/parent/root.tsx (1 hunks)
  • web/core/components/issues/issue-detail/parent/sibling-item.tsx (1 hunks)
🧰 Additional context used

@pushya22 pushya22 merged commit 8d0611b into preview Oct 15, 2024
14 of 15 checks passed
@pushya22 pushya22 deleted the chore/parent-sibling-issue branch October 15, 2024 08:07
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