Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Prefill export filename #211

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion electron/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'less/global.less';
/**
* Customize data service for your sandbox.
*/
const NS = 'lucas_apple_health_data.sleep';
const NS = 'test.sales';

import Connection from 'mongodb-connection-model';
const connection = new Connection({
Expand Down
1 change: 1 addition & 0 deletions src/components/export-modal/export-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class ExportModal extends PureComponent {
status={this.props.status}
fileType={this.props.fileType}
fileName={this.props.fileName}
ns={this.props.ns}
progress={this.props.progress}
exportStep={this.props.exportStep}
startExport={this.props.startExport}
Expand Down
5 changes: 4 additions & 1 deletion src/components/export-select-output/export-select-output.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SelectFileType from 'components/select-file-type';
import { IconTextButton } from 'hadron-react-buttons';
import toNS from 'mongodb-ns';
import fileSaveDialog from 'utils/file-save-dialog';
import ProgressBar from 'components/progress-bar';
import { FILETYPE } from 'constants/export-step';
Expand Down Expand Up @@ -38,6 +39,7 @@ class ExportSelectOutput extends PureComponent {
count: PropTypes.number,
fileType: PropTypes.string,
fileName: PropTypes.string,
ns: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
exportedDocsCount: PropTypes.number,
progress: PropTypes.number.isRequired,
Expand Down Expand Up @@ -65,7 +67,8 @@ class ExportSelectOutput extends PureComponent {
* Handle choosing a file from the file dialog.
*/
handleChooseFile = () => {
fileSaveDialog(this.props.fileType).then(result => {
const fileNamePrefill = toNS(this.props.ns).collection;
fileSaveDialog(this.props.fileType, fileNamePrefill).then(result => {
if (result && result.filePath && !result.canceled) {
this.props.selectExportFileName(result.filePath);
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/file-save-dialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function fileSaveDialog(fileType) {
export default function fileSaveDialog(fileType, prefillFileName) {
const { dialog, getCurrentWindow } = require('electron').remote;

const filters = [
Expand All @@ -11,6 +11,7 @@ export default function fileSaveDialog(fileType) {
const buttonLabel = 'Select';
return dialog.showSaveDialog(getCurrentWindow(), {
title,
defaultPath: prefillFileName,
filters,
buttonLabel
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formatters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('formatters', () => {
// The driver returns bson v1.x objects to us. They don't have a
// .toExtendedJSON() method, we simulate that.
class FakeBSON1Binary extends Binary {
get toExtendedJSON() { return undefined; };
get toExtendedJSON() { return undefined; }
}

const binary = new Binary(Buffer.from('56391cc226bc4affbe520f67856c09ec'), 4);
Expand Down