Skip to content

Commit 7cbf80b

Browse files
svenefftingeroboquat
authored andcommitted
[dashboard] add "with-options" buttons
1 parent 3c7bd7c commit 7cbf80b

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

components/dashboard/src/projects/Project.tsx

+22-19
Original file line numberDiff line numberDiff line change
@@ -398,26 +398,29 @@ export default function () {
398398
</a>
399399
<ItemFieldContextMenu
400400
className="py-0.5"
401-
menuEntries={
401+
menuEntries={[
402+
{
403+
title: "New Workspace ...",
404+
href: gitpodHostUrl
405+
.withContext(`${branch.url}`, { showOptions: true })
406+
.toString(),
407+
separator: true,
408+
},
402409
prebuild?.status === "queued" || prebuild?.status === "building"
403-
? [
404-
{
405-
title: "Cancel Prebuild",
406-
customFontStyle:
407-
"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300",
408-
onClick: () =>
409-
prebuild && cancelPrebuild(prebuild.info.id),
410-
},
411-
]
412-
: [
413-
{
414-
title: `${prebuild ? "Rerun" : "Run"} Prebuild (${
415-
branch.name
416-
})`,
417-
onClick: () => triggerPrebuild(branch),
418-
},
419-
]
420-
}
410+
? {
411+
title: "Cancel Prebuild",
412+
customFontStyle:
413+
"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300",
414+
onClick: () =>
415+
prebuild && cancelPrebuild(prebuild.info.id),
416+
}
417+
: {
418+
title: `${prebuild ? "Rerun" : "Run"} Prebuild (${
419+
branch.name
420+
})`,
421+
onClick: () => triggerPrebuild(branch),
422+
},
423+
]}
421424
/>
422425
</ItemField>
423426
</Item>

components/dashboard/src/projects/ProjectListItem.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useCurrentTeam } from "../teams/teams-context";
1313
import { RemoveProjectModal } from "./RemoveProjectModal";
1414
import { toRemoteURL } from "./render-utils";
1515
import { prebuildStatusIcon } from "./Prebuilds";
16+
import { gitpodHostUrl } from "../service/service";
1617

1718
type ProjectListItemProps = {
1819
project: Project;
@@ -40,7 +41,14 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
4041
menuEntries={[
4142
{
4243
title: "New Workspace",
43-
href: `/#${project.cloneUrl}`,
44+
href: gitpodHostUrl.withContext(`${project.cloneUrl}`).toString(),
45+
separator: true,
46+
},
47+
{
48+
title: "New Workspace ...",
49+
href: gitpodHostUrl
50+
.withContext(`${project.cloneUrl}`, { showOptions: true })
51+
.toString(),
4452
separator: true,
4553
},
4654
{

components/gitpod-protocol/src/util/gitpod-host-url.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,15 @@ export class GitpodHostUrl {
7777
return updated.with((url) => ({ pathname: `/api${url.pathname}` }));
7878
}
7979

80-
withContext(contextUrl: string) {
81-
return this.with((url) => ({ hash: contextUrl }));
80+
withContext(
81+
contextUrl: string,
82+
startOptions?: { showOptions?: boolean; editor?: string; workspaceClass?: string },
83+
) {
84+
const searchParams = new URLSearchParams();
85+
if (startOptions?.showOptions) {
86+
searchParams.append("showOptions", "true");
87+
}
88+
return this.with((url) => ({ hash: contextUrl, search: searchParams.toString() }));
8289
}
8390

8491
asWebsocket(): GitpodHostUrl {

0 commit comments

Comments
 (0)