-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open start workspace in modal from projects list #15914
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import { openAuthorizeWindow } from "../provider-utils"; | |
import Alert from "../components/Alert"; | ||
import { listAllProjects } from "../service/public-api"; | ||
import { UserContext } from "../user-context"; | ||
import { StartWorkspaceModalContext } from "../workspaces/start-workspace-modal-context"; | ||
|
||
export default function () { | ||
const location = useLocation(); | ||
|
@@ -29,6 +30,7 @@ export default function () { | |
const { teams } = useContext(TeamsContext); | ||
const { user } = useContext(UserContext); | ||
const team = getCurrentTeam(location, teams); | ||
const { setStartWorkspaceModalProps } = useContext(StartWorkspaceModalContext); | ||
|
||
const match = useRouteMatch<{ team: string; resource: string }>("/(t/)?:team/:resource"); | ||
const projectSlug = match?.params?.resource; | ||
|
@@ -395,9 +397,11 @@ export default function () { | |
menuEntries={[ | ||
{ | ||
title: "New Workspace ...", | ||
href: gitpodHostUrl | ||
.withContext(`${branch.url}`, { showOptions: true }) | ||
.toString(), | ||
onClick: () => | ||
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. Like the preserving of context here! |
||
setStartWorkspaceModalProps({ | ||
contextUrl: branch.url, | ||
allowContextUrlChange: true, | ||
}), | ||
separator: true, | ||
}, | ||
prebuild?.status === "queued" || prebuild?.status === "building" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ export interface StartWorkspaceModalProps { | |
ide?: string; | ||
workspaceClass?: string; | ||
contextUrl?: string; | ||
// If contextUrl is provided, setting `allowContextUrlChange` to true will allow it to be changed still | ||
allowContextUrlChange?: boolean; | ||
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 didn't want to change existing behavior for when the start workspace ui locks that context url, so adding this option felt like the safest approach. |
||
onClose?: () => void; | ||
} | ||
|
||
|
@@ -88,7 +90,10 @@ export function StartWorkspaceModal(props: StartWorkspaceModalProps) { | |
<div className="-mx-6 px-6"> | ||
<div className="text-xs text-gray-500">Start a new workspace with the following options.</div> | ||
<div className="pt-3"> | ||
<RepositoryFinder setSelection={props.contextUrl ? undefined : setRepo} initialValue={repo} /> | ||
<RepositoryFinder | ||
setSelection={props.contextUrl && !props.allowContextUrlChange ? undefined : setRepo} | ||
initialValue={repo} | ||
/> | ||
</div> | ||
<div className="pt-3"> | ||
{errorIde && <div className="text-red-500 text-sm">{errorIde}</div>} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this effect updates
suggestedContextURLs
, having it as a dep caused it to constantly run as soon as it callssetSuggestedContextURLs