Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions apps/dokploy/components/dashboard/project/add-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
LayoutGrid,
List,
Loader2,
PuzzleIcon,
SearchIcon,
} from "lucide-react";
import Link from "next/link";
Expand Down Expand Up @@ -42,9 +41,7 @@ import {
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Expand Down Expand Up @@ -76,11 +73,17 @@ const TEMPLATE_BASE_URL_KEY = "dokploy_template_base_url";
interface Props {
environmentId: string;
baseUrl?: string;
open: boolean;
onOpenChange: (open: boolean) => void;
}

export const AddTemplate = ({ environmentId, baseUrl }: Props) => {
export const AddTemplate = ({
environmentId,
baseUrl,
open,
onOpenChange,
}: Props) => {
const [query, setQuery] = useState("");
const [open, setOpen] = useState(false);
const [viewMode, setViewMode] = useState<"detailed" | "icon">("detailed");
const [selectedTags, setSelectedTags] = useState<string[]>([]);
const [showBookmarksOnly, setShowBookmarksOnly] = useState(false);
Expand Down Expand Up @@ -196,16 +199,7 @@ export const AddTemplate = ({ environmentId, baseUrl }: Props) => {
};

return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger className="w-full">
<DropdownMenuItem
className="w-full cursor-pointer space-x-3"
onSelect={(e) => e.preventDefault()}
>
<PuzzleIcon className="size-4 text-muted-foreground" />
<span>Template</span>
</DropdownMenuItem>
</DialogTrigger>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[90vw] p-0">
<DialogHeader className="sticky top-0 z-10 bg-background p-6 border-b">
<div className="flex flex-col space-y-6">
Expand Down Expand Up @@ -618,7 +612,7 @@ export const AddTemplate = ({ environmentId, baseUrl }: Props) => {
utils.environment.one.invalidate({
environmentId,
});
setOpen(false);
onOpenChange(false);
return `${template.name} template created successfully`;
},
error: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Loader2,
Play,
PlusIcon,
PuzzleIcon,
RefreshCw,
Search,
ServerIcon,
Expand Down Expand Up @@ -90,6 +91,7 @@ import {
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
Expand Down Expand Up @@ -431,6 +433,7 @@ const EnvironmentPage = (
const [openCombobox, setOpenCombobox] = useState(false);
const [selectedServices, setSelectedServices] = useState<string[]>([]);
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const [isTemplateDialogOpen, setIsTemplateDialogOpen] = useState(false);
const [isBulkDeleteDialogOpen, setIsBulkDeleteDialogOpen] = useState(false);
const [deleteVolumes, setDeleteVolumes] = useState(false);
const [selectedServerId, setSelectedServerId] = useState<string>("all");
Expand Down Expand Up @@ -1089,7 +1092,13 @@ const EnvironmentPage = (
projectName={projectData?.name}
environmentId={environmentId}
/>
<AddTemplate environmentId={environmentId} />
<DropdownMenuItem
className="w-full cursor-pointer space-x-3"
onSelect={() => setIsTemplateDialogOpen(true)}
>
<PuzzleIcon className="size-4 text-muted-foreground" />
<span>Template</span>
</DropdownMenuItem>
<AddAiAssistant
projectName={projectData?.name}
environmentId={environmentId}
Expand All @@ -1101,6 +1110,13 @@ const EnvironmentPage = (
</DropdownMenuContent>
</DropdownMenu>
)}
{permissions?.service.create && (
<AddTemplate
environmentId={environmentId}
open={isTemplateDialogOpen}
onOpenChange={setIsTemplateDialogOpen}
/>
)}
</div>
</div>
</div>
Expand Down