Spaces:
Paused
Paused
Commit
·
e26e708
1
Parent(s):
ee41a56
Update components/Settings/Key.tsx
Browse files- components/Settings/Key.tsx +1 -64
components/Settings/Key.tsx
CHANGED
@@ -11,68 +11,5 @@ interface Props {
|
|
11 |
}
|
12 |
|
13 |
export const Key: FC<Props> = ({ apiKey, onApiKeyChange }) => {
|
14 |
-
|
15 |
-
const [isChanging, setIsChanging] = useState(false);
|
16 |
-
const [newKey, setNewKey] = useState(apiKey);
|
17 |
-
const inputRef = useRef<HTMLInputElement>(null);
|
18 |
-
|
19 |
-
const handleEnterDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
20 |
-
if (e.key === 'Enter') {
|
21 |
-
e.preventDefault();
|
22 |
-
handleUpdateKey(newKey);
|
23 |
-
}
|
24 |
-
};
|
25 |
-
|
26 |
-
const handleUpdateKey = (newKey: string) => {
|
27 |
-
onApiKeyChange(newKey.trim());
|
28 |
-
setIsChanging(false);
|
29 |
-
};
|
30 |
-
|
31 |
-
useEffect(() => {
|
32 |
-
if (isChanging) {
|
33 |
-
inputRef.current?.focus();
|
34 |
-
}
|
35 |
-
}, [isChanging]);
|
36 |
-
|
37 |
-
return isChanging ? (
|
38 |
-
<div className="duration:200 flex w-full cursor-pointer items-center rounded-md py-3 px-3 transition-colors hover:bg-gray-500/10">
|
39 |
-
<IconKey size={18} />
|
40 |
-
|
41 |
-
<input
|
42 |
-
ref={inputRef}
|
43 |
-
className="ml-2 h-[20px] flex-1 overflow-hidden overflow-ellipsis border-b border-neutral-400 bg-transparent pr-1 text-[12.5px] leading-3 text-left text-white outline-none focus:border-neutral-100"
|
44 |
-
value={newKey}
|
45 |
-
onChange={(e) => setNewKey(e.target.value)}
|
46 |
-
onKeyDown={handleEnterDown}
|
47 |
-
placeholder={t('API Base Url') || 'Base Url'}
|
48 |
-
/>
|
49 |
-
|
50 |
-
<div className="flex w-[40px]">
|
51 |
-
<IconCheck
|
52 |
-
className="ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100"
|
53 |
-
size={18}
|
54 |
-
onClick={(e) => {
|
55 |
-
e.stopPropagation();
|
56 |
-
handleUpdateKey(newKey);
|
57 |
-
}}
|
58 |
-
/>
|
59 |
-
|
60 |
-
<IconX
|
61 |
-
className="ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100"
|
62 |
-
size={18}
|
63 |
-
onClick={(e) => {
|
64 |
-
e.stopPropagation();
|
65 |
-
setIsChanging(false);
|
66 |
-
setNewKey(apiKey);
|
67 |
-
}}
|
68 |
-
/>
|
69 |
-
</div>
|
70 |
-
</div>
|
71 |
-
) : (
|
72 |
-
<SidebarButton
|
73 |
-
text={t('API Base Url')}
|
74 |
-
icon={<IconKey size={18} />}
|
75 |
-
onClick={() => setIsChanging(true)}
|
76 |
-
/>
|
77 |
-
);
|
78 |
};
|
|
|
11 |
}
|
12 |
|
13 |
export const Key: FC<Props> = ({ apiKey, onApiKeyChange }) => {
|
14 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
};
|