1
1
import { useState } from 'react' ;
2
- import { Accordion , Button , Checkbox , Collapse , Group , Pill , Stack , Text , Tooltip } from '@mantine/core' ;
2
+ import { Accordion , Anchor , Button , Checkbox , Collapse , Group , Pill , Stack , Text , Tooltip } from '@mantine/core' ;
3
3
import { Link } from 'react-router-dom' ;
4
4
import { useDisclosure } from '@mantine/hooks' ;
5
- import { IconGavel } from '@tabler/icons-react' ;
5
+ import { IconDownload , IconGavel , IconPrompt } from '@tabler/icons-react' ;
6
6
import { Judge } from '../../hooks/useJudges.ts' ;
7
7
import { useUrlState } from '../../hooks/useUrlState.ts' ;
8
8
import { useUpdateJudge } from '../../hooks/useUpdateJudge.ts' ;
9
9
import { MarkdownContent } from '../MarkdownContent.tsx' ;
10
10
import { pluralize } from '../../lib/string.ts' ;
11
+ import { API_ROUTES } from '../../lib/routes.ts' ;
11
12
import { judgeTypeIconComponent , judgeTypeToHumanReadableName } from './types.ts' ;
12
13
import { DeleteJudgeButton } from './DeleteJudgeButton.tsx' ;
13
14
import { CanAccessJudgeStatusIndicator } from './CanAccessJudgeStatusIndicator.tsx' ;
@@ -30,6 +31,15 @@ export function JudgeAccordionItem({ judge }: Props) {
30
31
setIsEnabled ( prev => ! prev ) ;
31
32
}
32
33
34
+ const canDownload = judge . n_votes > 0 ;
35
+ const downloadUrl = canDownload ? API_ROUTES . downloadJudgeVotesCsv ( projectSlug , judge . id ) : undefined ;
36
+ const DownloadVotesComponent = (
37
+ < Anchor href = { downloadUrl } target = "_blank" >
38
+ < Button variant = "light" color = "teal" size = "xs" leftSection = { < IconDownload size = { 20 } /> } disabled = { ! canDownload } >
39
+ Download Votes CSV
40
+ </ Button >
41
+ </ Anchor >
42
+ ) ;
33
43
const IconComponent = judgeTypeIconComponent ( judge_type ) ;
34
44
return (
35
45
< Accordion . Item key = { id } value = { `${ judge_type } -${ id } ` } >
@@ -53,10 +63,15 @@ export function JudgeAccordionItem({ judge }: Props) {
53
63
</ Text >
54
64
</ Stack >
55
65
< Group >
56
- { isEnabled && (
57
- < Pill bg = "ice.0" c = "gray.8" >
66
+ < Text c = "dimmed" size = "xs" fs = "italic" >
67
+ { pluralize ( judge . n_votes , 'vote' ) }
68
+ </ Text >
69
+ { isEnabled ? (
70
+ < Pill bg = "ice.0" c = "ice.9" >
58
71
Enabled
59
72
</ Pill >
73
+ ) : (
74
+ < Pill c = "gray" > Disabled</ Pill >
60
75
) }
61
76
</ Group >
62
77
</ Group >
@@ -73,12 +88,16 @@ export function JudgeAccordionItem({ judge }: Props) {
73
88
onChange = { ( ) => handleToggleEnabled ( ) }
74
89
/>
75
90
< Group >
76
- < Text c = "dimmed" size = "xs" fs = "italic" >
77
- { pluralize ( judge . n_votes , 'vote' ) } submitted
78
- </ Text >
79
- < Button variant = "light" color = "gray" size = "xs" onClick = { toggleShowSystemPrompt } >
91
+ < Button
92
+ variant = "light"
93
+ color = "gray"
94
+ size = "xs"
95
+ leftSection = { < IconPrompt size = { 20 } /> }
96
+ onClick = { toggleShowSystemPrompt }
97
+ >
80
98
{ showSystemPrompt ? 'Hide' : 'Show' } System Prompt
81
99
</ Button >
100
+ { DownloadVotesComponent }
82
101
< Tooltip label = "Judge must be enabled" disabled = { judge . enabled } >
83
102
< Button
84
103
variant = "light"
@@ -111,9 +130,7 @@ export function JudgeAccordionItem({ judge }: Props) {
111
130
</ Link > { ' ' }
112
131
tab to provide ratings on head-to-head matchups between models.
113
132
</ Text >
114
- < Text c = "dimmed" size = "xs" fs = "italic" >
115
- { pluralize ( judge . n_votes , 'vote' ) } submitted
116
- </ Text >
133
+ { DownloadVotesComponent }
117
134
</ Group >
118
135
) }
119
136
< Collapse in = { showSystemPrompt } fz = "sm" >
0 commit comments