|
1 | 1 | import { useState, useEffect, useRef } from 'react' |
2 | 2 | import { cn } from '@/lib/utils' |
3 | | -import { Loader2, Plus, Trash2, Edit, StarOff, Download, RotateCcw, FileText, ArrowUpCircle, History, ChevronDown } from 'lucide-react' |
| 3 | +import { Loader2, Plus, Trash2, Edit, Download, RotateCcw, FileText, ArrowUpCircle, History, ChevronDown } from 'lucide-react' |
4 | 4 | import { Button } from '@/components/ui/button' |
5 | 5 | import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' |
6 | 6 | import { Label } from '@/components/ui/label' |
7 | 7 | import { Badge } from '@/components/ui/badge' |
8 | 8 | import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' |
| 9 | +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' |
9 | 10 | import { DeleteDialog } from '@/components/ui/delete-dialog' |
10 | 11 | import { CreateConfigDialog } from './CreateConfigDialog' |
11 | 12 | import { OpenCodeConfigEditor } from './OpenCodeConfigEditor' |
@@ -638,76 +639,103 @@ export function OpenCodeConfigManager({ hideHealthStatus = false }: OpenCodeConf |
638 | 639 | value={activeConfigName} |
639 | 640 | onValueChange={(value) => { |
640 | 641 | setActiveConfigName(value) |
641 | | - const next = configs.find((c) => c.name === value) |
642 | | - if (next && !next.isDefault) { |
643 | | - void setDefaultConfig(next) |
644 | | - } |
645 | 642 | }} |
646 | 643 | > |
647 | 644 | <SelectTrigger className="w-full sm:max-w-xs"> |
648 | | - <SelectValue placeholder="Select a configuration..." /> |
| 645 | + <SelectValue placeholder="Select a configuration..."> |
| 646 | + {activeConfig && ( |
| 647 | + <> |
| 648 | + {activeConfig.name} |
| 649 | + {activeConfig.isDefault && ( |
| 650 | + <span className="text-orange-500 dark:text-orange-400"> (Active)</span> |
| 651 | + )} |
| 652 | + {!activeConfig.isValid && ' (Invalid)'} |
| 653 | + </> |
| 654 | + )} |
| 655 | + </SelectValue> |
649 | 656 | </SelectTrigger> |
650 | 657 | <SelectContent> |
651 | 658 | {configs.map((config) => ( |
652 | 659 | <SelectItem key={config.id} value={config.name}> |
653 | 660 | {config.name} |
654 | | - {config.isDefault && ' (Current)'} |
| 661 | + {config.isDefault && ( |
| 662 | + <span className="text-orange-500 dark:text-orange-400"> (Active)</span> |
| 663 | + )} |
655 | 664 | {!config.isValid && ' (Invalid)'} |
656 | 665 | </SelectItem> |
657 | 666 | ))} |
658 | 667 | </SelectContent> |
659 | 668 | </Select> |
660 | 669 |
|
661 | 670 | <div className="flex items-center gap-2"> |
662 | | - {activeConfig?.isDefault && ( |
663 | | - <Badge variant="default" className="text-green-500 bg-green-500/10"> |
664 | | - Current |
665 | | - </Badge> |
666 | | - )} |
667 | 671 | {activeConfig && !activeConfig.isValid && ( |
668 | 672 | <Badge variant="destructive">Invalid Config</Badge> |
669 | 673 | )} |
670 | 674 | </div> |
671 | 675 |
|
672 | | - <div className="flex items-center gap-2 sm:ml-auto"> |
673 | | - <Button |
674 | | - variant="ghost" |
675 | | - size="sm" |
676 | | - disabled={!activeConfig} |
677 | | - onClick={() => activeConfig && downloadConfig(activeConfig)} |
678 | | - > |
679 | | - <Download className="h-4 w-4" /> |
680 | | - </Button> |
681 | | - <Button |
682 | | - variant="ghost" |
683 | | - size="sm" |
684 | | - disabled={!activeConfig} |
685 | | - onClick={() => activeConfig && startEdit(activeConfig)} |
686 | | - > |
687 | | - <Edit className="h-4 w-4" /> |
688 | | - </Button> |
689 | | - <Button |
690 | | - variant="ghost" |
691 | | - size="sm" |
692 | | - disabled={!activeConfig || activeConfig.isDefault || isUpdating} |
693 | | - onClick={() => activeConfig && setDefaultConfig(activeConfig)} |
694 | | - > |
695 | | - <StarOff className="h-4 w-4" /> |
696 | | - </Button> |
697 | | - <Button |
698 | | - variant="ghost" |
699 | | - size="sm" |
700 | | - disabled={!activeConfig} |
701 | | - className="text-red-500 hover:text-red-600" |
702 | | - onClick={() => activeConfig && setDeleteConfirmConfig(activeConfig)} |
703 | | - > |
704 | | - <Trash2 className="h-4 w-4" /> |
705 | | - </Button> |
706 | | - <Button size="sm" onClick={() => setIsCreateDialogOpen(true)}> |
707 | | - <Plus className="h-3 w-3 sm:h-4 sm:w-4 mr-1" /> |
708 | | - <span className="text-xs sm:text-sm">New Config</span> |
709 | | - </Button> |
710 | | - </div> |
| 676 | + <TooltipProvider delayDuration={200}> |
| 677 | + <div className="flex items-center gap-1 sm:gap-1.5 sm:ml-auto"> |
| 678 | + <Tooltip> |
| 679 | + <TooltipTrigger asChild> |
| 680 | + <Button |
| 681 | + variant="ghost" |
| 682 | + size="sm" |
| 683 | + disabled={!activeConfig} |
| 684 | + onClick={() => activeConfig && downloadConfig(activeConfig)} |
| 685 | + > |
| 686 | + <Download className="h-4 w-4" /> |
| 687 | + </Button> |
| 688 | + </TooltipTrigger> |
| 689 | + <TooltipContent side="bottom">Download</TooltipContent> |
| 690 | + </Tooltip> |
| 691 | + <Tooltip> |
| 692 | + <TooltipTrigger asChild> |
| 693 | + <Button |
| 694 | + variant="ghost" |
| 695 | + size="sm" |
| 696 | + disabled={!activeConfig} |
| 697 | + onClick={() => activeConfig && startEdit(activeConfig)} |
| 698 | + > |
| 699 | + <Edit className="h-4 w-4" /> |
| 700 | + </Button> |
| 701 | + </TooltipTrigger> |
| 702 | + <TooltipContent side="bottom">Edit</TooltipContent> |
| 703 | + </Tooltip> |
| 704 | + {!activeConfig?.isDefault && ( |
| 705 | + <Tooltip> |
| 706 | + <TooltipTrigger asChild> |
| 707 | + <Button |
| 708 | + size="sm" |
| 709 | + variant="default" |
| 710 | + disabled={!activeConfig || isUpdating} |
| 711 | + onClick={() => activeConfig && setDefaultConfig(activeConfig)} |
| 712 | + > |
| 713 | + Apply |
| 714 | + </Button> |
| 715 | + </TooltipTrigger> |
| 716 | + <TooltipContent side="bottom">Apply as default</TooltipContent> |
| 717 | + </Tooltip> |
| 718 | + )} |
| 719 | + <Tooltip> |
| 720 | + <TooltipTrigger asChild> |
| 721 | + <Button |
| 722 | + variant="ghost" |
| 723 | + size="sm" |
| 724 | + disabled={!activeConfig} |
| 725 | + className="text-red-500 hover:text-red-600" |
| 726 | + onClick={() => activeConfig && setDeleteConfirmConfig(activeConfig)} |
| 727 | + > |
| 728 | + <Trash2 className="h-4 w-4" /> |
| 729 | + </Button> |
| 730 | + </TooltipTrigger> |
| 731 | + <TooltipContent side="bottom">Delete</TooltipContent> |
| 732 | + </Tooltip> |
| 733 | + <Button size="sm" onClick={() => setIsCreateDialogOpen(true)}> |
| 734 | + <Plus className="h-3 w-3 sm:h-4 sm:w-4 mr-1" /> |
| 735 | + <span className="text-xs sm:text-sm">New Config</span> |
| 736 | + </Button> |
| 737 | + </div> |
| 738 | + </TooltipProvider> |
711 | 739 | </div> |
712 | 740 |
|
713 | 741 | {activeConfig && ( |
@@ -781,7 +809,7 @@ export function OpenCodeConfigManager({ hideHealthStatus = false }: OpenCodeConf |
781 | 809 | <div className="space-y-6"> |
782 | 810 | <div className='px-1'> |
783 | 811 | <Label className="text-sm sm:text-base font-medium">Select Configuration to Edit</Label> |
784 | | - <Select |
| 812 | + <Select |
785 | 813 | onValueChange={(value) => { |
786 | 814 | const config = configs.find(c => c.name === value) |
787 | 815 | setSelectedConfig(config || null) |
|
0 commit comments