From 2027cf957f576434d01bacb3d396ea8ac5481719 Mon Sep 17 00:00:00 2001 From: Aditya Choudhari Date: Sun, 16 Mar 2025 10:00:39 -0700 Subject: [PATCH 1/4] fix: Init release channel to dep vers channel frontend refactor --- .../flow-diagram/EnvironmentNode.tsx | 78 ++++++++++--------- .../release-table/ResourceReleaseTable.tsx | 14 ++-- .../(sidebar)/_components/DeploymentCTA.tsx | 6 +- .../release-cell/ReleaseEnvironmentCell.tsx | 18 +++-- ... CreateDeploymentVersionChannelDialog.tsx} | 15 ++-- ...tsx => DeploymentVersionChannelsTable.tsx} | 20 +++-- .../(sidebar)/channels/page.tsx | 6 +- ...nels.tsx => DeploymentVersionChannels.tsx} | 42 +++++----- .../policies/channels/page.tsx | 7 +- ...tsx => DeploymentVersionChannelDrawer.tsx} | 18 +++-- ...x => DeploymentVersionChannelDropdown.tsx} | 29 ++++--- .../_components/channel/drawer/Overview.tsx | 9 ++- ...s => useDeploymentVersionChannelDrawer.ts} | 13 +++- .../environment/drawer/EnvironmentDrawer.tsx | 8 +- .../drawer/policy-override/UpdateOverride.tsx | 6 +- .../_components/environment/drawer/tabs.ts | 2 +- .../(app)/_components/job/JobDropdownMenu.tsx | 8 +- .../_components/job/drawer/JobDrawer.tsx | 10 ++- .../policy/drawer/EnvironmentPolicyDrawer.tsx | 16 ++-- ...nels.tsx => DeploymentVersionChannels.tsx} | 44 +++++------ .../condition/ReleaseConditionDialog.tsx | 17 ++-- ...nnel.ts => useDeploymentVersionChannel.ts} | 23 +++--- .../src/app/[workspaceSlug]/(app)/layout.tsx | 4 +- 23 files changed, 225 insertions(+), 188 deletions(-) rename apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/{CreateReleaseChannelDialog.tsx => CreateDeploymentVersionChannelDialog.tsx} (94%) rename apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/{ReleaseChannelsTable.tsx => DeploymentVersionChannelsTable.tsx} (68%) rename apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/{ReleaseChannels.tsx => DeploymentVersionChannels.tsx} (80%) rename apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/{ReleaseChannelDrawer.tsx => DeploymentVersionChannelDrawer.tsx} (82%) rename apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/{ReleaseChannelDropdown.tsx => DeploymentVersionChannelDropdown.tsx} (82%) rename apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/{useReleaseChannelDrawer.ts => useDeploymentVersionChannelDrawer.ts} (57%) rename apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy/form/{ReleaseChannels.tsx => DeploymentVersionChannels.tsx} (79%) rename apps/webservice/src/app/[workspaceSlug]/(app)/_hooks/channel/{useReleaseChannel.ts => useDeploymentVersionChannel.ts} (64%) 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..c9def0c6f 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,14 +132,14 @@ 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, releaseChannelId, loading } = + useDeploymentVersionChannel(deploymentId, environmentId, releaseVersion); return (
@@ -149,36 +149,40 @@ const ReleaseChannelCheck: React.FC = ({ No release channel )} - {!loading && releaseChannelId != null && !isPassingReleaseChannel && ( - <> - - - Blocked by{" "} - - - - )} - {!loading && releaseChannelId != null && isPassingReleaseChannel && ( - <> - - - Passing{" "} - - - - )} + {!loading && + releaseChannelId != null && + !isPassingDeploymentVersionChannel && ( + <> + + + Blocked by{" "} + + + + )} + {!loading && + releaseChannelId != null && + isPassingDeploymentVersionChannel && ( + <> + + + Passing{" "} + + + + )}
); }; @@ -265,7 +269,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..31df6a016 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,8 +133,8 @@ const CollapsibleTableRow: React.FC = ({ return newState; }); - const { isPassingReleaseChannel, loading: releaseChannelLoading } = - useReleaseChannel(deployment.id, environment.id, release.version); + const { isPassingDeploymentVersionChannel, loading: releaseChannelLoading } = + useDeploymentVersionChannel(deployment.id, environment.id, release.version); const loading = approvalsQ.isLoading || releaseChannelLoading; @@ -312,7 +312,9 @@ const CollapsibleTableRow: React.FC = ({ id: trigger.job.id, status: trigger.job.status, }} - isPassingReleaseChannel={isPassingReleaseChannel} + isPassingDeploymentVersionChannel={ + isPassingDeploymentVersionChannel + } > - + ); 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..6c296c091 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,7 @@ const ReleaseEnvironmentCell: React.FC = ({ variant="link" size="sm" onClick={() => - setReleaseChannelId(blockedEnv.releaseChannelId ?? null) + setDeploymentVersionChannelId(blockedEnv.releaseChannelId ?? 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 94% 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..6d4a81009 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; }; @@ -57,8 +57,8 @@ const schema = z.object({ .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,14 +67,14 @@ export const CreateReleaseChannelDialog: React.FC< deploymentSlug: string; }>(); - const createReleaseChannel = + const createDeploymentVersionChannel = api.deployment.releaseChannel.create.useMutation(); const router = useRouter(); const form = useForm({ schema }); const onSubmit = form.handleSubmit((data) => { const filter = getFinalFilter(data.releaseFilter); - createReleaseChannel + createDeploymentVersionChannel .mutateAsync({ ...data, deploymentId, releaseFilter: filter }) .then(() => form.reset(data)) .then(() => router.refresh()) @@ -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/ReleaseChannelsTable.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/DeploymentVersionChannelsTable.tsx similarity index 68% rename from apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx rename to apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/DeploymentVersionChannelsTable.tsx index de7f1d33b..a8dd1e522 100644 --- 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/DeploymentVersionChannelsTable.tsx @@ -12,17 +12,21 @@ import { TableRow, } from "@ctrlplane/ui/table"; -import { useReleaseChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer"; +import { useDeploymentVersionChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer"; import { ReleaseConditionBadge } from "~/app/[workspaceSlug]/(app)/_components/release/condition/ReleaseConditionBadge"; -type ReleaseChannel = SCHEMA.DeploymentVersionChannel & { total: number }; +type DeploymentVersionChannel = SCHEMA.DeploymentVersionChannel & { + total: number; +}; -type ReleaseChannelTableProps = { releaseChannels: ReleaseChannel[] }; +type DeploymentVersionChannelTableProps = { + releaseChannels: DeploymentVersionChannel[]; +}; -export const ReleaseChannelsTable: React.FC = ({ - releaseChannels, -}) => { - const { setReleaseChannelId } = useReleaseChannelDrawer(); +export const DeploymentVersionChannelsTable: React.FC< + DeploymentVersionChannelTableProps +> = ({ releaseChannels }) => { + const { setDeploymentVersionChannelId } = useDeploymentVersionChannelDrawer(); return ( @@ -38,7 +42,7 @@ export const ReleaseChannelsTable: React.FC = ({ setReleaseChannelId(releaseChannel.id)} + onClick={() => setDeploymentVersionChannelId(releaseChannel.id)} > {releaseChannel.name} {releaseChannel.description} 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..b42dd0cda 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; @@ -26,7 +26,7 @@ export default async function ReleaseChannelsPage(props: { return (
- +
); } 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 80% 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..ce1933eb0 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 @@ -22,7 +22,7 @@ type Deployment = RouterOutputs["deployment"]["bySystemId"][number]; type DeploymentSelectProps = { deployment: Deployment; releaseChannels: Record; - updateReleaseChannel: ( + updateDeploymentVersionChannel: ( deploymentId: string, channelId: string | null, ) => Promise; @@ -31,7 +31,7 @@ type DeploymentSelectProps = { const DeploymentSelect: React.FC = ({ deployment, releaseChannels, - updateReleaseChannel, + updateDeploymentVersionChannel, }) => { const [open, setOpen] = useState(false); const releaseChannelId = releaseChannels[deployment.id]; @@ -40,15 +40,15 @@ const DeploymentSelect: React.FC = ({ ); 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.releaseChannels.sort( + (a, b) => a.name.localeCompare(b.name), ); return ( @@ -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) => ( = ({ ); }; -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( + const deploymentsWithDeploymentVersionChannels = deployments.filter( (d) => d.releaseChannels.length > 0, ); const { releaseChannels } = environmentPolicy; - const currReleaseChannels = Object.fromEntries( - deploymentsWithReleaseChannels.map((d) => [ + const currDeploymentVersionChannels = Object.fromEntries( + deploymentsWithDeploymentVersionChannels.map((d) => [ d.id, releaseChannels.find((rc) => rc.deploymentId === d.id)?.id ?? null, ]), ); - const updateReleaseChannel = ( + const updateDeploymentVersionChannel = ( deploymentId: string, channelId: string | null, ) => onUpdate({ - releaseChannels: { ...currReleaseChannels, [deploymentId]: channelId }, + releaseChannels: { + ...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 82% 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..276d38164 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,16 +14,16 @@ 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(); +export const DeploymentVersionChannelDrawer: React.FC = () => { + const { releaseChannelId, removeDeploymentVersionChannelId } = + useDeploymentVersionChannelDrawer(); const isOpen = Boolean(releaseChannelId); - const setIsOpen = removeReleaseChannelId; + const setIsOpen = removeDeploymentVersionChannelId; const releaseChannelQ = api.deployment.releaseChannel.byId.useQuery( releaseChannelId ?? "", @@ -50,11 +50,13 @@ export const ReleaseChannelDrawer: React.FC = () => { <> {releaseChannel.name} - + - +
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 82% 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..d6a52345d 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 = { +type DeleteDeploymentVersionChannelDialogProps = { releaseChannelId: string; onClose: () => void; children: React.ReactNode; }; -const DeleteReleaseChannelDialog: React.FC = ({ - releaseChannelId, - onClose, - children, -}) => { +const DeleteDeploymentVersionChannelDialog: React.FC< + DeleteDeploymentVersionChannelDialogProps +> = ({ releaseChannelId, onClose, children }) => { const [open, setOpen] = useState(false); const router = useRouter(); @@ -45,10 +43,10 @@ const DeleteReleaseChannelDialog: React.FC = ({ router.replace(`${url.pathname}?${url.searchParams.toString()}`); }; - const deleteReleaseChannel = + const deleteDeploymentVersionChannel = api.deployment.releaseChannel.delete.useMutation(); const onDelete = () => - deleteReleaseChannel + deleteDeploymentVersionChannel .mutateAsync(releaseChannelId) .then(() => deleteParams()) .then(() => router.refresh()) @@ -77,7 +75,7 @@ const DeleteReleaseChannelDialog: React.FC = ({
Delete @@ -88,21 +86,20 @@ const DeleteReleaseChannelDialog: React.FC = ({ ); }; -type ReleaseChannelDropdownProps = { +type DeploymentVersionChannelDropdownProps = { releaseChannelId: string; children: React.ReactNode; }; -export const ReleaseChannelDropdown: React.FC = ({ - releaseChannelId, - children, -}) => { +export const DeploymentVersionChannelDropdown: React.FC< + DeploymentVersionChannelDropdownProps +> = ({ releaseChannelId, children }) => { const [open, setOpen] = useState(false); return ( {children} - setOpen(false)} > @@ -113,7 +110,7 @@ export const ReleaseChannelDropdown: React.FC = ({ 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..d81dca61f 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 @@ -99,11 +99,11 @@ export const Overview: React.FC = ({ releaseChannel }) => { const router = useRouter(); const utils = api.useUtils(); - const updateReleaseChannel = + const updateDeploymentVersionChannel = api.deployment.releaseChannel.update.useMutation(); const onSubmit = form.handleSubmit((data) => { const releaseFilter = getFinalFilter(data.releaseFilter); - updateReleaseChannel + updateDeploymentVersionChannel .mutateAsync({ id: releaseChannel.id, data: { ...data, releaseFilter } }) .then(() => form.reset({ ...data, releaseFilter })) .then(() => @@ -187,7 +187,10 @@ export const Overview: React.FC = ({ releaseChannel }) => {
diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer.ts b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer.ts similarity index 57% rename from apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer.ts rename to apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer.ts index 87d05ecbb..d294dac3c 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useReleaseChannelDrawer.ts +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/useDeploymentVersionChannelDrawer.ts @@ -2,19 +2,24 @@ import { useRouter, useSearchParams } from "next/navigation"; const param = "release_channel_id"; -export const useReleaseChannelDrawer = () => { +export const useDeploymentVersionChannelDrawer = () => { const router = useRouter(); const params = useSearchParams(); const releaseChannelId = params.get(param); - const setReleaseChannelId = (id: string | null) => { + 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 removeReleaseChannelId = () => setReleaseChannelId(null); + const removeDeploymentVersionChannelId = () => + setDeploymentVersionChannelId(null); - return { releaseChannelId, setReleaseChannelId, removeReleaseChannelId }; + return { + releaseChannelId, + setDeploymentVersionChannelId, + removeDeploymentVersionChannelId, + }; }; 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..d6fd839f7 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,7 +3,7 @@ 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"; @@ -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( + const { isPassingDeploymentVersionChannel, loading: releaseChannelLoading } = + useDeploymentVersionChannel( job?.release.deployment.id ?? "", job?.environmentId ?? "", job?.release.version ?? "", @@ -75,7 +75,9 @@ export const JobDrawer: React.FC = () => { resource={job.resource} deployment={job.release.deployment} job={job.job} - isPassingReleaseChannel={isPassingReleaseChannel} + isPassingDeploymentVersionChannel={ + isPassingDeploymentVersionChannel + } >
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..42d070120 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 @@ -58,9 +58,8 @@ export const ReleaseConditionDialog: React.FC = ({ const [error, setError] = useState(null); const { setFilter, releaseChannelId } = useReleaseFilter(); - const [localReleaseChannelId, setLocalReleaseChannelId] = useState< - string | null - >(releaseChannelId); + const [localDeploymentVersionChannelId, setLocalDeploymentVersionChannelId] = + useState(releaseChannelId); const [localCondition, setLocalCondition] = useState( condition ?? defaultCondition, @@ -90,7 +89,7 @@ export const ReleaseConditionDialog: React.FC = ({ if (value === "new-filter") setLocalCondition(localCondition ?? defaultCondition); if (value === "release-channels") - setLocalReleaseChannelId(releaseChannelId); + setLocalDeploymentVersionChannelId(releaseChannelId); }} > {releaseChannels.length > 0 && ( @@ -109,13 +108,13 @@ export const ReleaseConditionDialog: React.FC = ({
@@ -38,22 +38,24 @@ export const DeploymentVersionChannelsTable: React.FC< - {releaseChannels.map((releaseChannel) => ( + {deploymentVersionChannels.map((deploymentVersionChannel) => ( setDeploymentVersionChannelId(releaseChannel.id)} + onClick={() => + setDeploymentVersionChannelId(deploymentVersionChannel.id) + } > - {releaseChannel.name} - {releaseChannel.description} + {deploymentVersionChannel.name} + {deploymentVersionChannel.description} - {releaseChannel.releaseFilter != null && ( + {deploymentVersionChannel.versionSelector != null && ( )} - {releaseChannel.total} + {deploymentVersionChannel.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 b42dd0cda..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 @@ -21,12 +21,14 @@ export default async function DeploymentVersionChannelsPage(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..b37bc2d72 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 @@ -35,8 +35,8 @@ 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( + const deploymentVersionChannel = searchParams["release-channel-id"] + ? await api.deployment.version.channel.byId( searchParams["release-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/DeploymentVersionChannels.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/DeploymentVersionChannels.tsx index ce1933eb0..f179228a0 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/DeploymentVersionChannels.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/policies/channels/DeploymentVersionChannels.tsx @@ -21,7 +21,7 @@ type Deployment = RouterOutputs["deployment"]["bySystemId"][number]; type DeploymentSelectProps = { deployment: Deployment; - releaseChannels: Record; + deploymentVersionChannels: Record; updateDeploymentVersionChannel: ( deploymentId: string, channelId: string | null, @@ -30,13 +30,13 @@ type DeploymentSelectProps = { const DeploymentSelect: React.FC = ({ deployment, - releaseChannels, + 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) => @@ -47,7 +47,7 @@ const DeploymentSelect: React.FC = ({ systemSlug?: string; }>(); - const sortedDeploymentVersionChannels = deployment.releaseChannels.sort( + const sortedDeploymentVersionChannels = deployment.versionChannels.sort( (a, b) => a.name.localeCompare(b.name), ); @@ -64,7 +64,7 @@ const DeploymentSelect: React.FC = ({ > - {releaseChannel?.name ?? `Select release channel...`} + {deploymentVersionChannel?.name ?? `Select release channel...`} @@ -102,7 +102,7 @@ const DeploymentSelect: React.FC = ({ @@ -121,14 +121,14 @@ export const DeploymentVersionChannels: React.FC< const { onUpdate, isPending } = useUpdatePolicy(environmentPolicy.id); const deploymentsWithDeploymentVersionChannels = deployments.filter( - (d) => d.releaseChannels.length > 0, + (d) => d.versionChannels.length > 0, ); - const { releaseChannels } = environmentPolicy; + 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, ]), ); @@ -137,7 +137,7 @@ export const DeploymentVersionChannels: React.FC< channelId: string | null, ) => onUpdate({ - releaseChannels: { + versionChannels: { ...currDeploymentVersionChannels, [deploymentId]: channelId, }, @@ -163,7 +163,7 @@ export const DeploymentVersionChannels: React.FC< ))} diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx index 276d38164..8eb0a8c6a 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/channel/drawer/DeploymentVersionChannelDrawer.tsx @@ -20,18 +20,19 @@ import { Usage } from "./Usage"; import { useDeploymentVersionChannelDrawer } from "./useDeploymentVersionChannelDrawer"; export const DeploymentVersionChannelDrawer: React.FC = () => { - const { releaseChannelId, removeDeploymentVersionChannelId } = + const { deploymentVersionChannelId, removeDeploymentVersionChannelId } = useDeploymentVersionChannelDrawer(); - const isOpen = Boolean(releaseChannelId); + 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,12 +47,12 @@ export const DeploymentVersionChannelDrawer: React.FC = () => { )} - {!loading && releaseChannel != null && ( + {!loading && deploymentVersionChannel != null && ( <> - {releaseChannel.name} + {deploymentVersionChannel.name} @@ -102,7 +102,7 @@ const DeploymentSelect: React.FC = ({ @@ -121,14 +121,14 @@ export const DeploymentVersionChannels: React.FC< DeploymentVersionChannelProps > = ({ environmentPolicy, deployments, isLoading, onUpdate }) => { const deploymentsWithDeploymentVersionChannels = deployments.filter( - (d) => d.releaseChannels.length > 0, + (d) => d.versionChannels.length > 0, ); - const { releaseChannels } = environmentPolicy; + 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, ]), ); @@ -137,7 +137,7 @@ export const DeploymentVersionChannels: React.FC< channelId: string | null, ) => onUpdate({ - releaseChannels: { + versionChannels: { ...currDeploymentVersionChannels, [deploymentId]: channelId, }, @@ -158,7 +158,7 @@ export const DeploymentVersionChannels: 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 42d070120..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,15 +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 [localDeploymentVersionChannelId, setLocalDeploymentVersionChannelId] = - useState(releaseChannelId); + useState(deploymentVersionChannelId); const [localCondition, setLocalCondition] = useState( condition ?? defaultCondition, @@ -82,17 +82,19 @@ export const ReleaseConditionDialog: React.FC = ({ > { if (value === "new-filter") setLocalCondition(localCondition ?? defaultCondition); if (value === "release-channels") - setLocalDeploymentVersionChannelId(releaseChannelId); + setLocalDeploymentVersionChannelId(deploymentVersionChannelId); }} > - {releaseChannels.length > 0 && ( + {deploymentVersionChannels.length > 0 && ( Release Channels @@ -110,24 +112,24 @@ export const ReleaseConditionDialog: React.FC = ({