Skip to content

Commit 8cf6b28

Browse files
committed
chore: improve saving button
1 parent 5f2e159 commit 8cf6b28

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/popup/App.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
<div class="flex items-center">
1010
<a
11-
v-if="state === 'data' && showcase.isPublic"
11+
v-if="!isLoading && state === 'data' && showcase.isPublic"
1212
:href="`https://vuetelemetry.com/explore/${showcase.slug}`"
1313
target="_blank"
1414
class="mr-3"
1515
>
16-
<AppButton size="small" appearance="primary">Open</AppButton>
16+
<AppButton size="small" appearance="primary" outlined>Open</AppButton>
1717
</a>
18-
<AppButton v-else @click.native="saveShowcase" size="small" appearance="primary" class="mr-3">Save</AppButton>
18+
<AppButton v-else-if="!isLoading && state === 'data' && !showcase.isPublic" @click.native="saveShowcase" size="small" appearance="primary" class="mr-3">{{ saving ? 'Saving...' : 'Save' }}</AppButton>
1919

2020
<a href="https://twitter.com/VueTelemetry" target="_blank" class="mr-3">
2121
<TwitterIcon class="w-5 h-5 hover:text-primary-500" />
@@ -47,7 +47,7 @@
4747
>
4848
<img
4949
class="w-6 h-6 mr-2"
50-
:src="getURL('/vue.svg')"
50+
:src="iconURL('/vue.svg')"
5151
alt
5252
/>
5353
<div class=" text-base leading-base font-bold-body-weight">
@@ -65,7 +65,7 @@
6565
>
6666
<img
6767
class="w-6 h-6 mr-2"
68-
:src="getURL(showcase.framework.imgPath)"
68+
:src="iconURL(showcase.framework.imgPath)"
6969
alt
7070
/>
7171
<div class="text-base leading-seven font-bold-body-weight">
@@ -83,7 +83,7 @@
8383
>
8484
<img
8585
class="w-6 h-6 mr-2"
86-
:src="getURL(showcase.ui.imgPath)"
86+
:src="iconURL(showcase.ui.imgPath)"
8787
alt
8888
/>
8989
<div class="text-base leading-seven font-bold-body-weight">
@@ -205,6 +205,11 @@ export default {
205205
ExploreDataItem,
206206
AppButton
207207
},
208+
data() {
209+
return {
210+
saving: false
211+
}
212+
},
208213
computed: {
209214
...mapGetters([
210215
'isLoading',
@@ -222,22 +227,23 @@ export default {
222227
}
223228
},
224229
methods: {
225-
getURL (path) {
230+
iconURL (path) {
226231
return `https://icons.vuetelemetry.com${path}`
227232
},
228233
refresh () {
229234
browser.runtime.sendMessage({ msg: 'refresh' })
230235
},
231236
async saveShowcase () {
232-
const res = await fetch(`https://vuetelemetry.com/api/analyze?url=${this.showcase.hostname}&isPublic=true`, {
237+
this.saving = true
238+
const res = await fetch(`https://vuetelemetry.com/api/analyze?url=${this.showcase.url}&isPublic=true`, {
233239
method: 'GET'
234240
})
235241
.then((response) => {
236-
this.pending = false
242+
this.saving = false
237243
return response.json()
238244
})
239245
.catch((err) => {
240-
this.pending = false
246+
this.saving = false
241247
throw new Error(err)
242248
})
243249
this.$store.commit('SET_SHOWCASE', res.body)

0 commit comments

Comments
 (0)