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

feat: Implements HTML as a column type in table widget. #37997

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Dec 6, 2024

Description

Adds support for rendering HTML content in Table Widget V2 columns with proper sanitization and filtering capabilities.

  • Adds new HTML column type with support for:
    • Rendering sanitized HTML content using Interweave
    • Search/filter functionality that ignores HTML tags
    • Sort functionality based on text content
    • CSV export with proper HTML content handling
    • Added unit tests covering HTML column functionality

Fixes #13681
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/12270923512
Commit: 5f873fc
Cypress dashboard.
Tags: @tag.Table
Spec:


Wed, 11 Dec 2024 07:23:01 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced support for HTML content in table cells with the new HTMLCell component.
    • Enhanced filtering and sorting functionalities to handle HTML columns effectively.
    • Added a feature flag to enable or disable HTML column types.
    • Implemented new configurations for column types, including HTML options.
    • Added analytics tracking for HTML cell usage.
  • Bug Fixes

    • Improved HTML sanitization to prevent unsafe content rendering.
  • Tests

    • Expanded test coverage for HTML handling in table widgets, including rendering, filtering, and sorting scenarios.
    • Added comprehensive testing for the HTMLCell component and its interaction with HTML content.
    • Introduced Cypress end-to-end tests for HTML cell functionality within the table widget.

- Introduced a new column type "HTML" in the TableWidgetV2 constants.
- Created a new HTMLCell component to render HTML content within table cells.
- Updated the TableWidgetV2 to support rendering of HTML cells.
- Enhanced the property configuration to include the new HTML column type.

This update improves the flexibility of the TableWidgetV2 by allowing HTML content to be displayed directly in table cells.
- Introduced new test files for AutoTooltipComponent, BasicCell, HTMLCell, and PlainTextCell to enhance test coverage.
- Implemented various test cases to validate rendering, tooltip functionality, and HTML content handling.
- Ensured proper behavior for different column types and edge cases, including truncated text and null values.

These additions improve the reliability and maintainability of the TableWidgetV2 components by ensuring they function as expected across various scenarios.
- Introduced a new column type `HTML` in the `ColumnTypes` enum to support HTML content in table widgets.
- Updated the CSV transformation logic to conditionally quote values based on the new `HTML` column type, enhancing data handling in CSV exports.

This change improves the flexibility of the table widget and ensures proper formatting of HTML content during CSV export.
- Introduced a new column type `HTML` in the `ColumnTypes` enum to allow HTML content in table widgets.
- Updated filtering and sorting logic to handle HTML columns, including a new utility function to extract text from HTML.
- Created a new constants file for table widget filter operators to streamline operator management.
- Enhanced unit tests to validate functionality for HTML columns, including search, filter, and sort operations.

This update improves the flexibility and usability of the TableWidgetV2 by enabling the display and manipulation of HTML content directly within table cells.
- Updated test cases to validate HTML content rendering, filtering, and searching within the TableWidgetV2.
- Modified status values to include inline styles for better visual representation.
- Added tests to ensure tags are not filterable or searchable in HTML content.
- Implemented complex filtering scenarios with multiple conditions and HTML entities.

This update improves the robustness of the TableWidgetV2 by ensuring accurate handling of HTML content in various scenarios.
@github-actions github-actions bot added Enhancement New feature or request High This issue blocks a user from building or impacts a lot of users Table Widget Table Widget V2 Issues related to Table Widget V2 Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets labels Dec 6, 2024
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Walkthrough

This pull request introduces extensive enhancements to the TableWidgetV2 by adding support for HTML as a column type. It includes the implementation of the HTMLCell component for rendering HTML content, updates to utilities for transforming table data into CSV, and modifications to filtering and sorting functionalities to accommodate HTML data. Additionally, a comprehensive test suite is added for the HTMLCell component and related functionalities, ensuring robust handling of HTML content within the table widget.

Changes

