-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add Copy Variables Between Projects #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,190 @@ | ||||||||||||||||||
| import { useState, useEffect } from 'react'; | ||||||||||||||||||
| import { Modal, Select, Switch, message, Alert, Tag, Space } from 'antd'; | ||||||||||||||||||
| import { Copy } from 'lucide-react'; | ||||||||||||||||||
|
||||||||||||||||||
|
|
||||||||||||||||||
| const { Option } = Select; | ||||||||||||||||||
|
|
||||||||||||||||||
| export default function CopyToProjectModal({ | ||||||||||||||||||
| open, | ||||||||||||||||||
| onClose, | ||||||||||||||||||
| sourceProject, | ||||||||||||||||||
| selectedVarIds, | ||||||||||||||||||
| allProjects, | ||||||||||||||||||
| onSuccess | ||||||||||||||||||
| }) { | ||||||||||||||||||
| const [targetProjectId, setTargetProjectId] = useState(null); | ||||||||||||||||||
| const [overwrite, setOverwrite] = useState(false); | ||||||||||||||||||
| const [loading, setLoading] = useState(false); | ||||||||||||||||||
|
|
||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||
| if (open) { | ||||||||||||||||||
| setTargetProjectId(null); | ||||||||||||||||||
| setOverwrite(false); | ||||||||||||||||||
| } | ||||||||||||||||||
| }, [open]); | ||||||||||||||||||
|
|
||||||||||||||||||
| const handleCopy = async () => { | ||||||||||||||||||
| if (!targetProjectId) { | ||||||||||||||||||
| message.error('Please select a target project'); | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (selectedVarIds.length === 0) { | ||||||||||||||||||
| message.error('No variables selected to copy'); | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| setLoading(true); | ||||||||||||||||||
| try { | ||||||||||||||||||
| const result = await window.electronAPI.envVars.copyToProject({ | ||||||||||||||||||
| sourceProjectId: sourceProject.id, | ||||||||||||||||||
| targetProjectId, | ||||||||||||||||||
| envVarIds: selectedVarIds, | ||||||||||||||||||
| overwrite, | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (result.success) { | ||||||||||||||||||
| const { copied, updated, skipped, errors } = result.data; | ||||||||||||||||||
|
|
||||||||||||||||||
| let messageText = `Copy complete: ${copied} copied`; | ||||||||||||||||||
| if (updated > 0) messageText += `, ${updated} updated`; | ||||||||||||||||||
| if (skipped > 0) messageText += `, ${skipped} skipped`; | ||||||||||||||||||
|
|
||||||||||||||||||
| message.success(messageText); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (errors && errors.length > 0) { | ||||||||||||||||||
| console.error('Copy errors:', errors); | ||||||||||||||||||
| message.warning(`${errors.length} variables had errors`); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| onSuccess(); | ||||||||||||||||||
| onClose(); | ||||||||||||||||||
| } else { | ||||||||||||||||||
| message.error(result.error || 'Failed to copy variables'); | ||||||||||||||||||
| } | ||||||||||||||||||
| } catch (error) { | ||||||||||||||||||
| message.error('Failed to copy: ' + error.message); | ||||||||||||||||||
| } finally { | ||||||||||||||||||
| setLoading(false); | ||||||||||||||||||
| } | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| // Filter out the source project from target options | ||||||||||||||||||
| const availableProjects = allProjects.filter(p => p.id !== sourceProject.id); | ||||||||||||||||||
| const targetProject = availableProjects.find(p => p.id === targetProjectId); | ||||||||||||||||||
|
|
||||||||||||||||||
| return ( | ||||||||||||||||||
| <Modal | ||||||||||||||||||
| title={ | ||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||
| <Copy className="w-5 h-5" /> | ||||||||||||||||||
| <span>Copy Variables to Another Project</span> | ||||||||||||||||||
| </div> | ||||||||||||||||||
|
Comment on lines
+79
to
+82
|
||||||||||||||||||
| <div className="flex items-center gap-2"> | |
| <Copy className="w-5 h-5" /> | |
| <span>Copy Variables to Another Project</span> | |
| </div> | |
| <Space align="center"> | |
| <Copy style={{ width: 20, height: 20 }} /> | |
| <span>Copy Variables to Another Project</span> | |
| </Space> |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Tailwind CSS classes alongside Ant Design components. This project appears to use Ant Design's styling system, so consider using Ant Design's Space component and theme tokens instead of Tailwind classes for consistency.
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Tailwind CSS classes alongside Ant Design components. This project appears to use Ant Design's styling system, so consider using Ant Design's Space component and theme tokens instead of Tailwind classes for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary decrypt/encrypt cycle when using the same master key. Since the comment acknowledges keys are the same, you can directly copy the encryptedValue without decryption/re-encryption to improve performance.