Add loading spinner to repo list (#3310)

This commit is contained in:
Lukas 2024-02-01 08:40:01 +01:00 committed by GitHub
parent 450a437cb6
commit a801f8cbc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,23 +5,28 @@
</template>
<div class="space-y-4">
<ListItem
v-for="repo in searchedRepos"
:key="repo.id"
class="items-center"
:to="repo.active ? { name: 'repo', params: { repoId: repo.id } } : undefined"
>
<span class="text-wp-text-100">{{ repo.full_name }}</span>
<span v-if="repo.active" class="ml-auto text-wp-text-alt-100">{{ $t('repo.enable.enabled') }}</span>
<div v-else class="ml-auto flex items-center">
<Badge v-if="repo.id" class="<md:hidden mr-2" :label="$t('repo.enable.disabled')" />
<Button
:text="$t('repo.enable.enable')"
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
@click="activateRepo(repo)"
/>
</div>
</ListItem>
<template v-if="repos !== undefined && repos.length > 0">
<ListItem
v-for="repo in searchedRepos"
:key="repo.id"
class="items-center"
:to="repo.active ? { name: 'repo', params: { repoId: repo.id } } : undefined"
>
<span class="text-wp-text-100">{{ repo.full_name }}</span>
<span v-if="repo.active" class="ml-auto text-wp-text-alt-100">{{ $t('repo.enable.enabled') }}</span>
<div v-else class="ml-auto flex items-center">
<Badge v-if="repo.id" class="<md:hidden mr-2" :label="$t('repo.enable.disabled')" />
<Button
:text="$t('repo.enable.enable')"
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
@click="activateRepo(repo)"
/>
</div>
</ListItem>
</template>
<div v-else-if="loading" class="flex justify-center text-wp-text-100">
<Icon name="spinner" />
</div>
</div>
</Scaffold>
</template>
@ -49,11 +54,14 @@ const repos = ref<Repo[]>();
const repoToActivate = ref<Repo>();
const search = ref('');
const i18n = useI18n();
const loading = ref(false);
const { searchedRepos } = useRepoSearch(repos, search);
onMounted(async () => {
loading.value = true;
repos.value = await apiClient.getRepoList({ all: true });
loading.value = false;
});
const { doSubmit: activateRepo, isLoading: isActivatingRepo } = useAsyncAction(async (repo: Repo) => {