|
1 | 1 | <script setup lang="ts">
|
2 | 2 | import hexRgb from 'hex-rgb'
|
3 | 3 |
|
4 |
| -import { allowedRepos } from '#shared/repos' |
| 4 | +import { allowedRepos, isAllowedRepo } from '#shared/repos' |
5 | 5 |
|
6 |
| -const repo = ref('nuxt/nuxt') |
| 6 | +const route = useRoute() |
| 7 | +const selectedRepo = computed(() => { |
| 8 | + const query = route.query.repo as string | undefined |
| 9 | + return query && isAllowedRepo(query) ? query : 'nuxt/nuxt' |
| 10 | +}) |
7 | 11 |
|
8 |
| -const { data: clusters, refresh, status } = useFetch(() => `/api/clusters/${repo.value}`, { |
| 12 | +const { data: clusters, refresh, status } = useFetch(() => `/api/clusters/${selectedRepo.value}`, { |
9 | 13 | server: false,
|
10 | 14 | immediate: import.meta.client && !('startViewTransition' in document),
|
11 | 15 | default: () => [],
|
@@ -54,7 +58,7 @@ async function updateSearch() {}
|
54 | 58 | </p>
|
55 | 59 | </nav>
|
56 | 60 | <p class="flex gap-2 items-center">
|
57 |
| - {{ repo }} |
| 61 | + {{ selectedRepo }} |
58 | 62 | <button
|
59 | 63 | class="rounded-full w-7 h-7 flex items-center justify-center border-solid border border-gray-700 bg-transparent color-gray-400 hover:color-gray-200 active:color-white focus:color-gray-200 hover:border-gray-400 active:border-white focus:border-gray-400 transition-colors flex-shrink-0"
|
60 | 64 | :class="{ 'animate-spin opacity-50 pointer-events-none': status === 'pending' || status === 'idle' }"
|
@@ -87,8 +91,8 @@ async function updateSearch() {}
|
87 | 91 | placeholder="repository"
|
88 | 92 | > -->
|
89 | 93 | <select
|
90 |
| - v-model="repo" |
91 | 94 | class="pl-8 bg-transparent pr-2 py-2 color-white border-0 w-full"
|
| 95 | + @change="(event) => navigateTo({ query: { repo: (event.target as HTMLSelectElement).value } })" |
92 | 96 | >
|
93 | 97 | <option
|
94 | 98 | v-for="repo in allowedRepos"
|
|
0 commit comments