Files
twenty/packages/twenty-ui/src/components/chip/LinkChip.tsx
T
Félix Malfait 1088f7bbab feat: add lingui/no-unlocalized-strings ESLint rule and fix translations (#16610)
## Summary
This PR adds the `lingui/no-unlocalized-strings` ESLint rule to detect
untranslated strings and fixes translation issues across multiple
components.

## Changes

### ESLint Configuration (`eslint.config.react.mjs`)
- Added comprehensive `ignore` patterns for non-translatable strings
(CSS values, HTML attributes, technical identifiers)
- Added `ignoreNames` for props that don't need translation (className,
data-*, aria-*, etc.)
- Added `ignoreFunctions` for console methods, URL APIs, and other
non-user-facing functions
- Disabled rule for debug files, storybook, and test files

### Components Fixed (~19 files)
- Object record components (field inputs, pickers, merge dialogs)
- Settings components (accounts, admin panel)
- Serverless function components
- Record table and title cell components

## Status
🚧 **Work in Progress** - ~124 files remaining to fix

This PR is being submitted as draft to allow progressive fixing of
remaining translation issues.

## Testing
- Run `npx eslint "src/**/*.tsx"` in `packages/twenty-front` to check
remaining issues
2025-12-17 22:08:33 +01:00

82 lines
1.9 KiB
TypeScript

import { styled } from '@linaria/react';
import {
Chip,
ChipAccent,
type ChipProps,
ChipSize,
ChipVariant,
} from '@ui/components/chip/Chip';
import { LINK_CHIP_CLICK_OUTSIDE_ID } from '@ui/components/chip/constants/LinkChipClickOutsideId';
import { type TriggerEventType, useMouseDownNavigation } from '@ui/utilities';
import { type MouseEvent } from 'react';
import { Link } from 'react-router-dom';
export type LinkChipProps = Omit<
ChipProps,
'onClick' | 'disabled' | 'clickable'
> & {
to: string;
onClick?: (event: MouseEvent<HTMLElement>) => void;
onMouseDown?: (event: MouseEvent<HTMLElement>) => void;
triggerEvent?: TriggerEventType;
target?: '_blank' | '_self';
};
const StyledLink = styled(Link)`
display: inline-flex;
text-decoration: none;
min-width: 0;
`;
export const LinkChip = ({
to,
size = ChipSize.Small,
label,
isLabelHidden = false,
variant = ChipVariant.Regular,
leftComponent = null,
rightComponent = null,
accent = ChipAccent.TextPrimary,
className,
maxWidth,
onClick,
triggerEvent,
target,
emptyLabel,
}: LinkChipProps) => {
const { onClick: onClickHandler, onMouseDown: onMouseDownHandler } =
useMouseDownNavigation({
to: to,
onClick: onClick,
triggerEvent,
});
return (
<StyledLink
to={to}
onClick={(event) => {
event.stopPropagation();
onClickHandler(event);
}}
onMouseDown={onMouseDownHandler}
data-click-outside-id={LINK_CHIP_CLICK_OUTSIDE_ID}
target={target}
rel={target === '_blank' ? 'noopener noreferrer' : undefined}
>
<Chip
size={size}
label={label}
isLabelHidden={isLabelHidden}
clickable={true}
variant={variant}
leftComponent={leftComponent}
rightComponent={rightComponent}
accent={accent}
className={className}
maxWidth={maxWidth}
emptyLabel={emptyLabel}
/>
</StyledLink>
);
};