From d8ee6317667062a4b1ea238ebcf07d852b32b64f Mon Sep 17 00:00:00 2001 From: Jan Koehnlein Date: Wed, 10 Nov 2021 14:12:58 +0000 Subject: [PATCH] [dashboard] show error message on new project for Bitbucket-only users Fixes #6345 --- .../dashboard/src/projects/NewProject.tsx | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/components/dashboard/src/projects/NewProject.tsx b/components/dashboard/src/projects/NewProject.tsx index 6caccb79845b4b..623496054bae79 100644 --- a/components/dashboard/src/projects/NewProject.tsx +++ b/components/dashboard/src/projects/NewProject.tsx @@ -45,6 +45,8 @@ export default function NewProject() { setProvider("gitlab.com"); } else if (user.identities.find(i => i.authProviderId === "Public-GitHub")) { setProvider("github.com"); + } else if (user.identities.find(i => i.authProviderId === "Public-Bitbucket")) { + setProvider("bitbucket.org"); } } }, [user]); @@ -85,7 +87,7 @@ export default function NewProject() { }, [selectedAccount]); useEffect(() => { - if (!provider) { + if (!provider || isBitbucket()) { return; } (async () => { @@ -95,11 +97,12 @@ export default function NewProject() { }, [provider]); const isGitHub = () => provider === "github.com"; + const isBitbucket = () => provider == "bitbucket.org"; const updateReposInAccounts = async (installationId?: string) => { setLoaded(false); setReposInAccounts([]); - if (!provider) { + if (!provider || isBitbucket()) { return []; } try { @@ -156,7 +159,7 @@ export default function NewProject() { } const createProject = async (teamOrUser: Team | User, selectedRepo: string) => { - if (!provider) { + if (!provider || isBitbucket()) { return; } const repo = reposInAccounts.find(r => r.account === selectedAccount && (r.path ? r.path === selectedRepo : r.name === selectedRepo)); @@ -335,11 +338,11 @@ export default function NewProject() { setProvider(host); } - if (!loaded) { + if (!loaded && !isBitbucket()) { return renderLoadingState(); } - if (showGitProviders) { + if (showGitProviders || isBitbucket()) { return (); } @@ -387,9 +390,26 @@ export default function NewProject() { ) }; + const renderBitbucketWarning = () => { + return ( +
+
+ +
+
+

Bitbucket support for projects is not available yet. Follow #5980 for updates.

+
+
); + } + + const renderSelectRepoHeading = () => { + return

Select a Git repository on {provider}. ( setShowGitProviders(true)}>change)

+ } + return (

New Project

-

Select a Git repository on {provider}. ( setShowGitProviders(true)}>change)

+ + {isBitbucket() || renderSelectRepoHeading()} {!selectedRepo && renderSelectRepository()} @@ -397,6 +417,8 @@ export default function NewProject() { {selectedRepo && selectedTeamOrUser && (
)} + {isBitbucket() && renderBitbucketWarning()} +
); }