Skip to content

Commit d6c9dc8

Browse files
Merge pull request #139 from diffix/cristian/misc
Set a default file path for export dialog.
2 parents 52c1bf3 + 2845893 commit d6c9dc8

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

src/AnonymizationStep/AnonymizationStep.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ function AnonymizationSummary({ result, loading }: CommonProps) {
6363
}
6464

6565
async function exportResult(schema: TableSchema, bucketColumns: BucketColumn[]) {
66-
const filePath = await window.selectExportFile();
66+
const defaultPath = schema.file.path.replace(/\.\w*$/, '') + '_anonymized.csv';
67+
const filePath = await window.selectExportFile(defaultPath);
6768
if (!filePath) return;
6869

6970
message.loading({ content: `Exporting anonymized data to ${filePath}...`, key: filePath, duration: 0 });

src/FileLoadStep/FileLoadStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const FileLoadStep: FunctionComponent<FileLoadStepProps> = ({ children, o
2828
<NotebookNavAnchor step={NotebookNavStep.CsvImport} status={file ? 'done' : 'active'} />
2929
<Title level={3}>Import data to anonymize</Title>
3030
<Dragger
31-
accept=".csv"
31+
accept=".csv,.tsv,.txt"
3232
fileList={[]}
3333
beforeUpload={(file) => {
3434
// Uploader is mid state update. We push the op to next frame to avoid react warning.

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ ipcMain.handle('call_service', (_event, taskId: string, request: string) =>
9494
}),
9595
);
9696

97-
ipcMain.handle('select_export_file', async (_event) => {
97+
ipcMain.handle('select_export_file', async (_event, defaultPath: string) => {
9898
const options = {
99+
defaultPath: defaultPath,
99100
filters: [
100101
{ name: 'CSV', extensions: ['csv'] },
101102
{ name: 'All Files', extensions: ['*'] },

src/preload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ window.callService = (request: unknown, signal: AbortSignal) =>
2727
return json ? JSON.parse(json) : null;
2828
});
2929

30-
window.selectExportFile = () => {
31-
return ipcRenderer.invoke('select_export_file');
30+
window.selectExportFile = (defaultPath: string) => {
31+
return ipcRenderer.invoke('select_export_file', defaultPath);
3232
};
3333

3434
window.hashFile = (fileName: string, signal: AbortSignal) =>

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export {};
114114
declare global {
115115
interface Window {
116116
callService(request: unknown, signal: AbortSignal): Promise<QueryResult>;
117-
selectExportFile(): Promise<string | null>;
117+
selectExportFile(defaultPath: string): Promise<string | null>;
118118
hashFile(fileName: string, signal: AbortSignal): Promise<string>;
119119
}
120120
}

0 commit comments

Comments
 (0)