actionSpecificTargetSelector.tsx 914 B

12345678910111213141516171819202122232425262728293031323334
  1. import Input from 'sentry/components/input';
  2. import {t} from 'sentry/locale';
  3. import {Action, ActionType, TargetType} from 'sentry/views/alerts/rules/metric/types';
  4. type Props = {
  5. action: Action;
  6. disabled: boolean;
  7. onChange: (value: string) => void;
  8. };
  9. function ActionSpecificTargetSelector({action, disabled, onChange}: Props) {
  10. const handleChangeSpecificTargetIdentifier = (
  11. e: React.ChangeEvent<HTMLInputElement>
  12. ) => {
  13. onChange(e.target.value);
  14. };
  15. if (action.targetType !== TargetType.SPECIFIC || action.type !== ActionType.SLACK) {
  16. return null;
  17. }
  18. return (
  19. <Input
  20. type="text"
  21. autoComplete="off"
  22. disabled={disabled}
  23. key="inputChannelId"
  24. value={action.inputChannelId || ''}
  25. onChange={handleChangeSpecificTargetIdentifier}
  26. placeholder={t('optional: channel ID or user ID')}
  27. />
  28. );
  29. }
  30. export default ActionSpecificTargetSelector;