From 3e45cde6206e8a18e2d1fcfd11da94c0a0132a83 Mon Sep 17 00:00:00 2001 From: yomybaby <621215+yomybaby@users.noreply.github.com> Date: Wed, 23 Oct 2024 02:28:25 +0000 Subject: [PATCH] fix: 0 desired routing count in endpoint edit page (#2768) **Changes:** This PR modifies the `ServiceLauncherPageContent` component to use the nullish coalescing operator (`??`) instead of the logical OR operator (`||`) when setting the `desiredRoutingCount` value. This ensures that a value of `0` for `endpoint?.desired_session_count` is respected rather than defaulting to `1`. **Rationale:** The previous implementation using `||` would treat `0` as a falsy value, causing it to default to `1`. By using `??`, we now correctly handle cases where `desired_session_count` is explicitly set to `0`, while still defaulting to `1` when the value is `null` or `undefined`. **Impact:** This change allows users to set a `desired_session_count` of `0` for endpoints, which may be necessary for certain service configurations or management scenarios. --- react/src/components/BAILink.tsx | 1 - react/src/components/ServiceLauncherPageContent.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/react/src/components/BAILink.tsx b/react/src/components/BAILink.tsx index a14ec56ed..6bfd558e8 100644 --- a/react/src/components/BAILink.tsx +++ b/react/src/components/BAILink.tsx @@ -1,5 +1,4 @@ import { createStyles } from 'antd-style'; -import { X } from 'lucide-react'; import React from 'react'; import { Link, LinkProps } from 'react-router-dom'; diff --git a/react/src/components/ServiceLauncherPageContent.tsx b/react/src/components/ServiceLauncherPageContent.tsx index 3f444277f..faa6aacbd 100644 --- a/react/src/components/ServiceLauncherPageContent.tsx +++ b/react/src/components/ServiceLauncherPageContent.tsx @@ -638,7 +638,7 @@ const ServiceLauncherPageContent: React.FC = ({ serviceName: endpoint?.name, resourceGroup: endpoint?.resource_group, allocationPreset: 'custom', - desiredRoutingCount: endpoint?.desired_session_count || 1, + desiredRoutingCount: endpoint?.desired_session_count ?? 1, // FIXME: memory doesn't applied to resource allocation resource: { cpu: parseInt(JSON.parse(endpoint?.resource_slots)?.cpu),