// Libs
// -----------------------------------------------------------------------------
import { TableColumnProps } from 'antd';
import moment from 'moment/moment';

// App
// -----------------------------------------------------------------------------
import { EventsJournalRecord } from 'types/default';
import { EllipsisWithToggle } from 'components';
import { ConditionRuleMessage } from '../types';

export const makeCorrelationRulesEventsColumns = (
  locale: ConditionRuleMessage,
): Array<TableColumnProps<EventsJournalRecord>> => {
  return [
    {
      title: locale.event.created,
      dataIndex: ['_source', '@created'],
      key: '@created',
      align: 'center',
      render: (value) => moment(value).format('DD.MM.YYYY hh:mm:ss'),
    },
    {
      title: locale.event.id,
      dataIndex: ['_source', 'event_id'],
      key: 'event_id',
      align: 'center',
    },
    {
      title: locale.event.message,
      dataIndex: ['_source', 'event_src_msg'],
      key: 'event_src_msg',
      align: 'left',
      render: (value) => (
        <EllipsisWithToggle
          text={value}
          collapseLabel={locale.event.showLess}
          expandLabel={locale.event.showMore}
          maxWidth={300}
        />
      ),
    },
    {
      title: locale.event.severity,
      dataIndex: ['_source', 'event_severity'],
      key: 'event_severity',
      align: 'center',
    },
    {
      title: locale.event.category,
      dataIndex: ['_source', 'sign_category'],
      key: 'sign_category',
      align: 'center',
    },
    {
      title: locale.event.sourceIp,
      dataIndex: ['_source', 'source_ip'],
      key: 'source_ip',
      align: 'center',
    },
    {
      title: locale.event.destinationIp,
      dataIndex: ['_source', 'destination_ip'],
      key: 'destination_ip',
      align: 'center',
    },
  ];
};
