Add option to generate plaintext files (#2748)

* Add option to generate plaintext files

* Default to csv file format for file generator
This commit is contained in:
Sherfin Shamsudeen 2022-04-04 22:27:35 +05:30 committed by GitHub
parent ee8438c1dc
commit 5779c5b9a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -322,8 +322,11 @@ export const EventManager = ({
<div className="col-9">
<SelectSearch
className={`${darkMode ? 'select-search-dark' : 'select-search'}`}
options={[{ name: 'CSV', value: 'csv' }]}
value={'csv'}
options={[
{ name: 'CSV', value: 'csv' },
{ name: 'Text', value: 'plaintext' },
]}
value={event.fileType ?? 'csv'}
search={true}
onChange={(value) => {
handlerChanged(index, 'fileType', value);

View file

@ -261,9 +261,14 @@ function executeAction(_ref, event, mode, customVariables) {
const data = resolveReferences(event.data, _ref.state.currentState, undefined, customVariables) ?? [];
const fileName =
resolveReferences(event.fileName, _ref.state.currentState, undefined, customVariables) ?? 'data.txt';
const fileType =
resolveReferences(event.fileType, _ref.state.currentState, undefined, customVariables) ?? 'csv';
const csv = generateCSV(data);
generateFile(fileName, csv);
const fileData = {
csv: generateCSV,
plaintext: (plaintext) => plaintext,
}[fileType](data);
generateFile(fileName, fileData);
return Promise.resolve();
}