-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[projects] remove configuration page from wizard #7102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+138
−35
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,9 +7,9 @@ | |||||||||||||||||||||||||
import { useContext, useEffect, useState } from "react"; | ||||||||||||||||||||||||||
import { getGitpodService, gitpodHostUrl } from "../service/service"; | ||||||||||||||||||||||||||
import { iconForAuthProvider, openAuthorizeWindow, simplifyProviderName } from "../provider-utils"; | ||||||||||||||||||||||||||
import { AuthProviderInfo, ProviderRepository, Team, TeamMemberInfo, User } from "@gitpod/gitpod-protocol"; | ||||||||||||||||||||||||||
import { AuthProviderInfo, Project, ProviderRepository, Team, TeamMemberInfo, User } from "@gitpod/gitpod-protocol"; | ||||||||||||||||||||||||||
import { TeamsContext } from "../teams/teams-context"; | ||||||||||||||||||||||||||
import { useHistory, useLocation } from "react-router"; | ||||||||||||||||||||||||||
import { useLocation } from "react-router"; | ||||||||||||||||||||||||||
import ContextMenu, { ContextMenuEntry } from "../components/ContextMenu"; | ||||||||||||||||||||||||||
import CaretDown from "../icons/CaretDown.svg"; | ||||||||||||||||||||||||||
import Plus from "../icons/Plus.svg"; | ||||||||||||||||||||||||||
|
@@ -23,7 +23,6 @@ import exclamation from "../images/exclamation.svg"; | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export default function NewProject() { | ||||||||||||||||||||||||||
const location = useLocation(); | ||||||||||||||||||||||||||
const history = useHistory(); | ||||||||||||||||||||||||||
const { teams } = useContext(TeamsContext); | ||||||||||||||||||||||||||
const { user, setUser } = useContext(UserContext); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -33,12 +32,16 @@ export default function NewProject() { | |||||||||||||||||||||||||
const [selectedAccount, setSelectedAccount] = useState<string | undefined>(undefined); | ||||||||||||||||||||||||||
const [noOrgs, setNoOrgs] = useState<boolean>(false); | ||||||||||||||||||||||||||
const [showGitProviders, setShowGitProviders] = useState<boolean>(false); | ||||||||||||||||||||||||||
const [selectedRepo, setSelectedRepo] = useState<string | undefined>(undefined); | ||||||||||||||||||||||||||
const [selectedRepo, setSelectedRepo] = useState<ProviderRepository | undefined>(undefined); | ||||||||||||||||||||||||||
const [selectedTeamOrUser, setSelectedTeamOrUser] = useState<Team | User | undefined>(undefined); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const [showNewTeam, setShowNewTeam] = useState<boolean>(false); | ||||||||||||||||||||||||||
const [loaded, setLoaded] = useState<boolean>(false); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const [project, setProject] = useState<Project | undefined>(); | ||||||||||||||||||||||||||
const [guessedConfigString, setGuessedConfigString] = useState<string | undefined>(); | ||||||||||||||||||||||||||
const [sourceOfConfig, setSourceOfConfig] = useState<"repo" | "db" | undefined>(); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||
if (user && provider === undefined) { | ||||||||||||||||||||||||||
if (user.identities.find(i => i.authProviderId === "Public-GitLab")) { | ||||||||||||||||||||||||||
|
@@ -83,6 +86,32 @@ export default function NewProject() { | |||||||||||||||||||||||||
})(); | ||||||||||||||||||||||||||
}, [teams]); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||
if (selectedRepo) { | ||||||||||||||||||||||||||
(async () => { | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||
const guessedConfigStringPromise = getGitpodService().server.guessRepositoryConfiguration(selectedRepo.cloneUrl); | ||||||||||||||||||||||||||
const repoConfigString = await getGitpodService().server.fetchRepositoryConfiguration(selectedRepo.cloneUrl); | ||||||||||||||||||||||||||
if (repoConfigString) { | ||||||||||||||||||||||||||
setSourceOfConfig("repo"); | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
setSourceOfConfig("db"); | ||||||||||||||||||||||||||
setGuessedConfigString(await guessedConfigStringPromise || `tasks: | ||||||||||||||||||||||||||
- init: | | ||||||||||||||||||||||||||
echo 'TODO: build project' | ||||||||||||||||||||||||||
command: | | ||||||||||||||||||||||||||
echo 'TODO: start app'`); | ||||||||||||||||||||||||||
Comment on lines
+99
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there can be a race here -- if Safer the other way around:
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||
console.error('Getting project configuration failed', error); | ||||||||||||||||||||||||||
setSourceOfConfig(undefined); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
})(); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
}, [selectedRepo]); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||
if (selectedTeamOrUser && selectedRepo) { | ||||||||||||||||||||||||||
createProject(selectedTeamOrUser, selectedRepo); | ||||||||||||||||||||||||||
|
@@ -118,6 +147,17 @@ export default function NewProject() { | |||||||||||||||||||||||||
})(); | ||||||||||||||||||||||||||
}, [provider]); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||
if (project && sourceOfConfig) { | ||||||||||||||||||||||||||
(async () => { | ||||||||||||||||||||||||||
if (guessedConfigString && sourceOfConfig === "db") { | ||||||||||||||||||||||||||
await getGitpodService().server.setProjectConfiguration(project.id, guessedConfigString); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
await getGitpodService().server.triggerPrebuild(project.id, null); | ||||||||||||||||||||||||||
})(); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
}, [project, sourceOfConfig]); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const isGitHub = () => provider === "github.com"; | ||||||||||||||||||||||||||
const isBitbucket = () => provider === "bitbucket.org"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -180,16 +220,10 @@ export default function NewProject() { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const createProject = async (teamOrUser: Team | User, selectedRepo: string) => { | ||||||||||||||||||||||||||
const createProject = async (teamOrUser: Team | User, repo: ProviderRepository) => { | ||||||||||||||||||||||||||
if (!provider || isBitbucket()) { | ||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
const repo = reposInAccounts.find(r => r.account === selectedAccount && (r.path ? r.path === selectedRepo : r.name === selectedRepo)); | ||||||||||||||||||||||||||
if (!repo) { | ||||||||||||||||||||||||||
console.error("No repo selected!") | ||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const repoSlug = repo.path || repo.name; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||
|
@@ -203,7 +237,7 @@ export default function NewProject() { | |||||||||||||||||||||||||
appInstallationId: String(repo.installationId), | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
history.push(`/${User.is(teamOrUser) ? 'projects' : 't/'+teamOrUser.slug}/${project.slug}/configure`); | ||||||||||||||||||||||||||
setProject(project); | ||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||
const message = (error && error?.message) || "Failed to create new project." | ||||||||||||||||||||||||||
window.alert(message); | ||||||||||||||||||||||||||
|
@@ -294,7 +328,7 @@ export default function NewProject() { | |||||||||||||||||||||||||
<div className="flex justify-end"> | ||||||||||||||||||||||||||
<div className="h-full my-auto flex self-center opacity-0 group-hover:opacity-100"> | ||||||||||||||||||||||||||
{!r.inUse ? ( | ||||||||||||||||||||||||||
<button className="primary" onClick={() => setSelectedRepo(r.path || r.name)}>Select</button> | ||||||||||||||||||||||||||
<button className="primary" onClick={() => setSelectedRepo(r)}>Select</button> | ||||||||||||||||||||||||||
) : ( | ||||||||||||||||||||||||||
<p className="my-auto">already taken</p> | ||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||
|
@@ -428,18 +462,53 @@ export default function NewProject() { | |||||||||||||||||||||||||
</div>); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return (<div className="flex flex-col w-96 mt-24 mx-auto items-center"> | ||||||||||||||||||||||||||
<h1>New Project</h1> | ||||||||||||||||||||||||||
const onNewWorkspace = async () => { | ||||||||||||||||||||||||||
const redirectToNewWorkspace = () => { | ||||||||||||||||||||||||||
// instead of `history.push` we want forcibly to redirect here in order to avoid a following redirect from `/` -> `/projects` (cf. App.tsx) | ||||||||||||||||||||||||||
const url = new URL(window.location.toString()); | ||||||||||||||||||||||||||
url.pathname = "/"; | ||||||||||||||||||||||||||
url.hash = project?.cloneUrl!; | ||||||||||||||||||||||||||
window.location.href = url.toString(); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
redirectToNewWorkspace(); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (!project) { | ||||||||||||||||||||||||||
return (<div className="flex flex-col w-96 mt-24 mx-auto items-center"> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{!selectedRepo && renderSelectRepository()} | ||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||
<h1>New Project</h1> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{selectedRepo && !selectedTeamOrUser && renderSelectTeam()} | ||||||||||||||||||||||||||
{!selectedRepo && renderSelectRepository()} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{selectedRepo && selectedTeamOrUser && (<div></div>)} | ||||||||||||||||||||||||||
{selectedRepo && !selectedTeamOrUser && renderSelectTeam()} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{selectedRepo && selectedTeamOrUser && (<div></div>)} | ||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{isBitbucket() && renderBitbucketWarning()} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
</div>); | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
const projectLink = User.is(selectedTeamOrUser) ? `/projects/${project.slug}` : `/t/${selectedTeamOrUser?.slug}/${project.slug}`; | ||||||||||||||||||||||||||
const location = User.is(selectedTeamOrUser) ? "" : (<> in team <a className="gp-link" href={`/t/${selectedTeamOrUser?.slug}/projects`}>{selectedTeamOrUser?.name}</a></>); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
{isBitbucket() && renderBitbucketWarning()} | ||||||||||||||||||||||||||
return (<div className="flex flex-col w-96 mt-24 mx-auto items-center"> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
</div>); | ||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||
<h1>Project Created</h1> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
<p className="mt-2 text-gray-500 text-center text-base">Created <a className="gp-link" href={projectLink}>{project.name}</a> {location} | ||||||||||||||||||||||||||
</p> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
<div className="mt-12"> | ||||||||||||||||||||||||||
<button onClick={onNewWorkspace}>New Workspace</button> | ||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
</div>); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.