mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-12 17:35:21 +02:00
refactor: enhance environment selector with service presence checks and alert notifications; update navigation links to include environment context for improved user experience
This commit is contained in:
@@ -24,6 +24,7 @@ import { Textarea } from "@/components/ui/textarea";
|
||||
import { toast } from "sonner";
|
||||
import { ChevronDownIcon, PlusIcon, PencilIcon, TrashIcon } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { AlertBlock } from "@/components/shared/alert-block";
|
||||
|
||||
interface Environment {
|
||||
environmentId: string;
|
||||
@@ -54,6 +55,11 @@ export const AdvancedEnvironmentSelector = ({
|
||||
const [description, setDescription] = useState("");
|
||||
|
||||
// API mutations
|
||||
const { data: environment } = api.environment.one.useQuery({ environmentId: currentEnvironmentId || "" },{
|
||||
enabled: !!currentEnvironmentId,
|
||||
});
|
||||
|
||||
const haveServices = environment && (environment?.mariadb?.length > 0 || environment?.mongo?.length > 0 || environment?.mysql?.length > 0 || environment?.postgres?.length > 0 || environment?.redis?.length > 0 || environment?.applications?.length > 0 || environment?.compose?.length > 0);
|
||||
const createEnvironment = api.environment.create.useMutation();
|
||||
const updateEnvironment = api.environment.update.useMutation();
|
||||
const deleteEnvironment = api.environment.remove.useMutation();
|
||||
@@ -356,6 +362,12 @@ export const AdvancedEnvironmentSelector = ({
|
||||
This action cannot be undone and will also delete all services in this environment.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{haveServices && (
|
||||
<AlertBlock type="warning">
|
||||
This environment have active services, please delete them first.
|
||||
</AlertBlock>
|
||||
)}
|
||||
|
||||
<DialogFooter>
|
||||
<Button
|
||||
@@ -370,7 +382,7 @@ export const AdvancedEnvironmentSelector = ({
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={handleDeleteEnvironment}
|
||||
disabled={deleteEnvironment.isLoading}
|
||||
disabled={deleteEnvironment.isLoading || haveServices}
|
||||
>
|
||||
{deleteEnvironment.isLoading ? "Deleting..." : "Delete"}
|
||||
</Button>
|
||||
|
||||
@@ -216,7 +216,7 @@ export const ShowProjects = () => {
|
||||
className="w-full lg:max-w-md"
|
||||
>
|
||||
<Link
|
||||
href={`/dashboard/project/${project.projectId}`}
|
||||
href={`/dashboard/project/${project.projectId}/environment/${project?.environments?.[0]?.environmentId}`}
|
||||
>
|
||||
<Card className="group relative w-full h-full bg-transparent transition-colors hover:bg-border">
|
||||
{haveServicesWithDomains ? (
|
||||
|
||||
Reference in New Issue
Block a user