(e)
| 52100 | }; |
| 52101 | } |
| 52102 | readFile(e) { |
| 52103 | if (e.target.files) { |
| 52104 | this.setState({ |
| 52105 | working: true |
| 52106 | }); |
| 52107 | const file = e.target.files[0]; |
| 52108 | const reader = new FileReader(); |
| 52109 | reader.onload = ()=>{ |
| 52110 | const rawText = reader.result; |
| 52111 | let snapshots; |
| 52112 | try { |
| 52113 | snapshots = JSON.parse(rawText); |
| 52114 | } catch (e) { |
| 52115 | this.setState({ |
| 52116 | fileFormatError: (0, _language.strings).errorInvalidFileFormat, |
| 52117 | working: false |
| 52118 | }); |
| 52119 | } |
| 52120 | //validate these are snapshots |
| 52121 | if (validSnapshots(snapshots)) { |
| 52122 | this.props.onImportSnapshot(snapshots); |
| 52123 | this.setState({ |
| 52124 | working: false |
| 52125 | }); |
| 52126 | this.props.onDismiss(); |
| 52127 | } else this.setState({ |
| 52128 | fileFormatError: (0, _language.strings).errorInvalidFileFormat, |
| 52129 | working: false |
| 52130 | }); |
| 52131 | }; |
| 52132 | reader.readAsText(file); |
| 52133 | } |
| 52134 | } |
| 52135 | render() { |
| 52136 | return /*#__PURE__*/ _react.createElement("div", null, /*#__PURE__*/ _react.createElement((0, _sanddanceExplorer.controls).Dialog, { |
| 52137 | hidden: false, |
no test coverage detected