<commit_before>import React from 'react';
import { c } from 'ttag';
import { Icon, Table, TableHeader, TableBody, TableRow, DropdownActions, Badge } from 'react-components';
import { getIsCalendarDisabled, getIsCalendarProbablyActive } from 'proton-shared/lib/calendar/calendar';
import { Calendar } from 'proton-shared/lib/interfaces/calendar';
import isTruthy from 'proton-shared/lib/helpers/isTruthy';

interface Props {
    calendars: Calendar[];
    defaultCalendarID?: string;
    onEdit: (calendar: Calendar) => void;
    onSetDefault: (id: string) => void;
    onDelete: (calendar: Calendar) => void;
    loadingMap: { [key: string]: boolean };
}
const CalendarsTable = ({ calendars, defaultCalendarID, onEdit, onSetDefault, onDelete, loadingMap }: Props) => {
    return (
        <Table>
            <TableHeader cells={[c('Header').t`Name`, c('Header').t`Status`, c('Header').t`Actions`]} />
            <TableBody>
                {(calendars || []).map((calendar) => {
                    const { ID, Name, Color } = calendar;

                    const isDisabled = getIsCalendarDisabled(calendar);
                    const isActive = getIsCalendarProbablyActive(calendar);
                    const isDefault = ID === defaultCalendarID;

                    const list = [
                        {
                            text: c('Action').t`Edit`,
                            onClick: () => onEdit(calendar),
                        },
                        !isDisabled &&
                            !isDefault && {
                                text: c('Action').t`Set as default`,
                                onClick: () => onSetDefault(ID),
                            },
                        {
                            text: c('Action').t`Delete`,
                            onClick: () => onDelete(calendar),
                        },
                    ].filter(isTruthy);

                    return (
                        <TableRow
                            key={ID}
                            cells={[
                                <div key="id" className="flex flex-nowrap flex-items-center">
                                    <Icon name="calendar" color={Color} className="mr0-5 flex-item-noshrink" />
                                    <span className="ellipsis" title={Name}>
                                        {Name}
                                    </span>
                                </div>,
                                <div data-test-id="calendar-settings-page:calendar-status" key="status">
                                    {isDefault && <Badge type="primary">{c('Calendar status').t`Default`}</Badge>}
                                    {isActive && <Badge type="success">{c('Calendar status').t`Active`}</Badge>}
                                    {isDisabled && <Badge type="warning">{c('Calendar status').t`Disabled`}</Badge>}
                                </div>,<commit_msg>Set delete action to red<commit_after>import React from 'react';
import { c } from 'ttag';
import { Icon, Table, TableHeader, TableBody, TableRow, DropdownActions, Badge } from 'react-components';
import { getIsCalendarDisabled, getIsCalendarProbablyActive } from 'proton-shared/lib/calendar/calendar';
import { Calendar } from 'proton-shared/lib/interfaces/calendar';
import isTruthy from 'proton-shared/lib/helpers/isTruthy';

interface Props {
    calendars: Calendar[];
    defaultCalendarID?: string;
    onEdit: (calendar: Calendar) => void;
    onSetDefault: (id: string) => void;
    onDelete: (calendar: Calendar) => void;
    loadingMap: { [key: string]: boolean };
}
const CalendarsTable = ({ calendars, defaultCalendarID, onEdit, onSetDefault, onDelete, loadingMap }: Props) => {
    return (
        <Table>
            <TableHeader cells={[c('Header').t`Name`, c('Header').t`Status`, c('Header').t`Actions`]} />
            <TableBody>
                {(calendars || []).map((calendar) => {
                    const { ID, Name, Color } = calendar;

                    const isDisabled = getIsCalendarDisabled(calendar);
                    const isActive = getIsCalendarProbablyActive(calendar);
                    const isDefault = ID === defaultCalendarID;

                    const list = [
                        {
                            text: c('Action').t`Edit`,
                            onClick: () => onEdit(calendar),
                        },
                        !isDisabled &&
                            !isDefault && {
                                text: c('Action').t`Set as default`,
                                onClick: () => onSetDefault(ID),
                            },
                        {
                            text: c('Action').t`Delete`,
                            actionType: 'delete',
                            onClick: () => onDelete(calendar),
                        } as const,
                    ].filter(isTruthy);

                    return (
                        <TableRow
                            key={ID}
                            cells={[
                                <div key="id" className="flex flex-nowrap flex-items-center">
                                    <Icon name="calendar" color={Color} className="mr0-5 flex-item-noshrink" />
                                    <span className="ellipsis" title={Name}>
                                        {Name}
                                    </span>
                                </div>,
                                <div data-test-id="calendar-settings-page:calendar-status" key="status">
                                    {isDefault && <Badge type="primary">{c('Calendar status').t`Default`}</Badge>}
                                    {isActive && <Badge type="success">{c('Calendar status').t`Active`}</Badge>}
                                    {isDisabled && <Badge type="warning">{c('Calendar status').t`Disabled`}</Badge>}
                                </div>,
{'fraction_non_alphanumeric': 0.12537412703691386, 'fraction_numerical': 0.0006651147322913202, 'mean_word_length': 1.3304920573421155, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5109564', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1414, 'n_words': 289}