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

Feat/file attachment display #68

Merged
merged 3 commits into from
Jun 25, 2024
Merged

Feat/file attachment display #68

merged 3 commits into from
Jun 25, 2024

Conversation

Harman-singh-waraich
Copy link
Contributor

@Harman-singh-waraich Harman-singh-waraich commented Jun 25, 2024


PR-Codex overview

This PR introduces a new feature for displaying attachments with a custom scrollbar and file viewers. It also includes styling updates and a new header component for the Attachment Display page.

Detailed summary

  • Added AttachmentDisplay page with header and file viewer components
  • Updated global styles for scrollbar and hidden canvas element
  • Included new components like Loader, FileViewer, and MarkdownRenderer
  • Added new dependencies like @cyntler/react-doc-viewer
  • Updated existing components with styled components and routing logic

The following files were skipped due to too many changes: web/src/pages/AttachmentDisplay/index.tsx, yarn.lock

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Added attachment viewer functionality with the new AttachmentDisplay route.
    • Introduced the FileViewer component for viewing various types of files.
  • Enhancements

    • Replaced anchor tags with styled Link components for better navigation and styling in the AttachedFile component.
    • Updated Header component's z-index for improved layering and display.
  • Bug Fixes

    • Added custom scrollbar styles for a better user experience.
    • Fixed an issue with the body tag height caused by a canvas element in @cyntler/react-doc-viewer, by hiding the element.
  • New Components

    • Introduced Loader component for loading animations.
    • Added Header and AttachmentDisplay components specific to the attachment viewing feature.

Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Walkthrough

The update introduces a document viewer feature within the web application, adding a new dependency, @cyntler/react-doc-viewer. It includes new components for file viewing, attachment display, and a loader animation. Additionally, route configurations and style enhancements were implemented for better user interaction and document management on the platform.

Changes

Files/Paths Change Summaries
web/package.json Added dependency @cyntler/react-doc-viewer at version 1.16.3.
web/src/app.tsx Imported AttachmentDisplay and added a new route attachment/* in the App component.
web/src/components/FileViewer/index.tsx Added FileViewer component for viewing various file types and StyledDocViewer styled component.
web/src/components/Loader.tsx Introduced Loader component with a styled Kleros icon and breathing animation.
web/src/components/PreviewCard/Terms/… Replaced anchor tag with Link component, adjusted styles, and updated link destination in AttachedFile component.
web/src/layout/Header/index.tsx Updated the z-index of the container from 1 to 10.
web/src/pages/AttachmentDisplay/Header.tsx Added Header component with title and navigation button for AttachmentDisplay page.
web/src/pages/AttachmentDisplay/index.tsx Implemented AttachmentDisplay component for viewing attachments with an option to open in a new tab.
web/src/pages/MyTransactions/index.tsx Added a new line before the <Route> declaration within the Dashboard component.
web/src/styles/customScrollbar.ts Introduced custom scrollbar styling.
web/src/styles/global-style.ts Added CSS rule .hiddenCanvasElement to hide the canvas element injected by @cyntler/react-doc-viewer.

Poem

A viewer now for files galore,
With Links to guide, no anchors more. 🌐
A loader breathes in rhythmic glee,
Custom scrollbars smooth and free.
Attachments viewable, oh what a sight,
In tabs or pages, day or night.
Our web app shines with features bright!✨🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

netlify bot commented Jun 25, 2024

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit 5473436
🔍 Latest deploy log https://app.netlify.com/sites/kleros-escrow-v2/deploys/667aa95cec469f0008394520
😎 Deploy Preview https://deploy-preview-68--kleros-escrow-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9a56ba0 and 867a34d.

Files ignored due to path filters (4)
  • web/src/assets/svgs/icons/arrow-left.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/new-tab.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/paperclip.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (12)
  • web/package.json (1 hunks)
  • web/src/app.tsx (2 hunks)
  • web/src/components/FileViewer/Viewers/MarkdownViewer.tsx (1 hunks)
  • web/src/components/FileViewer/index.tsx (1 hunks)
  • web/src/components/Loader.tsx (1 hunks)
  • web/src/components/PreviewCard/Terms/AttachedFile.tsx (1 hunks)
  • web/src/layout/Header/index.tsx (2 hunks)
  • web/src/pages/AttachmentDisplay/Header.tsx (1 hunks)
  • web/src/pages/AttachmentDisplay/index.tsx (1 hunks)
  • web/src/pages/MyTransactions/index.tsx (1 hunks)
  • web/src/styles/customScrollbar.ts (1 hunks)
  • web/src/styles/global-style.ts (1 hunks)
Files not reviewed due to errors (1)
  • web/src/components/FileViewer/index.tsx (no review received)
Files skipped from review due to trivial changes (3)
  • web/package.json
  • web/src/pages/AttachmentDisplay/Header.tsx
  • web/src/pages/MyTransactions/index.tsx
Additional comments not posted (8)
web/src/layout/Header/index.tsx (1)

8-8: Ensure z-index value is harmonized across the application.

The increase of z-index from 1 to 10 is appropriate for ensuring the header stays on top of other elements. However, confirm that this change does not conflict with other z-index values in the application to avoid layering issues.

Verification successful

Ensure z-index value is harmonized across the application.

The search results show that there are multiple z-index values across the application, with the highest being 30 in web/src/layout/Header/index.tsx. This indicates that the increase to 10 does not conflict with other values, as it is still lower than 30.

  • web/src/layout/Header/index.tsx: z-index: 10 and z-index: 30
  • web/src/components/Overlay.tsx: z-index: 1
  • web/src/layout/Header/navbar/index.tsx: z-index: 1
  • web/src/components/TransactionsDisplay/Search.tsx: z-index: 0
  • web/src/components/StyledSkeleton.tsx: z-index: 0
  • web/src/layout/Header/navbar/DappList.tsx: z-index: 1
  • web/src/layout/Header/navbar/Menu/Help.tsx: z-index: 1
  • web/src/layout/Header/navbar/Menu/Settings/index.tsx: z-index: 1
  • web/src/pages/MyTransactions/Modal/StyledModal.tsx: z-index: 10

Based on this, the z-index value of 10 in web/src/layout/Header/index.tsx is appropriate and does not cause any conflicts with other components.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for potential z-index conflicts across the application.

# Search for z-index usage in styles across the application. Expect: No conflicting higher values than 10.
rg --type css "z-index: [1-9][1-9]"

Length of output: 186



Script:

#!/bin/bash
# Description: Check for potential z-index conflicts across the application.

# Search for z-index usage in styles across the application in various file types.
rg "z-index: [1-9][1-9]" --glob '*.{css,scss,sass,less,tsx,ts,js,jsx}'

Length of output: 72



Script:

#!/bin/bash
# Description: Check for all z-index usage across the application to manually inspect potential conflicts.

# Search for all z-index usage in styles across the application in various file types.
rg "z-index:" --glob '*.{css,scss,sass,less,tsx,ts,js,jsx}'

Length of output: 660

web/src/styles/customScrollbar.ts (1)

3-26: Custom scrollbar implementation reviewed and looks good.

The custom scrollbar styles are well-implemented, making use of theme properties and ensuring consistent UI across browsers. This enhances the user experience by maintaining a uniform look and feel.

web/src/components/PreviewCard/Terms/AttachedFile.tsx (1)

2-2: Good use of Link component for internal navigation.

Replacing the a tag with Link from react-router-dom enhances SPA behavior by avoiding unnecessary page reloads. Ensure that all URI constructions are secure and do not expose any vulnerabilities, especially since getIpfsUrl is used for constructing the URI.

Also applies to: 9-31

Verification successful

Good use of Link component for internal navigation.

Replacing the a tag with Link from react-router-dom enhances SPA behavior by avoiding unnecessary page reloads. The getIpfsUrl function appears to be implemented securely by correctly formatting IPFS paths and appending them to a gateway URL.

  • web/src/utils/getIpfsUrl.ts: Implementation of getIpfsUrl and getFormattedPath functions.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure that the URI construction via `getIpfsUrl` is secure.

# Search for `getIpfsUrl` usage and ensure it is safely implemented.
rg --type tsx "getIpfsUrl"

Length of output: 54



Script:

#!/bin/bash
# Description: Ensure that the URI construction via `getIpfsUrl` is secure.

# Search for `getIpfsUrl` usage and ensure it is safely implemented.
rg --type js "getIpfsUrl"

Length of output: 25



Script:

#!/bin/bash
# Description: Ensure that the URI construction via `getIpfsUrl` is secure.

# Search for `getIpfsUrl` usage across all file types to ensure it is safely implemented.
rg "getIpfsUrl"

Length of output: 478



Script:

#!/bin/bash
# Description: Retrieve the implementation of `getIpfsUrl` to verify its security.

# Extract the implementation of `getIpfsUrl` from its definition file.
rg --type ts --context 10 "getIpfsUrl" web/src/utils/getIpfsUrl.ts

Length of output: 503

web/src/components/FileViewer/Viewers/MarkdownViewer.tsx (1)

21-32: Review base64 handling and Markdown rendering.

Ensure that the base64 decoding process is secure and does not expose the application to injection attacks, especially in the context of Markdown rendering which may include user-generated content.

web/src/components/Loader.tsx (1)

9-47: Animation implementation in Loader component reviewed.

The breathing animation for the Kleros icon is well-implemented, using keyframes for smooth transitions. Ensure that the performance is monitored, especially on devices with lower specifications to prevent UI sluggishness.

web/src/app.tsx (2)

16-16: Addition of AttachmentDisplay import

The import statement for AttachmentDisplay is correctly placed and follows the existing import structure. Ensure that AttachmentDisplay is properly unit tested, especially since it's a new entry in the routing configuration.


32-32: Routing integration for attachment/*

The addition of a new route for attachment/* is consistent with the application's routing structure. It's crucial to ensure that the AttachmentDisplay component handles edge cases, such as invalid or malicious URLs, to prevent potential security issues.

web/src/styles/global-style.ts (1)

119-123: Addition of .hiddenCanvasElement style

The addition of this rule to hide the canvas element injected by @cyntler/react-doc-viewer is a clever workaround to a common issue with third-party components altering global styles. Ensure that this does not unintentionally hide other canvas elements used in the application.

Verification successful

No other canvas elements found

The search did not find any <canvas> elements in the web/src directory. This indicates that the addition of the .hiddenCanvasElement class should not unintentionally hide other canvas elements in the application.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that no other canvas elements are affected by the .hiddenCanvasElement class.

# Expect: List all occurrences of canvas elements.
rg --type css "canvas" web/src/**/*.tsx

Length of output: 842



Script:

#!/bin/bash
# Description: Verify that no other canvas elements are affected by the .hiddenCanvasElement class.

# List all occurrences of canvas elements in relevant files.
rg "<canvas" web/src

Length of output: 22

web/src/pages/AttachmentDisplay/index.tsx Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 25, 2024
@kemuru kemuru self-requested a review June 25, 2024 11:12
Copy link
Contributor

@kemuru kemuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything looks good, except the styling in mobile is a bit messed up

image

comparing it with master:

image

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 867a34d and 5473436.

Files selected for processing (1)
  • web/src/components/PreviewCard/Terms/AttachedFile.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/components/PreviewCard/Terms/AttachedFile.tsx

@kemuru kemuru self-requested a review June 25, 2024 11:30
Copy link
Contributor

@kemuru kemuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing

@kemuru kemuru merged commit 60495b2 into master Jun 25, 2024
6 checks passed
@kemuru kemuru deleted the feat/file-attachment-display branch June 25, 2024 11:30
@kemuru kemuru linked an issue Jun 25, 2024 that may be closed by this pull request
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.

Attachment: display attachments in a container component
2 participants