mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
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>
This commit is contained in:
parent
f94d352a82
commit
99cc5977d1
1 changed files with 12 additions and 7 deletions
|
|
@ -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<string, unknown>).some(Boolean);
|
||||
}
|
||||
|
||||
export function modelsFieldForTeamUpdate(
|
||||
dirtyModels: unknown,
|
||||
models: string[] | undefined,
|
||||
): { models: string[] } | Record<string, never> {
|
||||
const isDirty =
|
||||
dirtyModels === true ||
|
||||
(Array.isArray(dirtyModels) && dirtyModels.some(Boolean)) ||
|
||||
(dirtyModels !== null &&
|
||||
typeof dirtyModels === "object" &&
|
||||
Object.values(dirtyModels as Record<string, unknown>).some(Boolean));
|
||||
if (!isDirty) {
|
||||
if (!isFieldDirty(dirtyModels)) {
|
||||
return {};
|
||||
}
|
||||
return { models: normalizeTeamModelSelection(models) };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue