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

internal(Data files): UI for importing data files #427

Merged
merged 5 commits into from
Jan 27, 2025

Conversation

going-confetti
Copy link
Collaborator

@going-confetti going-confetti commented Jan 22, 2025

Description

How to Test

  • Use konami code to enable the data-files feature
  • Click on + in the data files tree in the sidebar
  • Select a JSON/CSV file (ideally, try both)
  • Click on the file in the sidebar
  • Check its preview

I used is this JSON file, it has some nesting so it's good to test how nested properties are displayed

Screenshots (if appropriate):

image

Related PR(s)/Issue(s)

@@ -1,2 +1,5 @@
// eslint-disable-next-line no-control-regex
export const INVALID_FILENAME_CHARS = /[<>:"/\\|?*\x00-\x1F]/

// Limit the file size for preview to avoid performance issues
export const FILE_SIZE_PREVIEW_THRESHOLD = 1024 * 1024 * 10
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could probably be higher, I'll revisit this before opening the PR for review.
We don't want to load large files into the main process memory, so similarly to how GitHub doesn't show previews of large files, we'll display a message if the file size is above this threshold

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say github case is a bit different, it doesn't show preview to prevent overloading dom and slowing down the browser, while in our case we only show the first 10 rows. We should probably do some testing with large files and see how it affects electron's memory consumption, verify there's no memory leak, and that it gets cleaned up properly. Not part of this PR though 👍

@going-confetti going-confetti marked this pull request as ready for review January 23, 2025 13:06
@going-confetti going-confetti requested a review from a team as a code owner January 23, 2025 13:06
columns?: number
}

export function TableSkeleton({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Might be an overkill, considering the data loads pretty fast. Depends on whether we increase the file size threshold 🤔

Copy link
Collaborator

@e-fisher e-fisher left a comment

Choose a reason for hiding this comment

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

I think this works great! Had a few minor comments:

  1. Empty lines in CSV are parsed as empty rows:
    screencapture 2025-01-24 at 11 06 49

  2. If you import a CSV and JSON file with the same name, there's no indication which is which in the sidebar. Perhaps we could include file extension or add a badge, like the one you have in the preview title.
    screencapture 2025-01-24 at 11 07 04

  3. Not a chore 😅

Comment on lines +654 to +656
if (size > FILE_SIZE_PREVIEW_THRESHOLD) {
return null
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Show an error in the UI indicating file is too large to preview, instead of just "no preview available"?

Copy link
Member

Choose a reason for hiding this comment

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

or warning 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a warning/info message. Once the layout update PR is merged, I'll probably also add a grot illustration :D

src/components/Layout/Sidebar/Sidebar.tsx Outdated Show resolved Hide resolved
@@ -1,2 +1,5 @@
// eslint-disable-next-line no-control-regex
export const INVALID_FILENAME_CHARS = /[<>:"/\\|?*\x00-\x1F]/

// Limit the file size for preview to avoid performance issues
export const FILE_SIZE_PREVIEW_THRESHOLD = 1024 * 1024 * 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say github case is a bit different, it doesn't show preview to prevent overloading dom and slowing down the browser, while in our case we only show the first 10 rows. We should probably do some testing with large files and see how it affects electron's memory consumption, verify there's no memory leak, and that it gets cleaned up properly. Not part of this PR though 👍

@going-confetti
Copy link
Collaborator Author

I think this works great! Had a few minor comments:

1. Empty lines in CSV are parsed as empty rows:

Good catch, I'll need to verify how it works in the k6 csv module and match the behavior

2. If you import a CSV and JSON file with the same name, there's no indication which is which in the sidebar. Perhaps we could include file extension or add a badge, like the one you have in the preview title.

Good point, I'll check what works/looks better 👍

3. Not a `chore` 😅

Fair enough, it's just that it's currently also not a user-facing feature. Should we add the wip: prefix to the list? 🤔

@e-fisher
Copy link
Collaborator

3. Not a `chore` 😅

Fair enough, it's just that it's currently also not a user-facing feature. Should we add the wip: prefix to the list? 🤔

Either that or internal 🤷

@going-confetti going-confetti changed the title chore(Data files): UI for importing data files internal(Data files): UI for importing data files Jan 24, 2025
return parseCSV<DataRecord>(content, {
header: true,
delimiter: ',',
skipEmptyLines: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked k6/experimental/csv and it does skip empty lines 👍

@going-confetti
Copy link
Collaborator Author

  1. If you import a CSV and JSON file with the same name, there's no indication which is which in the sidebar. Perhaps we could include file extension or add a badge, like the one you have in the preview title.

I will address this in a separate PR

Copy link
Member

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

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

🚀

@going-confetti going-confetti merged commit 526dd3b into main Jan 27, 2025
3 checks passed
@going-confetti going-confetti deleted the chore/data-file-import branch January 27, 2025 15:23
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