Skip to content

Commit f2bc339

Browse files
committed
feat(onboarding): Pre-populate repo selector with full repo list
Load the complete list of accessible repositories on mount so users can browse and select without typing first. Search still narrows results server-side when the user types. Previously the dropdown was empty until a search query was entered, requiring users to know what to search for. Refs VDY-46
1 parent 801dacf commit f2bc339

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

static/app/views/onboarding/components/scmRepoSelector.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {trackAnalytics} from 'sentry/utils/analytics';
99
import {useOrganization} from 'sentry/utils/useOrganization';
1010

1111
import {ScmSearchControl} from './scmSearchControl';
12+
import {ScmVirtualizedMenuList} from './scmVirtualizedMenuList';
1213
import {useScmRepoSearch} from './useScmRepoSearch';
1314
import {useScmRepoSelection} from './useScmRepoSelection';
1415

@@ -20,14 +21,8 @@ export function ScmRepoSelector({integration}: ScmRepoSelectorProps) {
2021
const organization = useOrganization();
2122
const {selectedRepository, setSelectedRepository, clearDerivedState} =
2223
useOnboardingContext();
23-
const {
24-
reposByIdentifier,
25-
dropdownItems,
26-
isFetching,
27-
isError,
28-
debouncedSearch,
29-
setSearch,
30-
} = useScmRepoSearch(integration.id, selectedRepository);
24+
const {reposByIdentifier, dropdownItems, isFetching, isError, setSearch} =
25+
useScmRepoSearch(integration.id, selectedRepository);
3126

3227
const {busy, handleSelect, handleRemove} = useScmRepoSelection({
3328
integration,
@@ -75,14 +70,11 @@ export function ScmRepoSelector({integration}: ScmRepoSelectorProps) {
7570

7671
function noOptionsMessage() {
7772
if (isError) {
78-
return t('Failed to search repositories. Please try again.');
79-
}
80-
if (debouncedSearch) {
81-
return t(
82-
'No repositories found. Check your installation permissions to ensure your integration has access.'
83-
);
73+
return t('Failed to load repositories. Please try again.');
8474
}
85-
return t('Type to search repositories');
75+
return t(
76+
'No repositories found. Check your installation permissions to ensure your integration has access.'
77+
);
8678
}
8779

8880
return (
@@ -103,7 +95,7 @@ export function ScmRepoSelector({integration}: ScmRepoSelectorProps) {
10395
isDisabled={busy}
10496
clearable
10597
searchable
106-
components={{Control: ScmSearchControl}}
98+
components={{Control: ScmSearchControl, MenuList: ScmVirtualizedMenuList}}
10799
/>
108100
);
109101
}

static/app/views/onboarding/components/useScmRepoSearch.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ export function useScmRepoSearch(integrationId: string, selectedRepo?: Repositor
2626
},
2727
}
2828
),
29-
{method: 'GET', query: {search: debouncedSearch, accessibleOnly: true}},
29+
{
30+
method: 'GET',
31+
query: {
32+
...(debouncedSearch ? {search: debouncedSearch} : {}),
33+
accessibleOnly: true,
34+
},
35+
},
3036
] as const,
3137
queryFn: async context => {
3238
return fetchDataQuery<ScmRepoSearchResult>(context);
3339
},
3440
retry: 0,
3541
staleTime: 20_000,
36-
placeholderData: previousData => (debouncedSearch ? previousData : undefined),
37-
enabled: !!debouncedSearch,
42+
placeholderData: previousData => previousData,
3843
});
3944

4045
const selectedRepoSlug = selectedRepo?.externalSlug;
@@ -71,7 +76,6 @@ export function useScmRepoSearch(integrationId: string, selectedRepo?: Repositor
7176
dropdownItems,
7277
isFetching: searchQuery.isFetching,
7378
isError: searchQuery.isError,
74-
debouncedSearch,
7579
setSearch,
7680
};
7781
}

0 commit comments

Comments
 (0)