|
1 | 1 | <template> |
2 | 2 | <Panel |
3 | 3 | class="bg-transparent border-none" |
4 | | - header="Lychee Pull Requests" |
| 4 | + :header="formatOwnerRepo() + ' Pull Requests'" |
5 | 5 | :pt:header:class="'justify-center text-4xl font-bold'" |
6 | 6 | > |
7 | 7 | <div class="flex flex-col max-w-4xl mx-auto gap-4 text-left"> |
8 | 8 | <div class="group mb-4 text-muted-color text-center cursor-pointer" @click="refresh"> |
9 | 9 | <span class="group-hover:hidden">Last update: {{ formattedUpdated }}</span> |
10 | 10 | <span class="hidden group-hover:inline text-primary-emphasis">Click to clear cache.</span> |
11 | 11 | </div> |
| 12 | + <div class="flex flex-col gap-4 -mt-12"> |
| 13 | + <i |
| 14 | + class="self-end flex pi pi-question-circle text-xl text-muted-color hover:text-primary-emphasis peer cursor-help" |
| 15 | + ></i> |
| 16 | + <div |
| 17 | + class="text-muted-color flex flex-col gap-4 max-h-0 overflow-y-hidden peer-hover:max-h-dvh hover:max-h-dvh transition-all duration-1000 ease-in-out" |
| 18 | + > |
| 19 | + <p> |
| 20 | + The support of stacked PR on the GitHub pull request page is pretty much non-existent. This page |
| 21 | + attempts to provide a better way to visualize them. |
| 22 | + </p> |
| 23 | + <p> |
| 24 | + A stack is automatically recognized by following the branch naming-convention |
| 25 | + <span class="text-sm font-mono text-muted-color-emphasis">feature-name/pr-name</span>: all the |
| 26 | + pull requests that start with the same |
| 27 | + <span class="text-sm font-mono text-muted-color-emphasis">feature-name/</span> are part of the |
| 28 | + same stack. All other pull requests are considered standalone. |
| 29 | + </p> |
| 30 | + <p> |
| 31 | + You can also use this page for your projects by adding |
| 32 | + <span class="text-sm font-mono text-muted-color-emphasis">#<owner>/<repo></span> at |
| 33 | + the end of the url. |
| 34 | + </p> |
| 35 | + </div> |
| 36 | + </div> |
12 | 37 | <template v-if="pullRequests"> |
| 38 | + <template v-if="pullRequests.length === 0"> |
| 39 | + <p class="text-center text-muted-color">No active pull requests.</p> |
| 40 | + </template> |
13 | 41 | <template v-if="pullRequests.length === 1"> |
14 | 42 | <PrList v-if="pullRequests" :pull-requests="pullRequests[0].data" /> |
15 | 43 | </template> |
@@ -88,15 +116,33 @@ const formattedUpdated = computed(() => { |
88 | 116 | ); |
89 | 117 | }); |
90 | 118 |
|
| 119 | +function getOwnerRepo(): { owner: string; repo: string } { |
| 120 | + const search = window.location.hash; |
| 121 | + const [owner, repo] = search.replace('#', '').split('/'); |
| 122 | + return { |
| 123 | + owner: owner || 'LycheeOrg', |
| 124 | + repo: repo || 'Lychee', |
| 125 | + }; |
| 126 | +} |
| 127 | +
|
| 128 | +const { owner, repo } = getOwnerRepo(); |
| 129 | +
|
| 130 | +function formatOwnerRepo(): string { |
| 131 | + if (owner === 'LycheeOrg' && repo === 'Lychee') { |
| 132 | + return 'Lychee'; |
| 133 | + } |
| 134 | + return `${owner}/${repo}`; |
| 135 | +} |
| 136 | +
|
91 | 137 | async function refresh() { |
92 | 138 | queryStore.reset(); |
93 | 139 | pullRequestsData.value = undefined; |
94 | | - await getPrs(); |
95 | | - getStatuses(); |
| 140 | + await getPrs(owner, repo); |
| 141 | + getStatuses(owner, repo); |
96 | 142 | } |
97 | 143 |
|
98 | 144 | onMounted(async () => { |
99 | | - await getPrs(); |
100 | | - getStatuses(); |
| 145 | + await getPrs(owner, repo); |
| 146 | + getStatuses(owner, repo); |
101 | 147 | }); |
102 | 148 | </script> |
0 commit comments