Skip to content

Commit e06449c

Browse files
committed
adjust loading state to not be totally blocking
1 parent 1551f6a commit e06449c

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

components/dashboard/src/projects/new-project/NewProjectRepoSelection.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
5757
const noReposAvailable = !!(reposInAccounts?.length === 0 || areGitHubWebhooksUnauthorized);
5858
// TODO: check type instead of host?
5959
const isGitHub = selectedProvider?.host === "github.com";
60+
const isBitbucketServer = selectedProvider?.authProviderType !== "BitbucketServer";
6061

6162
const accounts = useMemo(() => {
6263
const accounts = new Map<string, { avatarUrl: string }>();
@@ -125,6 +126,11 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
125126

126127
// Adjusts selectedAccount when repos change if we don't have a selected account
127128
useEffect(() => {
129+
// TODO: find a better solution here
130+
if (isBitbucketServer) {
131+
return;
132+
}
133+
128134
if (reposInAccounts?.length === 0) {
129135
setSelectedAccountAndClearSearch(undefined);
130136
} else if (!selectedAccount) {
@@ -138,11 +144,7 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
138144
setSelectedAccountAndClearSearch(first?.account);
139145
}
140146
}
141-
}, [reposInAccounts, selectedAccount, setSelectedAccountAndClearSearch]);
142-
143-
if (isLoading) {
144-
return <ReposLoading />;
145-
}
147+
}, [isBitbucketServer, reposInAccounts, selectedAccount, setSelectedAccountAndClearSearch]);
146148

147149
return (
148150
<>
@@ -152,7 +154,7 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
152154
</p>
153155
<div className={`mt-2 flex-col ${noReposAvailable && isGitHub ? "w-96" : ""}`}>
154156
<div className="px-8 flex flex-col space-y-2" data-analytics='{"label":"Identity"}'>
155-
{selectedProvider?.authProviderType !== "BitbucketServer" && (
157+
{!isBitbucketServer && (
156158
<NewProjectAccountSelector
157159
accounts={accounts}
158160
selectedAccount={selectedAccount}
@@ -165,12 +167,16 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
165167
<NewProjectSearchInput searchFilter={repoSearchFilter} onSearchFilterChange={setRepoSearchFilter} />
166168
</div>
167169
<div className="p-6 flex-col">
168-
<NewProjectRepoList
169-
isCreating={createProject.isLoading}
170-
filteredRepos={filteredRepos}
171-
noReposAvailable={noReposAvailable}
172-
onRepoSelected={handleRepoSelected}
173-
/>
170+
{isLoading ? (
171+
<ReposLoading />
172+
) : (
173+
<NewProjectRepoList
174+
isCreating={createProject.isLoading}
175+
filteredRepos={filteredRepos}
176+
noReposAvailable={noReposAvailable}
177+
onRepoSelected={handleRepoSelected}
178+
/>
179+
)}
174180
{!isLoading && noReposAvailable && isGitHub && (
175181
<NewProjectAuthRequired
176182
selectedProviderHost={selectedProvider?.host}
@@ -180,7 +186,7 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
180186
)}
181187
</div>
182188
</div>
183-
{reposInAccounts && reposInAccounts.length > 0 && isGitHub && isGitHubAppEnabled && (
189+
{!isLoading && reposInAccounts && reposInAccounts.length > 0 && isGitHub && isGitHubAppEnabled && (
184190
<div>
185191
<div className="text-gray-500 text-center w-96 mx-8">
186192
Repository not found?{" "}
@@ -193,7 +199,7 @@ export const NewProjectRepoSelection: FC<Props> = ({ selectedProvider, onProject
193199
</div>
194200
</div>
195201
)}
196-
{(filteredRepos?.length ?? 0) === 0 && repoSearchFilter.length > 0 && (
202+
{!isLoading && (filteredRepos?.length ?? 0) === 0 && repoSearchFilter.length > 0 && (
197203
<NewProjectCreateFromURL
198204
repoSearchFilter={repoSearchFilter}
199205
isCreating={createProject.isLoading}

0 commit comments

Comments
 (0)