Skip to content

Commit fbcab49

Browse files
Fix asterisk for custom attributes
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
1 parent 9192d68 commit fbcab49

File tree

3 files changed

+42
-31
lines changed

3 files changed

+42
-31
lines changed

src/views/shared/workflows-list-columns-picker/__tests__/workflows-list-columns-picker.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jest.mock('baseui/popover', () => ({
2626
}));
2727

2828
const MOCK_ALL_COLUMNS: ColumnDefinition[] = [
29-
{ id: 'col-1', name: 'Workflow ID' },
30-
{ id: 'col-2', name: 'Status' },
31-
{ id: 'col-3', name: 'Start Time' },
32-
{ id: 'col-4', name: 'End Time' },
29+
{ id: 'col-1', name: 'Workflow ID', isSystem: true },
30+
{ id: 'col-2', name: 'Status', isSystem: true },
31+
{ id: 'col-3', name: 'Start Time', isSystem: false },
32+
{ id: 'col-4', name: 'End Time', isSystem: false },
3333
];
3434

3535
describe(WorkflowsListColumnsPicker.name, () => {
@@ -60,8 +60,8 @@ describe(WorkflowsListColumnsPicker.name, () => {
6060

6161
expect(screen.getByText('Workflow ID')).toBeInTheDocument();
6262
expect(screen.getByText('Status')).toBeInTheDocument();
63-
expect(screen.getByText('Start Time')).toBeInTheDocument();
64-
expect(screen.getByText('End Time')).toBeInTheDocument();
63+
expect(screen.getByText('*Start Time')).toBeInTheDocument();
64+
expect(screen.getByText('*End Time')).toBeInTheDocument();
6565
});
6666

6767
it('shows selected columns as checked and unselected as unchecked', async () => {
@@ -105,10 +105,10 @@ describe(WorkflowsListColumnsPicker.name, () => {
105105
'Start'
106106
);
107107

108-
expect(screen.getByText('Start Time')).toBeInTheDocument();
108+
expect(screen.getByText('*Start Time')).toBeInTheDocument();
109109
expect(screen.queryByText('Workflow ID')).not.toBeInTheDocument();
110110
expect(screen.queryByText('Status')).not.toBeInTheDocument();
111-
expect(screen.queryByText('End Time')).not.toBeInTheDocument();
111+
expect(screen.queryByText('*End Time')).not.toBeInTheDocument();
112112
});
113113

114114
it('toggles column checked state when checkbox is clicked', async () => {

src/views/shared/workflows-list-columns-picker/workflows-list-columns-picker.tsx

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,39 @@ export default function WorkflowsListColumnsPicker({
119119
</styled.SubHeader>
120120
<styled.ColumnsList>
121121
<List
122-
items={displayedColumns.map((entry) => {
123-
const col = columnMap.get(entry.id);
124-
return (
125-
<styled.ColumnRow key={entry.id}>
126-
<styled.ColumnName>
127-
{col?.name ?? entry.id}
128-
</styled.ColumnName>
129-
<styled.CheckboxContainer
130-
onClick={(e: React.MouseEvent) => e.stopPropagation()}
131-
onMouseDown={(e: React.MouseEvent) => e.stopPropagation()}
132-
onTouchStart={(e: React.TouchEvent) =>
133-
e.stopPropagation()
134-
}
135-
>
136-
<Checkbox
137-
checked={entry.checked}
138-
onChange={() => handleToggle(entry.id)}
139-
checkmarkType="toggle"
140-
/>
141-
</styled.CheckboxContainer>
142-
</styled.ColumnRow>
143-
);
144-
})}
122+
items={displayedColumns.reduce<React.ReactNode[]>(
123+
(acc, entry) => {
124+
const col = columnMap.get(entry.id);
125+
if (!col) return acc;
126+
127+
acc.push(
128+
<styled.ColumnRow key={entry.id}>
129+
<styled.ColumnName>
130+
{!col.isSystem ? '*' : ''}
131+
{col.name}
132+
</styled.ColumnName>
133+
<styled.CheckboxContainer
134+
onClick={(e: React.MouseEvent) => e.stopPropagation()}
135+
onMouseDown={(e: React.MouseEvent) =>
136+
e.stopPropagation()
137+
}
138+
onTouchStart={(e: React.TouchEvent) =>
139+
e.stopPropagation()
140+
}
141+
>
142+
<Checkbox
143+
checked={entry.checked}
144+
onChange={() => handleToggle(entry.id)}
145+
checkmarkType="toggle"
146+
/>
147+
</styled.CheckboxContainer>
148+
</styled.ColumnRow>
149+
);
150+
151+
return acc;
152+
},
153+
[]
154+
)}
145155
onChange={handleDragEnd}
146156
overrides={
147157
isDragDisabled

src/views/shared/workflows-list-columns-picker/workflows-list-columns-picker.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type ColumnDefinition = {
22
id: string;
33
name: string;
4+
isSystem: boolean;
45
};
56

67
export type ColumnState = { id: string; checked: boolean };

0 commit comments

Comments
 (0)