Skip to content

Commit

Permalink
[dashboard] show error message on new project for Bitbucket-only users
Browse files Browse the repository at this point in the history
Fixes #6345
  • Loading branch information
JanKoehnlein authored and roboquat committed Nov 19, 2021
1 parent 87e44ed commit d8ee631
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions components/dashboard/src/projects/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -85,7 +87,7 @@ export default function NewProject() {
}, [selectedAccount]);

useEffect(() => {
if (!provider) {
if (!provider || isBitbucket()) {
return;
}
(async () => {
Expand All @@ -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 {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -335,11 +338,11 @@ export default function NewProject() {
setProvider(host);
}

if (!loaded) {
if (!loaded && !isBitbucket()) {
return renderLoadingState();
}

if (showGitProviders) {
if (showGitProviders || isBitbucket()) {
return (<GitProviders onHostSelected={onGitProviderSeleted} />);
}

Expand Down Expand Up @@ -387,16 +390,35 @@ export default function NewProject() {
</>)
};

const renderBitbucketWarning = () => {
return (
<div className="mt-16 flex space-x-2 py-6 px-6 w-96 justify-betweeen bg-gitpod-kumquat-light rounded-xl">
<div className="pr-3 self-center w-6">
<img src={exclamation} />
</div>
<div className="flex-1 flex flex-col">
<p className="text-gitpod-red text-sm">Bitbucket support for projects is not available yet. Follow <a className="gp-link" href="https://github.com/gitpod-io/gitpod/issues/5980">#5980</a> for updates.</p>
</div>
</div>);
}

const renderSelectRepoHeading = () => {
return <p className="text-gray-500 text-center text-base">Select a Git repository on <strong>{provider}</strong>. (<a className="gp-link cursor-pointer" onClick={() => setShowGitProviders(true)}>change</a>)</p>
}

return (<div className="flex flex-col w-96 mt-24 mx-auto items-center">
<h1>New Project</h1>
<p className="text-gray-500 text-center text-base">Select a Git repository on <strong>{provider}</strong>. (<a className="gp-link cursor-pointer" onClick={() => setShowGitProviders(true)}>change</a>)</p>

{isBitbucket() || renderSelectRepoHeading()}

{!selectedRepo && renderSelectRepository()}

{selectedRepo && !selectedTeamOrUser && renderSelectTeam()}

{selectedRepo && selectedTeamOrUser && (<div></div>)}

{isBitbucket() && renderBitbucketWarning()}

</div>);

}
Expand Down

0 comments on commit d8ee631

Please sign in to comment.