Skip to content

Commit

Permalink
clenaup
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Nov 24, 2024
1 parent 6504257 commit eb2bde5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import type * as SCHEMA from "@ctrlplane/db/schema";
import type { NodeProps } from "reactflow";
import React from "react";
import { IconPlant } from "@tabler/icons-react";
import _ from "lodash";
import { Handle, Position } from "reactflow";

import { cn } from "@ctrlplane/ui";
import { Skeleton } from "@ctrlplane/ui/skeleton";
import { JobStatus, JobStatusReadable } from "@ctrlplane/validators/jobs";

import { api } from "~/trpc/react";
Expand Down Expand Up @@ -88,10 +90,11 @@ export const EnvironmentNode: React.FC<EnvironmentNodeProps> = (node) => {
</div>
<div className="flex flex-col gap-4">
{latestActiveReleasesQ.isLoading &&
Array.from({ length: 3 }).map((_, i) => (
<div
_.range(3).map((i) => (
<Skeleton
key={i}
className="h-8 w-full animate-pulse bg-neutral-800"
className="h-10 w-full"
style={{ opacity: 1 * (1 - i / 3) }}
/>
))}
{!latestActiveReleasesQ.isLoading &&
Expand Down
43 changes: 0 additions & 43 deletions packages/api/src/router/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,49 +734,6 @@ export const deploymentRouter = createTRPCRouter({
).then((r) => r.flat());
}),

byResourceAndDeploymentId: protectedProcedure
.input(
z.object({
resourceId: z.string().uuid(),
deploymentId: z.string().uuid(),
}),
)
.meta({
authorizationCheck: async ({ canUser, input }) => {
const { resourceId, deploymentId } = input;
const canGetDeploymentPromise = canUser
.perform(Permission.DeploymentGet)
.on({ type: "deployment", id: deploymentId });
const canGetResourcePromise = canUser
.perform(Permission.ResourceGet)
.on({ type: "resource", id: resourceId });
const [canGetDeployment, canGetResource] = await Promise.all([
canGetDeploymentPromise,
canGetResourcePromise,
]);
return canGetDeployment && canGetResource;
},
})
.query(async ({ ctx, input }) => {
const { resourceId, deploymentId } = input;
const activeRelease = latestActiveReleaseSubQuery(ctx.db);
return ctx.db
.select()
.from(deployment)
.innerJoin(activeRelease, eq(activeRelease.deploymentId, deployment.id))
.where(
and(
eq(activeRelease.resourceId, resourceId),
eq(deployment.id, deploymentId),
),
)
.then(takeFirst)
.then((row) => ({
...row.deployment,
latestActiveRelease: row.active_releases,
}));
}),

byWorkspaceId: protectedProcedure
.meta({
authorizationCheck: ({ canUser, input }) =>
Expand Down

0 comments on commit eb2bde5

Please sign in to comment.