<commit_before>import * as React from 'react';

import { formatDateTime } from '@waldur/core/dateUtils';
import { Tooltip } from '@waldur/core/Tooltip';
import { withTranslation } from '@waldur/i18n';
import { connectAngularComponent } from '@waldur/store/connect';
import { Table, connectTable, createFetcher } from '@waldur/table-react';
import { formatLongText } from '@waldur/table-react/utils';

import { JiraIssueCreateButton } from './JiraIssueCreateButton';

const IssueStatusField = props => (
  <Tooltip label={props.row.type_description} id="issueType">
    <img src={props.row.type_icon_url} style={{width: 16}} className="m-r-xs"/>
    {props.row.status}
  </Tooltip>
);

const IssueSlaField = withTranslation(props => (
  <Tooltip label={props.translate('Time to resolution')} id="slaField">
    {props.row.first_response_sla ? formatDateTime(props.row.first_response_sla) : 'N/A'}
  </Tooltip>
));

const TableComponent = props => {
  const { translate } = props;
  const columns = [
    {
      title: translate('Key'),
      render: ({ row }) => row.key,
    },
    {
      title: translate('Status'),
      render: IssueStatusField,
    },
    {
      title: translate('Title'),
      render: ({ row }) => formatLongText(row.summary),
    },
    {
      title: translate('Description'),
      render: ({ row }) => row.description ? formatLongText(row.description) : 'N/A',
    },
    {
      title: translate('Assigned to'),
      render: ({ row }) => row.assignee_name || 'N/A',
    },
    {
      title: translate('Resolution SLA'),
      render: IssueSlaField,
    },
    {
      title: translate('Created'),
      render: ({ row }) => formatDateTime(row.created),
    },
  ];
  return (
    <Table
      {...props}
      columns={columns}
      actions={<JiraIssueCreateButton project={props.resource}/>}
      verboseName={translate('requests')}
      hasQuery={true}
    />
  );
};

const TableOptions = {
  table: 'jiraIssues',
  fetchData: createFetcher('jira-issues'),
  queryField: 'summary',
  mapPropsToFilter: ({ resource }) => ({project_uuid: resource.uuid}),
  exportFields: [
    'key',
    'type',
    'status',
    'title',
    'description',
    'assignee',
    'sla',
    'created',
  ],
  exportRow: row => [
    row.key,
    row.type_name,
    row.status,
    row.summary,
    row.description,
    row.assignee_name,
    row.first_response_sla,<commit_msg>Improve JIRA issues exporter [WAL-1350]<commit_after>import * as React from 'react';

import { formatDateTime } from '@waldur/core/dateUtils';
import { Tooltip } from '@waldur/core/Tooltip';
import { withTranslation } from '@waldur/i18n';
import { connectAngularComponent } from '@waldur/store/connect';
import { Table, connectTable, createFetcher } from '@waldur/table-react';
import { formatLongText } from '@waldur/table-react/utils';

import { JiraIssueCreateButton } from './JiraIssueCreateButton';

const IssueStatusField = props => (
  <Tooltip label={props.row.type_description} id="issueType">
    <img src={props.row.type_icon_url} style={{width: 16}} className="m-r-xs"/>
    {props.row.status}
  </Tooltip>
);

const IssueSlaField = withTranslation(props => (
  <Tooltip label={props.translate('Time to resolution')} id="slaField">
    {props.row.first_response_sla ? formatDateTime(props.row.first_response_sla) : 'N/A'}
  </Tooltip>
));

const TableComponent = props => {
  const { translate } = props;
  const columns = [
    {
      title: translate('Key'),
      render: ({ row }) => row.key,
    },
    {
      title: translate('Status'),
      render: IssueStatusField,
    },
    {
      title: translate('Title'),
      render: ({ row }) => formatLongText(row.summary),
    },
    {
      title: translate('Description'),
      render: ({ row }) => row.description ? formatLongText(row.description) : 'N/A',
    },
    {
      title: translate('Assigned to'),
      render: ({ row }) => row.assignee_name || 'N/A',
    },
    {
      title: translate('Resolution SLA'),
      render: IssueSlaField,
    },
    {
      title: translate('Created'),
      render: ({ row }) => formatDateTime(row.created),
    },
  ];
  return (
    <Table
      {...props}
      columns={columns}
      actions={<JiraIssueCreateButton project={props.resource}/>}
      verboseName={translate('requests')}
      hasQuery={true}
    />
  );
};

const TableOptions = {
  table: 'jiraIssues',
  fetchData: createFetcher('jira-issues'),
  queryField: 'summary',
  mapPropsToFilter: ({ resource }) => ({project_uuid: resource.uuid}),
  exportFields: [
    'key',
    'type',
    'status',
    'title',
    'description',
    'assignee',
    'sla',
    'created',
  ],
  exportRow: row => [
    row.key,
    row.type_name,
    row.status,
    row.summary,
    row.description || 'N/A',
    row.assignee_name || 'N/A',
    row.first_response_sla || 'N/A',
{'fraction_non_alphanumeric': 0.1675954592363261, 'fraction_numerical': 0.002476780185758514, 'mean_word_length': 3.2397200349956257, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, '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': '821543', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1560, 'n_words': 294}