Skip to content

Commit 409d93c

Browse files
authored
Always show first-published-tag-for-merged-pr (refined-github#5899)
1 parent 1ac1fac commit 409d93c

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

source/features/first-published-tag-for-merged-pr.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ async function init(): Promise<void> {
3535

3636
if (tagName) {
3737
addExistingTagLink(tagName);
38-
} else if (canCreateRelease()) {
39-
void addLinkToCreateRelease('This pull request seems to be unreleased');
38+
} else {
39+
void addReleaseBanner('This pull request has not yet appeared in a release');
4040
}
4141
}
4242

@@ -76,14 +76,16 @@ function addExistingTagLink(tagName: string): void {
7676
});
7777
}
7878

79-
async function addLinkToCreateRelease(text = 'Now you can release this change'): Promise<void> {
80-
if (await getReleaseCount() > 0) {
79+
async function addReleaseBanner(text = 'Now you can release this change'): Promise<void> {
80+
if (await getReleaseCount() === 0) {
8181
return;
8282
}
8383

84-
const url = isRefinedGitHubRepo()
85-
? 'https://github.com/refined-github/refined-github/actions/workflows/release.yml'
86-
: buildRepoURL('releases/new');
84+
const url = canCreateRelease() ? (
85+
isRefinedGitHubRepo()
86+
? 'https://github.com/refined-github/refined-github/actions/workflows/release.yml'
87+
: buildRepoURL('releases/new')
88+
) : undefined;
8789
attachElement({
8890
anchor: '#issue-comment-box',
8991
before: () => (
@@ -99,6 +101,7 @@ async function addLinkToCreateRelease(text = 'Now you can release this change'):
99101
}
100102

101103
void features.add(import.meta.url, {
104+
// When arriving on an already-merged PR
102105
asLongAs: [
103106
pageDetect.isPRConversation,
104107
pageDetect.isMergedPR,
@@ -109,6 +112,7 @@ void features.add(import.meta.url, {
109112
deduplicate: 'has-rgh-inner',
110113
init,
111114
}, {
115+
// This catches a PR while it's being merged
112116
asLongAs: [
113117
pageDetect.isPRConversation,
114118
pageDetect.isOpenPR,
@@ -120,16 +124,14 @@ void features.add(import.meta.url, {
120124
onlyAdditionalListeners: true,
121125
deduplicate: false,
122126
init() {
123-
void addLinkToCreateRelease();
127+
void addReleaseBanner();
124128
},
125129
});
126130

127131
/*
128-
129-
# Test URLs
132+
Test URLs
130133
131134
- PR: https://github.com/refined-github/refined-github/pull/5600
132135
- Locked PR: https://github.com/eslint/eslint/pull/17
133136
- Archived repo: https://github.com/fregante/iphone-inline-video/pull/130
134-
135137
*/

source/github-helpers/banner.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React from 'dom-chef';
2-
import {RequireAllOrNone} from 'type-fest';
32

4-
type BannerProps = RequireAllOrNone<{
3+
interface BannerProps {
54
text: Array<string | JSX.Element> | string | JSX.Element;
6-
url: string;
5+
url?: string;
76
buttonLabel: JSX.Element | string;
87
classes?: string[];
9-
}, 'buttonLabel' | 'url'>;
8+
}
109

1110
// This could be a `<Banner/>` element but dom-chef doesn't pass props
1211
// https://github.com/vadimdemedes/dom-chef/issues/77

0 commit comments

Comments
 (0)