actionSpecificTargetSelector.tsx 974 B

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