Skip to content

Migrate more of the Dashboard to Podkit buttons #19012

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

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 4 additions & 4 deletions components/dashboard/src/FromReferrer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import { Link } from "react-router-dom";
import { LinkButton } from "@podkit/buttons/LinkButton";

export default function FromReferrer() {
const contextUrl = document.referrer;
Expand Down Expand Up @@ -36,9 +36,9 @@ export default function FromReferrer() {
</p>
</div>
<span>
<Link to="/">
<button className="secondary">Go to Dashboard</button>
</Link>
<LinkButton href="/" variant={"secondary"}>
Go to Dashboard
</LinkButton>
</span>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions components/dashboard/src/components/AuthorizeGit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Button } from "./Button";
import { Heading2, Heading3, Subheading } from "./typography/headings";
import classNames from "classnames";
import { iconForAuthProvider, simplifyProviderName } from "../provider-utils";
import { LinkButton } from "@podkit/buttons/LinkButton";

export function useNeedsGitAuthorization() {
const authProviders = useAuthProviders();
Expand Down Expand Up @@ -60,9 +61,9 @@ export const AuthorizeGit: FC<{ className?: string }> = ({ className }) => {
{!!org.data?.isOwner ? (
<div className="px-6">
<Subheading>You need to configure at least one Git integration.</Subheading>
<Link to="/settings/git">
<Button className="mt-6 w-full">Add a Git integration</Button>
</Link>
<LinkButton className="mt-6 w-full" href="/settings/git">
Add a Git integration
</LinkButton>
</div>
) : (
<>
Expand Down
26 changes: 12 additions & 14 deletions components/dashboard/src/projects/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { getProjectTabs } from "./projects.routes";
import { shortCommitMessage, toRemoteURL } from "./render-utils";
import search from "../icons/search.svg";
import Tooltip from "../components/Tooltip";
import { Button } from "@podkit/buttons/Button";
import { LinkButton } from "@podkit/buttons/LinkButton";

export default function ProjectsPage() {
const history = useHistory();
Expand Down Expand Up @@ -213,12 +215,9 @@ export default function ProjectsPage() {
Authorize {showAuthBanner.host} <br />
to access branch information.
</div>
<button
className={`primary mr-2 py-2`}
onClick={() => onConfirmShowAuthModal(showAuthBanner.host)}
>
<Button className="mr-2 py-2" onClick={() => onConfirmShowAuthModal(showAuthBanner.host)}>
Authorize Provider
</button>
</Button>
</div>
</div>
) : (
Expand Down Expand Up @@ -272,12 +271,12 @@ export default function ProjectsPage() {
</span>
)}
{!isResuming && (
<button
<Button
className="gp-link hover:text-gray-600"
onClick={() => resumePrebuilds()}
>
Resume prebuilds
</button>
</Button>
)}
</Alert>
)}
Expand Down Expand Up @@ -368,13 +367,12 @@ export default function ProjectsPage() {
)}
</a>
<span className="flex-grow" />
<a href={gitpodHostUrl.withContext(`${branch.url}`).toString()}>
<button
className={`primary mr-2 py-2 opacity-0 group-hover:opacity-100`}
>
New Workspace
</button>
</a>
<LinkButton
href={gitpodHostUrl.withContext(branch.url).toRelative()}
className={`mr-2 py-2 opacity-0 group-hover:opacity-100`}
>
New Workspace
</LinkButton>
<ItemFieldContextMenu
className="py-0.5"
menuEntries={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { PersonalAccessToken } from "@gitpod/public-api/lib/gitpod/experimental/v1/tokens_pb";
import { useCallback, useEffect, useState } from "react";
import { Redirect, useLocation } from "react-router";
import { Link } from "react-router-dom";
import { personalAccessTokensService } from "../service/public-api";
import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu";
import { settingsPathPersonalAccessTokenCreate, settingsPathPersonalAccessTokenEdit } from "./settings.routes";
Expand All @@ -23,6 +22,8 @@ import ShowTokenModal from "./ShowTokenModal";
import Pagination from "../Pagination/Pagination";
import { Heading2, Subheading } from "../components/typography/headings";
import { useFeatureFlag } from "../data/featureflag-query";
import { LinkButton } from "@podkit/buttons/LinkButton";
import { Button } from "@podkit/buttons/Button";

export default function PersonalAccessTokens() {
const enablePersonalAccessTokens = useFeatureFlag("personalAccessTokensEnabled");
Expand Down Expand Up @@ -179,9 +180,7 @@ function ListAccessTokensView() {
</Subheading>
</div>
{tokens.length > 0 && (
<Link to={settingsPathPersonalAccessTokenCreate}>
<button>New Access Token</button>
</Link>
<LinkButton href={settingsPathPersonalAccessTokenCreate}>New Access Token</LinkButton>
)}
</div>
{errorMsg.length > 0 && (
Expand Down Expand Up @@ -215,9 +214,9 @@ function ListAccessTokensView() {
<div className="mb-2 font-medium text-sm text-gray-500 dark:text-gray-300">
Make sure to copy your access token — you won't be able to access it again.
</div>
<button className="secondary" onClick={handleCopyToken}>
<Button variant="secondary" onClick={handleCopyToken}>
Copy Token to Clipboard
</button>
</Button>
</div>
</div>
)}
Expand All @@ -233,9 +232,7 @@ function ListAccessTokensView() {
<Subheading className="text-center pb-6 w-96">
Generate an access token for applications that need access to the Gitpod API.{" "}
</Subheading>
<Link to={settingsPathPersonalAccessTokenCreate}>
<button>New Access Token</button>
</Link>
<LinkButton href={settingsPathPersonalAccessTokenCreate}>New Access Token</LinkButton>
</div>
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { Timestamp } from "@bufbuild/protobuf";
import arrowDown from "../images/sort-arrow.svg";
import { Heading2, Subheading } from "../components/typography/headings";
import { useFeatureFlag } from "../data/featureflag-query";
import { LinkButton } from "@podkit/buttons/LinkButton";
import { Button } from "@podkit/buttons/Button";

interface EditPATData {
name: string;
Expand Down Expand Up @@ -152,21 +154,20 @@ function PersonalAccessTokenCreateView() {
<div>
<PageWithSettingsSubMenu>
<div className="mb-4 flex gap-2">
<Link to={settingsPathPersonalAccessTokens}>
<button className="secondary">
<div className="flex place-content-center">
<img src={arrowDown} className="w-4 mr-2 transform rotate-90 mb-0" alt="Back arrow" />
<span>Back to list</span>
</div>
</button>
</Link>
<LinkButton variant={"secondary"} href={settingsPathPersonalAccessTokens}>
<div className="flex place-content-center">
<img src={arrowDown} className="w-4 mr-2 transform rotate-90 mb-0" alt="Back arrow" />
<span>Back to list</span>
</div>
</LinkButton>
{editToken && (
<button
className="danger bg-red-50 dark:bg-red-600 text-red-600 dark:text-red-50"
<Button
variant={"destructive"}
className="bg-red-50 dark:bg-red-600 text-red-600 dark:text-red-50"
onClick={() => setModalData({ token: editToken })}
>
Regenerate
</button>
</Button>
)}
</div>
{errorMsg.length > 0 && (
Expand Down Expand Up @@ -257,14 +258,14 @@ function PersonalAccessTokenCreateView() {
<div className="flex gap-2">
{isEditing && (
<Link to={settingsPathPersonalAccessTokens}>
<button className="secondary" onClick={handleConfirm}>
<Button variant={"secondary"} onClick={handleConfirm}>
Cancel
</button>
</Button>
</Link>
)}
<button onClick={handleConfirm} disabled={isEditing && !editToken}>
<Button onClick={handleConfirm} disabled={isEditing && !editToken}>
{isEditing ? "Update" : "Create"} Access Token
</button>
</Button>
</div>
</SpinnerOverlayLoader>
</PageWithSettingsSubMenu>
Expand Down
13 changes: 5 additions & 8 deletions components/dashboard/src/workspaces/EmptyWorkspacesContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* See License.AGPL.txt in the project root for license information.
*/

import { Link } from "react-router-dom";
import { Heading2 } from "../components/typography/headings";
import { StartWorkspaceModalKeyBinding } from "../App";
import { Button } from "../components/Button";
import { LinkButton } from "@podkit/buttons/LinkButton";

export const EmptyWorkspacesContent = () => {
return (
Expand All @@ -30,12 +29,10 @@ export const EmptyWorkspacesContent = () => {
</a>
</div>
<span>
<Link to={"/new"}>
<Button>
New Workspace{" "}
<span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span>
</Button>
</Link>
<LinkButton className="mt-6 w-full" href="/new">
New Workspace{" "}
<span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span>
</LinkButton>
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/workspaces/Workspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const sortWorkspaces = (a: WorkspaceInfo, b: WorkspaceInfo) => {
};

/**
* Given a WorkspaceInfo, return a timestamp of the last related activitiy
* Given a WorkspaceInfo, return a timestamp of the last related activity
*
* @param info WorkspaceInfo
* @returns string timestamp
Expand Down
11 changes: 4 additions & 7 deletions components/dashboard/src/workspaces/WorkspacesSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
*/

import { FunctionComponent } from "react";
import { Link } from "react-router-dom";
import { StartWorkspaceModalKeyBinding } from "../App";
import DropDown from "../components/DropDown";
import search from "../icons/search.svg";
import { Button } from "../components/Button";
import { LinkButton } from "@podkit/buttons/LinkButton";

type WorkspacesSearchBarProps = {
searchTerm: string;
Expand Down Expand Up @@ -67,11 +66,9 @@ export const WorkspacesSearchBar: FunctionComponent<WorkspacesSearchBarProps> =
]}
/>
</div>
<Link to={"/new"}>
<Button className="ml-2">
New Workspace <span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span>
</Button>
</Link>
<LinkButton href={"/new"} className="ml-2">
New Workspace <span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span>
</LinkButton>
</div>
);
};
4 changes: 4 additions & 0 deletions components/gitpod-protocol/src/util/gitpod-host-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export class GitpodHostUrl {
return this.url.toString();
}

toRelative(): string {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed because the <Link>s do not support full-blown URLs, just relative ones.

return this.url.pathname + this.url.search + this.url.hash;
}

toStringWoRootSlash() {
let result = this.toString();
if (result.endsWith("/")) {
Expand Down