Skip to content

feat: Update TableWidgetV2 to include customIsLoading property#36857

Merged
rahulbarwal merged 9 commits intoreleasefrom
rahulbarwal/issue12308
Oct 22, 2024
Merged

feat: Update TableWidgetV2 to include customIsLoading property#36857
rahulbarwal merged 9 commits intoreleasefrom
rahulbarwal/issue12308

Conversation

@rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Oct 14, 2024

Description

Problem
There are many problems with table loader logic, for which many users try to implement a modal for loader. These problems stem from dependency and delay on eval, discussed comprehensively in #12308

Solution
This PR updates the TableWidgetV2 component to include a new property called customIsLoading. This property controls the loading state of the widget and is added to the TableWidgetProps interface. Additionally, the component's state is updated to include the customIsLoading property.

The contentConfig file for the TableWidgetV2 is also modified to include the customIsLoading property with its corresponding label, control type, help text, and validation.

These changes improve the flexibility and customization options of the TableWidgetV2 component.

This sits behind a feature flag

Fixes #12308
or
Fixes Issue URL

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.Table"

🔍 Cypress test results

Tip

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


Tue, 22 Oct 2024 09:17:37 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new feature flag for custom loading states in the table widget.
    • Added properties for managing custom loading behavior in the TableWidgetV2.
  • Bug Fixes

    • Enhanced loading state management to ensure accurate representation based on new properties.
  • Tests

    • Added unit tests for loading behavior in the TableWidgetV2 component, covering default and custom loading scenarios.
  • Documentation

    • Updated help text for properties related to loading states to improve clarity.

This commit updates the TableWidgetV2 component to include a new property called userDefinedIsLoading. This property controls the loading state of the widget and is added to the TableWidgetProps interface. Additionally, the component's state is updated to include the userDefinedIsLoading property.

The contentConfig file for the TableWidgetV2 is also modified to include the userDefinedIsLoading property with its corresponding label, control type, help text, and validation.

These changes improve the flexibility and customization options of the TableWidgetV2 component.
@rahulbarwal rahulbarwal changed the title refactor: Update TableWidgetV2 to include userDefinedIsLoading property feat: Update TableWidgetV2 to include userDefinedIsLoading property Oct 14, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Oct 14, 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/11323758326.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36857.
recreate: .

@github-actions
Copy link

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

- Added a new prop `userDefinedIsLoadingValue` to TableWidgetProps interface
- Updated TableWidgetV2 component to use `userDefinedIsLoadingValue` for loading state when `userDefinedIsLoading` is true
- Added new property configuration for `userDefinedIsLoadingValue` in `contentConfig.ts`
- Removed unused prop `userDefinedIsLoading` from TableWidgetProps interface
@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/11361844078.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36857.
recreate: .

@github-actions
Copy link

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

- Renamed userDefinedIsLoading to customIsLoading
- Renamed userDefinedIsLoadingValue to customIsLoadingValue
- Updated propertyConfig to reflect the changes
@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/11439819098.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36857.
recreate: .

@github-actions github-actions bot added Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Javascript Product Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform List Widget Issues related to the list widget Needs Triaging Needs attention from maintainers to triage Production Query & JS Pod Issues related to the query & JS Pod Table Widget UI Building Product Issues related to the UI Building experience UI Performance Issues related to UI performance Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets labels Oct 21, 2024
@rahulbarwal rahulbarwal marked this pull request as ready for review October 22, 2024 08:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

This pull request introduces a new feature flag, release_table_custom_loading_state_enabled, to manage custom loading states within the TableWidgetV2. Modifications include updates to the TableWidgetProps interface with new properties for custom loading behavior, as well as updates to the component's logic to utilize these properties. A new test suite is also added to validate the loading behavior under different configurations. Overall, the changes enhance the table widget's flexibility and user experience regarding loading states.

Changes

File Path Change Summary
app/client/src/ce/entities/FeatureFlag.ts Added release_table_custom_loading_state_enabled to FEATURE_FLAG and set default to false.
app/client/src/widgets/TableWidgetV2/constants.ts Updated TableWidgetProps with customIsLoading and customIsLoadingValue. Added CUSTOM_LOADING_STATE_ENABLED.
app/client/src/widgets/TableWidgetV2/widget/TableRendered.test.ts Added unit tests for loading behavior, incorporating new properties in TableWidgetProps.
app/client/src/widgets/TableWidgetV2/widget/index.tsx Added customIsLoading and customIsLoadingValue to the widget's default configuration and updated loading logic.
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts Added customIsLoading and customIsLoadingValue with updated visibility and validation conditions.

Assessment against linked issues

Objective Addressed Explanation
Ensure loading indicators remain visible until data is fully loaded (#12308)

Possibly related PRs

Suggested labels

Task, ok-to-test, Community Reported

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

Poem

In the realm of tables, a flag now flies,
Custom loading states, a welcomed surprise.
With tests in place, the logic is tight,
Ensuring our widgets perform just right.
So let’s celebrate this code anew,
For smoother experiences, we bid adieu! 🎉


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.

@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Oct 22, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Oct 22, 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: 1

🧹 Outside diff range and nitpick comments (5)
app/client/src/widgets/TableWidgetV2/constants.ts (2)

112-113: LGTM. Consider adding JSDoc comments.

The new properties look good and follow the existing naming conventions. To improve maintainability, consider adding JSDoc comments explaining the purpose and usage of these properties.


243-244: LGTM. Consider grouping related constants.

The new constant is well-named and correctly uses a feature flag. For better organization, consider grouping this constant with other related feature flag constants if they exist.

app/client/src/widgets/TableWidgetV2/widget/TableRendered.test.ts (1)

112-180: Well-structured test suite with comprehensive coverage.

The test cases effectively cover both default and custom loading behaviors. Consider using more descriptive test names for better clarity, e.g., "Should not be loading when isLoading is false and custom loading is disabled".

app/client/src/widgets/TableWidgetV2/widget/index.tsx (1)

1273-1277: Consider a minor optimization for conciseness.

The current implementation is correct, but we could make it slightly more concise. Consider using the logical OR operator for a more streamlined expression:

isLoading={customIsLoading ? (customIsLoadingValue || this.props.isLoading) : this.props.isLoading}

This achieves the same result with a bit less code.

app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts (1)

510-510: Use double quotes for consistency in the label property.

Replace backticks with double quotes to match the coding style used elsewhere.

Apply this diff:

-            label: `Custom loading state`,
+            label: "Custom loading state",
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1f72d75 and 1c6f4f9.

📒 Files selected for processing (5)
  • app/client/src/ce/entities/FeatureFlag.ts (2 hunks)
  • app/client/src/widgets/TableWidgetV2/constants.ts (2 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/TableRendered.test.ts (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx (3 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (8)
app/client/src/ce/entities/FeatureFlag.ts (2)

42-43: LGTM: New feature flag added correctly.

The new feature flag release_table_custom_loading_state_enabled follows the naming convention and is properly integrated into the FEATURE_FLAG object.


79-79: Confirm default value for new feature flag.

The default value for release_table_custom_loading_state_enabled is set to false. This is typically a safe approach for rolling out new features. Ensure this aligns with the intended release strategy for the custom loading state feature in TableWidgetV2.

app/client/src/widgets/TableWidgetV2/widget/TableRendered.test.ts (2)

1-110: Comprehensive props definition enhances test coverage.

The imports are concise and the TableWidgetProps definition is extensive, which is excellent for thorough testing. The inclusion of customIsLoading and customIsLoadingValue properties aligns with the PR objectives.


1-181: Excellent test coverage for custom loading functionality.

This test file effectively covers the new custom loading behavior, addressing the objectives of the PR and issue #12308. The comprehensive props definition and well-structured test cases ensure thorough validation of the TableWidgetV2 loading states.

app/client/src/widgets/TableWidgetV2/widget/index.tsx (2)

229-230: LGTM: New properties for custom loading state.

The addition of customIsLoading and customIsLoadingValue properties provides more flexibility for managing the loading state of the table. This is a good enhancement.


1273-1277: LGTM: Proper usage of custom loading properties.

The new customIsLoading and customIsLoadingValue properties are correctly implemented in the isLoading prop of the ReactTableComponent. This allows for more granular control over the loading state display.

app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts (2)

10-13: Imports are correctly added.

The new constants are correctly imported from "../../constants".


508-517: Verify access to the feature flag in the hidden property.

Ensure that Widget.getFeatureFlag(CUSTOM_LOADING_STATE_ENABLED) correctly retrieves the feature flag value.

Comment on lines +519 to +528
propertyName: "customIsLoadingValue",
label: "isLoading value",
controlType: "INPUT_TEXT",
defaultValue: "",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
hidden: (props: TableWidgetProps) => !props.customIsLoading,
dependencies: ["customIsLoading"],
},
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

Mismatch between controlType and validation for customIsLoadingValue.

The controlType is set to "INPUT_TEXT" but the validation expects a BOOLEAN. Consider updating the controlType to "SWITCH" or adjusting the validation accordingly.

Apply this diff to resolve the mismatch:

            propertyName: "customIsLoadingValue",
            label: "isLoading value",
-           controlType: "INPUT_TEXT",
+           controlType: "SWITCH",
            defaultValue: "",
            isBindProperty: true,
            isTriggerProperty: false,
            validation: { type: ValidationTypes.BOOLEAN },
            hidden: (props: TableWidgetProps) => !props.customIsLoading,
            dependencies: ["customIsLoading"],
📝 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
propertyName: "customIsLoadingValue",
label: "isLoading value",
controlType: "INPUT_TEXT",
defaultValue: "",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
hidden: (props: TableWidgetProps) => !props.customIsLoading,
dependencies: ["customIsLoading"],
},
propertyName: "customIsLoadingValue",
label: "isLoading value",
controlType: "SWITCH",
defaultValue: "",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
hidden: (props: TableWidgetProps) => !props.customIsLoading,
dependencies: ["customIsLoading"],
},

@rahulbarwal rahulbarwal self-assigned this Oct 22, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Oct 22, 2024
@rahulbarwal rahulbarwal merged commit 554ec58 into release Oct 22, 2024
@rahulbarwal rahulbarwal deleted the rahulbarwal/issue12308 branch October 22, 2024 09:21
@github-actions github-actions bot added Bug Something isn't working QA Needs QA attention QA Pod Issues under the QA Pod and removed Bug Something isn't working labels Oct 22, 2024
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…ithorg#36857)

## Description
<ins>Problem</ins>
There are many problems with table loader logic, for which many users
try to implement a modal for loader. These problems stem from dependency
and delay on eval, discussed comprehensively in appsmithorg#12308

<ins>Solution</ins>
This PR updates the TableWidgetV2 component to include a new property
called `customIsLoading`. This property controls the loading state of
the widget and is added to the TableWidgetProps interface. Additionally,
the component's state is updated to include the `customIsLoading`
property.

The `contentConfig` file for the TableWidgetV2 is also modified to
include the `customIsLoading` property with its corresponding label,
control type, help text, and validation.

These changes improve the flexibility and customization options of the
TableWidgetV2 component.

Fixes appsmithorg#12308
_or_  
Fixes `Issue URL`
> [!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.Table"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11456273525>
> Commit: 1c6f4f9
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11456273525&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Table`
> Spec:
> <hr>Tue, 22 Oct 2024 09:17:37 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## 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

- **New Features**
- Introduced a new feature flag for custom loading states in the table
widget.
- Added properties for managing custom loading behavior in the
`TableWidgetV2`.
  
- **Bug Fixes**
- Enhanced loading state management to ensure accurate representation
based on new properties.

- **Tests**
- Added unit tests for loading behavior in the `TableWidgetV2`
component, covering default and custom loading scenarios.

- **Documentation**
- Updated help text for properties related to loading states to improve
clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request High This issue blocks a user from building or impacts a lot of users Javascript Product Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform List Widget Issues related to the list widget Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production QA Pod Issues under the QA Pod QA Needs QA attention Query & JS Pod Issues related to the query & JS Pod Table Widget UI Building Product Issues related to the UI Building experience UI Performance Issues related to UI performance Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]-[4000]:Table Widget Skeleton should not disappear till the data is loaded

2 participants