123456789101112131415161718192021222324252627282930313233343536373839 |
- import {t} from 'sentry/locale';
- import {Rule} from '../types';
- import ModalManager from './modalManager';
- type ModalManagerProps = ModalManager['props'];
- type Props = Omit<ModalManagerProps, 'title' | 'initialValues' | 'onGetNewRules'> & {
- rule: Rule;
- };
- const Edit = ({savedRules, rule, ...props}: Props) => {
- const handleGetNewRules = (
- values: Parameters<ModalManagerProps['onGetNewRules']>[0]
- ) => {
- const updatedRule = {...values, id: rule.id};
- const newRules = savedRules.map(savedRule => {
- if (savedRule.id === updatedRule.id) {
- return updatedRule;
- }
- return savedRule;
- }) as Array<Rule>;
- return newRules;
- };
- return (
- <ModalManager
- {...props}
- savedRules={savedRules}
- title={t('Edit an advanced data scrubbing rule')}
- initialState={rule}
- onGetNewRules={handleGetNewRules}
- />
- );
- };
- export default Edit;
|