Skip to content

Commit 38ea2f7

Browse files
committed
fix(prs): keep local filtering for providers without reviewer search
1 parent 4862ded commit 38ea2f7

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
7979
const [error, setError] = useState<string | null>(null);
8080
const inFlight = useRef(false);
8181
const searchQuery = useDebouncedValue(query.trim(), 250);
82-
const searchesHost = result.data?.truncated === true && searchQuery.length > 0;
82+
const supportsSearch = pr?.provider === "github" || pr?.provider === "gitlab";
83+
const searchesHost = supportsSearch && result.data?.truncated === true && searchQuery.length > 0;
8384
const searched = searchesHost && searchQuery === query.trim();
8485
const searchResult = useEnvironmentQuery(
8586
searchesHost
@@ -97,6 +98,7 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
9798
),
9899
].sort((a, b) => Number(b.isRequested) - Number(a.isRequested) || a.login.localeCompare(b.login));
99100
const searchPending =
101+
supportsSearch &&
100102
result.data?.truncated === true &&
101103
query.trim().length > 0 &&
102104
(searchQuery !== query.trim() || searchResult.isPending);
@@ -277,14 +279,17 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
277279
}
278280
ListFooterComponent={
279281
result.data?.truncated &&
280-
(query.trim().length === 0 ||
282+
(!supportsSearch ||
283+
query.trim().length === 0 ||
281284
(searched && (searchResult.error !== null || searchResult.data?.truncated))) ? (
282285
<Text className="px-4 py-4 text-xs text-foreground-muted">
283-
{searched && searchResult.error
284-
? `Only listed reviewers are matched: the provider search failed. ${searchResult.error}`
285-
: searched
286-
? "More reviewers match than the provider returned. Keep typing to narrow it down."
287-
: "The provider has more reviewers than are listed here. Search to find them."}
286+
{!supportsSearch
287+
? "The provider has more reviewers than are listed here. Find additional reviewers on the provider."
288+
: searched && searchResult.error
289+
? `Only listed reviewers are matched: the provider search failed. ${searchResult.error}`
290+
: searched
291+
? "More reviewers match than the provider returned. Keep typing to narrow it down."
292+
: "The provider has more reviewers than are listed here. Search to find them."}
288293
</Text>
289294
) : undefined
290295
}

‎apps/web/src/components/pullRequest/PullRequestReviewerPicker.tsx‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
EnvironmentId,
44
PullRequestRef,
55
PullRequestReviewerCandidate,
6+
SourceControlProviderKind,
67
} from "@t3tools/contracts";
78
import { mergeReviewerCandidates } from "@t3tools/client-runtime/pull-request-reviewers";
89
import { CheckIcon, UserPlusIcon } from "lucide-react";
@@ -22,10 +23,12 @@ export function PullRequestReviewerPicker({
2223
environmentId,
2324
reference,
2425
allowed,
26+
provider,
2527
}: {
2628
environmentId: EnvironmentId;
2729
reference: PullRequestRef;
2830
allowed: boolean;
31+
provider: SourceControlProviderKind;
2932
}) {
3033
const [open, setOpen] = useState(false);
3134
const [query, setQuery] = useState("");
@@ -36,7 +39,9 @@ export function PullRequestReviewerPicker({
3639
);
3740
// Past the first page the host is asked, since what was loaded cannot answer for the rest.
3841
const searchQuery = useDebouncedValue(query.trim(), 250);
39-
const searchesHost = candidatesQuery.data?.truncated === true && searchQuery.length > 0;
42+
const supportsSearch = provider === "github" || provider === "gitlab";
43+
const searchesHost =
44+
supportsSearch && candidatesQuery.data?.truncated === true && searchQuery.length > 0;
4045
// Only once the debounce has caught up, or rows matching the previous text would linger.
4146
const searched = searchesHost && searchQuery === query.trim();
4247
const searchResult = useEnvironmentQuery(
@@ -108,6 +113,7 @@ export function PullRequestReviewerPicker({
108113
(candidatesQuery.isPending && candidatesQuery.data === null) ||
109114
// Nothing loaded matches yet, and the host has not answered: not a "nobody matches".
110115
(candidates.length === 0 &&
116+
supportsSearch &&
111117
candidatesQuery.data?.truncated === true &&
112118
query.trim().length > 0 &&
113119
(searchQuery !== query.trim() || searchResult.isPending))
@@ -125,15 +131,18 @@ export function PullRequestReviewerPicker({
125131
errorLabel="The people with access could not be read."
126132
truncated={
127133
candidatesQuery.data?.truncated === true &&
128-
(query.trim().length === 0 ||
134+
(!supportsSearch ||
135+
query.trim().length === 0 ||
129136
(searched && (searchResult.error !== null || searchResult.data?.truncated === true)))
130137
}
131138
truncatedLabel={
132-
searched && searchResult.error !== null
133-
? `Only the people already listed are matched: the host search failed. ${searchResult.error}`
134-
: searched
135-
? "More people match than the host returned. Keep typing to narrow it down."
136-
: "This repository has more people with access than are listed here. Search to find them."
139+
!supportsSearch
140+
? "The provider has more reviewers than are listed here. Find additional reviewers on the provider."
141+
: searched && searchResult.error !== null
142+
? `Only the people already listed are matched: the host search failed. ${searchResult.error}`
143+
: searched
144+
? "More people match than the host returned. Keep typing to narrow it down."
145+
: "This repository has more people with access than are listed here. Search to find them."
137146
}
138147
candidateKey={(candidate) => `${candidate.kind}:${candidate.id}`}
139148
disabled={pending !== null}

‎apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ export function PullRequestSummaryTab({
721721
{detail.capabilities.reviewers.request &&
722722
detail.capabilities.reviewers.listCandidates ? (
723723
<PullRequestReviewerPicker
724+
provider={detail.provider}
724725
environmentId={environmentId}
725726
reference={reference}
726727
allowed={detail.viewerPermissions.requestReviewers}

0 commit comments

Comments
 (0)