From 27c464c83367cec471aeb522631bd178e7bda31f Mon Sep 17 00:00:00 2001 From: Mihaly Gyongyosi Date: Wed, 7 Jan 2026 15:42:04 +0100 Subject: [PATCH] Address feedback --- public/app/features/teams/TeamGroupSync.tsx | 4 ++-- public/app/features/teams/hooks.ts | 23 +++++++-------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/public/app/features/teams/TeamGroupSync.tsx b/public/app/features/teams/TeamGroupSync.tsx index 9a22b42c10d..f147f5e10ed 100644 --- a/public/app/features/teams/TeamGroupSync.tsx +++ b/public/app/features/teams/TeamGroupSync.tsx @@ -47,8 +47,8 @@ export const TeamGroupSync = ({ isReadOnly, teamUid }: Props) => { if (!group.groupId) { return; } - // @ts-ignore - await removeTeamGroup({ teamId: teamUid, groupId: group.groupId, uid: group.uid }); + // group.uid is always defined here because it comes from the API + await removeTeamGroup({ teamId: teamUid, groupId: group.groupId, uid: group.uid! }); }; const isNewGroupValid = () => { diff --git a/public/app/features/teams/hooks.ts b/public/app/features/teams/hooks.ts index 37b0c4efa0b..264728b342d 100644 --- a/public/app/features/teams/hooks.ts +++ b/public/app/features/teams/hooks.ts @@ -174,17 +174,13 @@ export const useGetExternalGroupMappings = (args: { teamId: string }) => { const { data: newApiData, ...newApiRest } = useListExternalGroupMappingQuery({}); const groups: TeamGroupDto[] = useMemo(() => { + // FIXME: Consider using the search API which has sorting support return (newApiData?.items || []) .filter((item) => item.spec.teamRef.name === args.teamId) - .map( - (item) => - // eslint-disable-next-line - ({ - groupId: item.spec.externalGroupId, - teamId: item.spec.teamRef.name, - uid: item.metadata.name, - }) as unknown as TeamGroupDto - ); + .map((item) => ({ + groupId: item.spec.externalGroupId, + uid: item.metadata.name, + })); }, [newApiData, args.teamId]); return { @@ -203,8 +199,6 @@ export const useAddExternalGroupMapping = () => { const add = async (args: { teamId: string; teamGroupMapping: { groupId: string } }) => { return addNew({ externalGroupMapping: { - apiVersion: 'iam.grafana.app/v0alpha1', - kind: 'ExternalGroupMapping', metadata: { generateName: 'external-group-mapping-', }, @@ -228,11 +222,8 @@ export const useRemoveExternalGroupMapping = () => { const [deleteMapping, deleteResult] = useDeleteExternalGroupMappingMutation(); - const remove = async (args: { teamId: string; groupId: string; uid?: string }) => { - if (args.uid) { - return deleteMapping({ name: args.uid }); - } - return { data: {} }; + const remove = async (args: { teamId: string; groupId: string; uid: string }) => { + return deleteMapping({ name: args.uid }); }; return [remove, deleteResult] as const;