mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 18:01:02 +00:00
Show default branch on top (#3019)
This commit is contained in:
parent
d82e151440
commit
28bd6cc690
1 changed files with 16 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div v-if="branches" class="space-y-4">
|
||||
<ListItem
|
||||
v-for="branch in branches"
|
||||
v-for="branch in branchesWithDefaultBranchFirst"
|
||||
:key="branch"
|
||||
class="text-wp-text-100"
|
||||
:to="{ name: 'repo-branch', params: { branch } }"
|
||||
|
@ -13,7 +13,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { inject, Ref, watch } from 'vue';
|
||||
import { computed, inject, Ref, watch } from 'vue';
|
||||
|
||||
import Badge from '~/components/atomic/Badge.vue';
|
||||
import ListItem from '~/components/atomic/ListItem.vue';
|
||||
|
@ -38,5 +38,19 @@ async function loadBranches(page: number): Promise<string[]> {
|
|||
|
||||
const { resetPage, data: branches } = usePagination(loadBranches);
|
||||
|
||||
const branchesWithDefaultBranchFirst = computed(() =>
|
||||
branches.value.toSorted((a, b) => {
|
||||
if (a === repo.value.default_branch) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b === repo.value.default_branch) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}),
|
||||
);
|
||||
|
||||
watch(repo, resetPage);
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue