@@ -12,55 +12,32 @@ const props = defineProps<{
1212 repo: string ;
1313}>();
1414
15- type BranchesResponse = {
16- branches: string [];
17- };
18-
19- const [data, branchesResponse] = await Promise .all ([
20- $fetch (" /api/repo/commits" , {
21- query: {
22- owner: props .owner ,
23- repo: props .repo ,
24- },
25- }),
26- $fetch <BranchesResponse >(" /api/repo/branches" , {
27- query: {
28- owner: props .owner ,
29- repo: props .repo ,
30- },
31- }).catch (() => null ),
32- ]);
15+ const data = await $fetch (" /api/repo/commits" , {
16+ query: {
17+ owner: props .owner ,
18+ repo: props .repo ,
19+ },
20+ });
3321
3422if (! data ) {
3523 throw createError (" Could not load Commits" );
3624}
3725
3826const branch = shallowReactive (data );
39- const selectedBranch = ref (branch .name );
40- const availableBranches = ref <string []>(
41- branchesResponse ?.branches ?.length ? branchesResponse .branches : [branch .name ],
42- );
43-
44- if (! availableBranches .value .includes (branch .name )) {
45- availableBranches .value .unshift (branch .name );
46- }
4727
4828const commitsWithRelease = computed (() =>
4929 branch .target .history .nodes
50- .flatMap ((commit ) => {
51- const release = commit .statusCheckRollup ?.contexts .nodes .find (
30+ .filter ((commit ) =>
31+ commit .statusCheckRollup ?.contexts .nodes .some (
5232 (context ) => context .name === " Continuous Releases" ,
53- );
54-
55- return release
56- ? [
57- {
58- ... commit ,
59- release ,
60- },
61- ]
62- : [];
63- }),
33+ ),
34+ )
35+ .map ((commit ) => ({
36+ ... commit ,
37+ release: commit .statusCheckRollup .contexts .nodes .find (
38+ (context ) => context .name === " Continuous Releases" ,
39+ )! ,
40+ })),
6441);
6542
6643const selectedCommit = shallowRef <
@@ -137,39 +114,6 @@ onBeforeUnmount(() => {
137114// Pagination
138115const fetching = ref (false );
139116const fetchMoreForceDisabled = ref (! commitsWithRelease .value .length );
140- const switchingBranch = ref (false );
141-
142- async function loadBranch(branchName : string ) {
143- if (switchingBranch .value ) {
144- return ;
145- }
146-
147- const previousBranch = branch .name ;
148-
149- try {
150- switchingBranch .value = true ;
151- selectedCommit .value = null ;
152-
153- const result = await $fetch (" /api/repo/commits" , {
154- query: {
155- owner: props .owner ,
156- repo: props .repo ,
157- branch: branchName ,
158- },
159- });
160-
161- Object .assign (branch , result );
162- fetchMoreForceDisabled .value = ! commitsWithRelease .value .length ;
163- } catch (error ) {
164- selectedBranch .value = previousBranch ;
165- } finally {
166- switchingBranch .value = false ;
167- }
168- }
169-
170- async function onBranchChange() {
171- await loadBranch (selectedBranch .value );
172- }
173117
174118async function fetchMore() {
175119 if (! branch .target .history .pageInfo .hasNextPage ) {
@@ -189,7 +133,6 @@ async function fetchMore() {
189133 query: {
190134 owner: props .owner ,
191135 repo: props .repo ,
192- branch: selectedBranch .value ,
193136 cursor ,
194137 },
195138 });
@@ -216,23 +159,10 @@ async function fetchMore() {
216159
217160<template >
218161 <div class =" flex flex-col gap-6" >
219- <div class =" text-center flex justify-center items-center gap-2 opacity-80" >
162+ <div class =" text-center flex justify-center items-center gap-1 opacity-80" >
220163 Continuous Releases from
221164 <UIcon name="i-ph-git-branch" />
222- <select
223- v-model =" selectedBranch"
224- class =" px-2 py-1 rounded-md bg-transparent border border-gray-300 dark:border-gray-700 text-sm"
225- :disabled =" switchingBranch"
226- @change =" onBranchChange"
227- >
228- <option
229- v-for =" branchName of availableBranches"
230- :key =" branchName"
231- :value =" branchName"
232- >
233- {{ branchName }}
234- </option >
235- </select >
165+ {{ branch.name }}
236166 </div >
237167
238168 <div class =" flex flex-col gap-2" >
0 commit comments