Skip to content

Commit ce26a98

Browse files
committed
feat: handle setup url loading state
1 parent ab3fcd7 commit ce26a98

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

app/pages/index.vue

+46-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,57 @@
1+
<script setup lang="ts">
2+
const { data: allowedRepos, refresh } = useFetch('/api/repos', { default: () => [] })
3+
4+
const isCallback = ref(!!useRoute().query.installation_id)
5+
const numRepos = allowedRepos.value?.length
6+
7+
if (import.meta.client && isCallback.value) {
8+
setInterval(() => {
9+
refresh()
10+
}, 1000)
11+
watch(allowedRepos, (newRepos) => {
12+
if (newRepos.length === numRepos) return
13+
14+
isCallback.value = false
15+
}, { once: true })
16+
}
17+
</script>
18+
119
<template>
220
<section class="flex flex-col items-center flex-grow gap-4 md:gap-8">
321
<p class="text-xl md:text-2xl lg:text-3xl mb-8 text-center mt-18 md:mt-36">
422
cluster issues by similarity across multiple repositories
523
</p>
624
<NuxtLink
725
class="bg-green-700 rounded-md px-5 py-3 font-medium flex flex-row gap-2 items-center color-white no-underline focus:bg-green-800 hover:bg-green-800 transition-colors shadow-lg"
8-
href="https://github.com/apps/unsight-dev/installations/new"
26+
:href="isCallback ? null : 'https://github.com/apps/unsight-dev/installations/new'"
27+
:class="{ 'pointer-events-none opacity-50': isCallback }"
928
>
10-
<span class="i-ri:github-fill inline-block w-5 h-5" />
11-
install as a github app
29+
<template v-if="isCallback">
30+
<span class="i-tabler-refresh animate-spin inline-block w-5 h-5" />
31+
indexing repositories
32+
</template>
33+
<template v-else>
34+
<span class="i-ri:github-fill inline-block w-5 h-5" />
35+
install as a github app
36+
</template>
1237
</NuxtLink>
38+
<hr>
39+
<section class="text-center">
40+
or pick a repository to browse issue clusters
41+
<ul class="p-0">
42+
<li
43+
v-for="repo in allowedRepos"
44+
:key="repo"
45+
class="list-none"
46+
>
47+
<NuxtLink
48+
:to="`/${repo}`"
49+
class="no-underline text-gray-400 hover:underline active:text-white"
50+
>
51+
{{ repo }}
52+
</NuxtLink>
53+
</li>
54+
</ul>
55+
</section>
1356
</section>
1457
</template>

0 commit comments

Comments
 (0)