mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-11 14:35:17 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
@@ -22,12 +22,17 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { ChevronDownIcon, PlusIcon, PencilIcon, TrashIcon, CopyIcon } from "lucide-react";
|
import {
|
||||||
|
ChevronDownIcon,
|
||||||
|
PlusIcon,
|
||||||
|
PencilIcon,
|
||||||
|
TrashIcon,
|
||||||
|
CopyIcon,
|
||||||
|
} from "lucide-react";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { AlertBlock } from "@/components/shared/alert-block";
|
import { AlertBlock } from "@/components/shared/alert-block";
|
||||||
import { findEnvironmentById } from "@dokploy/server";
|
import { findEnvironmentById } from "@dokploy/server";
|
||||||
|
|
||||||
|
|
||||||
type Environment = Awaited<ReturnType<typeof findEnvironmentById>>;
|
type Environment = Awaited<ReturnType<typeof findEnvironmentById>>;
|
||||||
interface AdvancedEnvironmentSelectorProps {
|
interface AdvancedEnvironmentSelectorProps {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@@ -42,11 +47,15 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
|
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
|
||||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
||||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
||||||
const [selectedEnvironment, setSelectedEnvironment] = useState<Environment | null>(null);
|
const [selectedEnvironment, setSelectedEnvironment] =
|
||||||
|
useState<Environment | null>(null);
|
||||||
|
|
||||||
const { data: project } = api.project.one.useQuery({ projectId },{
|
const { data: project } = api.project.one.useQuery(
|
||||||
enabled: !!projectId,
|
{ projectId },
|
||||||
});
|
{
|
||||||
|
enabled: !!projectId,
|
||||||
|
},
|
||||||
|
);
|
||||||
const environments = project?.environments || [];
|
const environments = project?.environments || [];
|
||||||
|
|
||||||
// Form states
|
// Form states
|
||||||
@@ -54,20 +63,22 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
|
|
||||||
// API mutations
|
// API mutations
|
||||||
const { data: environment } = api.environment.one.useQuery({ environmentId: currentEnvironmentId || "" },{
|
const { data: environment } = api.environment.one.useQuery(
|
||||||
enabled: !!currentEnvironmentId,
|
{ environmentId: currentEnvironmentId || "" },
|
||||||
});
|
{
|
||||||
|
enabled: !!currentEnvironmentId,
|
||||||
|
},
|
||||||
const haveServices = selectedEnvironment && (
|
|
||||||
(selectedEnvironment?.mariadb?.length || 0) > 0 ||
|
|
||||||
(selectedEnvironment?.mongo?.length || 0) > 0 ||
|
|
||||||
(selectedEnvironment?.mysql?.length || 0) > 0 ||
|
|
||||||
(selectedEnvironment?.postgres?.length || 0) > 0 ||
|
|
||||||
(selectedEnvironment?.redis?.length || 0) > 0 ||
|
|
||||||
(selectedEnvironment?.applications?.length || 0) > 0 ||
|
|
||||||
(selectedEnvironment?.compose?.length || 0) > 0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const haveServices =
|
||||||
|
selectedEnvironment &&
|
||||||
|
((selectedEnvironment?.mariadb?.length || 0) > 0 ||
|
||||||
|
(selectedEnvironment?.mongo?.length || 0) > 0 ||
|
||||||
|
(selectedEnvironment?.mysql?.length || 0) > 0 ||
|
||||||
|
(selectedEnvironment?.postgres?.length || 0) > 0 ||
|
||||||
|
(selectedEnvironment?.redis?.length || 0) > 0 ||
|
||||||
|
(selectedEnvironment?.applications?.length || 0) > 0 ||
|
||||||
|
(selectedEnvironment?.compose?.length || 0) > 0);
|
||||||
const createEnvironment = api.environment.create.useMutation();
|
const createEnvironment = api.environment.create.useMutation();
|
||||||
const updateEnvironment = api.environment.update.useMutation();
|
const updateEnvironment = api.environment.update.useMutation();
|
||||||
const deleteEnvironment = api.environment.remove.useMutation();
|
const deleteEnvironment = api.environment.remove.useMutation();
|
||||||
@@ -130,9 +141,13 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
|
|
||||||
// Redirect to production if we deleted the current environment
|
// Redirect to production if we deleted the current environment
|
||||||
if (selectedEnvironment.environmentId === currentEnvironmentId) {
|
if (selectedEnvironment.environmentId === currentEnvironmentId) {
|
||||||
const productionEnv = environments.find(env => env.name === "production");
|
const productionEnv = environments.find(
|
||||||
|
(env) => env.name === "production",
|
||||||
|
);
|
||||||
if (productionEnv) {
|
if (productionEnv) {
|
||||||
router.push(`/dashboard/project/${projectId}/environment/${productionEnv.environmentId}`);
|
router.push(
|
||||||
|
`/dashboard/project/${projectId}/environment/${productionEnv.environmentId}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -152,7 +167,9 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
utils.project.one.invalidate({ projectId });
|
utils.project.one.invalidate({ projectId });
|
||||||
|
|
||||||
// Navigate to the new duplicated environment
|
// Navigate to the new duplicated environment
|
||||||
router.push(`/dashboard/project/${projectId}/environment/${result.environmentId}`);
|
router.push(
|
||||||
|
`/dashboard/project/${projectId}/environment/${result.environmentId}`,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Failed to duplicate environment");
|
toast.error("Failed to duplicate environment");
|
||||||
}
|
}
|
||||||
@@ -170,7 +187,9 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
setIsDeleteDialogOpen(true);
|
setIsDeleteDialogOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentEnv = environments.find(env => env.environmentId === currentEnvironmentId);
|
const currentEnv = environments.find(
|
||||||
|
(env) => env.environmentId === currentEnvironmentId,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -179,11 +198,7 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
<Button variant="outline" className="min-w-[200px] justify-between">
|
<Button variant="outline" className="min-w-[200px] justify-between">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span>{currentEnv?.name || "Select Environment"}</span>
|
<span>{currentEnv?.name || "Select Environment"}</span>
|
||||||
{currentEnv?.name === "production" && (
|
{currentEnv?.name === "production" && <Badge>Prod</Badge>}
|
||||||
<Badge >
|
|
||||||
Prod
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<ChevronDownIcon className="h-4 w-4" />
|
<ChevronDownIcon className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -197,17 +212,15 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="flex-1 cursor-pointer"
|
className="flex-1 cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(`/dashboard/project/${projectId}/environment/${environment.environmentId}`);
|
router.push(
|
||||||
|
`/dashboard/project/${projectId}/environment/${environment.environmentId}`,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-between w-full">
|
<div className="flex items-center justify-between w-full">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span>{environment.name}</span>
|
<span>{environment.name}</span>
|
||||||
{environment.name === "production" && (
|
{environment.name === "production" && <Badge>Prod</Badge>}
|
||||||
<Badge >
|
|
||||||
Prod
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{environment.environmentId === currentEnvironmentId && (
|
{environment.environmentId === currentEnvironmentId && (
|
||||||
<div className="w-2 h-2 bg-blue-500 rounded-full" />
|
<div className="w-2 h-2 bg-blue-500 rounded-full" />
|
||||||
@@ -377,15 +390,16 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Delete Environment</DialogTitle>
|
<DialogTitle>Delete Environment</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Are you sure you want to delete the environment "{selectedEnvironment?.name}"?
|
Are you sure you want to delete the environment "
|
||||||
This action cannot be undone and will also delete all services in this environment.
|
{selectedEnvironment?.name}"? This action cannot be undone and
|
||||||
|
will also delete all services in this environment.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
{haveServices && (
|
{haveServices && (
|
||||||
<AlertBlock type="warning">
|
<AlertBlock type="warning">
|
||||||
This environment have active services, please delete them first.
|
This environment have active services, please delete them first.
|
||||||
</AlertBlock>
|
</AlertBlock>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
@@ -401,7 +415,11 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
<Button
|
<Button
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onClick={handleDeleteEnvironment}
|
onClick={handleDeleteEnvironment}
|
||||||
disabled={deleteEnvironment.isLoading || haveServices || !selectedEnvironment}
|
disabled={
|
||||||
|
deleteEnvironment.isLoading ||
|
||||||
|
haveServices ||
|
||||||
|
!selectedEnvironment
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{deleteEnvironment.isLoading ? "Deleting..." : "Delete"}
|
{deleteEnvironment.isLoading ? "Deleting..." : "Delete"}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ export const TemplateGenerator = ({ environmentId }: Props) => {
|
|||||||
useState<TemplateInfo>(defaultTemplateInfo);
|
useState<TemplateInfo>(defaultTemplateInfo);
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
|
|
||||||
|
|
||||||
const haveAtleasOneProviderEnabled = aiSettings?.some(
|
const haveAtleasOneProviderEnabled = aiSettings?.some(
|
||||||
(ai) => ai.isEnabled === true,
|
(ai) => ai.isEnabled === true,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -57,17 +57,20 @@ export const DuplicateProject = ({
|
|||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [duplicateType, setDuplicateType] = useState("new-project"); // "new-project" or "existing-environment"
|
const [duplicateType, setDuplicateType] = useState("new-project"); // "new-project" or "existing-environment"
|
||||||
const [selectedTargetProject, setSelectedTargetProject] = useState<string>("");
|
const [selectedTargetProject, setSelectedTargetProject] =
|
||||||
const [selectedTargetEnvironment, setSelectedTargetEnvironment] = useState<string>("");
|
useState<string>("");
|
||||||
|
const [selectedTargetEnvironment, setSelectedTargetEnvironment] =
|
||||||
|
useState<string>("");
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// Queries for project and environment selection
|
// Queries for project and environment selection
|
||||||
const { data: allProjects } = api.project.all.useQuery();
|
const { data: allProjects } = api.project.all.useQuery();
|
||||||
const { data: selectedProjectEnvironments } = api.environment.byProjectId.useQuery(
|
const { data: selectedProjectEnvironments } =
|
||||||
{ projectId: selectedTargetProject },
|
api.environment.byProjectId.useQuery(
|
||||||
{ enabled: !!selectedTargetProject }
|
{ projectId: selectedTargetProject },
|
||||||
);
|
{ enabled: !!selectedTargetProject },
|
||||||
|
);
|
||||||
|
|
||||||
const selectedServices = services.filter((service) =>
|
const selectedServices = services.filter((service) =>
|
||||||
selectedServiceIds.includes(service.id),
|
selectedServiceIds.includes(service.id),
|
||||||
@@ -84,7 +87,9 @@ export const DuplicateProject = ({
|
|||||||
);
|
);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
if (duplicateType === "new-project") {
|
if (duplicateType === "new-project") {
|
||||||
router.push(`/dashboard/project/${newProject?.projectId}/environment/${newProject?.environmentId}`);
|
router.push(
|
||||||
|
`/dashboard/project/${newProject?.projectId}/environment/${newProject?.environmentId}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -172,8 +177,13 @@ export const DuplicateProject = ({
|
|||||||
<Label htmlFor="new-project">New project</Label>
|
<Label htmlFor="new-project">New project</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<RadioGroupItem value="existing-environment" id="existing-environment" />
|
<RadioGroupItem
|
||||||
<Label htmlFor="existing-environment">Existing environment</Label>
|
value="existing-environment"
|
||||||
|
id="existing-environment"
|
||||||
|
/>
|
||||||
|
<Label htmlFor="existing-environment">
|
||||||
|
Existing environment
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</div>
|
</div>
|
||||||
@@ -204,7 +214,8 @@ export const DuplicateProject = ({
|
|||||||
|
|
||||||
{duplicateType === "existing-environment" && (
|
{duplicateType === "existing-environment" && (
|
||||||
<>
|
<>
|
||||||
{allProjects?.filter((p) => p.projectId !== environmentId).length === 0 ? (
|
{allProjects?.filter((p) => p.projectId !== environmentId)
|
||||||
|
.length === 0 ? (
|
||||||
<div className="flex flex-col items-center justify-center gap-2 py-4 text-center">
|
<div className="flex flex-col items-center justify-center gap-2 py-4 text-center">
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
No other projects available. Create a new project first.
|
No other projects available. Create a new project first.
|
||||||
@@ -296,7 +307,8 @@ export const DuplicateProject = ({
|
|||||||
disabled={
|
disabled={
|
||||||
isLoading ||
|
isLoading ||
|
||||||
(duplicateType === "new-project" && !name) ||
|
(duplicateType === "new-project" && !name) ||
|
||||||
(duplicateType === "existing-environment" && (!selectedTargetProject || !selectedTargetEnvironment))
|
(duplicateType === "existing-environment" &&
|
||||||
|
(!selectedTargetProject || !selectedTargetEnvironment))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
|
|||||||
@@ -187,28 +187,40 @@ export const ShowProjects = () => {
|
|||||||
)}
|
)}
|
||||||
<div className="w-full grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5 flex-wrap gap-5">
|
<div className="w-full grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5 flex-wrap gap-5">
|
||||||
{filteredProjects?.map((project) => {
|
{filteredProjects?.map((project) => {
|
||||||
const emptyServices =
|
const emptyServices = project?.environments
|
||||||
project?.environments.map((env) => env.applications.length === 0 &&
|
.map(
|
||||||
env.mariadb.length === 0 &&
|
(env) =>
|
||||||
env.mongo.length === 0 &&
|
env.applications.length === 0 &&
|
||||||
env.mysql.length === 0 &&
|
env.mariadb.length === 0 &&
|
||||||
env.postgres.length === 0 &&
|
env.mongo.length === 0 &&
|
||||||
env.redis.length === 0 &&
|
env.mysql.length === 0 &&
|
||||||
env.applications.length === 0 &&
|
env.postgres.length === 0 &&
|
||||||
env.compose.length === 0).every(Boolean);
|
env.redis.length === 0 &&
|
||||||
|
env.applications.length === 0 &&
|
||||||
|
env.compose.length === 0,
|
||||||
|
)
|
||||||
|
.every(Boolean);
|
||||||
|
|
||||||
const totalServices =
|
const totalServices = project?.environments
|
||||||
project?.environments.map((env) => env.mariadb.length +
|
.map(
|
||||||
env.mongo.length +
|
(env) =>
|
||||||
env.mysql.length +
|
env.mariadb.length +
|
||||||
env.postgres.length +
|
env.mongo.length +
|
||||||
env.redis.length +
|
env.mysql.length +
|
||||||
env.applications.length +
|
env.postgres.length +
|
||||||
env.compose.length ).reduce((acc, curr) => acc + curr, 0);
|
env.redis.length +
|
||||||
|
env.applications.length +
|
||||||
|
env.compose.length,
|
||||||
|
)
|
||||||
|
.reduce((acc, curr) => acc + curr, 0);
|
||||||
|
|
||||||
const haveServicesWithDomains =
|
const haveServicesWithDomains = project?.environments
|
||||||
project?.environments.map((env) => env.applications.length > 0 ||
|
.map(
|
||||||
env.compose.length > 0).some(Boolean);
|
(env) =>
|
||||||
|
env.applications.length > 0 ||
|
||||||
|
env.compose.length > 0,
|
||||||
|
)
|
||||||
|
.some(Boolean);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -234,7 +246,9 @@ export const ShowProjects = () => {
|
|||||||
className="w-[200px] space-y-2 overflow-y-auto max-h-[400px]"
|
className="w-[200px] space-y-2 overflow-y-auto max-h-[400px]"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
{project.environments.some((env) => env.applications.length > 0) && (
|
{project.environments.some(
|
||||||
|
(env) => env.applications.length > 0,
|
||||||
|
) && (
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuLabel>
|
<DropdownMenuLabel>
|
||||||
Applications
|
Applications
|
||||||
@@ -247,7 +261,9 @@ export const ShowProjects = () => {
|
|||||||
<DropdownMenuLabel className="font-normal capitalize text-xs flex items-center justify-between">
|
<DropdownMenuLabel className="font-normal capitalize text-xs flex items-center justify-between">
|
||||||
{app.name}
|
{app.name}
|
||||||
<StatusTooltip
|
<StatusTooltip
|
||||||
status={app.applicationStatus}
|
status={
|
||||||
|
app.applicationStatus
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</DropdownMenuLabel>
|
</DropdownMenuLabel>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
@@ -270,7 +286,7 @@ export const ShowProjects = () => {
|
|||||||
))}
|
))}
|
||||||
</DropdownMenuGroup>
|
</DropdownMenuGroup>
|
||||||
</div>
|
</div>
|
||||||
))
|
)),
|
||||||
)}
|
)}
|
||||||
</DropdownMenuGroup>
|
</DropdownMenuGroup>
|
||||||
)}
|
)}
|
||||||
@@ -445,7 +461,7 @@ export const ShowProjects = () => {
|
|||||||
<DateTooltip date={project.createdAt}>
|
<DateTooltip date={project.createdAt}>
|
||||||
Created
|
Created
|
||||||
</DateTooltip>
|
</DateTooltip>
|
||||||
<span>
|
<span>
|
||||||
{totalServices}{" "}
|
{totalServices}{" "}
|
||||||
{totalServices === 1
|
{totalServices === 1
|
||||||
? "service"
|
? "service"
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ export const AddUserPermissions = ({ userId }: Props) => {
|
|||||||
<FormLabel className="text-base">Projects</FormLabel>
|
<FormLabel className="text-base">Projects</FormLabel>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
Select the Projects that the user can access
|
Select the Projects that the user can access
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
</div>
|
</div>
|
||||||
{projects?.length === 0 && (
|
{projects?.length === 0 && (
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
|
|||||||
@@ -159,17 +159,22 @@ const Project = (
|
|||||||
// Redirigir automáticamente al ambiente de producción por defecto
|
// Redirigir automáticamente al ambiente de producción por defecto
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.environments && data.environments.length > 0) {
|
if (data?.environments && data.environments.length > 0) {
|
||||||
const productionEnv = data.environments.find(env => env.name === "production");
|
const productionEnv = data.environments.find(
|
||||||
|
(env) => env.name === "production",
|
||||||
|
);
|
||||||
const defaultEnv = productionEnv || data.environments[0];
|
const defaultEnv = productionEnv || data.environments[0];
|
||||||
|
|
||||||
// Redirigir al ambiente por defecto
|
// Redirigir al ambiente por defecto
|
||||||
if (defaultEnv) {
|
if (defaultEnv) {
|
||||||
router.push(`/dashboard/project/${projectId}/environment/${defaultEnv.environmentId}`);
|
router.push(
|
||||||
|
`/dashboard/project/${projectId}/environment/${defaultEnv.environmentId}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [data?.environments, projectId, router]);
|
}, [data?.environments, projectId, router]);
|
||||||
|
|
||||||
const emptyEnvironments = !data?.environments || data.environments.length === 0;
|
const emptyEnvironments =
|
||||||
|
!data?.environments || data.environments.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -198,7 +203,6 @@ const Project = (
|
|||||||
<ProjectEnvironment projectId={projectId}>
|
<ProjectEnvironment projectId={projectId}>
|
||||||
<Button variant="outline">Project Environment</Button>
|
<Button variant="outline">Project Environment</Button>
|
||||||
</ProjectEnvironment>
|
</ProjectEnvironment>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -212,7 +216,8 @@ const Project = (
|
|||||||
<div className="flex h-[70vh] w-full flex-col items-center justify-center">
|
<div className="flex h-[70vh] w-full flex-col items-center justify-center">
|
||||||
<FolderInput className="size-8 self-center text-muted-foreground" />
|
<FolderInput className="size-8 self-center text-muted-foreground" />
|
||||||
<span className="text-center font-medium text-muted-foreground">
|
<span className="text-center font-medium text-muted-foreground">
|
||||||
No environments created yet. Click on Environments to create one.
|
No environments created yet. Click on Environments to create
|
||||||
|
one.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -284,10 +284,11 @@ const EnvironmentPage = (
|
|||||||
const [selectedTargetEnvironment, setSelectedTargetEnvironment] =
|
const [selectedTargetEnvironment, setSelectedTargetEnvironment] =
|
||||||
useState<string>("");
|
useState<string>("");
|
||||||
|
|
||||||
const { data: selectedProjectEnvironments } = api.environment.byProjectId.useQuery(
|
const { data: selectedProjectEnvironments } =
|
||||||
{ projectId: selectedTargetProject },
|
api.environment.byProjectId.useQuery(
|
||||||
{ enabled: !!selectedTargetProject }
|
{ projectId: selectedTargetProject },
|
||||||
);
|
{ enabled: !!selectedTargetProject },
|
||||||
|
);
|
||||||
|
|
||||||
const emptyServices =
|
const emptyServices =
|
||||||
!currentEnvironment ||
|
!currentEnvironment ||
|
||||||
@@ -774,9 +775,7 @@ const EnvironmentPage = (
|
|||||||
<FolderInput className="size-6 text-muted-foreground self-center" />
|
<FolderInput className="size-6 text-muted-foreground self-center" />
|
||||||
{currentEnvironment.name}
|
{currentEnvironment.name}
|
||||||
{currentEnvironment.name === "production" && (
|
{currentEnvironment.name === "production" && (
|
||||||
<Badge >
|
<Badge>Production</Badge>
|
||||||
Production
|
|
||||||
</Badge>
|
|
||||||
)}
|
)}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
@@ -819,9 +818,7 @@ const EnvironmentPage = (
|
|||||||
projectName={projectData?.name}
|
projectName={projectData?.name}
|
||||||
environmentId={environmentId}
|
environmentId={environmentId}
|
||||||
/>
|
/>
|
||||||
<AddTemplate
|
<AddTemplate environmentId={environmentId} />
|
||||||
environmentId={environmentId}
|
|
||||||
/>
|
|
||||||
<AddAiAssistant
|
<AddAiAssistant
|
||||||
projectName={projectData?.name}
|
projectName={projectData?.name}
|
||||||
environmentId={environmentId}
|
environmentId={environmentId}
|
||||||
@@ -980,12 +977,14 @@ const EnvironmentPage = (
|
|||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Move Services</DialogTitle>
|
<DialogTitle>Move Services</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Select the target project and environment to move{" "}
|
Select the target project and environment to
|
||||||
{selectedServices.length} services
|
move {selectedServices.length} services
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{allProjects?.filter((p) => p.projectId !== projectId).length === 0 ? (
|
{allProjects?.filter(
|
||||||
|
(p) => p.projectId !== projectId,
|
||||||
|
).length === 0 ? (
|
||||||
<div className="flex flex-col items-center justify-center gap-2 py-4">
|
<div className="flex flex-col items-center justify-center gap-2 py-4">
|
||||||
<FolderInput className="h-8 w-8 text-muted-foreground" />
|
<FolderInput className="h-8 w-8 text-muted-foreground" />
|
||||||
<p className="text-sm text-muted-foreground text-center">
|
<p className="text-sm text-muted-foreground text-center">
|
||||||
@@ -997,7 +996,9 @@ const EnvironmentPage = (
|
|||||||
<>
|
<>
|
||||||
{/* Step 1: Select Project */}
|
{/* Step 1: Select Project */}
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<label className="text-sm font-medium">Target Project</label>
|
<label className="text-sm font-medium">
|
||||||
|
Target Project
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={selectedTargetProject}
|
value={selectedTargetProject}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
@@ -1010,7 +1011,9 @@ const EnvironmentPage = (
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{allProjects
|
{allProjects
|
||||||
?.filter((p) => p.projectId !== projectId)
|
?.filter(
|
||||||
|
(p) => p.projectId !== projectId,
|
||||||
|
)
|
||||||
.map((project) => (
|
.map((project) => (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
key={project.projectId}
|
key={project.projectId}
|
||||||
@@ -1026,23 +1029,29 @@ const EnvironmentPage = (
|
|||||||
{/* Step 2: Select Environment (only show if project is selected) */}
|
{/* Step 2: Select Environment (only show if project is selected) */}
|
||||||
{selectedTargetProject && (
|
{selectedTargetProject && (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<label className="text-sm font-medium">Target Environment</label>
|
<label className="text-sm font-medium">
|
||||||
|
Target Environment
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={selectedTargetEnvironment}
|
value={selectedTargetEnvironment}
|
||||||
onValueChange={setSelectedTargetEnvironment}
|
onValueChange={
|
||||||
|
setSelectedTargetEnvironment
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select target environment" />
|
<SelectValue placeholder="Select target environment" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{selectedProjectEnvironments?.map((env) => (
|
{selectedProjectEnvironments?.map(
|
||||||
<SelectItem
|
(env) => (
|
||||||
key={env.environmentId}
|
<SelectItem
|
||||||
value={env.environmentId}
|
key={env.environmentId}
|
||||||
>
|
value={env.environmentId}
|
||||||
{env.name}
|
>
|
||||||
</SelectItem>
|
{env.name}
|
||||||
))}
|
</SelectItem>
|
||||||
|
),
|
||||||
|
)}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
@@ -1065,7 +1074,9 @@ const EnvironmentPage = (
|
|||||||
onClick={handleBulkMove}
|
onClick={handleBulkMove}
|
||||||
isLoading={isBulkActionLoading}
|
isLoading={isBulkActionLoading}
|
||||||
disabled={
|
disabled={
|
||||||
allProjects?.filter((p) => p.projectId !== projectId).length === 0 ||
|
allProjects?.filter(
|
||||||
|
(p) => p.projectId !== projectId,
|
||||||
|
).length === 0 ||
|
||||||
!selectedTargetProject ||
|
!selectedTargetProject ||
|
||||||
!selectedTargetEnvironment
|
!selectedTargetEnvironment
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -84,7 +84,8 @@ const Mariadb = (
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Head>
|
<Head>
|
||||||
<title>
|
<title>
|
||||||
Database: {data?.name} - {data?.environment?.project?.name} | Dokploy
|
Database: {data?.name} - {data?.environment?.project?.name} |
|
||||||
|
Dokploy
|
||||||
</title>
|
</title>
|
||||||
</Head>
|
</Head>
|
||||||
<Card className="h-full bg-sidebar p-2.5 rounded-xl w-full">
|
<Card className="h-full bg-sidebar p-2.5 rounded-xl w-full">
|
||||||
@@ -303,7 +304,11 @@ Mariadb.getLayout = (page: ReactElement) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getServerSideProps(
|
export async function getServerSideProps(
|
||||||
ctx: GetServerSidePropsContext<{ mariadbId: string; activeTab: TabState; environmentId: string }>,
|
ctx: GetServerSidePropsContext<{
|
||||||
|
mariadbId: string;
|
||||||
|
activeTab: TabState;
|
||||||
|
environmentId: string;
|
||||||
|
}>,
|
||||||
) {
|
) {
|
||||||
const { query, params, req, res } = ctx;
|
const { query, params, req, res } = ctx;
|
||||||
const activeTab = query.tab;
|
const activeTab = query.tab;
|
||||||
|
|||||||
+5
-1
@@ -305,7 +305,11 @@ Mongo.getLayout = (page: ReactElement) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getServerSideProps(
|
export async function getServerSideProps(
|
||||||
ctx: GetServerSidePropsContext<{ mongoId: string; activeTab: TabState; environmentId: string }>,
|
ctx: GetServerSidePropsContext<{
|
||||||
|
mongoId: string;
|
||||||
|
activeTab: TabState;
|
||||||
|
environmentId: string;
|
||||||
|
}>,
|
||||||
) {
|
) {
|
||||||
const { query, params, req, res } = ctx;
|
const { query, params, req, res } = ctx;
|
||||||
const activeTab = query.tab;
|
const activeTab = query.tab;
|
||||||
|
|||||||
+7
-2
@@ -83,7 +83,8 @@ const MySql = (
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Head>
|
<Head>
|
||||||
<title>
|
<title>
|
||||||
Database: {data?.name} - {data?.environment?.project?.name} | Dokploy
|
Database: {data?.name} - {data?.environment?.project?.name} |
|
||||||
|
Dokploy
|
||||||
</title>
|
</title>
|
||||||
</Head>
|
</Head>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
@@ -289,7 +290,11 @@ MySql.getLayout = (page: ReactElement) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getServerSideProps(
|
export async function getServerSideProps(
|
||||||
ctx: GetServerSidePropsContext<{ mysqlId: string; activeTab: TabState; environmentId: string }>,
|
ctx: GetServerSidePropsContext<{
|
||||||
|
mysqlId: string;
|
||||||
|
activeTab: TabState;
|
||||||
|
environmentId: string;
|
||||||
|
}>,
|
||||||
) {
|
) {
|
||||||
const { query, params, req, res } = ctx;
|
const { query, params, req, res } = ctx;
|
||||||
const activeTab = query.tab;
|
const activeTab = query.tab;
|
||||||
|
|||||||
+141
-188
@@ -73,8 +73,7 @@ const Postgresql = (
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: data?.environment?.name || "",
|
name: data?.environment?.name || "",
|
||||||
href:
|
href: `/dashboard/project/${projectId}/environment/${environmentId}`,
|
||||||
`/dashboard/project/${projectId}/environment/${environmentId}`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: data?.name || "",
|
name: data?.name || "",
|
||||||
@@ -83,9 +82,7 @@ const Postgresql = (
|
|||||||
/>
|
/>
|
||||||
<Head>
|
<Head>
|
||||||
<title>
|
<title>
|
||||||
Database: {data?.name} - {data?.environment?.project?.name}
|
Database: {data?.name} - {data?.environment?.project?.name} | Dokploy
|
||||||
{" "}
|
|
||||||
| Dokploy
|
|
||||||
</title>
|
</title>
|
||||||
</Head>
|
</Head>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
@@ -96,9 +93,7 @@ const Postgresql = (
|
|||||||
<CardTitle className="text-xl flex flex-row gap-2">
|
<CardTitle className="text-xl flex flex-row gap-2">
|
||||||
<div className="relative flex flex-row gap-4">
|
<div className="relative flex flex-row gap-4">
|
||||||
<div className="absolute -right-1 -top-2">
|
<div className="absolute -right-1 -top-2">
|
||||||
<StatusTooltip
|
<StatusTooltip status={data?.applicationStatus} />
|
||||||
status={data?.applicationStatus}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PostgresqlIcon className="h-6 w-6 text-muted-foreground" />
|
<PostgresqlIcon className="h-6 w-6 text-muted-foreground" />
|
||||||
@@ -106,9 +101,7 @@ const Postgresql = (
|
|||||||
{data?.name}
|
{data?.name}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
{data?.description && (
|
{data?.description && (
|
||||||
<CardDescription>
|
<CardDescription>{data?.description}</CardDescription>
|
||||||
{data?.description}
|
|
||||||
</CardDescription>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
@@ -118,17 +111,17 @@ const Postgresql = (
|
|||||||
<div className="flex flex-col h-fit w-fit gap-2">
|
<div className="flex flex-col h-fit w-fit gap-2">
|
||||||
<div className="flex flex-row h-fit w-fit gap-2">
|
<div className="flex flex-row h-fit w-fit gap-2">
|
||||||
<Badge
|
<Badge
|
||||||
variant={!data?.serverId
|
variant={
|
||||||
? "default"
|
!data?.serverId
|
||||||
: data?.server?.serverStatus ===
|
? "default"
|
||||||
"active"
|
: data?.server?.serverStatus === "active"
|
||||||
? "default"
|
? "default"
|
||||||
: "destructive"}
|
: "destructive"
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{data?.server?.name || "Dokploy Server"}
|
{data?.server?.name || "Dokploy Server"}
|
||||||
</Badge>
|
</Badge>
|
||||||
{data?.server?.serverStatus ===
|
{data?.server?.serverStatus === "inactive" && (
|
||||||
"inactive" && (
|
|
||||||
<TooltipProvider delayDuration={0}>
|
<TooltipProvider delayDuration={0}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
@@ -142,11 +135,9 @@ const Postgresql = (
|
|||||||
side="top"
|
side="top"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
You cannot, deploy this
|
You cannot, deploy this application because the
|
||||||
application because the
|
server is inactive, please upgrade your plan to add
|
||||||
server is inactive,
|
more servers.
|
||||||
please upgrade your plan
|
|
||||||
to add more servers.
|
|
||||||
</span>
|
</span>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -156,178 +147,138 @@ const Postgresql = (
|
|||||||
|
|
||||||
<div className="flex flex-row gap-2 justify-end">
|
<div className="flex flex-row gap-2 justify-end">
|
||||||
<UpdatePostgres postgresId={postgresId} />
|
<UpdatePostgres postgresId={postgresId} />
|
||||||
{(auth?.role === "owner" ||
|
{(auth?.role === "owner" || auth?.canDeleteServices) && (
|
||||||
auth?.canDeleteServices) && (
|
<DeleteService id={postgresId} type="postgres" />
|
||||||
<DeleteService
|
|
||||||
id={postgresId}
|
|
||||||
type="postgres"
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-2 py-8 border-t">
|
<CardContent className="space-y-2 py-8 border-t">
|
||||||
{data?.server?.serverStatus === "inactive"
|
{data?.server?.serverStatus === "inactive" ? (
|
||||||
? (
|
<div className="flex h-[55vh] border-2 rounded-xl border-dashed p-4">
|
||||||
<div className="flex h-[55vh] border-2 rounded-xl border-dashed p-4">
|
<div className="max-w-3xl mx-auto flex flex-col items-center justify-center self-center gap-3">
|
||||||
<div className="max-w-3xl mx-auto flex flex-col items-center justify-center self-center gap-3">
|
<ServerOff className="size-10 text-muted-foreground self-center" />
|
||||||
<ServerOff className="size-10 text-muted-foreground self-center" />
|
<span className="text-center text-base text-muted-foreground">
|
||||||
<span className="text-center text-base text-muted-foreground">
|
This service is hosted on the server {data.server.name},
|
||||||
This service is hosted on the
|
but this server has been disabled because your current
|
||||||
server{" "}
|
plan doesn't include enough servers. Please purchase more
|
||||||
{data.server.name}, but this
|
servers to regain access to this application.
|
||||||
server has been disabled because
|
</span>
|
||||||
your current plan doesn't
|
<span className="text-center text-base text-muted-foreground">
|
||||||
include enough servers. Please
|
Go to{" "}
|
||||||
purchase more servers to regain
|
<Link
|
||||||
access to this application.
|
href="/dashboard/settings/billing"
|
||||||
</span>
|
className="text-primary"
|
||||||
<span className="text-center text-base text-muted-foreground">
|
>
|
||||||
Go to{" "}
|
Billing
|
||||||
<Link
|
</Link>
|
||||||
href="/dashboard/settings/billing"
|
</span>
|
||||||
className="text-primary"
|
|
||||||
>
|
|
||||||
Billing
|
|
||||||
</Link>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
</div>
|
||||||
: (
|
) : (
|
||||||
<Tabs
|
<Tabs
|
||||||
value={tab}
|
value={tab}
|
||||||
defaultValue="general"
|
defaultValue="general"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
onValueChange={(e) => {
|
onValueChange={(e) => {
|
||||||
setSab(e as TabState);
|
setSab(e as TabState);
|
||||||
const newPath =
|
const newPath = `/dashboard/project/${projectId}/environment/${environmentId}/services/postgres/${postgresId}?tab=${e}`;
|
||||||
`/dashboard/project/${projectId}/environment/${environmentId}/services/postgres/${postgresId}?tab=${e}`;
|
|
||||||
|
|
||||||
router.push(newPath, undefined, {
|
router.push(newPath, undefined, {
|
||||||
shallow: true,
|
shallow: true,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex flex-row items-center justify-between w-full gap-4 overflow-x-scroll">
|
<div className="flex flex-row items-center justify-between w-full gap-4 overflow-x-scroll">
|
||||||
<TabsList
|
<TabsList
|
||||||
className={cn(
|
className={cn(
|
||||||
"md:grid md:w-fit max-md:overflow-y-scroll justify-start",
|
"md:grid md:w-fit max-md:overflow-y-scroll justify-start",
|
||||||
isCloud && data?.serverId
|
isCloud && data?.serverId
|
||||||
? "md:grid-cols-6"
|
? "md:grid-cols-6"
|
||||||
: data?.serverId
|
: data?.serverId
|
||||||
? "md:grid-cols-5"
|
? "md:grid-cols-5"
|
||||||
: "md:grid-cols-6",
|
: "md:grid-cols-6",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<TabsTrigger value="general">
|
<TabsTrigger value="general">General</TabsTrigger>
|
||||||
General
|
<TabsTrigger value="environment">Environment</TabsTrigger>
|
||||||
</TabsTrigger>
|
<TabsTrigger value="logs">Logs</TabsTrigger>
|
||||||
<TabsTrigger value="environment">
|
{((data?.serverId && isCloud) || !data?.server) && (
|
||||||
Environment
|
<TabsTrigger value="monitoring">Monitoring</TabsTrigger>
|
||||||
</TabsTrigger>
|
)}
|
||||||
<TabsTrigger value="logs">
|
<TabsTrigger value="backups">Backups</TabsTrigger>
|
||||||
Logs
|
<TabsTrigger value="advanced">Advanced</TabsTrigger>
|
||||||
</TabsTrigger>
|
</TabsList>
|
||||||
{((data?.serverId && isCloud) ||
|
</div>
|
||||||
!data?.server) && (
|
|
||||||
<TabsTrigger value="monitoring">
|
|
||||||
Monitoring
|
|
||||||
</TabsTrigger>
|
|
||||||
)}
|
|
||||||
<TabsTrigger value="backups">
|
|
||||||
Backups
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger value="advanced">
|
|
||||||
Advanced
|
|
||||||
</TabsTrigger>
|
|
||||||
</TabsList>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<TabsContent value="general">
|
<TabsContent value="general">
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
<ShowGeneralPostgres
|
<ShowGeneralPostgres postgresId={postgresId} />
|
||||||
postgresId={postgresId}
|
<ShowInternalPostgresCredentials
|
||||||
/>
|
postgresId={postgresId}
|
||||||
<ShowInternalPostgresCredentials
|
/>
|
||||||
postgresId={postgresId}
|
<ShowExternalPostgresCredentials
|
||||||
/>
|
postgresId={postgresId}
|
||||||
<ShowExternalPostgresCredentials
|
/>
|
||||||
postgresId={postgresId}
|
</div>
|
||||||
/>
|
</TabsContent>
|
||||||
|
<TabsContent value="environment">
|
||||||
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
|
<ShowEnvironment id={postgresId} type="postgres" />
|
||||||
|
</div>
|
||||||
|
</TabsContent>
|
||||||
|
<TabsContent value="monitoring">
|
||||||
|
<div className="pt-2.5">
|
||||||
|
<div className="flex flex-col gap-4 border rounded-lg p-6">
|
||||||
|
{data?.serverId && isCloud ? (
|
||||||
|
<ContainerPaidMonitoring
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
baseUrl={`${
|
||||||
|
data?.serverId
|
||||||
|
? `http://${data?.server?.ipAddress}:${data?.server?.metricsConfig?.server?.port}`
|
||||||
|
: "http://localhost:4500"
|
||||||
|
}`}
|
||||||
|
token={
|
||||||
|
data?.server?.metricsConfig?.server?.token || ""
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<ContainerFreeMonitoring
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</div>
|
||||||
<TabsContent value="environment">
|
</TabsContent>
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
<TabsContent value="logs">
|
||||||
<ShowEnvironment
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
id={postgresId}
|
<ShowDockerLogs
|
||||||
type="postgres"
|
serverId={data?.serverId || ""}
|
||||||
/>
|
appName={data?.appName || ""}
|
||||||
</div>
|
/>
|
||||||
</TabsContent>
|
</div>
|
||||||
<TabsContent value="monitoring">
|
</TabsContent>
|
||||||
<div className="pt-2.5">
|
<TabsContent value="backups">
|
||||||
<div className="flex flex-col gap-4 border rounded-lg p-6">
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
{data?.serverId && isCloud
|
<ShowBackups
|
||||||
? (
|
id={postgresId}
|
||||||
<ContainerPaidMonitoring
|
databaseType="postgres"
|
||||||
appName={data
|
backupType="database"
|
||||||
?.appName ||
|
/>
|
||||||
""}
|
</div>
|
||||||
baseUrl={`${
|
</TabsContent>
|
||||||
data?.serverId
|
<TabsContent value="advanced">
|
||||||
? `http://${data?.server?.ipAddress}:${data?.server?.metricsConfig?.server?.port}`
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
: "http://localhost:4500"
|
<ShowDatabaseAdvancedSettings
|
||||||
}`}
|
id={postgresId}
|
||||||
token={data
|
type="postgres"
|
||||||
?.server
|
/>
|
||||||
?.metricsConfig
|
</div>
|
||||||
?.server
|
</TabsContent>
|
||||||
?.token ||
|
</Tabs>
|
||||||
""}
|
)}
|
||||||
/>
|
|
||||||
)
|
|
||||||
: (
|
|
||||||
<>
|
|
||||||
<ContainerFreeMonitoring
|
|
||||||
appName={data
|
|
||||||
?.appName ||
|
|
||||||
""}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
<TabsContent value="logs">
|
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
|
||||||
<ShowDockerLogs
|
|
||||||
serverId={data?.serverId ||
|
|
||||||
""}
|
|
||||||
appName={data?.appName ||
|
|
||||||
""}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
<TabsContent value="backups">
|
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
|
||||||
<ShowBackups
|
|
||||||
id={postgresId}
|
|
||||||
databaseType="postgres"
|
|
||||||
backupType="database"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
<TabsContent value="advanced">
|
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
|
||||||
<ShowDatabaseAdvancedSettings
|
|
||||||
id={postgresId}
|
|
||||||
type="postgres"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</TabsContent>
|
|
||||||
</Tabs>
|
|
||||||
)}
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -342,9 +293,11 @@ Postgresql.getLayout = (page: ReactElement) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getServerSideProps(
|
export async function getServerSideProps(
|
||||||
ctx: GetServerSidePropsContext<
|
ctx: GetServerSidePropsContext<{
|
||||||
{ postgresId: string; activeTab: TabState; environmentId: string }
|
postgresId: string;
|
||||||
>,
|
activeTab: TabState;
|
||||||
|
environmentId: string;
|
||||||
|
}>,
|
||||||
) {
|
) {
|
||||||
const { query, params, req, res } = ctx;
|
const { query, params, req, res } = ctx;
|
||||||
const activeTab = query.tab;
|
const activeTab = query.tab;
|
||||||
|
|||||||
+6
-3
@@ -73,8 +73,7 @@ const Redis = (
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: data?.environment?.name || "",
|
name: data?.environment?.name || "",
|
||||||
href:
|
href: `/dashboard/project/${projectId}/environment/${environmentId}`,
|
||||||
`/dashboard/project/${projectId}/environment/${environmentId}`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: data?.name || "",
|
name: data?.name || "",
|
||||||
@@ -295,7 +294,11 @@ Redis.getLayout = (page: ReactElement) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getServerSideProps(
|
export async function getServerSideProps(
|
||||||
ctx: GetServerSidePropsContext<{ redisId: string; activeTab: TabState; environmentId: string }>,
|
ctx: GetServerSidePropsContext<{
|
||||||
|
redisId: string;
|
||||||
|
activeTab: TabState;
|
||||||
|
environmentId: string;
|
||||||
|
}>,
|
||||||
) {
|
) {
|
||||||
const { query, params, req, res } = ctx;
|
const { query, params, req, res } = ctx;
|
||||||
const activeTab = query.tab;
|
const activeTab = query.tab;
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ import {
|
|||||||
apiUpdateAi,
|
apiUpdateAi,
|
||||||
deploySuggestionSchema,
|
deploySuggestionSchema,
|
||||||
} from "@dokploy/server/db/schema/ai";
|
} from "@dokploy/server/db/schema/ai";
|
||||||
import { createDomain, createMount, findEnvironmentById } from "@dokploy/server/index";
|
import {
|
||||||
|
createDomain,
|
||||||
|
createMount,
|
||||||
|
findEnvironmentById,
|
||||||
|
} from "@dokploy/server/index";
|
||||||
import {
|
import {
|
||||||
deleteAiSettings,
|
deleteAiSettings,
|
||||||
getAiSettingById,
|
getAiSettingById,
|
||||||
@@ -194,8 +198,6 @@ export const aiRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const projectName = slugify(`${project.name} ${input.id}`);
|
const projectName = slugify(`${project.name} ${input.id}`);
|
||||||
|
|
||||||
const compose = await createComposeByTemplate({
|
const compose = await createComposeByTemplate({
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -218,7 +219,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -260,7 +262,10 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneApplication)
|
.input(apiFindOneApplication)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const service = await findApplicationById(input.applicationId);
|
const service = await findApplicationById(input.applicationId);
|
||||||
if (service.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
service.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to stop this application",
|
message: "You are not authorized to stop this application",
|
||||||
@@ -280,7 +285,10 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneApplication)
|
.input(apiFindOneApplication)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const service = await findApplicationById(input.applicationId);
|
const service = await findApplicationById(input.applicationId);
|
||||||
if (service.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
service.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to start this application",
|
message: "You are not authorized to start this application",
|
||||||
@@ -302,7 +310,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -337,7 +346,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -355,7 +365,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -380,7 +391,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -407,7 +419,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -435,7 +448,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -461,7 +475,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -487,7 +502,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -510,7 +526,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -535,7 +552,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -596,7 +614,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -610,7 +629,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -636,7 +656,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -653,7 +674,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -689,7 +711,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -704,7 +727,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -740,7 +764,10 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const app = await findApplicationById(input.applicationId as string);
|
const app = await findApplicationById(input.applicationId as string);
|
||||||
|
|
||||||
if (app.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
app.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this application",
|
message: "You are not authorized to deploy this application",
|
||||||
@@ -783,7 +810,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -825,7 +853,8 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -833,8 +862,13 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
|
|||||||
@@ -121,7 +121,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this compose",
|
message: "You are not authorized to access this compose",
|
||||||
@@ -172,7 +175,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiUpdateCompose)
|
.input(apiUpdateCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to update this compose",
|
message: "You are not authorized to update this compose",
|
||||||
@@ -227,7 +233,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to clean this compose",
|
message: "You are not authorized to clean this compose",
|
||||||
@@ -240,7 +249,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFetchServices)
|
.input(apiFetchServices)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to load this compose",
|
message: "You are not authorized to load this compose",
|
||||||
@@ -257,7 +269,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to load this compose",
|
message: "You are not authorized to load this compose",
|
||||||
@@ -276,7 +291,8 @@ export const composeRouter = createTRPCRouter({
|
|||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
compose.environment.project.organizationId !== ctx.session.activeOrganizationId
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -302,7 +318,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiRandomizeCompose)
|
.input(apiRandomizeCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to randomize this compose",
|
message: "You are not authorized to randomize this compose",
|
||||||
@@ -314,7 +333,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiRandomizeCompose)
|
.input(apiRandomizeCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to randomize this compose",
|
message: "You are not authorized to randomize this compose",
|
||||||
@@ -329,7 +351,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to get this compose",
|
message: "You are not authorized to get this compose",
|
||||||
@@ -347,7 +372,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
|
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this compose",
|
message: "You are not authorized to deploy this compose",
|
||||||
@@ -380,7 +408,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to redeploy this compose",
|
message: "You are not authorized to redeploy this compose",
|
||||||
@@ -412,7 +443,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to stop this compose",
|
message: "You are not authorized to stop this compose",
|
||||||
@@ -426,7 +460,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to stop this compose",
|
message: "You are not authorized to stop this compose",
|
||||||
@@ -441,7 +478,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
|
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to get this compose",
|
message: "You are not authorized to get this compose",
|
||||||
@@ -454,7 +494,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to refresh this compose",
|
message: "You are not authorized to refresh this compose",
|
||||||
@@ -599,7 +642,10 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to disconnect this git provider",
|
message: "You are not authorized to disconnect this git provider",
|
||||||
@@ -660,15 +706,23 @@ export const composeRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move this compose",
|
message: "You are not authorized to move this compose",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
@@ -706,7 +760,8 @@ export const composeRouter = createTRPCRouter({
|
|||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
compose.environment.project.organizationId !== ctx.session.activeOrganizationId
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -777,7 +832,8 @@ export const composeRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
compose.environment.project.organizationId !== ctx.session.activeOrganizationId
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ export const deploymentRouter = createTRPCRouter({
|
|||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -43,7 +44,10 @@ export const deploymentRouter = createTRPCRouter({
|
|||||||
.input(apiFindAllByCompose)
|
.input(apiFindAllByCompose)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this compose",
|
message: "You are not authorized to access this compose",
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
if (input.domainType === "compose" && input.composeId) {
|
if (input.domainType === "compose" && input.composeId) {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (
|
if (
|
||||||
compose.environment.project.organizationId !== ctx.session.activeOrganizationId
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -70,7 +71,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -83,7 +85,10 @@ export const domainRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this compose",
|
message: "You are not authorized to access this compose",
|
||||||
@@ -122,7 +127,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
if (currentDomain.applicationId) {
|
if (currentDomain.applicationId) {
|
||||||
const newApp = await findApplicationById(currentDomain.applicationId);
|
const newApp = await findApplicationById(currentDomain.applicationId);
|
||||||
if (
|
if (
|
||||||
newApp.environment.project.organizationId !== ctx.session.activeOrganizationId
|
newApp.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -132,7 +138,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
} else if (currentDomain.composeId) {
|
} else if (currentDomain.composeId) {
|
||||||
const newCompose = await findComposeById(currentDomain.composeId);
|
const newCompose = await findComposeById(currentDomain.composeId);
|
||||||
if (
|
if (
|
||||||
newCompose.environment.project.organizationId !== ctx.session.activeOrganizationId
|
newCompose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -144,8 +151,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
currentDomain.previewDeploymentId,
|
currentDomain.previewDeploymentId,
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
newPreviewDeployment.application.environment.project.organizationId !==
|
newPreviewDeployment.application.environment.project
|
||||||
ctx.session.activeOrganizationId
|
.organizationId !== ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -175,7 +182,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
if (domain.applicationId) {
|
if (domain.applicationId) {
|
||||||
const application = await findApplicationById(domain.applicationId);
|
const application = await findApplicationById(domain.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -184,7 +192,10 @@ export const domainRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
} else if (domain.composeId) {
|
} else if (domain.composeId) {
|
||||||
const compose = await findComposeById(domain.composeId);
|
const compose = await findComposeById(domain.composeId);
|
||||||
if (compose.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this compose",
|
message: "You are not authorized to access this compose",
|
||||||
@@ -211,7 +222,8 @@ export const domainRouter = createTRPCRouter({
|
|||||||
} else if (domain.composeId) {
|
} else if (domain.composeId) {
|
||||||
const compose = await findComposeById(domain.composeId);
|
const compose = await findComposeById(domain.composeId);
|
||||||
if (
|
if (
|
||||||
compose.environment.project.organizationId !== ctx.session.activeOrganizationId
|
compose.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
|
|||||||
@@ -107,7 +107,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this Mariadb",
|
message: "You are not authorized to access this Mariadb",
|
||||||
@@ -120,7 +123,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMariaDB)
|
.input(apiFindOneMariaDB)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const service = await findMariadbById(input.mariadbId);
|
const service = await findMariadbById(input.mariadbId);
|
||||||
if (service.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
service.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to start this Mariadb",
|
message: "You are not authorized to start this Mariadb",
|
||||||
@@ -157,7 +163,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiSaveExternalPortMariaDB)
|
.input(apiSaveExternalPortMariaDB)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMariadbById(input.mariadbId);
|
const mongo = await findMariadbById(input.mariadbId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this external port",
|
message: "You are not authorized to save this external port",
|
||||||
@@ -173,7 +182,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiDeployMariaDB)
|
.input(apiDeployMariaDB)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this Mariadb",
|
message: "You are not authorized to deploy this Mariadb",
|
||||||
@@ -194,7 +206,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiDeployMariaDB)
|
.input(apiDeployMariaDB)
|
||||||
.subscription(async ({ input, ctx }) => {
|
.subscription(async ({ input, ctx }) => {
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this Mariadb",
|
message: "You are not authorized to deploy this Mariadb",
|
||||||
@@ -211,7 +226,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiChangeMariaDBStatus)
|
.input(apiChangeMariaDBStatus)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMariadbById(input.mariadbId);
|
const mongo = await findMariadbById(input.mariadbId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to change this Mariadb status",
|
message: "You are not authorized to change this Mariadb status",
|
||||||
@@ -235,7 +253,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mongo = await findMariadbById(input.mariadbId);
|
const mongo = await findMariadbById(input.mariadbId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to delete this Mariadb",
|
message: "You are not authorized to delete this Mariadb",
|
||||||
@@ -261,7 +282,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiSaveEnvironmentVariablesMariaDB)
|
.input(apiSaveEnvironmentVariablesMariaDB)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this environment",
|
message: "You are not authorized to save this environment",
|
||||||
@@ -284,7 +308,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiResetMariadb)
|
.input(apiResetMariadb)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to reload this Mariadb",
|
message: "You are not authorized to reload this Mariadb",
|
||||||
@@ -314,7 +341,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const { mariadbId, ...rest } = input;
|
const { mariadbId, ...rest } = input;
|
||||||
const mariadb = await findMariadbById(mariadbId);
|
const mariadb = await findMariadbById(mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to update this Mariadb",
|
message: "You are not authorized to update this Mariadb",
|
||||||
@@ -342,15 +372,23 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move this mariadb",
|
message: "You are not authorized to move this mariadb",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
@@ -380,7 +418,10 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiRebuildMariadb)
|
.input(apiRebuildMariadb)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mariadb.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to rebuild this MariaDB database",
|
message: "You are not authorized to rebuild this MariaDB database",
|
||||||
|
|||||||
@@ -112,7 +112,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this mongo",
|
message: "You are not authorized to access this mongo",
|
||||||
@@ -126,7 +129,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const service = await findMongoById(input.mongoId);
|
const service = await findMongoById(input.mongoId);
|
||||||
|
|
||||||
if (service.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
service.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to start this mongo",
|
message: "You are not authorized to start this mongo",
|
||||||
@@ -149,7 +155,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
|
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to stop this mongo",
|
message: "You are not authorized to stop this mongo",
|
||||||
@@ -171,7 +180,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiSaveExternalPortMongo)
|
.input(apiSaveExternalPortMongo)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this external port",
|
message: "You are not authorized to save this external port",
|
||||||
@@ -187,7 +199,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiDeployMongo)
|
.input(apiDeployMongo)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this mongo",
|
message: "You are not authorized to deploy this mongo",
|
||||||
@@ -207,7 +222,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiDeployMongo)
|
.input(apiDeployMongo)
|
||||||
.subscription(async ({ input, ctx }) => {
|
.subscription(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this mongo",
|
message: "You are not authorized to deploy this mongo",
|
||||||
@@ -224,7 +242,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiChangeMongoStatus)
|
.input(apiChangeMongoStatus)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to change this mongo status",
|
message: "You are not authorized to change this mongo status",
|
||||||
@@ -239,7 +260,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiResetMongo)
|
.input(apiResetMongo)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to reload this mongo",
|
message: "You are not authorized to reload this mongo",
|
||||||
@@ -278,7 +302,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
|
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to delete this mongo",
|
message: "You are not authorized to delete this mongo",
|
||||||
@@ -304,7 +331,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiSaveEnvironmentVariablesMongo)
|
.input(apiSaveEnvironmentVariablesMongo)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this environment",
|
message: "You are not authorized to save this environment",
|
||||||
@@ -328,7 +358,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const { mongoId, ...rest } = input;
|
const { mongoId, ...rest } = input;
|
||||||
const mongo = await findMongoById(mongoId);
|
const mongo = await findMongoById(mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to update this mongo",
|
message: "You are not authorized to update this mongo",
|
||||||
@@ -356,15 +389,23 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move this mongo",
|
message: "You are not authorized to move this mongo",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
@@ -394,7 +435,10 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiRebuildMongo)
|
.input(apiRebuildMongo)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to rebuild this MongoDB database",
|
message: "You are not authorized to rebuild this MongoDB database",
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this MySQL",
|
message: "You are not authorized to access this MySQL",
|
||||||
@@ -126,7 +129,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMySql)
|
.input(apiFindOneMySql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const service = await findMySqlById(input.mysqlId);
|
const service = await findMySqlById(input.mysqlId);
|
||||||
if (service.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
service.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to start this MySQL",
|
message: "You are not authorized to start this MySQL",
|
||||||
@@ -148,7 +154,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMySql)
|
.input(apiFindOneMySql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMySqlById(input.mysqlId);
|
const mongo = await findMySqlById(input.mysqlId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to stop this MySQL",
|
message: "You are not authorized to stop this MySQL",
|
||||||
@@ -169,7 +178,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiSaveExternalPortMySql)
|
.input(apiSaveExternalPortMySql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMySqlById(input.mysqlId);
|
const mongo = await findMySqlById(input.mysqlId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this external port",
|
message: "You are not authorized to save this external port",
|
||||||
@@ -185,7 +197,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiDeployMySql)
|
.input(apiDeployMySql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this MySQL",
|
message: "You are not authorized to deploy this MySQL",
|
||||||
@@ -205,7 +220,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiDeployMySql)
|
.input(apiDeployMySql)
|
||||||
.subscription(async ({ input, ctx }) => {
|
.subscription(async ({ input, ctx }) => {
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this MySQL",
|
message: "You are not authorized to deploy this MySQL",
|
||||||
@@ -222,7 +240,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiChangeMySqlStatus)
|
.input(apiChangeMySqlStatus)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findMySqlById(input.mysqlId);
|
const mongo = await findMySqlById(input.mysqlId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to change this MySQL status",
|
message: "You are not authorized to change this MySQL status",
|
||||||
@@ -237,7 +258,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiResetMysql)
|
.input(apiResetMysql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to reload this MySQL",
|
message: "You are not authorized to reload this MySQL",
|
||||||
@@ -273,7 +297,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const mongo = await findMySqlById(input.mysqlId);
|
const mongo = await findMySqlById(input.mysqlId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to delete this MySQL",
|
message: "You are not authorized to delete this MySQL",
|
||||||
@@ -299,7 +326,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiSaveEnvironmentVariablesMySql)
|
.input(apiSaveEnvironmentVariablesMySql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this environment",
|
message: "You are not authorized to save this environment",
|
||||||
@@ -323,7 +353,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const { mysqlId, ...rest } = input;
|
const { mysqlId, ...rest } = input;
|
||||||
const mysql = await findMySqlById(mysqlId);
|
const mysql = await findMySqlById(mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to update this MySQL",
|
message: "You are not authorized to update this MySQL",
|
||||||
@@ -351,15 +384,23 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move this mysql",
|
message: "You are not authorized to move this mysql",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
@@ -389,7 +430,10 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiRebuildMysql)
|
.input(apiRebuildMysql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mysql.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to rebuild this MySQL database",
|
message: "You are not authorized to rebuild this MySQL database",
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -128,7 +129,10 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const service = await findPostgresById(input.postgresId);
|
const service = await findPostgresById(input.postgresId);
|
||||||
|
|
||||||
if (service.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
service.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to start this Postgres",
|
message: "You are not authorized to start this Postgres",
|
||||||
@@ -151,7 +155,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -175,7 +180,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -193,7 +199,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -216,7 +223,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.subscription(async ({ input, ctx }) => {
|
.subscription(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -235,7 +243,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -261,7 +270,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -286,7 +296,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -311,7 +322,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -343,7 +355,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
const { postgresId, ...rest } = input;
|
const { postgresId, ...rest } = input;
|
||||||
const postgres = await findPostgresById(postgresId);
|
const postgres = await findPostgresById(postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -373,7 +386,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -381,8 +395,13 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
@@ -413,7 +432,8 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
if (
|
if (
|
||||||
postgres.environment.project.organizationId !== ctx.session.activeOrganizationId
|
postgres.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ export const previewDeploymentRouter = createTRPCRouter({
|
|||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
|
|||||||
@@ -347,10 +347,15 @@ export const projectRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get source project
|
// Get source project
|
||||||
const sourceEnvironment = input.duplicateInSameProject ? await findEnvironmentById(input.sourceEnvironmentId) : null;
|
const sourceEnvironment = input.duplicateInSameProject
|
||||||
|
? await findEnvironmentById(input.sourceEnvironmentId)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (
|
||||||
if (input.duplicateInSameProject &&sourceEnvironment?.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.duplicateInSameProject &&
|
||||||
|
sourceEnvironment?.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this project",
|
message: "You are not authorized to access this project",
|
||||||
@@ -369,8 +374,7 @@ export const projectRouter = createTRPCRouter({
|
|||||||
ctx.session.activeOrganizationId,
|
ctx.session.activeOrganizationId,
|
||||||
).then((value) => value.environment);
|
).then((value) => value.environment);
|
||||||
|
|
||||||
console.log("targetProject", targetProject);
|
console.log("targetProject", targetProject);
|
||||||
|
|
||||||
|
|
||||||
if (input.includeServices) {
|
if (input.includeServices) {
|
||||||
const servicesToDuplicate = input.selectedServices || [];
|
const servicesToDuplicate = input.selectedServices || [];
|
||||||
|
|||||||
@@ -104,7 +104,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to access this Redis",
|
message: "You are not authorized to access this Redis",
|
||||||
@@ -117,7 +120,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneRedis)
|
.input(apiFindOneRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to start this Redis",
|
message: "You are not authorized to start this Redis",
|
||||||
@@ -139,7 +145,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiResetRedis)
|
.input(apiResetRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to reload this Redis",
|
message: "You are not authorized to reload this Redis",
|
||||||
@@ -169,7 +178,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneRedis)
|
.input(apiFindOneRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to stop this Redis",
|
message: "You are not authorized to stop this Redis",
|
||||||
@@ -190,7 +202,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiSaveExternalPortRedis)
|
.input(apiSaveExternalPortRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findRedisById(input.redisId);
|
const mongo = await findRedisById(input.redisId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this external port",
|
message: "You are not authorized to save this external port",
|
||||||
@@ -206,7 +221,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiDeployRedis)
|
.input(apiDeployRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this Redis",
|
message: "You are not authorized to deploy this Redis",
|
||||||
@@ -226,7 +244,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiDeployRedis)
|
.input(apiDeployRedis)
|
||||||
.subscription(async ({ input, ctx }) => {
|
.subscription(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to deploy this Redis",
|
message: "You are not authorized to deploy this Redis",
|
||||||
@@ -242,7 +263,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiChangeRedisStatus)
|
.input(apiChangeRedisStatus)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const mongo = await findRedisById(input.redisId);
|
const mongo = await findRedisById(input.redisId);
|
||||||
if (mongo.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
mongo.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to change this Redis status",
|
message: "You are not authorized to change this Redis status",
|
||||||
@@ -267,7 +291,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
|
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to delete this Redis",
|
message: "You are not authorized to delete this Redis",
|
||||||
@@ -290,7 +317,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiSaveEnvironmentVariablesRedis)
|
.input(apiSaveEnvironmentVariablesRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to save this environment",
|
message: "You are not authorized to save this environment",
|
||||||
@@ -335,15 +365,23 @@ export const redisRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move this redis",
|
message: "You are not authorized to move this redis",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetEnvironment = await findEnvironmentById(input.targetEnvironmentId);
|
const targetEnvironment = await findEnvironmentById(
|
||||||
if (targetEnvironment.project.organizationId !== ctx.session.activeOrganizationId) {
|
input.targetEnvironmentId,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
targetEnvironment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to move to this environment",
|
message: "You are not authorized to move to this environment",
|
||||||
@@ -373,7 +411,10 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiRebuildRedis)
|
.input(apiRebuildRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
if (redis.environment.project.organizationId !== ctx.session.activeOrganizationId) {
|
if (
|
||||||
|
redis.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
message: "You are not authorized to rebuild this Redis database",
|
message: "You are not authorized to rebuild this Redis database",
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export const securityRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -34,7 +35,8 @@ export const securityRouter = createTRPCRouter({
|
|||||||
const security = await findSecurityById(input.securityId);
|
const security = await findSecurityById(input.securityId);
|
||||||
const application = await findApplicationById(security.applicationId);
|
const application = await findApplicationById(security.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -49,7 +51,8 @@ export const securityRouter = createTRPCRouter({
|
|||||||
const security = await findSecurityById(input.securityId);
|
const security = await findSecurityById(input.securityId);
|
||||||
const application = await findApplicationById(security.applicationId);
|
const application = await findApplicationById(security.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -64,7 +67,8 @@ export const securityRouter = createTRPCRouter({
|
|||||||
const security = await findSecurityById(input.securityId);
|
const security = await findSecurityById(input.securityId);
|
||||||
const application = await findApplicationById(security.applicationId);
|
const application = await findApplicationById(security.applicationId);
|
||||||
if (
|
if (
|
||||||
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ export const applications = pgTable("application", {
|
|||||||
export const applicationsRelations = relations(
|
export const applicationsRelations = relations(
|
||||||
applications,
|
applications,
|
||||||
({ one, many }) => ({
|
({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [applications.environmentId],
|
fields: [applications.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ export const compose = pgTable("compose", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const composeRelations = relations(compose, ({ one, many }) => ({
|
export const composeRelations = relations(compose, ({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [compose.environmentId],
|
fields: [compose.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ export const mariadb = pgTable("mariadb", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const mariadbRelations = relations(mariadb, ({ one, many }) => ({
|
export const mariadbRelations = relations(mariadb, ({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [mariadb.environmentId],
|
fields: [mariadb.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ export const mongo = pgTable("mongo", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const mongoRelations = relations(mongo, ({ one, many }) => ({
|
export const mongoRelations = relations(mongo, ({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [mongo.environmentId],
|
fields: [mongo.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ export const mysql = pgTable("mysql", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const mysqlRelations = relations(mysql, ({ one, many }) => ({
|
export const mysqlRelations = relations(mysql, ({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [mysql.environmentId],
|
fields: [mysql.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ export const postgres = pgTable("postgres", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const postgresRelations = relations(postgres, ({ one, many }) => ({
|
export const postgresRelations = relations(postgres, ({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [postgres.environmentId],
|
fields: [postgres.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ export const redis = pgTable("redis", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const redisRelations = relations(redis, ({ one, many }) => ({
|
export const redisRelations = relations(redis, ({ one, many }) => ({
|
||||||
|
|
||||||
environment: one(environments, {
|
environment: one(environments, {
|
||||||
fields: [redis.environmentId],
|
fields: [redis.environmentId],
|
||||||
references: [environments.environmentId],
|
references: [environments.environmentId],
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ export const createApplication = async (
|
|||||||
.returning()
|
.returning()
|
||||||
.then((value) => value[0]);
|
.then((value) => value[0]);
|
||||||
|
|
||||||
|
|
||||||
if (!newApplication) {
|
if (!newApplication) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ export const findEnvironmentsByProjectId = async (projectId: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteEnvironment = async (environmentId: string) => {
|
export const deleteEnvironment = async (environmentId: string) => {
|
||||||
|
|
||||||
const currentEnvironment = await findEnvironmentById(environmentId);
|
const currentEnvironment = await findEnvironmentById(environmentId);
|
||||||
if (currentEnvironment.name === "production") {
|
if (currentEnvironment.name === "production") {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ export const findPreviewDeploymentById = async (
|
|||||||
return application;
|
return application;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const removePreviewDeployment = async (previewDeploymentId: string) => {
|
export const removePreviewDeployment = async (previewDeploymentId: string) => {
|
||||||
try {
|
try {
|
||||||
const previewDeployment =
|
const previewDeployment =
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ export const createProject = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Automatically create a production environment
|
// Automatically create a production environment
|
||||||
const newEnvironment = await createProductionEnvironment(newProject.projectId);
|
const newEnvironment = await createProductionEnvironment(
|
||||||
return {
|
newProject.projectId,
|
||||||
project: newProject,
|
);
|
||||||
environment: newEnvironment,
|
return {
|
||||||
};
|
project: newProject,
|
||||||
|
environment: newEnvironment,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findProjectById = async (projectId: string) => {
|
export const findProjectById = async (projectId: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user