mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
Fix bugs in MCP user-fields deep linking
- Remove unused hasAnyUserFields export from userFields.ts - Preserve existing query params when building user-fields deep-link URL in UserFieldsModal so the link still routes via ?page=mcp-servers - Only clear ?openUserFields from the URL after the target server is found, so the deep link can be re-applied when the list later loads Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
677809ad18
commit
2d11f40707
3 changed files with 16 additions and 10 deletions
|
|
@ -61,13 +61,23 @@ const UserFieldsModal: React.FC<UserFieldsModalProps> = ({
|
|||
};
|
||||
|
||||
const serverDisplayName = server.server_name || server.alias || server.server_id;
|
||||
|
||||
const buildDeepLinkUrl = (): string => {
|
||||
if (typeof window === "undefined") {
|
||||
return `<dashboard-url>?openUserFields=${server.server_id}`;
|
||||
}
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set("openUserFields", server.server_id);
|
||||
return `${window.location.origin}${window.location.pathname}?${params.toString()}`;
|
||||
};
|
||||
|
||||
const errorPreview = `Error: MCP server "${serverDisplayName}" requires user configuration before use.
|
||||
|
||||
${missing.length > 0 ? `Missing field${missing.length === 1 ? "" : "s"}:` : "All fields configured."}
|
||||
${missing.map((f) => ` • ${f.label || f.name}${f.description ? ` — ${f.description}` : ""}`).join("\n")}
|
||||
|
||||
Please configure your fields at:
|
||||
${typeof window !== "undefined" ? `${window.location.origin}${window.location.pathname}?openUserFields=${server.server_id}` : `<dashboard-url>?openUserFields=${server.server_id}`}
|
||||
${buildDeepLinkUrl()}
|
||||
|
||||
Once configured, retry your request.`;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@ const MCPServers: React.FC<MCPServerProps> = ({ accessToken, userRole, userID })
|
|||
const target = serversWithHealth.find((s) => s.server_id === targetId);
|
||||
if (target) {
|
||||
setUserFieldsServer(target);
|
||||
params.delete("openUserFields");
|
||||
const remaining = params.toString();
|
||||
const newUrl =
|
||||
window.location.pathname + (remaining ? `?${remaining}` : "") + window.location.hash;
|
||||
window.history.replaceState({}, "", newUrl);
|
||||
}
|
||||
params.delete("openUserFields");
|
||||
const remaining = params.toString();
|
||||
const newUrl =
|
||||
window.location.pathname + (remaining ? `?${remaining}` : "") + window.location.hash;
|
||||
window.history.replaceState({}, "", newUrl);
|
||||
}, [serversWithHealth]);
|
||||
|
||||
// Servers with one or more missing user fields for the current user (prototype)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,3 @@ export function getMissingUserFields(
|
|||
values[f.name].trim() === "",
|
||||
);
|
||||
}
|
||||
|
||||
export function hasAnyUserFields(serverId: string): boolean {
|
||||
return getUserFieldDefs(serverId).length > 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue