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: loading indicator ui for infinite loading table #39208

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

AmanAgarwal041
Copy link
Contributor

@AmanAgarwal041 AmanAgarwal041 commented Feb 12, 2025

Description

Fixing the loading indicator for the infinite scroll of table widget.
Figma : https://www.figma.com/design/cBdxf04BPf5XiBCDtlMdxE/Feature-requests?node-id=20-9718&t=nhblcqfbZ2I0vxny-4

Fixes #39081
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.Widget"

🔍 Cypress test results

Tip

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


Thu, 13 Feb 2025 08:09:36 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new loading indicator in table views that displays a spinner alongside a loading message to inform users when records are being loaded.
  • Tests

    • Implemented automated tests verifying that the loading indicator appears correctly, ensuring it consistently displays the spinner and accompanying message.

Copy link
Contributor

coderabbitai bot commented Feb 12, 2025

Walkthrough

This pull request adds a new constant TABLE_LOADING_RECORDS for representing a loading message, introduces a LoadingIndicator component that uses this constant to display a spinner and text, and includes tests to validate its rendering. The changes ensure that when table records are loading, a consistent message and corresponding UI behavior are provided in the application.

Changes

File(s) Change Summary
app/client/src/ce/.../messages.ts Added a new constant TABLE_LOADING_RECORDS that returns the string "loading records".
app/client/src/widgets/.../LoadingIndicator.tsx,
app/client/src/widgets/.../LoadingIndicator.test.tsx
Introduced a new LoadingIndicator component using Flex, Spinner, and Text from the @appsmith/ads library; added tests to verify spinner, layout, and loading text rendering.

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant LI as LoadingIndicator
    participant CG as createMessage (using TABLE_LOADING_RECORDS)
    participant UI as UI Elements (Flex/Spinner/Text)

    Test->>LI: Render LoadingIndicator component
    LI->>CG: Call TABLE_LOADING_RECORDS()
    CG-->>LI: Return "loading records"
    LI->>UI: Render Flex container with Spinner and Text ("loading records")
Loading

Possibly related PRs

Suggested labels

Enhancement, Task, ok-to-test, Widgets Product, High, Production, UI Building Product, Javascript Product, List Widget

Suggested reviewers

  • ApekshaBhosale
  • NandanAnantharamu
  • sneha122

Poem

In our code, a message now gleams,
Loading spinner dances in dreams,
A constant speaks as records load,
In tests and UI, its story is told,
A code delight that brightly beams! 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@AmanAgarwal041 AmanAgarwal041 force-pushed the fix/loading-indicator-ui branch from 19eb088 to 8d0909a Compare February 12, 2025 11:26
@AmanAgarwal041 AmanAgarwal041 requested review from jacquesikot and removed request for a team February 12, 2025 11:26
@AmanAgarwal041 AmanAgarwal041 changed the base branch from feat/-infinite-scroll-poc-infinite-loader to release February 12, 2025 11:27
@github-actions github-actions bot added Bug Something isn't working Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets Table Widget V2 Issues related to Table Widget V2 Task A simple Todo Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets labels Feb 12, 2025
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

🧹 Nitpick comments (4)
app/client/src/widgets/TableWidgetV2/component/LoadingIndicator.test.tsx (3)

11-13: Consider using Testing Library queries instead of querySelector.

Replace querySelector with Testing Library's built-in queries for more resilient tests. This aligns better with Testing Library's philosophy of testing user interactions.

-    const flexContainer = document.querySelector(".ads-v2-flex");
-
-    expect(flexContainer).toBeInTheDocument();
+    const flexContainer = screen.getByTestId("loading-indicator-container");
+    expect(flexContainer).toBeInTheDocument();
+    expect(flexContainer).toHaveClass("ads-v2-flex");

16-18: Use Testing Library queries for spinner element.

Similar to the previous comment, prefer Testing Library queries over direct DOM queries.

-    const spinner = document.querySelector(".ads-v2-spinner");
-
-    expect(spinner).toBeInTheDocument();
+    const spinner = screen.getByTestId("loading-spinner");
+    expect(spinner).toBeInTheDocument();
+    expect(spinner).toHaveClass("ads-v2-spinner");

6-26: Enhance test coverage with additional test cases.

Consider adding tests for:

  1. Accessibility (role, aria-label)
  2. Different loading states if applicable
  3. Component unmounting

Example addition:

it("meets accessibility requirements", () => {
  render(<LoadingIndicator />);
  const spinner = screen.getByRole("progressbar");
  expect(spinner).toHaveAttribute("aria-label", "Loading records");
});
app/client/src/widgets/TableWidgetV2/component/LoadingIndicator.tsx (1)

5-22: LGTM! Consider adding prop types for future extensibility.

The implementation is clean and follows best practices. It properly uses design system components and CSS variables.

Consider adding TypeScript interface for future props:

-export const LoadingIndicator = () => (
+interface LoadingIndicatorProps {
+  className?: string;
+}
+
+export const LoadingIndicator = ({ className }: LoadingIndicatorProps = {}) => (
   <Flex
+    className={className}
     alignItems="center"
     // ... rest of the props
   >
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e878088 and 8d0909a.

📒 Files selected for processing (3)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/LoadingIndicator.test.tsx (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/LoadingIndicator.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/ce/constants/messages.ts

@AmanAgarwal041 AmanAgarwal041 requested review from rahulbarwal and removed request for a team and KelvinOm February 12, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets Table Widget V2 Issues related to Table Widget V2 Task A simple Todo 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.

Implement loading row at the bottom according to figma design.
2 participants