Skip to content

[Fix]: backward compatibility for button, link and links column types #1769

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

Merged
merged 9 commits into from
Jun 14, 2025
Prev Previous commit
Next Next commit
add backward compatibility for link type
  • Loading branch information
iamfaran committed Jun 13, 2025
commit 28d37435ce51b095493c98c73828d864017bde6a
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import {
ColumnTypeCompBuilder,
ColumnTypeViewFn,
} from "comps/comps/tableComp/column/columnTypeCompBuilder";
import { ActionSelectorControlInContext } from "comps/controls/actionSelector/actionSelectorControl";
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
import { trans } from "i18n";
import { disabledPropertyView } from "comps/utils/propertyUtils";
import styled, { css } from "styled-components";
import { styleControl } from "comps/controls/styleControl";
import { TableColumnLinkStyle } from "comps/controls/styleControlConstants";
import { clickEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators";
import { fixOldActionData } from "comps/comps/tableComp/column/simpleColumnTypeComps";

export const ColumnValueTooltip = trans("table.columnValueTooltip");

const LinkEventOptions = [clickEvent] as const;

const childrenMap = {
text: StringControl,
onClick: ActionSelectorControlInContext,
onClick: eventHandlerControl(LinkEventOptions),
disabled: BoolCodeControl,
style: styleControl(TableColumnLinkStyle),
};
Expand All @@ -34,11 +38,10 @@ const StyledLink = styled.a<{ $disabled: boolean }>`
`;

// Memoized link component
export const ColumnLink = React.memo(({ disabled, label, onClick }: { disabled: boolean; label: string; onClick?: () => void }) => {
export const ColumnLink = React.memo(({ disabled, label, onClick }: { disabled: boolean; label: string; onClick?: (eventName: string) => void }) => {
const handleClick = useCallback(() => {
if (!disabled && onClick) {
onClick();
}
if (disabled) return;
onClick?.("click");
}, [disabled, onClick]);

return (
Expand Down Expand Up @@ -101,7 +104,7 @@ LinkEdit.displayName = 'LinkEdit';

const getBaseValue: ColumnTypeViewFn<typeof childrenMap, string, string> = (props) => props.text;

export const LinkComp = (function () {
const LinkCompTmp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
Expand All @@ -125,10 +128,7 @@ export const LinkComp = (function () {
tooltip: ColumnValueTooltip,
})}
{disabledPropertyView(children)}
{children.onClick.propertyView({
label: trans("table.action"),
placement: "table",
})}
{children.onClick.propertyView()}
</>
))
.setStylePropertyViewFn((children) => (
Expand All @@ -138,3 +138,5 @@ export const LinkComp = (function () {
))
.build();
})();

export const LinkComp = migrateOldData(LinkCompTmp, fixOldActionData);
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy