mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-16 19:35:14 +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>
|
<template>
|
||||||
<div v-if="branches" class="space-y-4">
|
<div v-if="branches" class="space-y-4">
|
||||||
<ListItem
|
<ListItem
|
||||||
v-for="branch in branches"
|
v-for="branch in branchesWithDefaultBranchFirst"
|
||||||
:key="branch"
|
:key="branch"
|
||||||
class="text-wp-text-100"
|
class="text-wp-text-100"
|
||||||
:to="{ name: 'repo-branch', params: { branch } }"
|
:to="{ name: 'repo-branch', params: { branch } }"
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<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 Badge from '~/components/atomic/Badge.vue';
|
||||||
import ListItem from '~/components/atomic/ListItem.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 { 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);
|
watch(repo, resetPage);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue