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

task/WG-418 - File Listing Component Enhancement and Fixes #337

Merged
merged 9 commits into from
Mar 5, 2025

Conversation

shayanaijaz
Copy link
Contributor

Overview:

Adds infinite scrolling for file listing. Fixes bugs related to invalid file selection and empty message.

PR Status:

  • Ready.
  • Work in Progress.
  • Hold.

Related Jira tickets:

Summary of Changes:

Testing Steps:

  1. Use the File Listing component Create Map, Import from DesignSafe and Add Asset buttons
  2. Ensure functionality works as expected

UI Photos:

Screenshot 2025-02-27 at 2 40 52 PM

Notes:

TODO:

  • Update tests

Copy link
Contributor

@rstijerina rstijerina left a comment

Choose a reason for hiding this comment

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

LGTM, added some thoughts for the future

Comment on lines +88 to +91
listingState.path ||
(selectedSystem?.id === myDataSystem?.id ? user?.username : ''),
offset: listingState.offset.toString(),
limit: DEFAULT_FILE_LIMIT.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Few suggestions for future improvement:

  • offset and limit should be type int, and adjust in the hook query params
  • react query has a nice infinite query hook. Used in tandem with InterSectionObserver, or react-intersection-observer, this would simplify this code a bit with the use of a ref for a node at the bottom of the listing, and a callback to the react-query built-in fetchNextPage() method. If gone that route, you'd be able to get rid of most of the useStates in this component

const [selectedSystem, setSelectedSystem] = React.useState<TTapisSystem>(
myDataSystem as TTapisSystem
);
const [hasError, setHasError] = React.useState(false);
const [loadingMoreFiles, setLoadingMoreFiles] = React.useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the isLoading state from the useFiles hook instead?


if (!dynamicListContainer) return;

const handleScroll = debounce(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick and you don't need to take my advice, but personally I like to avoid lodash. Is there a way to handle the scroll event in this way without the debounce frequency?

Comment on lines +311 to +313
{loadingMoreFiles && (
<p style={{ textAlign: 'center' }}>Loading...</p>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use a bit more vertical padding here

Copy link
Collaborator

@nathanfranklin nathanfranklin left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@nathanfranklin nathanfranklin merged commit 0f204f8 into main Mar 5, 2025
5 checks passed
@nathanfranklin nathanfranklin deleted the task/WG-418--File-listing-fixes branch March 5, 2025 14:45
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