From d607e67164a2a96fc4859a050e23ccd605578256 Mon Sep 17 00:00:00 2001 From: "Laurie T. Malau" Date: Tue, 19 Jul 2022 18:22:15 +0000 Subject: [PATCH] pagination --- components/dashboard/src/Menu.tsx | 8 +- components/dashboard/src/components/Arrow.tsx | 16 +- .../dashboard/src/components/DropDown.tsx | 2 +- .../dashboard/src/components/Pagination.tsx | 50 ++++ components/dashboard/src/images/credits.svg | 1 + .../dashboard/src/start/StartWorkspace.tsx | 2 +- .../dashboard/src/teams/TeamBilling.tsx | 4 +- .../dashboard/src/teams/TeamSettings.tsx | 16 +- components/dashboard/src/teams/TeamUsage.tsx | 221 ++++++++++++------ .../dashboard/src/workspaces/Workspaces.tsx | 4 +- components/gitpod-protocol/src/usage.ts | 1 - 11 files changed, 232 insertions(+), 93 deletions(-) create mode 100644 components/dashboard/src/components/Pagination.tsx create mode 100644 components/dashboard/src/images/credits.svg diff --git a/components/dashboard/src/Menu.tsx b/components/dashboard/src/Menu.tsx index 26c9c0dc63fbd7..de4de96518a7c5 100644 --- a/components/dashboard/src/Menu.tsx +++ b/components/dashboard/src/Menu.tsx @@ -217,11 +217,17 @@ export default function Menu() { link: `/t/${team.slug}/members`, }, ]; + if (showUsageBasedUI) { + teamSettingsList.push({ + title: "Usage", + link: `/t/${team.slug}/usage`, + }); + } if (currentUserInTeam?.role === "owner") { teamSettingsList.push({ title: "Settings", link: `/t/${team.slug}/settings`, - alternatives: getTeamSettingsMenu({ team, showPaymentUI, showUsageBasedUI }).flatMap((e) => e.link), + alternatives: getTeamSettingsMenu({ team, showPaymentUI }).flatMap((e) => e.link), }); } diff --git a/components/dashboard/src/components/Arrow.tsx b/components/dashboard/src/components/Arrow.tsx index 7ac5b282516042..4fcb79fb1ed11c 100644 --- a/components/dashboard/src/components/Arrow.tsx +++ b/components/dashboard/src/components/Arrow.tsx @@ -4,12 +4,22 @@ * See License-AGPL.txt in the project root for license information. */ -function Arrow(props: { up: boolean; customBorderClasses?: string }) { +function Arrow(props: { direction: string; customBorderClasses?: string }) { + const { direction, customBorderClasses } = props; + + // Using any because of known TS bug with bracket notation: + // https://github.com/microsoft/TypeScript/issues/10530 + const directionMap: any = { + up: "-135deg", + down: "45deg", + left: "135deg", + right: "315deg", + }; return ( ); diff --git a/components/dashboard/src/components/DropDown.tsx b/components/dashboard/src/components/DropDown.tsx index 7cb488d83a9458..32a7204d36290d 100644 --- a/components/dashboard/src/components/DropDown.tsx +++ b/components/dashboard/src/components/DropDown.tsx @@ -49,7 +49,7 @@ function DropDown(props: DropDownProps) { > {props.prefix} {current} - + ); diff --git a/components/dashboard/src/components/Pagination.tsx b/components/dashboard/src/components/Pagination.tsx new file mode 100644 index 00000000000000..69177626ab9850 --- /dev/null +++ b/components/dashboard/src/components/Pagination.tsx @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +import Arrow from "./Arrow"; + +function Pagination(props: { numberOfPages: number; currentPage: number; setCurrentPage: any }) { + const { numberOfPages, currentPage, setCurrentPage } = props; + const availablePageNumbers = [...Array(numberOfPages + 1).keys()].slice(1); + + const nextPage = () => { + if (currentPage !== numberOfPages) setCurrentPage(currentPage + 1); + }; + const prevPage = () => { + if (currentPage !== 1) setCurrentPage(currentPage - 1); + }; + + return ( + + ); +} + +export default Pagination; diff --git a/components/dashboard/src/images/credits.svg b/components/dashboard/src/images/credits.svg new file mode 100644 index 00000000000000..b7f014a8653665 --- /dev/null +++ b/components/dashboard/src/images/credits.svg @@ -0,0 +1 @@ + diff --git a/components/dashboard/src/start/StartWorkspace.tsx b/components/dashboard/src/start/StartWorkspace.tsx index 5970e5a28f8044..7915b7be1001a6 100644 --- a/components/dashboard/src/start/StartWorkspace.tsx +++ b/components/dashboard/src/start/StartWorkspace.tsx @@ -519,7 +519,7 @@ export default class StartWorkspace extends React.Component