11import React , { useState , useRef , useEffect , useCallback , useMemo } from "react" ;
22import { default as Menu } from "antd/es/menu" ;
33import { ColumnTypeCompBuilder } from "comps/comps/tableComp/column/columnTypeCompBuilder" ;
4- import { ActionSelectorControlInContext } from "comps/controls/actionSelector/actionSelectorControl" ;
54import { BoolCodeControl , StringControl } from "comps/controls/codeControl" ;
65import { manualOptionsControl } from "comps/controls/optionsControl" ;
76import { MultiCompBuilder } from "comps/generators" ;
@@ -10,6 +9,9 @@ import { trans } from "i18n";
109import styled from "styled-components" ;
1110import { ColumnLink } from "comps/comps/tableComp/column/columnTypeComps/columnLinkComp" ;
1211import { LightActiveTextColor , PrimaryColor } from "constants/style" ;
12+ import { clickEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
13+ import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators" ;
14+ import { fixOldActionData } from "comps/comps/tableComp/column/simpleColumnTypeComps" ;
1315
1416const MenuLinkWrapper = styled . div `
1517 > a {
@@ -37,11 +39,13 @@ const MenuWrapper = styled.div`
3739 }
3840` ;
3941
42+ const LinkEventOptions = [ clickEvent ] as const ;
43+
4044// Memoized menu item component
4145const MenuItem = React . memo ( ( { option, index} :{ option :any ; index :number } ) => {
4246const handleClick = useCallback ( ( ) => {
4347if ( ! option . disabled && option . onClick ) {
44- option . onClick ( ) ;
48+ option . onClick ( "click" ) ;
4549}
4650} , [ option . disabled , option . onClick ] ) ;
4751
@@ -58,10 +62,10 @@ const MenuItem = React.memo(({ option, index }: { option: any; index: number })
5862
5963MenuItem . displayName = 'MenuItem' ;
6064
61- const OptionItem = new MultiCompBuilder (
65+ const OptionItemTmp = new MultiCompBuilder (
6266{
6367label :StringControl ,
64- onClick :ActionSelectorControlInContext ,
68+ onClick :eventHandlerControl ( LinkEventOptions ) ,
6569hidden :BoolCodeControl ,
6670disabled :BoolCodeControl ,
6771} ,
@@ -73,17 +77,16 @@ const OptionItem = new MultiCompBuilder(
7377return (
7478< >
7579{ children . label . propertyView ( { label :trans ( "label" ) } ) }
76- { children . onClick . propertyView ( {
77- label :trans ( "table.action" ) ,
78- placement :"table" ,
79- } ) }
8080{ hiddenPropertyView ( children ) }
8181{ disabledPropertyView ( children ) }
82+ { children . onClick . propertyView ( ) }
8283</ >
8384) ;
8485} )
8586. build ( ) ;
8687
88+ const OptionItem = migrateOldData ( OptionItemTmp , fixOldActionData ) ;
89+
8790// Memoized menu component
8891const LinksMenu = React . memo ( ( { options} :{ options :any [ ] } ) => {
8992const mountedRef = useRef ( true ) ;
@@ -114,7 +117,7 @@ const LinksMenu = React.memo(({ options }: { options: any[] }) => {
114117
115118LinksMenu . displayName = 'LinksMenu' ;
116119
117- export const ColumnLinksComp = ( function ( ) {
120+ const ColumnLinksCompTmp = ( function ( ) {
118121const childrenMap = {
119122options :manualOptionsControl ( OptionItem , {
120123initOptions :[ { label :trans ( "table.option1" ) } ] ,
@@ -137,3 +140,5 @@ export const ColumnLinksComp = (function () {
137140) )
138141. build ( ) ;
139142} ) ( ) ;
143+
144+ export const ColumnLinksComp = migrateOldData ( ColumnLinksCompTmp , fixOldActionData ) ;