|
15 | 15 | >
|
16 | 16 | <AppButton size="small" appearance="primary" outlined>Open</AppButton>
|
17 | 17 | </a>
|
18 |
| - <AppButton v-else-if="isRootUrl && showcase && !showcase.isPublic" @click.native="saveShowcase" size="small" appearance="primary" class="mr-3">{{ saving ? 'Saving...' : 'Save' }}</AppButton> |
| 18 | + <AppButton v-else-if="isRootUrl && showcase && !showcase.isPublic && !savingError" @click.native="saveShowcase" size="small" appearance="primary" class="mr-3">{{ saving ? 'Saving...' : 'Save' }}</AppButton> |
19 | 19 |
|
20 | 20 | <a href="https://twitter.com/VueTelemetry" target="_blank" class="mr-3">
|
21 | 21 | <TwitterIcon class="w-5 h-5 hover:text-primary-500" />
|
|
40 | 40 | <div v-else-if="showcase">
|
41 | 41 | <div v-if="showcase.hasVue">
|
42 | 42 | <div class="mb-8">
|
| 43 | + <div v-if="savingError" class="mb-4 text-orange"> |
| 44 | + Could not save website to Vue Telemetry, please try again later or < a class= "underline" :href= "`mailto:[email protected]?subject=Could not save ${showcase.url}`">contact us</ a>. |
| 45 | + </div> |
43 | 46 | <div class="mb-4">
|
44 | 47 | <h3 class="flex items-center font-bold-body-weight pl-2 text-primary-500 uppercase">
|
45 | 48 | <InfoIcon class="h-5 mr-2 text-primary-5700 opacity-50" />Info
|
@@ -211,6 +214,7 @@ export default {
|
211 | 214 | return {
|
212 | 215 | isLoading: true,
|
213 | 216 | saving: false,
|
| 217 | + savingError: false, |
214 | 218 | showcase: null,
|
215 | 219 | currentTab: null
|
216 | 220 | }
|
@@ -289,18 +293,26 @@ export default {
|
289 | 293 | },
|
290 | 294 | async saveShowcase () {
|
291 | 295 | this.saving = true
|
292 |
| - const res = await fetch(`https://vuetelemetry.com/api/analyze?url=${this.showcase.url}&isPublic=true&force=true`, { |
293 |
| - method: 'GET' |
294 |
| - }) |
295 |
| - .then((response) => { |
296 |
| - this.saving = false |
297 |
| - return response.json() |
| 296 | + this.savingError = false |
| 297 | + try { |
| 298 | + await fetch(`https://vuetelemetry.com/api/analyze?url=${this.showcase.url}&isPublic=true&force=true`, { |
| 299 | + method: 'GET' |
298 | 300 | })
|
299 |
| - .catch((err) => { |
300 |
| - this.saving = false |
301 |
| - throw new Error(err) |
302 |
| - }) |
303 |
| - this.showcase.isPublic = res.body.isPublic |
| 301 | + .then((response) => { |
| 302 | + if (!response.ok) { |
| 303 | + throw new Error('API call to VT failed') |
| 304 | + } |
| 305 | + return response.json() |
| 306 | + }) |
| 307 | + .then(({ body }) => { |
| 308 | + this.showcase.slug = body.slug |
| 309 | + this.showcase.isPublic = body.isPublic |
| 310 | + this.saving = false |
| 311 | + }) |
| 312 | + } catch (err) { |
| 313 | + this.saving = false |
| 314 | + this.savingError = true |
| 315 | + } |
304 | 316 | }
|
305 | 317 | }
|
306 | 318 | }
|
|
0 commit comments