fix: allow currentRow for onClick in menuButton item in Table widget
Fixes #26052
Summary by CodeRabbit
-
New Features
- Introduced a new property,
customJSControl, for enhanced configuration in the Table Widget, allowing for dynamic table data handling. - Added a new test case to ensure the menu button's
onClickproperty correctly accesses thecurrentRowcontext, improving the robustness of the component.
- Introduced a new property,
-
Bug Fixes
- Enhanced testing coverage for the table menu button component to ensure correct behavior of dynamic properties.
Walkthrough
The recent changes enhance the functionality of a table widget by enabling the use of the currentRow context in menu button actions. Additionally, a new property, customJSControl, has been introduced to support more dynamic configurations within the widget. These updates collectively improve the component's usability and flexibility, addressing specific user-reported issues.
Changes
| Files | Change Summary |
|---|---|
app/client/cypress/e2e/.../menubutton_spec.js |
Added a test case to verify that menu item actions can reference currentRow, enhancing coverage for dynamic behavior. |
app/client/src/widgets/TableWidgetV2/widget/.../Basic.ts |
Introduced a new property customJSControl with the value "TABLE_COMPUTE_VALUE", allowing for custom JavaScript logic. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
Use currentRow within menu items of a Menu Button (26052) |
ā | |
| Enhance widget flexibility with custom controls (26052) | ā |
Possibly related PRs
-
#36061: This PR enhances the test specifications for the TableV2 component, which is directly related to the main PR's focus on testing the behavior of table components, specifically regarding the
onClickproperty and its context. - #36375: This PR introduces validation for required select columns in the table widget, which aligns with the main PR's focus on testing the functionality of menu items in a table context, ensuring that dynamic properties are correctly linked to the current row data.
-
#36393: This PR addresses the issue of incorrect updates to the
selectedRowIndexwhen the primary column is set, which is relevant to the main PR's focus on ensuring that theonClickproperty of menu items correctly accesses thecurrentRowcontext.
Suggested labels
Bug, Enhancement, Table Widget, Widgets Product, ok-to-test, Widgets & Accelerators Pod
Suggested reviewers
- sagar-qa007
- ApekshaBhosale
- rahulbarwal
Poem
In the realm of tables bright,
Menu buttons take to flight.
WithcurrentRow, actions thrive,
Custom controls help us drive.
A widget's dance, so rich and bold,
In code we trust, new tales unfold! š
š Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL
š„ Commits
Files that changed from the base of the PR and between 29251b42bdf3099456a9cc1aaaadc897c33f19f6 and baadf6b0a824c3259f9f65a281dc533a7f735d42.
š Files selected for processing (1)
- app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/ColumnTypeMenubutton_spec.js (1 hunks)
š§° Additional context used
š Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/ColumnTypeMenubutton_spec.js (1)
Pattern
app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:
- Follow best practices for Cypress code and e2e automation.
- Avoid using cy.wait in code.
- Avoid using cy.pause in code.
- Avoid using agHelper.sleep().
- Use locator variables for locators and do not use plain strings.
- Use data-* attributes for selectors.
- Avoid Xpaths, Attributes and CSS path.
- Avoid selectors like .btn.submit or button[type=submit].
- Perform logins via API with LoginFromAPI.
- Perform logout via API with LogOutviaAPI.
- Perform signup via API with SignupFromAPI.
- Avoid using it.only.
- Avoid using after and aftereach in test cases.
- Use multiple assertions for expect statements.
- Avoid using strings for assertions.
- Do not use duplicate filenames even with different paths.
- Avoid using agHelper.Sleep, this.Sleep in any file in code.
š Additional comments (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/ColumnTypeMenubutton_spec.js (1)
166-175: Good job on adding a new test case, class! Let's review it together.The new test case follows the structure of previous tests and adheres to many of our coding guidelines. Well done on avoiding
cy.wait, using locator variables, and implementing multiple assertions!However, I have a few suggestions to make it even better:
Consider adding more descriptive assertions to clearly state what you're testing. For example:
_.agHelper.GetNAssertElementText( _.locators._hints, "currentRow", "contain.text", "The autocomplete hints should include 'currentRow'" );It might be helpful to add a comment explaining the purpose of typing "{{currentR" - this is to trigger the autocomplete suggestions, right?
Consider checking if the entire "currentRow" object is accessible, not just its existence in the hints.
Keep up the good work, and remember to always strive for clarity in your tests!
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?
šŖ§ 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
@SaiCharanChetpelly31 Can you please explain me for the cypress test case requirement here? Can we test with Unit test ?
@SaiCharanChetpelly31 Can you please explain me for the cypress test case requirement here? Can we test with Unit test ?
@sagar-qa007 For other fields like visible and disabled, they are checking if currentRow is accessible in the Cypress tests itself. I didn't find any unit tests related to this in the Table widget code, which is why I have only written Cypress tests.
You can check the already existing cypress tests for visible and disable fields here https://github.com/appsmithorg/appsmith/blob/486662a2ed37a9e616d478c5ce296426d522c9c8/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/menubutton_spec.js#L100C1-L165C8
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.
@sagar-qa007 @ApekshaBhosale I hope you're well. Iām curious and excited to hear your thoughts on my pull request raised a while ago. Looking forward to your review! Thank you. cc: @ramsaptami
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.
@sagar-qa007 @ApekshaBhosale I hope you're well. Iām curious and excited to hear your thoughts on my pull request raised a while ago. Looking forward to your review! Thank you. cc: @ramsaptami
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.
@ApekshaBhosale Could you please review this PR?
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.
@SaiCharanChetpelly31 Please fix merge conflicts.
@SaiCharanChetpelly31 Please fix merge conflicts.
sure, working on it
@rahulbarwal I resolved merge conflicts. can you please check? Thanks in advance.
@jsartisan could you please review this PR?
@rahulbarwal can you check this PR?