File Change Summary
app/client/src/widgets/TableWidgetV2/component/cellComponents/__tests__/HTMLCell.test.tsx Added a comprehensive test suite for the HTMLCell component, verifying HTML rendering, sanitization, and handling of null/undefined values.
app/client/src/widgets/TableWidgetV2/component/header/actions/Utilities.test.ts Introduced a new test case for transformTableDataIntoCsv to verify handling of HTML content in CSV transformation.
app/client/src/widgets/TableWidgetV2/component/header/actions/Utilities.ts Modified transformTableDataIntoCsv to enhance quoting logic for HTML column types.
app/client/src/widgets/TableWidgetV2/component/header/actions/filter/CascadeFields.tsx Enhanced typeOperatorsMap and columnTypeNameMap to support HTML column types.
app/client/src/widgets/TableWidgetV2/constants.ts Updated enums and arrays to include HTML column types and added a feature flag constant HTML_COLUMN_TYPE_ENABLED.
app/client/src/widgets/TableWidgetV2/widget/derived.js Introduced getTextFromHTML function and modified getFilteredTableData to handle HTML columns for search, filter, and sort functionalities.
app/client/src/widgets/TableWidgetV2/widget/derived.test.js Added tests for HTML column handling in getFilteredTableData, covering search, filter, and sort functionalities.
app/client/src/widgets/TableWidgetV2/widget/index.tsx Modified renderCell to include handling for HTML column types and added safety checks for feature flags.
app/client/src/widgets/TableWidgetV2/component/cellComponents/HTMLCell/index.tsx Introduced the HTMLCell component for rendering HTML content within table cells.
app/client/src/widgets/TableWidgetV2/component/cellComponents/HTMLCell/utils.tsx Added utility functions for logging analytics and extracting HTML tags, including a debounced analytics function.
app/client/src/ce/entities/FeatureFlag.ts Added a new feature flag release_table_html_column_type_enabled to manage HTML column type visibility.
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Data/ColumnType.ts Introduced configurations for column types, including support for HTML.
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Data/index.ts Restructured column type property configuration to utilize new column type configurations.
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/index.ts Updated imports to include DateProperties in the configuration.
app/client/src/ce/utils/analyticsUtilTypes.ts Added new event type "TABLE_WIDGET_V2_HTML_CELL_USAGE" to the analytics event names.

Assessment against linked issues

