diff --git a/client/src/features/admin/AddResourcePoolButton.tsx b/client/src/features/admin/AddResourcePoolButton.tsx index 8f24446b5c..07fc517cb5 100644 --- a/client/src/features/admin/AddResourcePoolButton.tsx +++ b/client/src/features/admin/AddResourcePoolButton.tsx @@ -39,6 +39,7 @@ import { usePostResourcePoolsMutation, type RemoteConfiguration, } from "../sessionsV2/api/computeResources.api"; +import { PAUSE_SESSION_WARNING_GRACE_PERIOD_SECONDS } from "../sessionsV2/session.constants"; import { useGetNotebooksVersionQuery } from "../versions/versions.api"; import type { ResourcePoolForm } from "./adminComputeResources.types"; import ResourcePoolClusterIdInput from "./forms/ResourcePoolClusterIdInput"; @@ -105,6 +106,7 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) { gpu: defaultQuota.gpu, }, idleThresholdMinutes: undefined, + pauseWarningMinutes: undefined, hibernationThresholdMinutes: undefined, clusterId: "", remote: { @@ -159,6 +161,9 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) { idle_threshold: data.idleThresholdMinutes ? data.idleThresholdMinutes * 60 : undefined, + hibernation_warning_period: data.pauseWarningMinutes + ? data.pauseWarningMinutes * 60 + : undefined, name: data.name, public: data.public, quota: data.quota, @@ -180,6 +185,7 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) { gpu: defaultQuota.gpu, }, idleThresholdMinutes: undefined, + pauseWarningMinutes: undefined, hibernationThresholdMinutes: undefined, clusterId: "", remote: { @@ -248,9 +254,10 @@ function AddResourcePoolModal({ isOpen, toggle }: AddResourcePoolModalProps) { />
Please provide a name
+
+ +
+ + ( + + )} + rules={{ min: 0 }} + /> +
+ Please enter 0 (or leave it blank) for default or anything greater + than 0 to specify a custom value. +
+ +
+
+
+ Warn in advance{" "} + + {hibernationWarningPeriod + ? toFullHumanDuration(hibernationWarningPeriod) + : isLoading + ? "(Loading...)" + : isError + ? "unavailable" + : "(unknown default)"} + +
Delete after{" "} diff --git a/client/src/features/admin/UpdateResourceClassButton.tsx b/client/src/features/admin/UpdateResourceClassButton.tsx index dce6d1306f..6a4ffe7caa 100644 --- a/client/src/features/admin/UpdateResourceClassButton.tsx +++ b/client/src/features/admin/UpdateResourceClassButton.tsx @@ -18,7 +18,13 @@ import cx from "classnames"; import { useCallback, useEffect, useState } from "react"; -import { CheckLg, PlusLg, TrashFill, XLg } from "react-bootstrap-icons"; +import { + CheckLg, + PencilSquare, + PlusLg, + TrashFill, + XLg, +} from "react-bootstrap-icons"; import { Controller, useFieldArray, useForm } from "react-hook-form"; import { Button, @@ -60,7 +66,8 @@ export default function UpdateResourceClassButton({ return ( <> ({ - defaultValues: { + const defaultValues = useMemo( + () => ({ idleThresholdMinutes: resourcePool.idle_threshold ? resourcePool.idle_threshold / 60 : undefined, + pauseWarningMinutes: resourcePool.hibernation_warning_period + ? resourcePool.hibernation_warning_period / 60 + : undefined, hibernationThresholdMinutes: resourcePool.hibernation_threshold ? resourcePool.hibernation_threshold / 60 : undefined, - }, + }), + [ + resourcePool.idle_threshold, + resourcePool.hibernation_warning_period, + resourcePool.hibernation_threshold, + ] + ); + + const { + control, + formState: { errors }, + handleSubmit, + reset, + } = useForm({ + defaultValues, }); // Handle invoking API to update resource pools @@ -117,6 +132,9 @@ function UpdateResourcePoolThresholdsModal({ idle_threshold: data.idleThresholdMinutes ? data.idleThresholdMinutes * 60 : undefined, + hibernation_warning_period: data.pauseWarningMinutes + ? data.pauseWarningMinutes * 60 + : undefined, hibernation_threshold: data.hibernationThresholdMinutes ? data.hibernationThresholdMinutes * 60 : undefined, @@ -126,17 +144,21 @@ function UpdateResourcePoolThresholdsModal({ [id, updateResourcePool] ); - // Reset form and close modal on successful submissions + // Reset form to show up-to-date values useEffect(() => { if (!result.isSuccess) { return; } + reset(defaultValues); toggle(); - }, [result.isSuccess, toggle]); + }, [result.isSuccess, defaultValues, reset, toggle]); + + useEffect(() => { + if (isOpen) reset(defaultValues); + }, [isOpen, reset, defaultValues]); useEffect(() => { if (!isOpen) { - reset(); result.reset(); } }, [isOpen, reset, result]); @@ -158,16 +180,12 @@ function UpdateResourcePoolThresholdsModal({ Please note that changes only affect new sessions, not already running ones.

-
+ {result.error && }
)}
+
+ + ( + + )} + rules={{ min: 0 }} + /> +
+ Please enter 0 (or leave it blank) for default or anything greater + than 0 to specify a custom value. +
+ +
+ +