forked from stackblitz-labs/bolt.diy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ali00209/new_bolt1
- Loading branch information
Showing
10 changed files
with
175 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useState } from 'react'; | ||
import { IconButton } from '~/components/ui/IconButton'; | ||
|
||
interface APIKeyManagerProps { | ||
provider: string; | ||
apiKey: string; | ||
setApiKey: (key: string) => void; | ||
} | ||
|
||
export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey, setApiKey }) => { | ||
const [isEditing, setIsEditing] = useState(false); | ||
const [tempKey, setTempKey] = useState(apiKey); | ||
|
||
const handleSave = () => { | ||
setApiKey(tempKey); | ||
setIsEditing(false); | ||
}; | ||
|
||
return ( | ||
<div className="flex items-center gap-2 mt-2 mb-2"> | ||
<span className="text-sm text-bolt-elements-textSecondary">{provider} API Key:</span> | ||
{isEditing ? ( | ||
<> | ||
<input | ||
type="password" | ||
value={tempKey} | ||
onChange={(e) => setTempKey(e.target.value)} | ||
className="flex-1 p-1 text-sm rounded border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus" | ||
/> | ||
<IconButton onClick={handleSave} title="Save API Key"> | ||
<div className="i-ph:check" /> | ||
</IconButton> | ||
<IconButton onClick={() => setIsEditing(false)} title="Cancel"> | ||
<div className="i-ph:x" /> | ||
</IconButton> | ||
</> | ||
) : ( | ||
<> | ||
<span className="flex-1 text-sm text-bolt-elements-textPrimary"> | ||
{apiKey ? '••••••••' : 'Not set'} | ||
</span> | ||
<IconButton onClick={() => setIsEditing(true)} title="Edit API Key"> | ||
<div className="i-ph:pencil-simple" /> | ||
</IconButton> | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.