Skip to content

Commit 86d94bc

Browse files
#89 added supportedFilesFilters to config.ts + restrict open file dialog selection to only supported data formats
1 parent 3bdf6de commit 86d94bc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ export const supportedDataFiles: RegExp = /.*\.(json|json5|hjson|arrow|arr|avro|
77

88
export const supportedBinaryDataFiles: RegExp = /.*\.(arrow|arr|avro|parquet|parq|dif|ods|slk|xls|xlsb|xlsx|xlsm)/;
99

10+
export const supportedFilesFilters: any = {
11+
'JSON': ['json', 'json5', 'hjson'],
12+
'CSV/TSV': ['csv', 'tsv', 'tab', 'txt'],
13+
'Excel': ['dif', 'ods', 'slk', 'xls', 'xlsb', 'xlsx', 'xlsm', 'xml', 'html'],
14+
'Arrow': ['arrow'],
15+
'Avro': ['avro'],
16+
'Config': ['config'],
17+
'Markdown': ['md'],
18+
'Properties': ['env', 'properties', 'ini'],
19+
'YAML': ['yml']
20+
};
21+
1022
// arrow to data view type mappings
1123
// see: https://github.com/finos/perspective/blob/master/packages/perspective/src/js/utils.js
1224
// and https://github.com/finos/perspective/blob/master/packages/perspective/src/js/perspective.js#ArrowColumnLoader

src/data.preview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ export class DataPreview {
299299
const selectedFiles: Array<Uri> = await window.showOpenDialog({
300300
defaultUri: openFolderUri,
301301
canSelectMany: false,
302-
canSelectFolders: false
302+
canSelectFolders: false,
303+
filters: config.supportedFilesFilters
303304
});
304305
if (selectedFiles && selectedFiles.length >= 1) {
305306
// launch new data preview for the selected data file

0 commit comments

Comments
 (0)