add.tsx 684 B

123456789101112131415161718192021222324252627
  1. import {t} from 'sentry/locale';
  2. import {Rule} from '../types';
  3. import ModalManager from './modalManager';
  4. type ModalManagerProps = ModalManager['props'];
  5. type Props = Omit<ModalManagerProps, 'title' | 'initialValues' | 'onGetNewRules'>;
  6. const Add = ({savedRules, ...props}: Props) => {
  7. const handleGetNewRules = (
  8. values: Parameters<ModalManagerProps['onGetNewRules']>[0]
  9. ) => {
  10. return [...savedRules, {...values, id: savedRules.length}] as Array<Rule>;
  11. };
  12. return (
  13. <ModalManager
  14. {...props}
  15. savedRules={savedRules}
  16. title={t('Add an advanced data scrubbing rule')}
  17. onGetNewRules={handleGetNewRules}
  18. />
  19. );
  20. };
  21. export default Add;