<commit_before>import FileSaver from 'file-saver';
import Papa from 'papaparse';
import { put, call, select } from 'redux-saga/effects';

import { fetchAll } from '@waldur/table-react/api';
import { getTableState } from '@waldur/table-react/store';

import { blockStart, blockStop } from './actions';
import exportExcel from './excel';
import { getTableOptions } from './registry';

export function* exportTable(action) {
  const { table, format } = action.payload;
  let { rows } = yield select(getTableState(table));
  const { exportFields, exportRow, fetchData, exportAll } = getTableOptions(table);

  if (exportAll) {
    yield put(blockStart(table));
    rows = yield call(fetchAll, fetchData);
    yield put(blockStop(table));
  }

  const data = {
    fields: exportFields,
    data: rows.map(exportRow),
  };
  exporters[format](table, data);<commit_msg>Fix table export.<commit_after>import FileSaver from 'file-saver';
import Papa from 'papaparse';
import { put, call, select } from 'redux-saga/effects';

import { fetchAll } from '@waldur/table-react/api';

import { blockStart, blockStop } from './actions';
import exportExcel from './excel';
import { getTableOptions } from './registry';
import { selectTableRows } from './selectors';

export function* exportTable(action) {
  const { table, format } = action.payload;
  let rows = yield select(state => selectTableRows(state, table));
  const { exportFields, exportRow, fetchData, exportAll } = getTableOptions(table);

  if (exportAll) {
    yield put(blockStart(table));
    rows = yield call(fetchAll, fetchData);
    yield put(blockStop(table));
  }

  const data = {
    fields: exportFields,
    data: rows.map(exportRow),
  };
  exporters[format](table, data);
{'fraction_non_alphanumeric': 0.13856812933025403, 'fraction_numerical': 0.0, 'mean_word_length': 4.590322580645161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '242829', 'n_tokens_mistral': 535, 'n_tokens_neox': 524, 'n_words': 143}