Objective Addressed Explanation
Support HTML as a column type in the table widget (#13681)

Possibly related PRs

Suggested labels

Bug, Production, UI Building Product

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • jacquesikot

🎉 In the realm of tables, so grand and wide,
HTML now dances, with style and pride.
Cells filled with content, both rich and bright,
Filtering and sorting, all done just right!
A test suite robust, to catch all the quirks,
In the world of widgets, this change truly works! 🌟


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. (Experiment)
  • @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 Enhancement New feature or request and removed Enhancement New feature or request labels Dec 6, 2024
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Dec 6, 2024

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

@rahulbarwal rahulbarwal changed the title Rahulbarwal/Issue13681/Implementation/HTML-Column-type-in-table feat: Implements HTML as a column type in table widget. Dec 6, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Dec 6, 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: 2

🧹 Outside diff range and nitpick comments (10)
app/client/src/widgets/TableWidgetV2/widget/derived.js (6)

Line range hint 1831-1831: Avoid using the delete operator for better performance

Deleting object properties can impact performance in JavaScript. Consider setting input.searchText to undefined instead.

Apply this diff to refactor:

-delete input.searchText;
+input.searchText = undefined;

Line range hint 1860-1860: Avoid using the delete operator for better performance

Similarly, consider setting input.filters to undefined instead of deleting it.

Apply this diff:

-delete input.filters;
+input.filters = undefined;

Line range hint 1939-1939: Avoid using the delete operator for better performance

Consider replacing the delete operation with an assignment to undefined for input.filters.

-delete input.filters;
+input.filters = undefined;

Line range hint 1954-1954: Avoid using the delete operator for better performance

Set input.searchText to undefined instead of deleting the property.

-delete input.searchText;
+input.searchText = undefined;

Line range hint 2038-2038: Avoid using the delete operator for better performance

Replace the delete statement with an assignment to undefined for input.filters.

-delete input.filters;
+input.filters = undefined;

Line range hint 2089-2090: Avoid using the delete operator for better performance

For both complexHTMLInput.searchText and complexHTMLInput.filters, set them to undefined instead of deleting.

Apply this diff:

-delete complexHTMLInput.searchText;
-delete complexHTMLInput.filters;
+complexHTMLInput.searchText = undefined;
+complexHTMLInput.filters = undefined;
app/client/src/widgets/TableWidgetV2/component/cellComponents/HTMLCell.tsx (2)

8-69: Add missing h4 heading styles for consistency

The HTMLContainer component includes styles for h1-h3 and h5-h6, but h4 is missing despite being included in the general heading styles.

Add the missing h4 styles:

  h3 {
    font-size: 1.17em;
    margin: 0.83em 0;
  }
+ h4 {
+   font-size: 1em;
+   margin: 1.33em 0;
+ }
  h5 {

111-115: Consider adding sanitization options

While Interweave provides basic sanitization, consider exposing sanitization options through props for more granular control.

app/client/src/widgets/TableWidgetV2/component/cellComponents/__tests__/HTMLCell.test.tsx (2)

29-40: Add return type annotation for renderComponent

The utility function should have an explicit return type for better type safety.

const renderComponent = (
  props: Partial<HTMLCellProps> = {},
  store = unitTestBaseMockStore,
- ) => {
+ ): ReturnType<typeof render> => {

105-138: Enhance security test coverage

While the current security tests are good, consider adding tests for:

  • iframe elements
  • javascript: URLs
  • data: URLs
  • event handlers other than onclick
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6d41e77 and 21c9eee.

📒 Files selected for processing (11)
  • app/client/src/widgets/TableWidgetV2/component/cellComponents/HTMLCell.tsx (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/cellComponents/__tests__/HTMLCell.test.tsx (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/header/actions/Utilities.test.ts (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/header/actions/Utilities.ts (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/header/actions/filter/CascadeFields.tsx (3 hunks)
  • app/client/src/widgets/TableWidgetV2/component/header/actions/filter/Constants.ts (1 hunks)
  • app/client/src/widgets/TableWidgetV2/constants.ts (3 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (5 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/derived.test.js (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx (2 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Data.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/widgets/TableWidgetV2/widget/derived.test.js

[error] 1831-1831: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1860-1860: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1939-1939: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1954-1954: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2038-2038: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2089-2090: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (15)
app/client/src/widgets/TableWidgetV2/widget/derived.js (5)

284-291: Well-implemented getTextFromHTML function

The getTextFromHTML utility correctly extracts text content from HTML strings, ensuring that HTML tags do not interfere with search, filter, and sort functionalities.


515-519: Correct sorting for HTML columns

Using getTextFromHTML in the sorting logic ensures that HTML columns are sorted based on their text content, providing accurate sorting behavior.


716-719: Efficient identification of HTML columns

Filtering columns by columnType === "html" effectively identifies HTML columns for further processing.


818-823: Proper exclusion of HTML tags from search

By extracting the text content from HTML columns using getTextFromHTML, you prevent HTML tags and inline styles from affecting search results, enhancing search accuracy.


870-880: Accurate filtering for HTML columns

Applying getTextFromHTML to both the original and displayed column values ensures that filtering conditions are evaluated based on text content, improving filter reliability for HTML columns.

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

1649-2172: Comprehensive tests for HTML column functionality

The added test suite thoroughly covers searching, filtering, and sorting operations for HTML columns, enhancing test coverage and ensuring reliable functionality.

🧰 Tools
🪛 Biome (1.9.4)

[error] 1831-1831: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1860-1860: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1939-1939: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1954-1954: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2038-2038: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2089-2090: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

app/client/src/widgets/TableWidgetV2/component/header/actions/Utilities.ts (1)

39-43: Proper CSV quoting for HTML columns

Including ColumnTypes.HTML in the shouldQuote condition ensures that HTML content is correctly quoted, preserving the integrity of HTML data in the exported CSV.

app/client/src/widgets/TableWidgetV2/component/header/actions/Utilities.test.ts (1)

93-116: Adequate test for CSV transformation with HTML content

The new test case effectively verifies that transformTableDataIntoCsv correctly handles HTML content, ensuring accurate CSV exports.

app/client/src/widgets/TableWidgetV2/component/header/actions/filter/Constants.ts (1)

1-45: Organized filter operators definition

Defining TABLE_WIDGET_FILTER_OPERATORS enhances code maintainability by centralizing filter operator configurations.

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

45-48: LGTM: HTML column type configuration added correctly

The HTML column type is properly integrated into the column type dropdown options.


180-180: LGTM: HTML column type added to computedValue property

HTML column type is correctly added to the list of column types that hide the computedValue property.

app/client/src/widgets/TableWidgetV2/component/header/actions/filter/CascadeFields.tsx (2)

176-180: LGTM: HTML column filter operators are appropriate and secure

The HTML column type correctly implements essential text search operators (contains, does not contain) and existence checks (empty, not empty). This is appropriate for HTML content as it allows searching within the text content while maintaining security.


199-199: LGTM: HTML type mapping added

HTML column type is correctly mapped in the columnTypeNameMap.

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

142-142: LGTM: HTMLCell component imported

Clean import of the HTMLCell component.


2521-2538: LGTM: HTML cell rendering implementation is complete

The HTML cell implementation:

  • Correctly handles all necessary styling props
  • Manages cell visibility and disabled states
  • Follows the established pattern for cell rendering
✅ Verification successful

HTML cell implementation is secure and well-tested

The implementation is verified to be robust and secure:

  • Uses Interweave for HTML sanitization
  • Comprehensive test coverage for XSS prevention
  • Proper handling of null/undefined values
  • Well-styled HTML elements with proper hierarchy
  • Link handling with security considerations (newWindow prop)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify HTMLCell component implementation
# Check if HTMLCell has proper sanitization
ast-grep --pattern 'import { Interweave } from "interweave"'

# Check if HTMLCell has proper tests
fd HTMLCell.test.tsx

Length of output: 175


Script:

#!/bin/bash
# Check HTMLCell implementation for proper sanitization
ast-grep --pattern 'function HTMLCell' -A 20

# Check content of HTMLCell test file
cat app/client/src/widgets/TableWidgetV2/component/cellComponents/__tests__/HTMLCell.test.tsx

Length of output: 4559


Script:

#!/bin/bash
# Check HTMLCell implementation for sanitization
cat app/client/src/widgets/TableWidgetV2/component/cellComponents/HTMLCell.tsx

Length of output: 2743

@@ -146,6 +146,7 @@ export enum ColumnTypes {
CHECKBOX = "checkbox",
SWITCH = "switch",
CURRENCY = "currency",
HTML = "html",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

HTML column type integration is incomplete

The HTML column type has been added to the enums but lacks proper implementation in switch statements handling column types. This needs to be addressed in:

  • TableWidget/component/TableUtilities.tsx
  • TableWidget/component/CommonUtilities.ts
  • TableWidgetV2/component/cellComponents/PlainTextCell.tsx
  • TableWidgetV2/component/cellComponents/BasicCell.tsx
  • TableWidgetV2/component/cellComponents/AutoToolTipComponent.tsx

Only TableWidgetV2/widget/index.tsx has the HTML case implementation with HTMLCell component.

🔗 Analysis chain

Verify HTML column type integration

The HTML column type has been added to all necessary enums and arrays. Let's verify its usage across the codebase.

Also applies to: 162-162, 170-170, 181-181

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any existing usage of HTML column type
rg -l "ColumnTypes\.HTML" --type ts --type tsx

# Check for column type handling in transformers
ast-grep --pattern 'switch ($expr) {
  $$$
  case ColumnTypes.HTML:
    $$$
}'

Length of output: 157


Script:

#!/bin/bash
# Check for any existing usage of HTML column type, fixing the file type flag
rg -l "ColumnTypes\.HTML" -t ts

# Check for column type handling in transformers and processors
rg -A 5 "case.*HTML" -t ts

# Look for potential HTML column type implementations
rg -A 5 "HTML.*column" -t ts

# Search for switch statements handling column types
rg -A 10 "switch.*columnType" -t ts

Length of output: 8890

- Removed the Constants.ts file and integrated filter operators directly into CascadeFields.tsx.
streamlining the filtering process for different column types.
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Dec 6, 2024

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

Copy link

github-actions bot commented Dec 6, 2024

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

…null or undefined HTML inputs, improving robustness.
Copy link

github-actions bot commented Dec 9, 2024

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

Copy link

github-actions bot commented Dec 9, 2024

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

Copy link

github-actions bot commented Dec 9, 2024

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

Copy link

github-actions bot commented Dec 9, 2024

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

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

Copy link

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

case "string":
return dateFormatOptions.some(({ value: format }) =>
case "string": {
const isHTML = /<[^>]*>/.test(columnValue as string);
Copy link
Contributor

@jacquesikot jacquesikot Dec 10, 2024

Choose a reason for hiding this comment

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

This method doesn't seem exhaustive enough, there's a high chance of false positives with this, can we use something like this?

function detectHTML(input: string): boolean {
const div = document.createElement("div");
div.innerHTML = input;
return div.innerHTML !== input; // If innerHTML modifies input, it's likely HTML
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Or a stricter regex?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We analyzed this, and the current check is sufficient to validate html.

  1. Testing <span> text </text>
  2. <strong> Rahul

Invalid HTML, text not starting with a tag are all rendered by browser correctly and will not pass the aforementioned validity function.
It's best to stay put with current implementation. Let me know if you disagree.

},
);

const htmlTableData = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please put this data in fixture folder as file?

jsartisan
jsartisan previously approved these changes Dec 10, 2024
`HTMLCell_spec.ts` to enhance maintainability and clarity.
Copy link

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

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 (1)
app/client/cypress/fixtures/htmlCellInTableWidgetV2.ts (1)

1-11: Consider adding TypeScript interface for data structure.

The test data structure would benefit from a TypeScript interface to ensure type safety and provide better documentation.

interface UserData {
  id: number;
  name: string;
  email: string;
  role?: string;
  status: string | null;
  applicationDate: string;
  lastUpdated: string;
  department: string;
}

export const htmlTableData: UserData[] = [...]
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 51cd403 and 5f873fc.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/HTMLCell_spec.ts (1 hunks)
  • app/client/cypress/fixtures/htmlCellInTableWidgetV2.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/HTMLCell_spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/fixtures/htmlCellInTableWidgetV2.ts (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/fixtures/htmlCellInTableWidgetV2.ts (1)

1-56: LGTM! The test data structure is comprehensive.

The fixture provides a good variety of test cases including:

  • Undefined and null values
  • Different status states with visual indicators
  • Consistent date formats
  • Various departments and roles

@rahulbarwal rahulbarwal merged commit 3610bae into release Dec 11, 2024
42 checks passed
@rahulbarwal rahulbarwal deleted the rahulbarwal/Issue13681/Implementation/HTML-Column-type-in-table branch December 11, 2024 07:37
Copy link

sentry-io bot commented Dec 12, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: Cannot convert undefined or null to object Function.values(<anonymous>) View Issue
  • ‼️ TypeError: Cannot convert undefined or null to object Function.values(<anonymous>) View Issue

Did you find this useful? React with a 👍 or 👎

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 ok-to-test Required label for CI Table Widget V2 Issues related to Table Widget V2 Table Widget 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.

[Feature]: Support HTML as a column type in the table widget
4 participants