Skip to content

Commit 9109951

Browse files
committed
Lots of improvements.
1 parent 015cc84 commit 9109951

File tree

1 file changed

+55
-31
lines changed

1 file changed

+55
-31
lines changed

browser-extension/tests/playground/claude.tsx

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const generateMockDrafts = () => [
1818
charCount: 245,
1919
content:
2020
'This PR addresses the memory leak issue reported in #1233. The problem was caused by event listeners not being properly disposed...',
21-
hasCode: true,
22-
hasImage: true,
21+
codeCount: 3,
22+
imageCount: 2,
2323
id: '1',
2424
kind: 'PR',
2525
lastEdit: Date.now() - 1000 * 60 * 30,
@@ -36,8 +36,8 @@ const generateMockDrafts = () => [
3636
charCount: 180,
3737
content:
3838
"I've been using GitLens for years and it's absolutely essential for my workflow. The inline blame annotations are incredibly helpful when...",
39-
hasCode: false,
40-
hasImage: false,
39+
codeCount: 0,
40+
imageCount: 0,
4141
id: '2',
4242
kind: 'Comment',
4343
lastEdit: Date.now() - 1000 * 60 * 60 * 2,
@@ -52,8 +52,8 @@ const generateMockDrafts = () => [
5252
charCount: 456,
5353
content:
5454
"When using useEffect with async functions, the cleanup function doesn't seem to be called correctly in certain edge cases...",
55-
hasCode: true,
56-
hasImage: false,
55+
codeCount: 1,
56+
imageCount: 0,
5757
id: '3',
5858
kind: 'Issue',
5959
lastEdit: Date.now() - 1000 * 60 * 60 * 5,
@@ -70,8 +70,8 @@ const generateMockDrafts = () => [
7070
charCount: 322,
7171
content:
7272
'LGTM! Just a few minor suggestions about the examples in the routing section. Consider adding more context about...',
73-
hasCode: false,
74-
hasImage: true,
73+
codeCount: 0,
74+
imageCount: 4,
7575
id: '4',
7676
kind: 'PR',
7777
lastEdit: Date.now() - 1000 * 60 * 60 * 24,
@@ -88,8 +88,8 @@ const generateMockDrafts = () => [
8888
charCount: 678,
8989
content:
9090
'This PR implements ESM support in worker threads as discussed in the last TSC meeting. The implementation follows...',
91-
hasCode: true,
92-
hasImage: true,
91+
codeCount: 7,
92+
imageCount: 1,
9393
id: '5',
9494
kind: 'PR',
9595
lastEdit: Date.now() - 1000 * 60 * 60 * 48,
@@ -128,18 +128,22 @@ export const ClaudePrototype = () => {
128128
const [drafts] = useState(generateMockDrafts())
129129
const [selectedIds, setSelectedIds] = useState(new Set())
130130
const [hasCodeFilter, setHasCodeFilter] = useState(false)
131-
const [privateOnlyFilter, setPrivateOnlyFilter] = useState(false)
131+
const [hasImageFilter, setHasImageFilter] = useState(false)
132+
const [hasLinkFilter, setHasLinkFilter] = useState(false)
132133
const [searchQuery, setSearchQuery] = useState('')
133134
const [sortBy, setSortBy] = useState('edited-newest')
134135
const [showFilters, setShowFilters] = useState(false)
135136

136137
const filteredDrafts = useMemo(() => {
137138
let filtered = [...drafts]
138139
if (hasCodeFilter) {
139-
filtered = filtered.filter((d) => d.hasCode)
140+
filtered = filtered.filter((d) => d.codeCount > 0)
140141
}
141-
if (privateOnlyFilter) {
142-
filtered = filtered.filter((d) => d.private)
142+
if (hasImageFilter) {
143+
filtered = filtered.filter((d) => d.imageCount > 0)
144+
}
145+
if (hasLinkFilter) {
146+
filtered = filtered.filter((d) => d.linkCount > 0)
143147
}
144148
if (searchQuery) {
145149
const query = searchQuery.toLowerCase()
@@ -161,7 +165,7 @@ export const ClaudePrototype = () => {
161165
break
162166
}
163167
return filtered
164-
}, [drafts, hasCodeFilter, privateOnlyFilter, searchQuery, sortBy])
168+
}, [drafts, hasCodeFilter, hasImageFilter, hasLinkFilter, searchQuery, sortBy])
165169

166170
const toggleSelection = (id: string) => {
167171
const newSelected = new Set(selectedIds)
@@ -223,7 +227,8 @@ export const ClaudePrototype = () => {
223227
filteredDrafts.length === 0 &&
224228
(searchQuery ||
225229
hasCodeFilter ||
226-
privateOnlyFilter)
230+
hasImageFilter ||
231+
hasLinkFilter)
227232
) {
228233
return (
229234
<div className='min-h-screen bg-white'>
@@ -250,7 +255,8 @@ export const ClaudePrototype = () => {
250255
type='button'
251256
onClick={() => {
252257
setHasCodeFilter(false)
253-
setPrivateOnlyFilter(false)
258+
setHasImageFilter(false)
259+
setHasLinkFilter(false)
254260
setSearchQuery('')
255261
}}
256262
className='text-blue-600 hover:underline'
@@ -311,7 +317,7 @@ export const ClaudePrototype = () => {
311317
</th>
312318
<th
313319
scope='col'
314-
className='px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider'
320+
className='px-3 py-3 text-left text-xs font-medium text-gray-500 tracking-wider'
315321
>
316322
<div className='relative'>
317323
<div className='flex items-center gap-1'>
@@ -340,20 +346,38 @@ export const ClaudePrototype = () => {
340346
<label className='flex items-center gap-2 cursor-pointer'>
341347
<input
342348
type='checkbox'
343-
checked={hasCodeFilter}
344-
onChange={(e) => setHasCodeFilter(e.target.checked)}
349+
checked={hasLinkFilter}
350+
onChange={(e) => setHasLinkFilter(e.target.checked)}
345351
className='rounded'
346352
/>
347-
<span className='text-sm'>Has code</span>
353+
<span className='inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-blue-50 text-blue-700'>
354+
<Link className='w-3 h-3' />
355+
links
356+
</span>
348357
</label>
349358
<label className='flex items-center gap-2 cursor-pointer'>
350359
<input
351360
type='checkbox'
352-
checked={privateOnlyFilter}
353-
onChange={(e) => setPrivateOnlyFilter(e.target.checked)}
361+
checked={hasImageFilter}
362+
onChange={(e) => setHasImageFilter(e.target.checked)}
363+
className='rounded'
364+
/>
365+
<span className='inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-purple-50 text-purple-700'>
366+
<Image className='w-3 h-3' />
367+
images
368+
</span>
369+
</label>
370+
<label className='flex items-center gap-2 cursor-pointer'>
371+
<input
372+
type='checkbox'
373+
checked={hasCodeFilter}
374+
onChange={(e) => setHasCodeFilter(e.target.checked)}
354375
className='rounded'
355376
/>
356-
<span className='text-sm'>Private only</span>
377+
<span className='inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-pink-50 text-pink-700'>
378+
<Code className='w-3 h-3' />
379+
code
380+
</span>
357381
</label>
358382
</div>
359383
</div>
@@ -362,7 +386,7 @@ export const ClaudePrototype = () => {
362386
</th>
363387
<th
364388
scope='col'
365-
className='px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider'
389+
className='px-3 py-3 text-left text-xs font-medium text-gray-500 tracking-wider'
366390
>
367391
<button
368392
type='button'
@@ -379,9 +403,9 @@ export const ClaudePrototype = () => {
379403
</th>
380404
<th
381405
scope='col'
382-
className='px-3 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider'
406+
className='px-3 py-3 text-right text-xs font-medium text-gray-500 tracking-wider'
383407
>
384-
Actions
408+
ACTIONS
385409
</th>
386410
</tr>
387411
</thead>
@@ -431,16 +455,16 @@ export const ClaudePrototype = () => {
431455
{draft.linkCount}
432456
</span>
433457
)}
434-
{draft.hasImage && (
458+
{draft.imageCount > 0 && (
435459
<span className='inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-purple-50 text-purple-700'>
436460
<Image className='w-3 h-3' />
437-
image
461+
{draft.imageCount}
438462
</span>
439463
)}
440-
{draft.hasCode && (
464+
{draft.codeCount > 0 && (
441465
<span className='inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-pink-50 text-pink-700'>
442466
<Code className='w-3 h-3' />
443-
code
467+
{draft.codeCount}
444468
</span>
445469
)}
446470
<span className='text-xs text-gray-500'>{draft.charCount} chars</span>

0 commit comments

Comments
 (0)