Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import/Export issue new dashboard #633

Merged
merged 4 commits into from
Oct 17, 2024
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
13 changes: 8 additions & 5 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2049,14 +2049,16 @@ class Browser extends DashboardView {
const element = document.createElement('a');
const file = new Blob(
[
JSON.stringify(
objects.map(obj => {
JSON.stringify({
results: objects.map(obj => {
const json = obj._toFullJSON();
delete json.__type;
delete json.className
return json;
}),
null,
indentation ? 2 : null
})
},
null,
indentation ? 2 : null
),
],
{ type: 'application/json' }
Expand Down Expand Up @@ -2520,6 +2522,7 @@ class Browser extends DashboardView {
<ImportDialog
className={className}
onCancel={() => this.setState({ showImportDialog: false })}
showNote={this.showNote}
onConfirm={(file) => this.importClass(className, file)} />
);
} else if (this.state.showImportRelationDialog) {
Expand Down
22 changes: 10 additions & 12 deletions src/dashboard/Data/Browser/ImportDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import Label from 'components/Label/Label.react';

export default class ImportDialog extends React.Component {
constructor() {
super();
this.state = {
file: undefined,
startedImport: false,
errorMessage: null
};
super();
this.state = {
file: undefined,
startedImport: false
};
}

valid() {
Expand All @@ -41,14 +40,17 @@ export default class ImportDialog extends React.Component {
disabled={!this.valid()}
onCancel={this.props.onCancel}
onConfirm={() => {
this.setState({ startedImport: true })
this.props.onConfirm(this.state.file)
.then((res) => {
if (res.error) {
this.setState({ errorMessage: res.message });
this.props.showNote(`Import Request failed with the following error: "${res.error }".`)
} else {
this.props.onCancel();
this.props.showNote('We are importing your data. You will be notified by e-mail once it is completed.')
}
});
}).finally(() => this.setState({ startedImport: false, file: undefined }));
}}>

<Field
Expand All @@ -58,14 +60,10 @@ export default class ImportDialog extends React.Component {
input={
<div style={{ padding: '0 1rem', width: '100%' }}>
<FileInput
onChange={(file) => {this.setState({ file: file });}} />
onChange={(file) => {this.setState({ file: file });}} accept=".csv,.json" />
</div>
}
/>
{this.state.startedImport ?
<div style={{ padding: 20, color: '#0F1C32' }}>We are importing your data. You will be notified by e-mail once it is completed.</div> : null }
{this.state.errorMessage ?
<div style={{ padding: 20, color: '#E85C3E' }}>Import Request failed with the following error: "{ this.state.errorMessage }".</div> : null }
</B4aModal>

);
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Data/Browser/ImportRelationDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class ImportRelationDialog extends React.Component {
input={
<div style={{ padding: '0 1rem', width: '100%' }}>
<FileInput
onChange={(file) => {this.setState({ file: file });}} />
onChange={(file) => {this.setState({ file: file });}} accept=".csv,.json" />
</div>
}
/>
Expand Down
Loading