fix(ui): match the Team ID selector to the backend's proxy-admin-only bypass and show its placeholder

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Devin AI 2026-09-11 09:33:38 +00:00
parent 21a8289251
commit f474c331b0
3 changed files with 16 additions and 4 deletions

View file

@ -816,7 +816,7 @@ const ModelInfoEditForm: React.FC<ModelInfoEditFormProps> = ({
return (
<Select
items={items}
value={(value as string) ?? ""}
value={(value as string | undefined) || null}
onValueChange={(selected: string | null) => onChange(selected ?? "")}
>
<SelectTrigger id={id} className="w-full" onBlur={onBlur}>

View file

@ -1596,7 +1596,19 @@ describe("ModelInfoView", () => {
expect(payload.model_info.team_id).toBe("team-2");
});
it("only offers a team admin the teams they administer", async () => {
it("shows the Team ID placeholder for a model with no team", async () => {
mockUseTeams.mockReturnValue({
data: [{ team_id: "team-1", team_alias: "alpha" }],
isLoading: false,
error: null,
});
const user = userEvent.setup();
await enterEditMode(user);
expect(screen.getByText("Select a team")).toBeInTheDocument();
});
it.each(["Internal User", "Org Admin"])("only offers a %s the teams they administer", async (userRole) => {
mockUseTeams.mockReturnValue({
data: [
{ team_id: "team-1", team_alias: "alpha", members_with_roles: [{ user_id: "123", role: "admin" }] },
@ -1613,7 +1625,7 @@ describe("ModelInfoView", () => {
mockUseModelsInfo.mockReturnValue({ data: { data: [teamModel] }, isLoading: false, error: null });
mockModelInfoV1Call.mockResolvedValue({ data: [teamModel] });
const user = userEvent.setup();
render(<ModelInfoView {...DEFAULT_ADMIN_PROPS} userRole="Internal User" />, { wrapper });
render(<ModelInfoView {...DEFAULT_ADMIN_PROPS} userRole={userRole} />, { wrapper });
await user.click(await screen.findByRole("button", { name: /edit settings/i }));
await user.click(await screen.findByText("alpha (team-1)"));

View file

@ -51,7 +51,7 @@ export const teamsUserCanAssign = (
userRole: string | null,
userID: string | null,
): Team[] | null => {
if (teams == null || all_admin_roles.includes(userRole ?? "") || isOrgAdminSessionRole(userRole)) {
if (teams == null || isProxyAdminRole(userRole ?? "")) {
return teams;
}
return teams.filter((team) => isUserTeamAdminForSingleTeam(team.members_with_roles, userID ?? ""));