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

Add CSV Viewer to MessageFiles #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nickhowell6425
Copy link

Added CSV Viewer to MessageFiles. Broke out the component as well to accomadate rendering various file types in the future.

** Note, need to add proper icons.

** Also, recommend adding table virtualization for full view of data to improve performance of large files.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x ] Feature
[ ] Code style update (formatting, local variables)
[x ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #38

What is the new behavior?

Added CSV Viewer to MessageFiles. Broke out the component as well to accomadate rendering various file types in the future.

Does this PR introduce a breaking change?

[ ] Yes
[X ] No

Other information

Added CSV Viewer to MessageFiles. Broke out the component as well to accomadate rendering various file types in the future.

** Note, need to add proper icons.

** Also, recommend adding table virtualization for full view of data to improve performance of large files.
Copy link

netlify bot commented Sep 26, 2024

Deploy Preview for reachat-storybook ready!

Name Link
🔨 Latest commit fac4d24
🔍 Latest deploy log https://app.netlify.com/sites/reachat-storybook/deploys/66f582f956acb100081fffc4
😎 Deploy Preview https://deploy-preview-42--reachat-storybook.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.

@amcdnl amcdnl added the enhancement New feature or request label Sep 27, 2024
}) => {
const { theme } = useContext(ChatContext);

const fileTypeRendererMap: { [key: string]: FC<any> } = {
Copy link
Member

Choose a reason for hiding this comment

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

This could probably be moved outside the function scope since its static.

* @returns The sanitized cell content.
*/
const sanitizeCell = (cell: string): string => {
return cell.trim().replace(/^[=+\-@]/, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

we'll probably want to do a bit more here - i feel like simply stripping out the characters could be confusing

Copy link
Contributor

@steppy452 steppy452 Sep 27, 2024

Choose a reason for hiding this comment

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

Alternatively, apply the following sanitization to each field of the CSV, so that their content will be read as text by the spreadsheet editor:

  • Wrap each cell field in double quotes
  • Prepend each cell field with a single quote
  • Escape every double quote using an additional double quote

possibly just these items w/ updated CSV example

ref: https://owasp.org/www-community/attacks/CSV_Injection

top: 0,
left: 0,
right: 0,
bottom: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe inset: 0 instead

* Renderer for image files.
*/
const ImageFileRenderer: FC<ImageFileRendererProps> = ({ url }) => (
<img src={url} alt="Image" className="h-10 w-10" />
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: size-10

Copy link
Contributor

Choose a reason for hiding this comment

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

file org nit - i think i would keep this file separate from the rendered components. especially if we continue adding more renderers, this could get lost a bit

@steppy452
Copy link
Contributor

@nickhowell6425 thanks for the contribution! i just have some really minor nits + 1 comment around sanitization before i feel this is ready to get merged. but overall, this looks really good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants