Skip to content
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

[dashboard] add "with-options" buttons #15668

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions components/dashboard/src/projects/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,26 +398,29 @@ export default function () {
</a>
<ItemFieldContextMenu
className="py-0.5"
menuEntries={
menuEntries={[
{
title: "New Workspace ...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 thought: Next steps could include improving the modal to allow branch selection as mentioned in #5372, #12591, #10168, and a relevant discussion (internal).

href: gitpodHostUrl
.withContext(`${branch.url}`, { showOptions: true })
.toString(),
separator: true,
},
Comment on lines +402 to +408
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Nice and much needed addition! ✨

prebuild?.status === "queued" || prebuild?.status === "building"
? [
{
title: "Cancel Prebuild",
customFontStyle:
"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300",
onClick: () =>
prebuild && cancelPrebuild(prebuild.info.id),
},
]
: [
{
title: `${prebuild ? "Rerun" : "Run"} Prebuild (${
branch.name
})`,
onClick: () => triggerPrebuild(branch),
},
]
}
? {
title: "Cancel Prebuild",
customFontStyle:
"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300",
onClick: () =>
prebuild && cancelPrebuild(prebuild.info.id),
}
: {
title: `${prebuild ? "Rerun" : "Run"} Prebuild (${
branch.name
})`,
onClick: () => triggerPrebuild(branch),
},
]}
/>
</ItemField>
</Item>
Expand Down
10 changes: 9 additions & 1 deletion components/dashboard/src/projects/ProjectListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useCurrentTeam } from "../teams/teams-context";
import { RemoveProjectModal } from "./RemoveProjectModal";
import { toRemoteURL } from "./render-utils";
import { prebuildStatusIcon } from "./Prebuilds";
import { gitpodHostUrl } from "../service/service";

type ProjectListItemProps = {
project: Project;
Expand Down Expand Up @@ -40,7 +41,14 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
menuEntries={[
{
title: "New Workspace",
Copy link
Contributor

@gtsiolis gtsiolis Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(non-blocking): Could we measure how much this button link (New Workspace) is used on the projects page specifically? I created a report (internal) for measuring usage (clicks) but couldn't differentiate the clicks on the specific dropdown that exists on the projects cards. Cc @jakobhero

href: `/#${project.cloneUrl}`,
href: gitpodHostUrl.withContext(`${project.cloneUrl}`).toString(),
separator: true,
},
Comment on lines 42 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: From what I understand this will keep the existing new workspace menu entry with no options and was wondering it if we still need it, but this can become clearer later. Also, it doesn't hurt to keep this here for now, since it's hidden behind the more actions menu.

BEFORE AFTER
dropdown-before dropdown-after

{
title: "New Workspace ...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Excellent ... 🥯

href: gitpodHostUrl
.withContext(`${project.cloneUrl}`, { showOptions: true })
.toString(),
separator: true,
},
{
Expand Down
11 changes: 9 additions & 2 deletions components/gitpod-protocol/src/util/gitpod-host-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,15 @@ export class GitpodHostUrl {
return updated.with((url) => ({ pathname: `/api${url.pathname}` }));
}

withContext(contextUrl: string) {
return this.with((url) => ({ hash: contextUrl }));
withContext(
contextUrl: string,
startOptions?: { showOptions?: boolean; editor?: string; workspaceClass?: string },
) {
const searchParams = new URLSearchParams();
if (startOptions?.showOptions) {
searchParams.append("showOptions", "true");
}
return this.with((url) => ({ hash: contextUrl, search: searchParams.toString() }));
}

asWebsocket(): GitpodHostUrl {
Expand Down