diff --git a/plugins/splunk-on-call/src/components/Escalation/EscalationPolicy.tsx b/plugins/splunk-on-call/src/components/Escalation/EscalationPolicy.tsx index 2ebc95aa7c..f51bc4e773 100644 --- a/plugins/splunk-on-call/src/components/Escalation/EscalationPolicy.tsx +++ b/plugins/splunk-on-call/src/components/Escalation/EscalationPolicy.tsx @@ -26,20 +26,23 @@ import { User } from '../types'; type Props = { users: { [key: string]: User }; + team: string; }; -export const EscalationPolicy = ({ users }: Props) => { +export const EscalationPolicy = ({ users, team }: Props) => { const api = useApi(splunkOnCallApiRef); const { value: userNames, loading, error } = useAsync(async () => { const oncalls = await api.getOnCallUsers(); - const users = oncalls.flatMap(oncall => { - return oncall.oncallNow?.flatMap(oncallNow => { - return oncallNow.users?.flatMap(user => { - return user?.onCalluser?.username; + const users = oncalls + .filter(oncall => oncall.team?.name === team) + .flatMap(oncall => { + return oncall.oncallNow?.flatMap(oncallNow => { + return oncallNow.users?.flatMap(user => { + return user?.onCalluser?.username; + }); }); }); - }); return users; }); diff --git a/plugins/splunk-on-call/src/components/Incident/IncidentListItem.tsx b/plugins/splunk-on-call/src/components/Incident/IncidentListItem.tsx index 7384498df5..895844a483 100644 --- a/plugins/splunk-on-call/src/components/Incident/IncidentListItem.tsx +++ b/plugins/splunk-on-call/src/components/Incident/IncidentListItem.tsx @@ -225,7 +225,7 @@ export const IncidentListItem = ({ incident, onIncidentAction }: Props) => { resolveAction={handleResolveIncident} aknowledgeAction={handleAcknowledgeIncident} /> - + - Boolean(entity.metadata.annotations?.[SPLUNK_ON_CALL_INTEGRATION_KEY]); + Boolean(entity.metadata.annotations?.[SPLUNK_ON_CALL_TEAM]); type Props = { entity: Entity; }; -export const SplunkOnCallCard = () => { +export const SplunkOnCallCard = ({ entity }: Props) => { const classes = useStyles(); const api = useApi(splunkOnCallApiRef); const [showDialog, setShowDialog] = useState(false); const [refreshIncidents, setRefreshIncidents] = useState(false); + const team = entity.metadata.annotations![SPLUNK_ON_CALL_TEAM]; const handleRefresh = useCallback(() => { setRefreshIncidents(x => !x); @@ -127,7 +128,9 @@ export const SplunkOnCallCard = () => { - {users?.usersHashMap && } + {users?.usersHashMap && ( + + )} {users && ( - - Select users - } + renderValue={selected => ( +
+ {(selected as string[]).map(value => ( + + ))} +
+ )} + MenuProps={MenuProps} + > + {users.map(user => ( + + {user.firstName} {user.lastName} + ))} - - )} - MenuProps={MenuProps} - > - {users.map(user => ( - - {user.firstName} {user.lastName} - - ))} - -
- - Select an escalation poilicy - - + + + + Select an escalation poilicy + + +
+ Acknowledge Behavior @@ -271,7 +298,7 @@ export const TriggerDialog = ({ fullWidth rows="2" margin="normal" - label="Problem details" + label="Incident body" variant="outlined" onChange={detailsChanged} />