Skip to content

chore: external merge request from Contributor#36878

Closed
rahulbarwal wants to merge 26 commits intoreleasefrom
external-contri/fix/16584-table-edit-with-filter
Closed

chore: external merge request from Contributor#36878
rahulbarwal wants to merge 26 commits intoreleasefrom
external-contri/fix/16584-table-edit-with-filter

Conversation

@rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Oct 15, 2024

Description

Issue: #16584

Original PR: #36849
EE PR: https://github.com/appsmithorg/appsmith-ee/pull/5358

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

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

  • Yes
  • No

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11588111041
Commit: f40199d
Cypress dashboard.
Tags: @tag.All
Spec:


Wed, 30 Oct 2024 09:05:46 UTC

@rahulbarwal rahulbarwal self-assigned this Oct 15, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

Walkthrough

The pull request introduces significant enhancements to the derived.js file in the TableWidgetV2 component. Key modifications include improved logic for row selection and filtering, validation of editable cells, and the proper handling of indices. The test suite for these functionalities has also been expanded to cover new scenarios and edge cases, ensuring robust validation of the table's behavior under various conditions.

Changes

File Change Summary
app/client/src/widgets/TableWidgetV2/widget/derived.js Enhanced methods for row selection, filtering, validation, and header sorting. Updated method signatures.
app/client/src/widgets/TableWidgetV2/widget/derived.test.js Added new test cases for filtering and editing functionality; enhanced existing tests for edge cases.

Assessment against linked issues

Objective Addressed Explanation
Improve filtering accuracy when editing rows with active filters (36849)
Ensure that original row data is used for filtering evaluations (36849)
Validate the functionality of new filtering logic in tests (36849)

Possibly related PRs

Suggested labels

Task, Bug, Enhancement, Widgets Product, Production, Needs Triaging, Medium, Table Widget V2, ok-to-test, Widgets & Accelerators Pod

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

In the realm of tables, where data does dwell,
Filters and rows weave a magical spell.
With edits and checks, the logic refined,
Ensuring each cell is perfectly aligned.
So raise up your glasses, let’s cheer with delight,
For the TableWidgetV2, it’s shining so 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>, 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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 15, 2024
@rahulbarwal rahulbarwal marked this pull request as draft October 15, 2024 08:14
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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3032adc and be21c62.

📒 Files selected for processing (2)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/derived.test.js (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
app/client/src/widgets/TableWidgetV2/widget/derived.js (1)

814-818: Great job incorporating originalRow into filter conditions

By evaluating the filter conditions against both originalRow and displayedRow, you ensure that filtering remains accurate even when rows have been edited. This approach effectively handles scenarios where the displayed data may differ from the original data, enhancing the functionality of the table when editing while filters are applied.

app/client/src/widgets/TableWidgetV2/widget/derived.test.js (1)

199-204: Well done initializing the 'tableData' in inputWithDisplayText

You have correctly structured the tableData, which will be beneficial for your tests involving display text.

ConditionFunctions[props.filters[i].condition];

if (conditionFunction) {
const originalRow = props.tableData[row.__originalIndex__];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure originalRow is defined to prevent potential errors

It's important to verify that originalRow is valid before using it in the condition function. If row.__originalIndex__ does not correspond to a valid index in props.tableData, originalRow could be undefined, leading to runtime errors. Consider adding a check to ensure that originalRow is defined.

Comment on lines +1296 to +1303
const expected = [
{ id: 234, name: "Khadija Khafaga", __originalIndex__: 2 },
{ id: 123, name: "Hamza Anas", __originalIndex__: 1 },
];

let result = getFilteredTableData(input, moment, _);

expect(result).toStrictEqual(expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Please revisit the expected results in your test case

After changing the name from "Hamza Khafaga" to "Hamza Anas", the row no longer meets the filter condition contains "Khafaga". Therefore, it should not appear in the filtered results. Let's update the expected results to reflect this change.

Apply this diff to correct the expected results:

 const expected = [
   { id: 234, name: "Khadija Khafaga", __originalIndex__: 2 },
-  { id: 123, name: "Hamza Anas", __originalIndex__: 1 },
 ];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const expected = [
{ id: 234, name: "Khadija Khafaga", __originalIndex__: 2 },
{ id: 123, name: "Hamza Anas", __originalIndex__: 1 },
];
let result = getFilteredTableData(input, moment, _);
expect(result).toStrictEqual(expected);
const expected = [
{ id: 234, name: "Khadija Khafaga", __originalIndex__: 2 },
];
let result = getFilteredTableData(input, moment, _);
expect(result).toStrictEqual(expected);

@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Oct 16, 2024
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11359473512.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36878.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-36878.dp.appsmith.com

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11434813360.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36878.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-36878.dp.appsmith.com

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11496843091.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36878.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-36878.dp.appsmith.com

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Oct 30, 2024
@rahulbarwal
Copy link
Contributor Author

Closing as original PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants