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

fix: Change the value of pageOffset when enabling server side pagination #36056

Conversation

phennapa-saeliw
Copy link
Contributor

@phennapa-saeliw phennapa-saeliw commented Sep 2, 2024

Description

Fixed issue #36022 where incorrect data is displayed when navigating to the previous page after reaching the last page with fewer items in the table during server-side pagination enabled by using props.pageSize instead of props.tableData?.length.

Fix:

Replaced props.tableData?.length with props.pageSize to ensure consistent data display when navigating between pages, especially when dealing with the last page that has fewer items than the pageSize.

Fixes #36022

Automation

/ok-to-test tags="@tag.Table"

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Improved pagination logic for the table widget, simplifying the handling of page size.
  • Bug Fixes

    • Resolved potential inconsistencies in pagination when server-side data is utilized.

Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (4)
  • app/client/cypress/scripts/.yarn/cache/ansi-regex-npm-4.1.1-af0a582bb9-b1a6ee44cb.zip is excluded by !**/.yarn/**
  • app/client/cypress/scripts/.yarn/cache/prompt-sync-npm-4.2.0-1ce4e10166-b14dfb7d25.zip is excluded by !**/.yarn/**
  • app/client/cypress/scripts/.yarn/cache/strip-ansi-npm-5.2.0-275214c316-bdb5f76ade.zip is excluded by !**/.yarn/**
  • app/client/cypress/scripts/.yarn/install-state.gz is excluded by !**/.yarn/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes made to the derived.js file involve a modification to the getPageOffset function, specifically in how the pageSize variable is calculated. The logic has been simplified by directly assigning props.pageSize to pageSize, eliminating the previous conditional check based on props.tableData. This adjustment may impact pagination behavior, particularly in scenarios involving server-side pagination.

Changes

File Path Change Summary
app/client/src/widgets/TableWidgetV2/widget/derived.js Modified getPageOffset function to simplify pageSize calculation by using props.pageSize directly.

Assessment against linked issues

Objective Addressed Explanation
Correct the table data display when server-side pagination is enabled (36022)

🌟 In code we trust, with logic so bright,
Page sizes now clear, like stars in the night.
Server-side woes, now fading away,
Data flows smoothly, come what may!
🎉 With each little change, our tables delight,
A seamless experience, a developer's right!


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.

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.

@phennapa-saeliw phennapa-saeliw changed the title Fix issue #36022: Change the value of pageOffset when enabling server side pagination fix: Change the value of pageOffset when enabling server side pagination Sep 2, 2024
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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4516129 and dd73d5b.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (1 hunks)

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dd73d5b and 1579fc0.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (1 hunks)
Additional comments not posted (1)
app/client/src/widgets/TableWidgetV2/widget/derived.js (1)

794-794: Simplified pageSize calculation logic. Verify impact on pagination behavior.

The change simplifies the logic by directly assigning props.pageSize to pageSize, removing the conditional check based on props.tableData.

Please ensure that this change does not introduce any unintended side effects or break existing functionality, especially in scenarios involving server-side pagination.

To verify the impact, you can run the following script:

Thoroughly test the pagination functionality to confirm that the behavior remains consistent and as expected after this change.

Verification successful

Run existing tests to verify the impact of the pageSize logic change.

The getPageOffset function is well-covered by tests in both WDSTableWidget and TableWidgetV2. These tests include various scenarios, such as null, undefined, and numeric values for pageNo and pageSize. Running these tests will help ensure that the simplified pageSize calculation logic does not introduce any unintended side effects or break existing functionality, particularly in server-side pagination scenarios.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash

echo "Searching for usages of the getPageOffset function..."

# Search for the function usage
rg --type js -A 5 $'getPageOffset\\('

echo "Manually review the search results to ensure that the simplified pageSize calculation logic does not break any existing functionality or introduce unintended side effects, particularly in server-side pagination scenarios."

Length of output: 8244

@phennapa-saeliw
Copy link
Contributor Author

/ok-to-test

@phennapa-saeliw

This comment was marked as duplicate.

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added Stale and removed Stale labels Sep 16, 2024
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@jacquesikot
Copy link
Contributor

@phennapa can you please remove changes in cypress/scripts/.yarn. There should only be 1 file change in this PR

@jacquesikot jacquesikot self-requested a review October 17, 2024 09:23
@phennapa-saeliw
Copy link
Contributor Author

@phennapa can you please remove changes in cypress/scripts/.yarn. There should only be 1 file change in this PR

Thanks. I have deleted the files as per your suggestion.

@yatinappsmith yatinappsmith merged commit 2ad374a into appsmithorg:release Oct 25, 2024
4 checks passed
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…ion (appsmithorg#36056)

## Description
Fixed issue appsmithorg#36022 where incorrect data is displayed when navigating to
the previous page after reaching the last page with fewer items in the
table during server-side pagination enabled by using `props.pageSize`
instead of `props.tableData?.length`.


Fix:

Replaced `props.tableData?.length` with `props.pageSize` to ensure
consistent data display when navigating between pages, especially when
dealing with the last page that has fewer items than the pageSize.


Fixes appsmithorg#36022

## Automation

/ok-to-test tags="@tag.Table"




## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Improved pagination logic for the table widget, simplifying the
handling of page size.

- **Bug Fixes**
- Resolved potential inconsistencies in pagination when server-side data
is utilized.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Phennapa Saeliw <psaeliw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants