mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-04-29 06:54:43 +00:00
Co-authored-by: qwerty287 <qwerty287@posteo.de> Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
59 lines
2.1 KiB
Vue
59 lines
2.1 KiB
Vue
<template>
|
|
<div class="space-y-4">
|
|
<template v-if="pullRequests.length > 0">
|
|
<ListItem
|
|
v-for="pullRequest in pullRequests"
|
|
:key="pullRequest.index"
|
|
class="text-wp-text-100"
|
|
:to="{ name: 'repo-pull-request', params: { pullRequest: pullRequest.index } }"
|
|
>
|
|
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
|
|
<span class="text-wp-text-alt-100 <md:hidden">#{{ pullRequest.index }}</span>
|
|
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
|
|
<span class="text-wp-text-alt-100 <md:hidden mx-2">-</span>
|
|
<span class="text-wp-text-100 <md:underline whitespace-nowrap overflow-hidden overflow-ellipsis">{{
|
|
pullRequest.title
|
|
}}</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>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { inject, watch, type Ref } from 'vue';
|
|
|
|
import Icon from '~/components/atomic/Icon.vue';
|
|
import ListItem from '~/components/atomic/ListItem.vue';
|
|
import Panel from '~/components/layout/Panel.vue';
|
|
import useApiClient from '~/compositions/useApiClient';
|
|
import { usePagination } from '~/compositions/usePaginate';
|
|
import type { PullRequest, Repo } from '~/lib/api/types';
|
|
|
|
const apiClient = useApiClient();
|
|
|
|
const repo = inject<Ref<Repo>>('repo');
|
|
if (!repo) {
|
|
throw new Error('Unexpected: "repo" should be provided at this place');
|
|
}
|
|
if (!repo.value.pr_enabled || !repo.value.allow_pr) {
|
|
throw new Error('Unexpected: pull requests are disabled for repo');
|
|
}
|
|
|
|
async function loadPullRequests(page: number): Promise<PullRequest[]> {
|
|
if (!repo) {
|
|
throw new Error('Unexpected: "repo" should be provided at this place');
|
|
}
|
|
|
|
return apiClient.getRepoPullRequests(repo.value.id, { page });
|
|
}
|
|
|
|
const { resetPage, data: pullRequests, loading } = usePagination(loadPullRequests);
|
|
|
|
watch(repo, resetPage);
|
|
</script>
|