@@ -14,36 +14,36 @@ import {
14
14
Tooltip ,
15
15
TooltipInfoButton ,
16
16
TooltipTrigger ,
17
- } from " @stacklok/ui-kit" ;
18
- import { twMerge } from " tailwind-merge" ;
19
- import { useMutationPreferredModelWorkspace } from " ../hooks/use-mutation-preferred-model-workspace" ;
17
+ } from ' @stacklok/ui-kit'
18
+ import { twMerge } from ' tailwind-merge'
19
+ import { useMutationPreferredModelWorkspace } from ' ../hooks/use-mutation-preferred-model-workspace'
20
20
import {
21
21
MuxMatcherType ,
22
22
V1ListAllModelsForAllProvidersResponse ,
23
- } from " @/api/generated" ;
24
- import { FormEvent } from " react" ;
23
+ } from ' @/api/generated'
24
+ import { FormEvent } from ' react'
25
25
import {
26
26
LayersThree01 ,
27
27
LinkExternal01 ,
28
28
Plus ,
29
29
Trash01 ,
30
- } from " @untitled-ui/icons-react" ;
31
- import { SortableArea } from " @/components/SortableArea" ;
32
- import { WorkspaceModelsDropdown } from " ./workspace-models-dropdown" ;
33
- import { useQueryListAllModelsForAllProviders } from " @/hooks/use-query-list-all-models-for-all-providers" ;
34
- import { useQueryMuxingRulesWorkspace } from " ../hooks/use-query-muxing-rules-workspace" ;
30
+ } from ' @untitled-ui/icons-react'
31
+ import { SortableArea } from ' @/components/SortableArea'
32
+ import { WorkspaceModelsDropdown } from ' ./workspace-models-dropdown'
33
+ import { useQueryListAllModelsForAllProviders } from ' @/hooks/use-query-list-all-models-for-all-providers'
34
+ import { useQueryMuxingRulesWorkspace } from ' ../hooks/use-query-muxing-rules-workspace'
35
35
import {
36
36
PreferredMuxRule ,
37
37
useMuxingRulesFormState ,
38
- } from " ../hooks/use-muxing-rules-form-workspace" ;
39
- import { FormButtons } from " @/components/FormButtons" ;
38
+ } from ' ../hooks/use-muxing-rules-form-workspace'
39
+ import { FormButtons } from ' @/components/FormButtons'
40
40
41
41
function MissingProviderBanner ( ) {
42
42
return (
43
43
// TODO needs to update the related ui-kit component that diverges from the design
44
44
< Alert
45
45
variant = "warning"
46
- className = "bg-brand-200 text-primary font-normal dark:bg-[#272472]"
46
+ className = "bg-brand-200 font-normal text-primary dark:bg-[#272472]"
47
47
title = "You must configure at least one provider before selecting your desired model."
48
48
>
49
49
< LinkButton
@@ -53,19 +53,19 @@ function MissingProviderBanner() {
53
53
Configure a provider
54
54
</ LinkButton >
55
55
</ Alert >
56
- ) ;
56
+ )
57
57
}
58
58
59
59
type SortableItemProps = {
60
- index : number ;
61
- rule : PreferredMuxRule ;
62
- models : V1ListAllModelsForAllProvidersResponse ;
63
- isArchived : boolean ;
64
- showRemoveButton : boolean ;
65
- isDefaultRule : boolean ;
66
- setRuleItem : ( rule : PreferredMuxRule ) => void ;
67
- removeRule : ( index : number ) => void ;
68
- } ;
60
+ index : number
61
+ rule : PreferredMuxRule
62
+ models : V1ListAllModelsForAllProvidersResponse
63
+ isArchived : boolean
64
+ showRemoveButton : boolean
65
+ isDefaultRule : boolean
66
+ setRuleItem : ( rule : PreferredMuxRule ) => void
67
+ removeRule : ( index : number ) => void
68
+ }
69
69
70
70
function SortableItem ( {
71
71
rule,
@@ -77,18 +77,17 @@ function SortableItem({
77
77
isArchived,
78
78
isDefaultRule,
79
79
} : SortableItemProps ) {
80
- const placeholder = isDefaultRule ? " Catch All" : " eg file type, file name" ;
80
+ const placeholder = isDefaultRule ? ' Catch All' : ' eg file type, file name'
81
81
return (
82
82
< div className = "flex items-center gap-2" key = { rule . id } >
83
83
< div className = "flex w-full justify-between" >
84
84
< TextField
85
85
aria-labelledby = "filter-by-label-id"
86
- onFocus = { ( event ) => event . preventDefault ( ) }
87
- value = { rule ?. matcher ?? "" }
86
+ value = { rule ?. matcher ?? '' }
88
87
isDisabled = { isArchived || isDefaultRule }
89
88
name = "matcher"
90
89
onChange = { ( matcher ) => {
91
- setRuleItem ( { ...rule , matcher } ) ;
90
+ setRuleItem ( { ...rule , matcher } )
92
91
} }
93
92
>
94
93
< Input placeholder = { placeholder } />
@@ -117,61 +116,61 @@ function SortableItem({
117
116
) }
118
117
</ div >
119
118
</ div >
120
- ) ;
119
+ )
121
120
}
122
121
123
122
export function WorkspaceMuxingModel ( {
124
123
className,
125
124
workspaceName,
126
125
isArchived,
127
126
} : {
128
- className ?: string ;
129
- workspaceName : string ;
130
- isArchived : boolean | undefined ;
127
+ className ?: string
128
+ workspaceName : string
129
+ isArchived : boolean | undefined
131
130
} ) {
132
131
const { data : muxingRules , isPending } =
133
- useQueryMuxingRulesWorkspace ( workspaceName ) ;
132
+ useQueryMuxingRulesWorkspace ( workspaceName )
134
133
const { addRule, setRules, setRuleItem, removeRule, formState } =
135
- useMuxingRulesFormState ( muxingRules ) ;
134
+ useMuxingRulesFormState ( muxingRules )
136
135
const {
137
136
values : { rules } ,
138
- } = formState ;
137
+ } = formState
139
138
140
- const { mutateAsync } = useMutationPreferredModelWorkspace ( ) ;
141
- const { data : providerModels = [ ] } = useQueryListAllModelsForAllProviders ( ) ;
142
- const isModelsEmpty = ! isPending && providerModels . length === 0 ;
143
- const showRemoveButton = rules . length > 1 ;
139
+ const { mutateAsync } = useMutationPreferredModelWorkspace ( )
140
+ const { data : providerModels = [ ] } = useQueryListAllModelsForAllProviders ( )
141
+ const isModelsEmpty = ! isPending && providerModels . length === 0
142
+ const showRemoveButton = rules . length > 1
144
143
145
144
const handleSubmit = ( event : FormEvent ) => {
146
- event . preventDefault ( ) ;
145
+ event . preventDefault ( )
147
146
mutateAsync (
148
147
{
149
148
path : { workspace_name : workspaceName } ,
150
149
body : rules . map ( ( { id, ...rest } ) => {
151
- void id ;
150
+ void id
152
151
153
152
return rest . matcher
154
153
? { ...rest , matcher_type : MuxMatcherType . FILENAME_MATCH }
155
- : { ...rest } ;
154
+ : { ...rest }
156
155
} ) ,
157
156
} ,
158
157
{
159
158
onSuccess : ( ) => {
160
- formState . setInitialValues ( { rules } ) ;
159
+ formState . setInitialValues ( { rules } )
161
160
} ,
162
- } ,
163
- ) ;
164
- } ;
161
+ }
162
+ )
163
+ }
165
164
166
165
if ( isModelsEmpty ) {
167
166
return (
168
- < Card className = { twMerge ( className , " shrink-0" ) } >
167
+ < Card className = { twMerge ( className , ' shrink-0' ) } >
169
168
< CardBody className = "flex flex-col gap-2" >
170
169
< Text className = "text-primary" > Model Muxing</ Text >
171
170
< MissingProviderBanner />
172
171
</ CardBody >
173
172
</ Card >
174
- ) ;
173
+ )
175
174
}
176
175
177
176
return (
@@ -180,11 +179,11 @@ export function WorkspaceMuxingModel({
180
179
validationBehavior = "aria"
181
180
data-testid = "preferred-model"
182
181
>
183
- < Card className = { twMerge ( className , " shrink-0" ) } >
182
+ < Card className = { twMerge ( className , ' shrink-0' ) } >
184
183
< CardBody className = "flex flex-col gap-6" >
185
184
< div className = "flex flex-col justify-start" >
186
185
< Text className = "text-primary" > Model Muxing</ Text >
187
- < Text className = "flex items-center gap-1 text-secondary mb-0 text-balance " >
186
+ < Text className = "mb-0 flex items-center gap-1 text-balance text-secondary " >
188
187
Select the model you would like to use in this workspace. This
189
188
section applies only if you are using the MUX endpoint.
190
189
< Link
@@ -198,7 +197,7 @@ export function WorkspaceMuxingModel({
198
197
</ Text >
199
198
</ div >
200
199
201
- < div className = "flex flex-col gap-2 w-full " >
200
+ < div className = "flex w-full flex-col gap-2" >
202
201
< div className = "flex gap-2" >
203
202
< div className = "w-12" > </ div >
204
203
< div className = "w-full" >
@@ -224,7 +223,7 @@ export function WorkspaceMuxingModel({
224
223
disableDragByIndex = { rules . length - 1 }
225
224
>
226
225
{ ( rule , index ) => {
227
- const isDefaultRule = rules . length - 1 === index ;
226
+ const isDefaultRule = rules . length - 1 === index
228
227
return (
229
228
< SortableItem
230
229
key = { rule . id }
@@ -237,7 +236,7 @@ export function WorkspaceMuxingModel({
237
236
isArchived = { ! ! isArchived }
238
237
isDefaultRule = { isDefaultRule }
239
238
/>
240
- ) ;
239
+ )
241
240
} }
242
241
</ SortableArea >
243
242
</ div >
@@ -265,5 +264,5 @@ export function WorkspaceMuxingModel({
265
264
</ CardFooter >
266
265
</ Card >
267
266
</ Form >
268
- ) ;
267
+ )
269
268
}
0 commit comments