diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/EnvironmentNode.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/EnvironmentNode.tsx index 8500af98e..a7f711066 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/EnvironmentNode.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/EnvironmentNode.tsx @@ -24,8 +24,8 @@ import { } from "@ctrlplane/validators/conditions"; import { JobFilterType, JobStatus } from "@ctrlplane/validators/jobs"; -import { useReleaseChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer"; -import { useReleaseChannel } from "~/app/[workspaceSlug]/(app)/_hooks/channel/useReleaseChannel"; +import { useDeploymentVersionChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer"; +import { useDeploymentVersionChannel } from "~/app/[workspaceSlug]/(app)/_hooks/channel/useDeploymentVersionChannel"; import { api } from "~/trpc/react"; import { Cancelled, Failing, Loading, Passing, Waiting } from "./StatusIcons"; @@ -132,53 +132,64 @@ const WaitingOnActiveCheck: React.FC = ({ ); }; -const ReleaseChannelCheck: React.FC = ({ +const DeploymentVersionChannelCheck: React.FC = ({ deploymentId, environmentId, releaseVersion, }) => { - const { setReleaseChannelId } = useReleaseChannelDrawer(); - const { isPassingReleaseChannel, releaseChannelId, loading } = - useReleaseChannel(deploymentId, environmentId, releaseVersion); + const { setDeploymentVersionChannelId } = useDeploymentVersionChannelDrawer(); + const { + isPassingDeploymentVersionChannel, + deploymentVersionChannelId, + loading, + } = useDeploymentVersionChannel(deploymentId, environmentId, releaseVersion); return (
{loading && } - {!loading && releaseChannelId == null && ( + {!loading && deploymentVersionChannelId == null && ( <> No release channel )} - {!loading && releaseChannelId != null && !isPassingReleaseChannel && ( - <> - - - Blocked by{" "} - - - - )} - {!loading && releaseChannelId != null && isPassingReleaseChannel && ( - <> - - - Passing{" "} - - - - )} + {!loading && + deploymentVersionChannelId != null && + !isPassingDeploymentVersionChannel && ( + <> + + + Blocked by{" "} + + + + )} + {!loading && + deploymentVersionChannelId != null && + isPassingDeploymentVersionChannel && ( + <> + + + Passing{" "} + + + + )}
); }; @@ -265,7 +276,7 @@ export const EnvironmentNode: React.FC = ({ data }) => (
- +
diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx index 6d6042f57..d4365717a 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx @@ -36,7 +36,7 @@ import { JobConditionDialog } from "~/app/[workspaceSlug]/(app)/_components/job/ import { useJobDrawer } from "~/app/[workspaceSlug]/(app)/_components/job/drawer/useJobDrawer"; import { JobDropdownMenu } from "~/app/[workspaceSlug]/(app)/_components/job/JobDropdownMenu"; import { JobTableStatusIcon } from "~/app/[workspaceSlug]/(app)/_components/job/JobTableStatusIcon"; -import { useReleaseChannel } from "~/app/[workspaceSlug]/(app)/_hooks/channel/useReleaseChannel"; +import { useDeploymentVersionChannel } from "~/app/[workspaceSlug]/(app)/_hooks/channel/useDeploymentVersionChannel"; import { useFilter } from "~/app/[workspaceSlug]/(app)/_hooks/useFilter"; import { Sidebars } from "~/app/[workspaceSlug]/sidebars"; import { api } from "~/trpc/react"; @@ -133,10 +133,16 @@ const CollapsibleTableRow: React.FC = ({ return newState; }); - const { isPassingReleaseChannel, loading: releaseChannelLoading } = - useReleaseChannel(deployment.id, environment.id, release.version); + const { + isPassingDeploymentVersionChannel, + loading: deploymentVersionChannelLoading, + } = useDeploymentVersionChannel( + deployment.id, + environment.id, + release.version, + ); - const loading = approvalsQ.isLoading || releaseChannelLoading; + const loading = approvalsQ.isLoading || deploymentVersionChannelLoading; if (allTriggers.length === 0) return null; @@ -312,7 +318,9 @@ const CollapsibleTableRow: React.FC = ({ id: trigger.job.id, status: trigger.job.status, }} - isPassingReleaseChannel={isPassingReleaseChannel} + isPassingDeploymentVersionChannel={ + isPassingDeploymentVersionChannel + } > - {filter != null && releaseChannel == null && ( + {filter != null && deploymentVersionChannel == null && ( )} diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/DeploymentCTA.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/DeploymentCTA.tsx index 7b1925c3a..e9b0a7acd 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/DeploymentCTA.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/DeploymentCTA.tsx @@ -6,7 +6,7 @@ import { usePathname } from "next/navigation"; import { Button } from "@ctrlplane/ui/button"; import { CreateReleaseDialog } from "~/app/[workspaceSlug]/(app)/(deploy)/_components/release/CreateRelease"; -import { CreateReleaseChannelDialog } from "../channels/CreateReleaseChannelDialog"; +import { CreateDeploymentVersionChannelDialog } from "../channels/CreateDeploymentVersionChannelDialog"; import { CreateVariableDialog } from "../variables/CreateVariableDialog"; export const DeploymentCTA: React.FC<{ @@ -27,11 +27,11 @@ export const DeploymentCTA: React.FC<{ if (tab === "channels") return ( - + - + ); return ( diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx index b12e2c002..2ce7eea24 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx @@ -17,7 +17,7 @@ import { import { JobStatus } from "@ctrlplane/validators/jobs"; import { ReleaseStatus } from "@ctrlplane/validators/releases"; -import { useReleaseChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer"; +import { useDeploymentVersionChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer"; import { ApprovalDialog } from "~/app/[workspaceSlug]/(app)/(deploy)/_components/release/ApprovalDialog"; import { ReleaseDropdownMenu } from "~/app/[workspaceSlug]/(app)/(deploy)/_components/release/ReleaseDropdownMenu"; import { api } from "~/trpc/react"; @@ -106,7 +106,7 @@ const ReleaseEnvironmentCell: React.FC = ({ { refetchInterval: 2_000 }, ); - const { setReleaseChannelId } = useReleaseChannelDrawer(); + const { setDeploymentVersionChannelId } = useDeploymentVersionChannelDrawer(); const isLoading = isStatusesLoading || @@ -135,16 +135,18 @@ const ReleaseEnvironmentCell: React.FC = ({ const isAlreadyDeployed = statuses != null && statuses.length > 0; const hasJobAgent = deployment.jobAgentId != null; - const isBlockedByReleaseChannel = blockedEnv != null; + const isBlockedByDeploymentVersionChannel = blockedEnv != null; const isPendingApproval = approval?.status === "pending"; - const showBlockedByReleaseChannel = - isBlockedByReleaseChannel && + const showBlockedByDeploymentVersionChannel = + isBlockedByDeploymentVersionChannel && !statuses?.some((s) => s.job.status === JobStatus.InProgress); const showRelease = - isAlreadyDeployed && !showBlockedByReleaseChannel && !isPendingApproval; + isAlreadyDeployed && + !showBlockedByDeploymentVersionChannel && + !isPendingApproval; if (showRelease) return ( @@ -175,7 +177,7 @@ const ReleaseEnvironmentCell: React.FC = ({
Release failed
); - if (showBlockedByReleaseChannel) + if (showBlockedByDeploymentVersionChannel) return (
Blocked by{" "} @@ -183,7 +185,9 @@ const ReleaseEnvironmentCell: React.FC = ({ variant="link" size="sm" onClick={() => - setReleaseChannelId(blockedEnv.releaseChannelId ?? null) + setDeploymentVersionChannelId( + blockedEnv.deploymentVersionChannelId ?? null, + ) } className="px-0 text-muted-foreground/70" > diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/CreateReleaseChannelDialog.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/CreateDeploymentVersionChannelDialog.tsx similarity index 88% rename from apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/CreateReleaseChannelDialog.tsx rename to apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/CreateDeploymentVersionChannelDialog.tsx index 88d35ccba..1914c0c06 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/CreateReleaseChannelDialog.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/CreateDeploymentVersionChannelDialog.tsx @@ -41,7 +41,7 @@ import { ReleaseConditionDialog } from "~/app/[workspaceSlug]/(app)/_components/ import { urls } from "~/app/urls"; import { api } from "~/trpc/react"; -type CreateReleaseChannelDialogProps = { +type CreateDeploymentVersionChannelDialogProps = { deploymentId: string; children: React.ReactNode; }; @@ -52,13 +52,13 @@ const getFinalFilter = (filter?: ReleaseCondition) => const schema = z.object({ name: z.string().min(1).max(50), description: z.string().max(1000).optional(), - releaseFilter: releaseCondition + versionSelector: releaseCondition .optional() .refine((cond) => cond == null || isValidReleaseCondition(cond)), }); -export const CreateReleaseChannelDialog: React.FC< - CreateReleaseChannelDialogProps +export const CreateDeploymentVersionChannelDialog: React.FC< + CreateDeploymentVersionChannelDialogProps > = ({ deploymentId, children }) => { const [open, setOpen] = useState(false); const { workspaceSlug, systemSlug, deploymentSlug } = useParams<{ @@ -67,23 +67,23 @@ export const CreateReleaseChannelDialog: React.FC< deploymentSlug: string; }>(); - const createReleaseChannel = - api.deployment.releaseChannel.create.useMutation(); + const createDeploymentVersionChannel = + api.deployment.version.channel.create.useMutation(); const router = useRouter(); const form = useForm({ schema }); const onSubmit = form.handleSubmit((data) => { - const filter = getFinalFilter(data.releaseFilter); - createReleaseChannel - .mutateAsync({ ...data, deploymentId, releaseFilter: filter }) + const filter = getFinalFilter(data.versionSelector); + createDeploymentVersionChannel + .mutateAsync({ ...data, deploymentId, versionSelector: filter }) .then(() => form.reset(data)) .then(() => router.refresh()) .then(() => setOpen(false)) .catch((error) => toast.error(error.message)); }); - const { releaseFilter } = form.watch(); - const filter = getFinalFilter(releaseFilter); + const { versionSelector } = form.watch(); + const filter = getFinalFilter(versionSelector); const filterHash = filter != null @@ -143,7 +143,7 @@ export const CreateReleaseChannelDialog: React.FC< ( @@ -186,7 +186,10 @@ export const CreateReleaseChannelDialog: React.FC< /> - diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/DeploymentVersionChannelsTable.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/DeploymentVersionChannelsTable.tsx new file mode 100644 index 000000000..59fa65db3 --- /dev/null +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/DeploymentVersionChannelsTable.tsx @@ -0,0 +1,64 @@ +"use client"; + +import type * as SCHEMA from "@ctrlplane/db/schema"; +import React from "react"; + +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@ctrlplane/ui/table"; + +import { useDeploymentVersionChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer"; +import { ReleaseConditionBadge } from "~/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionBadge"; + +type DeploymentVersionChannel = SCHEMA.DeploymentVersionChannel & { + total: number; +}; + +type DeploymentVersionChannelTableProps = { + deploymentVersionChannels: DeploymentVersionChannel[]; +}; + +export const DeploymentVersionChannelsTable: React.FC< + DeploymentVersionChannelTableProps +> = ({ deploymentVersionChannels }) => { + const { setDeploymentVersionChannelId } = useDeploymentVersionChannelDrawer(); + return ( + + + + Name + Description + Release Filter + Total Releases + + + + {deploymentVersionChannels.map((deploymentVersionChannel) => ( + + setDeploymentVersionChannelId(deploymentVersionChannel.id) + } + > + {deploymentVersionChannel.name} + {deploymentVersionChannel.description} + + {deploymentVersionChannel.versionSelector != null && ( + + )} + + {deploymentVersionChannel.total} + + ))} + +
+ ); +}; diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx deleted file mode 100644 index de7f1d33b..000000000 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx +++ /dev/null @@ -1,58 +0,0 @@ -"use client"; - -import type * as SCHEMA from "@ctrlplane/db/schema"; -import React from "react"; - -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@ctrlplane/ui/table"; - -import { useReleaseChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer"; -import { ReleaseConditionBadge } from "~/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionBadge"; - -type ReleaseChannel = SCHEMA.DeploymentVersionChannel & { total: number }; - -type ReleaseChannelTableProps = { releaseChannels: ReleaseChannel[] }; - -export const ReleaseChannelsTable: React.FC = ({ - releaseChannels, -}) => { - const { setReleaseChannelId } = useReleaseChannelDrawer(); - return ( - - - - Name - Description - Release Filter - Total Releases - - - - {releaseChannels.map((releaseChannel) => ( - setReleaseChannelId(releaseChannel.id)} - > - {releaseChannel.name} - {releaseChannel.description} - - {releaseChannel.releaseFilter != null && ( - - )} - - {releaseChannel.total} - - ))} - -
- ); -}; diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/page.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/page.tsx index 67db2ba16..9991d1f71 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/page.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/page.tsx @@ -1,9 +1,9 @@ import { notFound } from "next/navigation"; import { api } from "~/trpc/server"; -import { ReleaseChannelsTable } from "./ReleaseChannelsTable"; +import { DeploymentVersionChannelsTable } from "./DeploymentVersionChannelsTable"; -export default async function ReleaseChannelsPage(props: { +export default async function DeploymentVersionChannelsPage(props: { params: Promise<{ workspaceSlug: string; systemSlug: string; @@ -21,12 +21,14 @@ export default async function ReleaseChannelsPage(props: { }); if (!deployment) notFound(); - const releaseChannels = - await api.deployment.releaseChannel.list.byDeploymentId(deployment.id); + const deploymentVersionChannels = + await api.deployment.version.channel.list.byDeploymentId(deployment.id); return (
- +
); } diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx index 667d699c3..829966112 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx @@ -12,7 +12,7 @@ type PageProps = { systemSlug: string; deploymentSlug: string; }>; - searchParams: Promise<{ "release-channel-id"?: string }>; + searchParams: Promise<{ "deployment-version-channel-id"?: string }>; }; export async function generateMetadata(props: PageProps): Promise { @@ -35,9 +35,9 @@ export default async function DeploymentPage(props: PageProps) { const { system } = deployment; const roots = await api.system.directory.listRoots(system.id); const { rootEnvironments: environments, directories } = roots; - const releaseChannel = searchParams["release-channel-id"] - ? await api.deployment.releaseChannel.byId( - searchParams["release-channel-id"], + const deploymentVersionChannel = searchParams["deployment-version-channel-id"] + ? await api.deployment.version.channel.byId( + searchParams["deployment-version-channel-id"], ) : null; @@ -47,7 +47,7 @@ export default async function DeploymentPage(props: PageProps) { deployment={deployment} environments={environments} directories={directories} - releaseChannel={releaseChannel} + deploymentVersionChannel={deploymentVersionChannel} /> ); } diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/ReleaseChannels.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/DeploymentVersionChannels.tsx similarity index 69% rename from apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/ReleaseChannels.tsx rename to apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/DeploymentVersionChannels.tsx index 05b2c63e9..f179228a0 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/ReleaseChannels.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/DeploymentVersionChannels.tsx @@ -21,8 +21,8 @@ type Deployment = RouterOutputs["deployment"]["bySystemId"][number]; type DeploymentSelectProps = { deployment: Deployment; - releaseChannels: Record; - updateReleaseChannel: ( + deploymentVersionChannels: Record; + updateDeploymentVersionChannel: ( deploymentId: string, channelId: string | null, ) => Promise; @@ -30,25 +30,25 @@ type DeploymentSelectProps = { const DeploymentSelect: React.FC = ({ deployment, - releaseChannels, - updateReleaseChannel, + deploymentVersionChannels, + updateDeploymentVersionChannel, }) => { const [open, setOpen] = useState(false); - const releaseChannelId = releaseChannels[deployment.id]; - const releaseChannel = deployment.releaseChannels.find( - (rc) => rc.id === releaseChannelId, + const deploymentVersionChannelId = deploymentVersionChannels[deployment.id]; + const deploymentVersionChannel = deployment.versionChannels.find( + (rc) => rc.id === deploymentVersionChannelId, ); const onChange = (channelId: string | null) => - updateReleaseChannel(deployment.id, channelId); + updateDeploymentVersionChannel(deployment.id, channelId); const { workspaceSlug, systemSlug } = useParams<{ workspaceSlug?: string; systemSlug?: string; }>(); - const sortedReleaseChannels = deployment.releaseChannels.sort((a, b) => - a.name.localeCompare(b.name), + const sortedDeploymentVersionChannels = deployment.versionChannels.sort( + (a, b) => a.name.localeCompare(b.name), ); return ( @@ -64,7 +64,7 @@ const DeploymentSelect: React.FC = ({ > - {releaseChannel?.name ?? `Select release channel...`} + {deploymentVersionChannel?.name ?? `Select release channel...`} @@ -72,7 +72,7 @@ const DeploymentSelect: React.FC = ({ - {sortedReleaseChannels.length === 0 && ( + {sortedDeploymentVersionChannels.length === 0 && ( = ({ )} - {sortedReleaseChannels.length > 0 && - sortedReleaseChannels.map((rc) => ( + {sortedDeploymentVersionChannels.length > 0 && + sortedDeploymentVersionChannels.map((rc) => ( = ({ @@ -110,35 +110,37 @@ const DeploymentSelect: React.FC = ({ ); }; -type ReleaseChannelProps = { +type DeploymentVersionChannelProps = { environmentPolicy: RouterOutputs["environment"]["policy"]["byEnvironmentId"]; deployments: Deployment[]; }; -export const ReleaseChannels: React.FC = ({ - environmentPolicy, - deployments, -}) => { +export const DeploymentVersionChannels: React.FC< + DeploymentVersionChannelProps +> = ({ environmentPolicy, deployments }) => { const { onUpdate, isPending } = useUpdatePolicy(environmentPolicy.id); - const deploymentsWithReleaseChannels = deployments.filter( - (d) => d.releaseChannels.length > 0, + const deploymentsWithDeploymentVersionChannels = deployments.filter( + (d) => d.versionChannels.length > 0, ); - const { releaseChannels } = environmentPolicy; - const currReleaseChannels = Object.fromEntries( - deploymentsWithReleaseChannels.map((d) => [ + const { versionChannels } = environmentPolicy; + const currDeploymentVersionChannels = Object.fromEntries( + deploymentsWithDeploymentVersionChannels.map((d) => [ d.id, - releaseChannels.find((rc) => rc.deploymentId === d.id)?.id ?? null, + versionChannels.find((rc) => rc.deploymentId === d.id)?.id ?? null, ]), ); - const updateReleaseChannel = ( + const updateDeploymentVersionChannel = ( deploymentId: string, channelId: string | null, ) => onUpdate({ - releaseChannels: { ...currReleaseChannels, [deploymentId]: channelId }, + versionChannels: { + ...currDeploymentVersionChannels, + [deploymentId]: channelId, + }, }); return ( @@ -161,8 +163,8 @@ export const ReleaseChannels: React.FC = ({ ))}
diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/page.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/page.tsx index f391da7e7..2d23f4bac 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/page.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/page.tsx @@ -1,5 +1,5 @@ import { api } from "~/trpc/server"; -import { ReleaseChannels } from "./ReleaseChannels"; +import { DeploymentVersionChannels } from "./DeploymentVersionChannels"; export default async function ChannelsPage(props: { params: Promise<{ @@ -16,6 +16,9 @@ export default async function ChannelsPage(props: { const deployments = await api.deployment.bySystemId(system.id); return ( - + ); } diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/ReleaseChannelDrawer.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx similarity index 64% rename from apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/ReleaseChannelDrawer.tsx rename to apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx index 30172f544..8eb0a8c6a 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/ReleaseChannelDrawer.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx @@ -14,24 +14,25 @@ import { Drawer, DrawerContent, DrawerTitle } from "@ctrlplane/ui/drawer"; import { api } from "~/trpc/react"; import { TabButton } from "../../drawer/TabButton"; +import { DeploymentVersionChannelDropdown } from "./DeploymentVersionChannelDropdown"; import { Overview } from "./Overview"; -import { ReleaseChannelDropdown } from "./ReleaseChannelDropdown"; import { Usage } from "./Usage"; -import { useReleaseChannelDrawer } from "./useReleaseChannelDrawer"; +import { useDeploymentVersionChannelDrawer } from "./useDeploymentVersionChannelDrawer"; -export const ReleaseChannelDrawer: React.FC = () => { - const { releaseChannelId, removeReleaseChannelId } = - useReleaseChannelDrawer(); - const isOpen = Boolean(releaseChannelId); - const setIsOpen = removeReleaseChannelId; +export const DeploymentVersionChannelDrawer: React.FC = () => { + const { deploymentVersionChannelId, removeDeploymentVersionChannelId } = + useDeploymentVersionChannelDrawer(); + const isOpen = Boolean(deploymentVersionChannelId); + const setIsOpen = removeDeploymentVersionChannelId; - const releaseChannelQ = api.deployment.releaseChannel.byId.useQuery( - releaseChannelId ?? "", - { enabled: isOpen }, - ); - const releaseChannel = releaseChannelQ.data; + const deploymentVersionChannelQ = + api.deployment.version.channel.byId.useQuery( + deploymentVersionChannelId ?? "", + { enabled: isOpen }, + ); + const deploymentVersionChannel = deploymentVersionChannelQ.data; - const loading = releaseChannelQ.isLoading; + const loading = deploymentVersionChannelQ.isLoading; const [activeTab, setActiveTab] = useState("overview"); @@ -46,15 +47,17 @@ export const ReleaseChannelDrawer: React.FC = () => { )} - {!loading && releaseChannel != null && ( + {!loading && deploymentVersionChannel != null && ( <> - {releaseChannel.name} - + {deploymentVersionChannel.name} + - +
@@ -75,10 +78,12 @@ export const ReleaseChannelDrawer: React.FC = () => {
{activeTab === "overview" && ( - + )} {activeTab === "usage" && ( - + )}
diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/ReleaseChannelDropdown.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDropdown.tsx similarity index 75% rename from apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/ReleaseChannelDropdown.tsx rename to apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDropdown.tsx index 2ecab515d..d22b35c11 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/ReleaseChannelDropdown.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDropdown.tsx @@ -23,17 +23,15 @@ import { import { api } from "~/trpc/react"; -type DeleteReleaseChannelDialogProps = { - releaseChannelId: string; +type DeleteDeploymentVersionChannelDialogProps = { + deploymentVersionChannelId: string; onClose: () => void; children: React.ReactNode; }; -const DeleteReleaseChannelDialog: React.FC = ({ - releaseChannelId, - onClose, - children, -}) => { +const DeleteDeploymentVersionChannelDialog: React.FC< + DeleteDeploymentVersionChannelDialogProps +> = ({ deploymentVersionChannelId, onClose, children }) => { const [open, setOpen] = useState(false); const router = useRouter(); @@ -45,11 +43,11 @@ const DeleteReleaseChannelDialog: React.FC = ({ router.replace(`${url.pathname}?${url.searchParams.toString()}`); }; - const deleteReleaseChannel = - api.deployment.releaseChannel.delete.useMutation(); + const deleteDeploymentVersionChannel = + api.deployment.version.channel.delete.useMutation(); const onDelete = () => - deleteReleaseChannel - .mutateAsync(releaseChannelId) + deleteDeploymentVersionChannel + .mutateAsync(deploymentVersionChannelId) .then(() => deleteParams()) .then(() => router.refresh()) .then(() => setOpen(false)); @@ -77,7 +75,7 @@ const DeleteReleaseChannelDialog: React.FC = ({
Delete @@ -88,22 +86,21 @@ const DeleteReleaseChannelDialog: React.FC = ({ ); }; -type ReleaseChannelDropdownProps = { - releaseChannelId: string; +type DeploymentVersionChannelDropdownProps = { + deploymentVersionChannelId: string; children: React.ReactNode; }; -export const ReleaseChannelDropdown: React.FC = ({ - releaseChannelId, - children, -}) => { +export const DeploymentVersionChannelDropdown: React.FC< + DeploymentVersionChannelDropdownProps +> = ({ deploymentVersionChannelId, children }) => { const [open, setOpen] = useState(false); return ( {children} - setOpen(false)} > = ({ Delete - + ); diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Overview.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Overview.tsx index c4a5d340b..76880063e 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Overview.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Overview.tsx @@ -35,10 +35,11 @@ import { import { ReleaseConditionRender } from "~/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionRender"; import { useReleaseFilter } from "~/app/[workspaceSlug]/(app)/_components/release/condition/useReleaseFilter"; import { ReleaseBadgeList } from "~/app/[workspaceSlug]/(app)/_components/release/ReleaseBadgeList"; +import { urls } from "~/app/urls"; import { api } from "~/trpc/react"; type OverviewProps = { - releaseChannel: SCHEMA.DeploymentVersionChannel; + deploymentVersionChannel: SCHEMA.DeploymentVersionChannel; }; const getFinalFilter = (filter: ReleaseCondition | null) => @@ -46,24 +47,28 @@ const getFinalFilter = (filter: ReleaseCondition | null) => const getReleaseFilterUrl = ( workspaceSlug: string, - releaseChannelId: string, + deploymentVersionChannelId: string, systemSlug?: string, deploymentSlug?: string, filter?: ReleaseCondition, ) => { if (filter == null || systemSlug == null || deploymentSlug == null) return null; - const baseUrl = `/${workspaceSlug}/systems/${systemSlug}/deployments/${deploymentSlug}`; + const baseUrl = urls + .workspace(workspaceSlug) + .system(systemSlug) + .deployment(deploymentSlug) + .baseUrl(); const filterHash = LZString.compressToEncodedURIComponent( JSON.stringify(filter), ); - return `${baseUrl}/releases?filter=${filterHash}&release-channel-id=${releaseChannelId}`; + return `${baseUrl}?filter=${filterHash}&deployment-version-channel-id=${deploymentVersionChannelId}`; }; const schema = z.object({ name: z.string().min(1).max(50), description: z.string().max(1000).optional(), - releaseFilter: releaseCondition + versionSelector: releaseCondition .nullable() .refine((r) => r == null || isValidReleaseCondition(r)), }); @@ -82,7 +87,9 @@ const getFilter = ( return releaseFilter; }; -export const Overview: React.FC = ({ releaseChannel }) => { +export const Overview: React.FC = ({ + deploymentVersionChannel, +}) => { const { workspaceSlug, systemSlug, deploymentSlug } = useParams<{ workspaceSlug: string; systemSlug?: string; @@ -91,30 +98,35 @@ export const Overview: React.FC = ({ releaseChannel }) => { const { filter: paramFilter, setFilter } = useReleaseFilter(); const defaultValues = { - ...releaseChannel, - releaseFilter: getFilter(releaseChannel.releaseFilter), - description: releaseChannel.description ?? undefined, + ...deploymentVersionChannel, + versionSelector: getFilter(deploymentVersionChannel.versionSelector), + description: deploymentVersionChannel.description ?? undefined, }; const form = useForm({ schema, defaultValues }); const router = useRouter(); const utils = api.useUtils(); - const updateReleaseChannel = - api.deployment.releaseChannel.update.useMutation(); + const updateDeploymentVersionChannel = + api.deployment.version.channel.update.useMutation(); const onSubmit = form.handleSubmit((data) => { - const releaseFilter = getFinalFilter(data.releaseFilter); - updateReleaseChannel - .mutateAsync({ id: releaseChannel.id, data: { ...data, releaseFilter } }) - .then(() => form.reset({ ...data, releaseFilter })) + const versionSelector = getFinalFilter(data.versionSelector); + updateDeploymentVersionChannel + .mutateAsync({ + id: deploymentVersionChannel.id, + data: { ...data, versionSelector }, + }) + .then(() => form.reset({ ...data, versionSelector })) .then(() => - utils.deployment.releaseChannel.byId.invalidate(releaseChannel.id), + utils.deployment.version.channel.byId.invalidate( + deploymentVersionChannel.id, + ), ) - .then(() => paramFilter != null && setFilter(releaseFilter ?? null)) + .then(() => paramFilter != null && setFilter(versionSelector ?? null)) .then(() => router.refresh()); }); - const { deploymentId } = releaseChannel; - const filter = getFinalFilter(form.watch("releaseFilter")); + const { deploymentId } = deploymentVersionChannel; + const filter = getFinalFilter(form.watch("versionSelector")); const releasesQ = api.deployment.version.list.useQuery({ deploymentId, @@ -124,7 +136,7 @@ export const Overview: React.FC = ({ releaseChannel }) => { const releases = releasesQ.data; const releaseFilterUrl = getReleaseFilterUrl( workspaceSlug, - releaseChannel.id, + deploymentVersionChannel.id, systemSlug, deploymentSlug, filter, @@ -163,7 +175,7 @@ export const Overview: React.FC = ({ releaseChannel }) => { ( @@ -187,7 +199,10 @@ export const Overview: React.FC = ({ releaseChannel }) => {
diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Usage.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Usage.tsx index f1e6805da..cb9c3aa84 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Usage.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/Usage.tsx @@ -2,7 +2,7 @@ import type { RouterOutputs } from "@ctrlplane/api"; import { IconFilter } from "@tabler/icons-react"; type UsageInfo = NonNullable< - RouterOutputs["deployment"]["releaseChannel"]["byId"] + RouterOutputs["deployment"]["version"]["channel"]["byId"] >["usage"]; export const Usage: React.FC<{ usage: UsageInfo }> = ({ usage }) => { diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer.ts b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer.ts new file mode 100644 index 000000000..9a9e8bc62 --- /dev/null +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer.ts @@ -0,0 +1,25 @@ +import { useRouter, useSearchParams } from "next/navigation"; + +const param = "deployment_version_channel_id"; + +export const useDeploymentVersionChannelDrawer = () => { + const router = useRouter(); + const params = useSearchParams(); + const deploymentVersionChannelId = params.get(param); + + const setDeploymentVersionChannelId = (id: string | null) => { + const url = new URL(window.location.href); + if (id == null) url.searchParams.delete(param); + if (id != null) url.searchParams.set(param, id); + router.replace(`${url.pathname}?${url.searchParams.toString()}`); + }; + + const removeDeploymentVersionChannelId = () => + setDeploymentVersionChannelId(null); + + return { + deploymentVersionChannelId, + setDeploymentVersionChannelId, + removeDeploymentVersionChannelId, + }; +}; diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer.ts b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer.ts deleted file mode 100644 index 87d05ecbb..000000000 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { useRouter, useSearchParams } from "next/navigation"; - -const param = "release_channel_id"; - -export const useReleaseChannelDrawer = () => { - const router = useRouter(); - const params = useSearchParams(); - const releaseChannelId = params.get(param); - - const setReleaseChannelId = (id: string | null) => { - const url = new URL(window.location.href); - if (id == null) url.searchParams.delete(param); - if (id != null) url.searchParams.set(param, id); - router.replace(`${url.pathname}?${url.searchParams.toString()}`); - }; - - const removeReleaseChannelId = () => setReleaseChannelId(null); - - return { releaseChannelId, setReleaseChannelId, removeReleaseChannelId }; -}; diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployments/resource-drawer/DeploymentResourceDrawer.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployments/resource-drawer/DeploymentResourceDrawer.tsx index 7b98b45cb..f454383bf 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployments/resource-drawer/DeploymentResourceDrawer.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployments/resource-drawer/DeploymentResourceDrawer.tsx @@ -46,8 +46,8 @@ export const DeploymentResourceDrawer: React.FC = () => { { enabled: isOpen }, ); - const { releaseFilter } = - environment?.policy.releaseChannels.find( + const { versionSelector } = + environment?.policy.versionChannels.find( (rc) => rc.deploymentId === deploymentId, ) ?? {}; @@ -77,7 +77,7 @@ export const DeploymentResourceDrawer: React.FC = () => { api.deployment.version.list.useQuery( { deploymentId: deploymentId ?? "", - filter: releaseFilter ?? undefined, + filter: versionSelector ?? undefined, jobFilter, limit: 100, }, diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/EnvironmentDrawer.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/EnvironmentDrawer.tsx index 8ca6c5ecf..cbc4a4e14 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/EnvironmentDrawer.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/EnvironmentDrawer.tsx @@ -176,8 +176,12 @@ export const EnvironmentDrawer: React.FC = () => { label="Release Management" /> setTab(EnvironmentDrawerTab.ReleaseChannels)} + active={ + tab === EnvironmentDrawerTab.DeploymentVersionChannels + } + onClick={() => + setTab(EnvironmentDrawerTab.DeploymentVersionChannels) + } icon={} label="Release Channels" /> diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/policy-override/UpdateOverride.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/policy-override/UpdateOverride.tsx index 15e1f72a3..c2a13fff7 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/policy-override/UpdateOverride.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment/drawer/policy-override/UpdateOverride.tsx @@ -3,14 +3,14 @@ import type * as SCHEMA from "@ctrlplane/db/schema"; import { ApprovalAndGovernance } from "~/app/[workspaceSlug]/(app)/_components/policy/form/ApprovalAndGovernance"; import { DeploymentControl } from "~/app/[workspaceSlug]/(app)/_components/policy/form/DeploymentControl"; -import { ReleaseChannels } from "~/app/[workspaceSlug]/(app)/_components/policy/form/ReleaseChannels"; +import { DeploymentVersionChannels } from "~/app/[workspaceSlug]/(app)/_components/policy/form/DeploymentVersionChannels"; import { ReleaseManagement } from "~/app/[workspaceSlug]/(app)/_components/policy/form/ReleaseManagement"; import { RolloutAndTiming } from "~/app/[workspaceSlug]/(app)/_components/policy/form/RolloutAndTiming"; import { EnvironmentDrawerTab } from "../tabs"; import { useUpdateOverridePolicy } from "./useOverridePolicy"; type Deployment = SCHEMA.Deployment & { - releaseChannels: SCHEMA.DeploymentVersionChannel[]; + versionChannels: SCHEMA.DeploymentVersionChannel[]; }; type Policy = NonNullable< @@ -58,8 +58,8 @@ export const UpdateOverridePolicy: React.FC = ({ isLoading={isUpdating} /> )} - {activeTab === EnvironmentDrawerTab.ReleaseChannels && ( - = ({ release, @@ -295,7 +295,7 @@ export const JobDropdownMenu: React.FC<{ resource, environmentId, job, - isPassingReleaseChannel, + isPassingDeploymentVersionChannel, children, }) => { const [open, setOpen] = useState(false); @@ -324,7 +324,7 @@ export const JobDropdownMenu: React.FC<{ )} - {!isActive && !isPassingReleaseChannel && ( + {!isActive && !isPassingDeploymentVersionChannel && ( @@ -343,7 +343,7 @@ export const JobDropdownMenu: React.FC<{ )} - {!isActive && isPassingReleaseChannel && ( + {!isActive && isPassingDeploymentVersionChannel && ( { ? (JSON.parse(linksMetadata) as Record) : null; - const { isPassingReleaseChannel, loading: releaseChannelLoading } = - useReleaseChannel( - job?.release.deployment.id ?? "", - job?.environmentId ?? "", - job?.release.version ?? "", - jobQ.isSuccess, - ); + const { + isPassingDeploymentVersionChannel, + loading: deploymentVersionChannelLoading, + } = useDeploymentVersionChannel( + job?.release.deployment.id ?? "", + job?.environmentId ?? "", + job?.release.version ?? "", + jobQ.isSuccess, + ); - const loading = jobQ.isLoading || releaseChannelLoading; + const loading = jobQ.isLoading || deploymentVersionChannelLoading; return ( @@ -75,7 +77,9 @@ export const JobDrawer: React.FC = () => { resource={job.resource} deployment={job.release.deployment} job={job.job} - isPassingReleaseChannel={isPassingReleaseChannel} + isPassingDeploymentVersionChannel={ + isPassingDeploymentVersionChannel + } > @@ -72,7 +72,7 @@ const DeploymentSelect: React.FC = ({ - {sortedReleaseChannels.length === 0 && ( + {sortedDeploymentVersionChannels.length === 0 && ( = ({ )} - {sortedReleaseChannels.length > 0 && - sortedReleaseChannels.map((rc) => ( + {sortedDeploymentVersionChannels.length > 0 && + sortedDeploymentVersionChannels.map((rc) => ( = ({ @@ -110,37 +110,37 @@ const DeploymentSelect: React.FC = ({ ); }; -type ReleaseChannelProps = { +type DeploymentVersionChannelProps = { environmentPolicy: Policy; deployments: Deployment[]; isLoading: boolean; onUpdate: (data: SCHEMA.UpdateEnvironmentPolicy) => Promise; }; -export const ReleaseChannels: React.FC = ({ - environmentPolicy, - deployments, - isLoading, - onUpdate, -}) => { - const deploymentsWithReleaseChannels = deployments.filter( - (d) => d.releaseChannels.length > 0, +export const DeploymentVersionChannels: React.FC< + DeploymentVersionChannelProps +> = ({ environmentPolicy, deployments, isLoading, onUpdate }) => { + const deploymentsWithDeploymentVersionChannels = deployments.filter( + (d) => d.versionChannels.length > 0, ); - const { releaseChannels } = environmentPolicy; - const currReleaseChannels = Object.fromEntries( - deploymentsWithReleaseChannels.map((d) => [ + const { versionChannels } = environmentPolicy; + const currDeploymentVersionChannels = Object.fromEntries( + deploymentsWithDeploymentVersionChannels.map((d) => [ d.id, - releaseChannels.find((rc) => rc.deploymentId === d.id)?.id ?? null, + versionChannels.find((rc) => rc.deploymentId === d.id)?.id ?? null, ]), ); - const updateReleaseChannel = ( + const updateDeploymentVersionChannel = ( deploymentId: string, channelId: string | null, ) => onUpdate({ - releaseChannels: { ...currReleaseChannels, [deploymentId]: channelId }, + versionChannels: { + ...currDeploymentVersionChannels, + [deploymentId]: channelId, + }, }); return ( @@ -158,8 +158,8 @@ export const ReleaseChannels: React.FC = ({ ))}
diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionDialog.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionDialog.tsx index df19500bd..ec24cb0e6 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionDialog.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionDialog.tsx @@ -41,9 +41,9 @@ type ReleaseConditionDialogProps = { deploymentId?: string; onChange: ( condition: ReleaseCondition | null, - releaseChannelId?: string | null, + deploymentVersionChannelId?: string | null, ) => void; - releaseChannels?: SCHEMA.DeploymentVersionChannel[]; + deploymentVersionChannels?: SCHEMA.DeploymentVersionChannel[]; children: React.ReactNode; }; @@ -51,16 +51,15 @@ export const ReleaseConditionDialog: React.FC = ({ condition, deploymentId, onChange, - releaseChannels = [], + deploymentVersionChannels = [], children, }) => { const [open, setOpen] = useState(false); const [error, setError] = useState(null); - const { setFilter, releaseChannelId } = useReleaseFilter(); + const { setFilter, deploymentVersionChannelId } = useReleaseFilter(); - const [localReleaseChannelId, setLocalReleaseChannelId] = useState< - string | null - >(releaseChannelId); + const [localDeploymentVersionChannelId, setLocalDeploymentVersionChannelId] = + useState(deploymentVersionChannelId); const [localCondition, setLocalCondition] = useState( condition ?? defaultCondition, @@ -83,17 +82,19 @@ export const ReleaseConditionDialog: React.FC = ({ > { if (value === "new-filter") setLocalCondition(localCondition ?? defaultCondition); if (value === "release-channels") - setLocalReleaseChannelId(releaseChannelId); + setLocalDeploymentVersionChannelId(deploymentVersionChannelId); }} > - {releaseChannels.length > 0 && ( + {deploymentVersionChannels.length > 0 && ( Release Channels @@ -109,26 +110,26 @@ export const ReleaseConditionDialog: React.FC = ({