mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-04-26 13:34:45 +00:00
Add loading spinner and no pull request text (#3113)
This commit is contained in:
parent
1742fb2b97
commit
f8a4d72381
4 changed files with 43 additions and 25 deletions
|
@ -15,6 +15,7 @@
|
||||||
"unknown_error": "An unknown error occurred",
|
"unknown_error": "An unknown error occurred",
|
||||||
"documentation_for": "Documentation for \"{topic}\"",
|
"documentation_for": "Documentation for \"{topic}\"",
|
||||||
"pipeline_feed": "Pipeline feed",
|
"pipeline_feed": "Pipeline feed",
|
||||||
|
"empty_list": "No {entity} found!",
|
||||||
"not_found": {
|
"not_found": {
|
||||||
"not_found": "Whoa 404, either we broke something or you had a typing mishap :-/",
|
"not_found": "Whoa 404, either we broke something or you had a typing mishap :-/",
|
||||||
"back_home": "Back to home"
|
"back_home": "Back to home"
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
<i-teenyicons-refresh-outline v-else-if="name === 'refresh'" class="h-6 w-6" />
|
<i-teenyicons-refresh-outline v-else-if="name === 'refresh'" class="h-6 w-6" />
|
||||||
<i-ic-baseline-play-arrow v-else-if="name === 'play'" class="h-6 w-6" />
|
<i-ic-baseline-play-arrow v-else-if="name === 'play'" class="h-6 w-6" />
|
||||||
<i-ic-baseline-pause v-else-if="name === 'pause'" class="h-6 w-6" />
|
<i-ic-baseline-pause v-else-if="name === 'pause'" class="h-6 w-6" />
|
||||||
|
<i-svg-spinners-180-ring-with-bg v-else-if="name === 'spinner'" class="h-6 w-6" />
|
||||||
<div v-else-if="name === 'blank'" class="h-6 w-6" />
|
<div v-else-if="name === 'blank'" class="h-6 w-6" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ export type IconNames =
|
||||||
| 'pause'
|
| 'pause'
|
||||||
| 'warning'
|
| 'warning'
|
||||||
| 'attention'
|
| 'attention'
|
||||||
|
| 'spinner'
|
||||||
| 'error';
|
| 'error';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="branches" class="space-y-4">
|
<div class="space-y-4">
|
||||||
<ListItem
|
<template v-if="branches.length > 0">
|
||||||
v-for="branch in branchesWithDefaultBranchFirst"
|
<ListItem
|
||||||
:key="branch"
|
v-for="branch in branchesWithDefaultBranchFirst"
|
||||||
class="text-wp-text-100"
|
:key="branch"
|
||||||
:to="{ name: 'repo-branch', params: { branch } }"
|
class="text-wp-text-100"
|
||||||
>
|
:to="{ name: 'repo-branch', params: { branch } }"
|
||||||
{{ branch }}
|
>
|
||||||
<Badge v-if="branch === repo?.default_branch" :label="$t('default')" class="ml-auto" />
|
{{ branch }}
|
||||||
</ListItem>
|
<Badge v-if="branch === repo?.default_branch" :label="$t('default')" class="ml-auto" />
|
||||||
|
</ListItem>
|
||||||
|
</template>
|
||||||
|
<div v-else-if="loading" class="flex justify-center text-wp-text-100">
|
||||||
|
<Icon name="spinner" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -36,7 +41,7 @@ async function loadBranches(page: number): Promise<string[]> {
|
||||||
return apiClient.getRepoBranches(repo.value.id, page);
|
return apiClient.getRepoBranches(repo.value.id, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { resetPage, data: branches } = usePagination(loadBranches);
|
const { resetPage, data: branches, loading } = usePagination(loadBranches);
|
||||||
|
|
||||||
const branchesWithDefaultBranchFirst = computed(() =>
|
const branchesWithDefaultBranchFirst = computed(() =>
|
||||||
branches.value.toSorted((a, b) => {
|
branches.value.toSorted((a, b) => {
|
||||||
|
|
|
@ -1,24 +1,34 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="pullRequests" class="space-y-4">
|
<div class="space-y-4">
|
||||||
<ListItem
|
<template v-if="pullRequests.length > 0">
|
||||||
v-for="pullRequest in pullRequests"
|
<ListItem
|
||||||
:key="pullRequest.index"
|
v-for="pullRequest in pullRequests"
|
||||||
class="text-wp-text-100"
|
:key="pullRequest.index"
|
||||||
:to="{ name: 'repo-pull-request', params: { pullRequest: pullRequest.index } }"
|
class="text-wp-text-100"
|
||||||
>
|
:to="{ name: 'repo-pull-request', params: { pullRequest: pullRequest.index } }"
|
||||||
<span class="text-wp-text-alt-100 <md:hidden">#{{ pullRequest.index }}</span>
|
>
|
||||||
<span class="text-wp-text-alt-100 <md:hidden mx-2">-</span>
|
<span class="text-wp-text-alt-100 <md:hidden">#{{ pullRequest.index }}</span>
|
||||||
<span class="text-wp-text-100 <md:underline whitespace-nowrap overflow-hidden overflow-ellipsis">{{
|
<span class="text-wp-text-alt-100 <md:hidden mx-2">-</span>
|
||||||
pullRequest.title
|
<span class="text-wp-text-100 <md:underline whitespace-nowrap overflow-hidden overflow-ellipsis">{{
|
||||||
}}</span>
|
pullRequest.title
|
||||||
</ListItem>
|
}}</span>
|
||||||
|
</ListItem>
|
||||||
|
</template>
|
||||||
|
<div v-else-if="loading" class="flex justify-center text-wp-text-100">
|
||||||
|
<Icon name="spinner" />
|
||||||
|
</div>
|
||||||
|
<Panel v-else class="flex justify-center">
|
||||||
|
{{ $t('empty_list', { entity: $t('repo.pull_requests') }) }}
|
||||||
|
</Panel>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { inject, Ref, watch } from 'vue';
|
import { inject, Ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import Icon from '~/components/atomic/Icon.vue';
|
||||||
import ListItem from '~/components/atomic/ListItem.vue';
|
import ListItem from '~/components/atomic/ListItem.vue';
|
||||||
|
import Panel from '~/components/layout/Panel.vue';
|
||||||
import useApiClient from '~/compositions/useApiClient';
|
import useApiClient from '~/compositions/useApiClient';
|
||||||
import { usePagination } from '~/compositions/usePaginate';
|
import { usePagination } from '~/compositions/usePaginate';
|
||||||
import { PullRequest, Repo } from '~/lib/api/types';
|
import { PullRequest, Repo } from '~/lib/api/types';
|
||||||
|
@ -41,7 +51,7 @@ async function loadPullRequests(page: number): Promise<PullRequest[]> {
|
||||||
return apiClient.getRepoPullRequests(repo.value.id, page);
|
return apiClient.getRepoPullRequests(repo.value.id, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { resetPage, data: pullRequests } = usePagination(loadPullRequests);
|
const { resetPage, data: pullRequests, loading } = usePagination(loadPullRequests);
|
||||||
|
|
||||||
watch(repo, resetPage);
|
watch(repo, resetPage);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue