Skip to content

Commit

Permalink
Show default branch on top (#3019)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashass committed Dec 26, 2023
1 parent d82e151 commit 28bd6cc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions web/src/views/repo/RepoBranches.vue
Original file line number Diff line number Diff line change
@@ -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 } }"
Expand All @@ -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';
Expand All @@ -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>

0 comments on commit 28bd6cc

Please sign in to comment.