<commit_before>import React from 'react';
import { c } from 'ttag';
import PropTypes from 'prop-types';
import {
    Alert,
    DropdownActions,
    ConfirmModal,
    useModals,
    useApiWithoutResult,
    useNotifications,
    useEventManager
} from 'react-components';
import { deleteDomain } from 'proton-shared/lib/api/domains';

import DomainModal from './DomainModal';
import CatchAllModal from './CatchAllModal';

const DomainActions = ({ domain, domainAddresses }) => {
    const { request } = useApiWithoutResult(deleteDomain);
    const { createNotification } = useNotifications();
    const { createModal } = useModals();
    const { call } = useEventManager();

    const handleConfirmDelete = async () => {
        await request(domain.ID);
        await call();
        createNotification({ text: c('Success message').t`Domain deleted` });
    };

    const list = [
        {
            text: c('Action').t`Edit`,
            onClick: () => createModal(<DomainModal domain={domain} domainAddresses={domainAddresses} />)
        },
        {
            text: c('Action').t`Set catch-all`,
            onClick: () => createModal(<CatchAllModal domain={domain} domainAddresses={domainAddresses} />)
        },
        {
            text: c('Action').t`Delete`,
            onClick: () => {
                createModal(
                    <ConfirmModal onConfirm={handleConfirmDelete} title={c('Title').t`Delete domain`}>
                        <Alert>{c('Info').t`Are you sure you want to delete this domain?`}</Alert>
                    </ConfirmModal>
                );
            }
        }
    ];

    return <DropdownActions className="pm-button--small" list={list} />;<commit_msg>Fix MAILWEB-400 - Display "Set catch-all" when we have addresses<commit_after>import React from 'react';
import { c } from 'ttag';
import PropTypes from 'prop-types';
import {
    Alert,
    DropdownActions,
    ConfirmModal,
    useModals,
    useApiWithoutResult,
    useNotifications,
    useEventManager
} from 'react-components';
import { deleteDomain } from 'proton-shared/lib/api/domains';

import DomainModal from './DomainModal';
import CatchAllModal from './CatchAllModal';

const DomainActions = ({ domain, domainAddresses }) => {
    const { request } = useApiWithoutResult(deleteDomain);
    const { createNotification } = useNotifications();
    const { createModal } = useModals();
    const { call } = useEventManager();

    const handleConfirmDelete = async () => {
        await request(domain.ID);
        await call();
        createNotification({ text: c('Success message').t`Domain deleted` });
    };

    const list = [
        {
            text: c('Action').t`Edit`,
            onClick: () => createModal(<DomainModal domain={domain} domainAddresses={domainAddresses} />)
        },
        Array.isArray(domainAddresses) &&
            domainAddresses.length && {
                text: c('Action').t`Set catch-all`,
                onClick: () => createModal(<CatchAllModal domain={domain} domainAddresses={domainAddresses} />)
            },
        {
            text: c('Action').t`Delete`,
            onClick: () => {
                createModal(
                    <ConfirmModal onConfirm={handleConfirmDelete} title={c('Title').t`Delete domain`}>
                        <Alert>{c('Info').t`Are you sure you want to delete this domain?`}</Alert>
                    </ConfirmModal>
                );
            }
        }
    ].filter(Boolean);

    return <DropdownActions className="pm-button--small" list={list} />;
{'fraction_non_alphanumeric': 0.13632538569424965, 'fraction_numerical': 0.0008415147265077139, 'mean_word_length': 2.448742746615087, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5625120', 'n_tokens_mistral': 970, 'n_tokens_neox': 947, 'n_words': 209}