@@ -26,7 +26,16 @@ export function KtResolvedEntities(props: BoxProps) {
2626 const globalEntities = table . globalRules . flatMap ( rule => rule . resolvedEntities || [ ] ) ;
2727 const columnEntities = table . columns . flatMap ( column => column . resolvedEntities || [ ] ) ;
2828 const entities = [ ...globalEntities , ...columnEntities ] ;
29- return entities ;
29+
30+ // Only show entities where a transformation was actually applied
31+ return entities . filter ( entity => {
32+ // For arrays, compare stringified versions
33+ if ( Array . isArray ( entity . original ) && Array . isArray ( entity . resolved ) ) {
34+ return JSON . stringify ( entity . original ) !== JSON . stringify ( entity . resolved ) ;
35+ }
36+ // For strings, direct comparison
37+ return entity . original !== entity . resolved ;
38+ } ) ;
3039 } , [ table . globalRules , table . columns ] ) ;
3140
3241 const handleUndoTransformation = ( entity : ResolvedEntity ) => {
@@ -39,22 +48,16 @@ export function KtResolvedEntities(props: BoxProps) {
3948 return [ columnId , cellValue ] ;
4049 }
4150
42- if ( typeof cellValue === 'string' ) {
43- // Replace resolved with original in string values
44- return [ columnId , cellValue . includes ( entity . resolved )
45- ? cellValue . replace ( entity . resolved , entity . original )
46- : cellValue ] ;
47- } else if ( Array . isArray ( cellValue ) ) {
48- // Replace resolved with original in array values
49- return [
50- columnId ,
51- cellValue . map ( item =>
52- typeof item === 'string' && item . includes ( entity . resolved )
53- ? item . replace ( entity . resolved , entity . original )
54- : item
55- )
56- ] ;
51+ // Check if values match (either both arrays or both strings)
52+ const valuesMatch = Array . isArray ( cellValue ) && Array . isArray ( entity . resolved )
53+ ? JSON . stringify ( cellValue ) === JSON . stringify ( entity . resolved )
54+ : cellValue === entity . resolved ;
55+
56+ // If they match, replace with original value
57+ if ( valuesMatch ) {
58+ return [ columnId , entity . original ] ;
5759 }
60+
5861 return [ columnId , cellValue ] ;
5962 } )
6063 )
@@ -84,7 +87,12 @@ export function KtResolvedEntities(props: BoxProps) {
8487
8588 return (
8689 < Group gap = { 8 } { ...props } >
87- < Button leftSection = { < IconReplace size = { 16 } /> } onClick = { handlers . open } >
90+ < Button
91+ leftSection = { < IconReplace size = { 16 } /> }
92+ onClick = { handlers . open }
93+ disabled = { allResolvedEntities . length === 0 }
94+ variant = "light" // Always light variant
95+ >
8896 Resolved entities
8997 </ Button >
9098
0 commit comments