()
| 52168 | return "#" + JSON.stringify(dss); |
| 52169 | } |
| 52170 | loadUrl() { |
| 52171 | const urlError = (0, _url.invalidUrlError)(this.state.url); |
| 52172 | if (urlError) return this.setState({ |
| 52173 | urlError |
| 52174 | }); |
| 52175 | const { url } = this.state; |
| 52176 | fetch(url).then((response)=>{ |
| 52177 | if (response.status === 200) return response.json(); |
| 52178 | else this.setState({ |
| 52179 | urlError: response.statusText |
| 52180 | }); |
| 52181 | }).then((snapshots)=>{ |
| 52182 | if (validSnapshots(snapshots)) { |
| 52183 | this.props.onImportSnapshot(snapshots); |
| 52184 | this.props.onSnapshotsUrl(url); |
| 52185 | this.setState({ |
| 52186 | working: false |
| 52187 | }); |
| 52188 | this.props.onDismiss(); |
| 52189 | } else this.setState({ |
| 52190 | fileFormatError: (0, _language.strings).errorInvalidFileFormat, |
| 52191 | working: false |
| 52192 | }); |
| 52193 | }).catch((e)=>{ |
| 52194 | this.setState({ |
| 52195 | urlError: e |
| 52196 | }); |
| 52197 | }); |
| 52198 | } |
| 52199 | render() { |
| 52200 | let shortcut; |
| 52201 | if (this.props.dataSource.dataSourceType !== "local" && this.state.url && !(0, _url.invalidUrlError)(this.state.url) && !this.state.urlError) shortcut = this.getUrlShortcut(); |
no test coverage detected