diff --git a/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx b/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx index a7079841a8..c4b5aaa11f 100644 --- a/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx +++ b/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx @@ -48,6 +48,16 @@ export const MissingTeamAnnotation = () => ( ); +export const InvalidTeamAnnotation = ({ teamName }: { teamName: string }) => ( + + + +); + export const MissingEventsRestEndpoint = () => ( { setShowDialog(x => !x); }, []); - const { value: users, loading, error } = useAsync(async () => { + const { value: usersAndTeam, loading, error } = useAsync(async () => { const allUsers = await api.getUsers(); const usersHashMap = allUsers.reduce( (map: Record, obj: User) => { @@ -94,7 +104,9 @@ export const SplunkOnCallCard = ({ entity }: Props) => { }, {}, ); - return { usersHashMap, userList: allUsers }; + const teams = await api.getTeams(); + const foundTeam = teams.find(teamValue => teamValue.name === team); + return { usersHashMap, foundTeam }; }); if (error instanceof UnauthorizedError) { @@ -118,6 +130,10 @@ export const SplunkOnCallCard = ({ entity }: Props) => { return ; } + if (!usersAndTeam?.foundTeam) { + return ; + } + if (!eventsRestEndpoint) { return ; } @@ -125,8 +141,8 @@ export const SplunkOnCallCard = ({ entity }: Props) => { return ( <> - {users?.usersHashMap && team && ( - + {usersAndTeam?.usersHashMap && team && ( + )}