Skip to content

Commit a496ce3

Browse files
Copilothotlong
andcommitted
fix: address code review feedback - extract variables, add JSX parens, improve test coverage
- Extract headerClassName and handleHeaderClick variables for readability - Add parentheses around JSX elements in ternary operators - Add comment documenting SEMANTIC_COLOR_MAP key convention - Add test cases for hyphen and space normalization in status values Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 79e205e commit a496ce3

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

packages/fields/src/__tests__/cell-renderers.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,26 @@ describe('SelectCellRenderer', () => {
275275
expect(container.querySelector('[class*="bg-blue-100"]')).toBeInTheDocument();
276276
});
277277

278+
it('should auto-detect status semantic colors with hyphen (in-progress → blue)', () => {
279+
const { container } = render(
280+
<SelectCellRenderer
281+
value="in-progress"
282+
field={{ name: 'status', type: 'select', options: [] } as any}
283+
/>
284+
);
285+
expect(container.querySelector('[class*="bg-blue-100"]')).toBeInTheDocument();
286+
});
287+
288+
it('should auto-detect status semantic colors with spaces (in progress → blue)', () => {
289+
const { container } = render(
290+
<SelectCellRenderer
291+
value="in progress"
292+
field={{ name: 'status', type: 'select', options: [] } as any}
293+
/>
294+
);
295+
expect(container.querySelector('[class*="bg-blue-100"]')).toBeInTheDocument();
296+
});
297+
278298
it('should render dash for null/empty value', () => {
279299
render(
280300
<SelectCellRenderer

packages/fields/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ export function DateTimeCellRenderer({ value }: CellRendererProps): React.ReactE
369369
}
370370

371371
// Semantic color mapping (auto-detect from value text for priority & status fields)
372+
// Keys use underscore notation; lookup normalizes spaces/hyphens to underscores automatically.
372373
const SEMANTIC_COLOR_MAP: Record<string, string> = {
373374
// Priority values
374375
critical: 'red',

packages/plugin-detail/src/RelatedList.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,18 @@ export const RelatedList: React.FC<RelatedListProps> = ({
260260

261261
const hasRowActions = !!onRowEdit || !!onRowDelete;
262262

263+
const headerClassName = collapsible ? 'cursor-pointer select-none' : undefined;
264+
const handleHeaderClick = collapsible ? () => setCollapsed((c) => !c) : undefined;
265+
263266
return (
264267
<Card className={className}>
265-
<CardHeader className={collapsible ? 'cursor-pointer select-none' : undefined} onClick={collapsible ? () => setCollapsed((c) => !c) : undefined}>
268+
<CardHeader className={headerClassName} onClick={handleHeaderClick}>
266269
<CardTitle className="flex items-center justify-between">
267270
<div className="flex items-center gap-2">
268271
{collapsible && (
269272
collapsed
270-
? <ChevronRight className="h-4 w-4 text-muted-foreground" />
271-
: <ChevronDown className="h-4 w-4 text-muted-foreground" />
273+
? (<ChevronRight className="h-4 w-4 text-muted-foreground" />)
274+
: (<ChevronDown className="h-4 w-4 text-muted-foreground" />)
272275
)}
273276
<span>{title}</span>
274277
<span className="text-sm font-normal text-muted-foreground">

0 commit comments

Comments
 (0)