import SelectControl from 'sentry/components/forms/controls/selectControl'; import Input from 'sentry/components/input'; import SelectMembers from 'sentry/components/selectMembers'; import TeamSelector from 'sentry/components/teamSelector'; import type {Organization, Project, SelectValue} from 'sentry/types'; import type {Action, MetricActionTemplate} from 'sentry/views/alerts/rules/metric/types'; import {ActionType, TargetType} from 'sentry/views/alerts/rules/metric/types'; const getPlaceholderForType = (type: ActionType) => { switch (type) { case ActionType.SLACK: return '@username or #channel'; case ActionType.MSTEAMS: // no prefixes for msteams return 'username or channel'; case ActionType.DISCORD: return 'Discord channel ID'; case ActionType.PAGERDUTY: return 'service'; case ActionType.OPSGENIE: return 'team'; default: throw Error('Not implemented'); } }; type Props = { action: Action; disabled: boolean; loading: boolean; onChange: (value: string) => void; organization: Organization; availableAction?: MetricActionTemplate; project?: Project; }; export default function ActionTargetSelector(props: Props) { const {action, availableAction, disabled, loading, onChange, organization, project} = props; const handleChangeTargetIdentifier = (value: SelectValue) => { onChange(value.value); }; const handleChangeSpecificTargetIdentifier = ( e: React.ChangeEvent ) => { onChange(e.target.value); }; switch (action.targetType) { case TargetType.TEAM: case TargetType.USER: const isTeam = action.targetType === TargetType.TEAM; return isTeam ? ( ) : ( ); case TargetType.SPECIFIC: return availableAction?.options ? ( ) : ( ); default: return null; } }