From 99cc5977d15580f2628e7fc9779f6b35548c4eaf Mon Sep 17 00:00:00 2001 From: GokayAI <60583610+gokay-ai@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:21:51 +0100 Subject: [PATCH] fix(ui): extract team models dirty check into a helper Keeps the dirty-field test under the no-long-condition-chain lint budget. Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com> --- .../src/components/team/teamModelAccess.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/team/teamModelAccess.ts b/ui/litellm-dashboard/src/components/team/teamModelAccess.ts index 93d6cf68c50..9399845efce 100644 --- a/ui/litellm-dashboard/src/components/team/teamModelAccess.ts +++ b/ui/litellm-dashboard/src/components/team/teamModelAccess.ts @@ -104,17 +104,22 @@ export function computeTeamModelBadges( ]; } +// react-hook-form reports a dirty array field as `true` or as an array/object of flags. +function isFieldDirty(dirty: unknown): boolean { + if (dirty === true) { + return true; + } + if (dirty === null || typeof dirty !== "object") { + return false; + } + return Object.values(dirty as Record).some(Boolean); +} + export function modelsFieldForTeamUpdate( dirtyModels: unknown, models: string[] | undefined, ): { models: string[] } | Record { - const isDirty = - dirtyModels === true || - (Array.isArray(dirtyModels) && dirtyModels.some(Boolean)) || - (dirtyModels !== null && - typeof dirtyModels === "object" && - Object.values(dirtyModels as Record).some(Boolean)); - if (!isDirty) { + if (!isFieldDirty(dirtyModels)) { return {}; } return { models: normalizeTeamModelSelection(models) };