|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { useShallow } from 'zustand/react/shallow'; |
3 | 3 |
|
4 | | -import { Avatar, Badge, Box, Button, Chip, CircularProgress, Input, Sheet, Typography } from '@mui/joy'; |
| 4 | +import { Avatar, Badge, Box, Button, Chip, CircularProgress, Sheet, Typography } from '@mui/joy'; |
5 | 5 |
|
| 6 | +import { FormInputKey } from '~/common/components/forms/FormInputKey'; |
6 | 7 | import { TooltipOutlined } from '~/common/components/TooltipOutlined'; |
7 | 8 | import { llmsStoreActions, llmsStoreState, useModelsStore } from '~/common/stores/llms/store-llms'; |
8 | 9 | import { useShallowStabilizer } from '~/common/util/hooks/useShallowObject'; |
@@ -126,12 +127,12 @@ function WizardProviderSetup(props: { |
126 | 127 | const valueName = isLocal ? 'server' : 'API Key'; |
127 | 128 | const { name: vendorName } = providerVendor; |
128 | 129 |
|
| 130 | + // use consistent autoCompleteId pattern: vendor-key for API keys, vendor-host for servers |
| 131 | + const autoCompleteId = isLocal ? `${providerVendor.id}-host` : `${providerVendor.id}-key`; |
| 132 | + |
129 | 133 |
|
130 | 134 | // handlers |
131 | 135 |
|
132 | | - const handleTextChanged = React.useCallback((e: React.ChangeEvent) => { |
133 | | - setLocalValue((e.target as HTMLInputElement).value); |
134 | | - }, []); |
135 | 136 |
|
136 | 137 | const handleSetServiceKeyValue = React.useCallback(async () => { |
137 | 138 |
|
@@ -180,11 +181,12 @@ function WizardProviderSetup(props: { |
180 | 181 | {/*</TooltipOutlined>*/} |
181 | 182 | {/*<TooltipOutlined title='Confirm'>*/} |
182 | 183 | <Button |
183 | | - variant='solid' color='primary' |
| 184 | + color='primary' |
| 185 | + variant='solid' |
184 | 186 | onClick={handleSetServiceKeyValue} |
185 | 187 | // endDecorator={<CheckRoundedIcon />} |
186 | 188 | > |
187 | | - {!serviceKeyValue ? 'Confirm' : !localValue?.trim() ? 'Clear' : 'Update'} |
| 189 | + {!serviceKeyValue ? 'Save' : !localValue?.trim() ? 'Delete' : 'Update'} |
188 | 190 | </Button> |
189 | 191 | {/*</TooltipOutlined>*/} |
190 | 192 | </Box> |
@@ -219,30 +221,20 @@ function WizardProviderSetup(props: { |
219 | 221 | </TooltipOutlined> |
220 | 222 |
|
221 | 223 | {/* Main key inputs */} |
222 | | - <Box sx={{ flex: 1, display: 'grid' }}> |
223 | | - |
224 | | - {/* Line 1 */} |
225 | | - {/*{!!props.serviceLabel && (*/} |
226 | | - {/* <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>*/} |
227 | | - {/* /!*<props.vendorIcon />*!/*/} |
228 | | - {/* <Box>{props.serviceLabel}</Box>*/} |
229 | | - {/* </Box>*/} |
230 | | - {/*)}*/} |
231 | | - |
232 | | - {/* Line 2 */} |
233 | | - <Input |
234 | | - fullWidth |
235 | | - name={`wizard-settings-value-${providerVendor.id}`} |
236 | | - autoComplete='off' |
237 | | - variant='outlined' |
238 | | - value={localValue ?? ''} |
239 | | - onChange={handleTextChanged} |
240 | | - placeholder={`${vendorName} ${valueName}`} |
241 | | - type={isLocal ? undefined : 'password'} |
242 | | - // error={!isValidKey} |
243 | | - // startDecorator={<props.vendorIcon />} |
244 | | - endDecorator={endButtons} |
245 | | - /> |
| 224 | + <Box sx={{ flex: 1, display: 'flex', flexDirection: 'row', gap: 0.5 }}> |
| 225 | + |
| 226 | + <Box sx={{ flex: 1 }}> |
| 227 | + <FormInputKey |
| 228 | + noKey={isLocal} |
| 229 | + autoCompleteId={autoCompleteId} |
| 230 | + value={localValue ?? ''} |
| 231 | + placeholder={`${vendorName} ${valueName}`} |
| 232 | + onChange={setLocalValue} |
| 233 | + required={false} |
| 234 | + /> |
| 235 | + </Box> |
| 236 | + |
| 237 | + {endButtons} |
246 | 238 |
|
247 | 239 | </Box> |
248 | 240 |
|
|
0 commit comments