-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Enhance URL handling in table by rendering URL column types with <a>
tag.
#37179
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
61230b2
refactor: replace string type with ColumnTypes for columnType prop in…
rahulbarwal dd2a392
refactor: simplify AutoToolTipComponent by removing LinkWrapper and e…
rahulbarwal 5caa9ba
feat: enhance BasicCell to render URLs as links using ColumnTypes
rahulbarwal a82baf3
refactor: optimize BasicCell to use useMemo for content rendering
rahulbarwal ee45872
refactor: replace string type with CompactModeTypes in BaseCellCompon…
rahulbarwal 054ab9c
test: add unit tests for BasicCell component functionality
rahulbarwal be453a1
feat: enhance BasicCell to improve URL link security with rel and tar…
rahulbarwal 2ffbe75
[Bug]: Unable to right click on the link present in URL column type o…
rahulbarwal 83d6004
test: update AutoTooltipComponent test to handle non-empty tooltip title
rahulbarwal a267986
fix: prevent pointer events on URL links in BasicCell to improve user…
rahulbarwal 308a73d
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
rahulbarwal 58b7dd1
fix: simplify URL handling in AutoToolTipComponent to enhance clarity…
rahulbarwal f8ec7e0
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
rahulbarwal b47908e
test: remove redundant URL click test from AutoTooltipComponent tests…
rahulbarwal b7c5d17
test: update TableV2 URL column spec to check href and target attribu…
rahulbarwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/client/src/widgets/TableWidgetV2/component/cellComponents/BasicCell.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from "react"; | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import { BasicCell, type PropType } from "./BasicCell"; | ||
import { ColumnTypes } from "widgets/TableWidgetV2/constants"; | ||
import { CompactModeTypes } from "widgets/TableWidget/component/Constants"; | ||
|
||
describe("BasicCell Component", () => { | ||
const defaultProps: PropType = { | ||
value: "Test Value", | ||
onEdit: jest.fn(), | ||
isCellEditable: false, | ||
hasUnsavedChanges: false, | ||
columnType: ColumnTypes.TEXT, | ||
url: "", | ||
compactMode: CompactModeTypes.DEFAULT, | ||
isHidden: false, | ||
isCellVisible: true, | ||
accentColor: "", | ||
tableWidth: 100, | ||
disabledEditIcon: false, | ||
disabledEditIconMessage: "", | ||
}; | ||
|
||
it("renders the value", () => { | ||
render(<BasicCell {...defaultProps} />); | ||
expect(screen.getByText("Test Value")).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders a link when columnType is URL", () => { | ||
render( | ||
<BasicCell | ||
{...defaultProps} | ||
columnType={ColumnTypes.URL} | ||
url="http://example.com" | ||
/>, | ||
); | ||
const link = screen.getByText("Test Value"); | ||
|
||
expect(link).toBeInTheDocument(); | ||
expect(link).toHaveAttribute("href", "http://example.com"); | ||
}); | ||
|
||
it("calls onEdit when double-clicked", () => { | ||
render(<BasicCell {...defaultProps} isCellEditable />); | ||
fireEvent.doubleClick(screen.getByText("Test Value")); | ||
expect(defaultProps.onEdit).toHaveBeenCalled(); | ||
}); | ||
|
||
it("forwards ref to the div element", () => { | ||
const ref = React.createRef<HTMLDivElement>(); | ||
|
||
render(<BasicCell {...defaultProps} ref={ref} />); | ||
expect(ref.current).toBeInstanceOf(HTMLDivElement); | ||
}); | ||
}); | ||
rahulbarwal marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Refactor selectors and reduce code duplication.
Consider refactoring to:
Also applies to: 32-39