Skip to content

Commit ed775c2

Browse files
author
Laurie T. Malau
committed
Allow sorting in the UI
1 parent 46b6310 commit ed775c2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

components/dashboard/src/teams/TeamUsage.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
2323
import { FeatureFlagContext } from "../contexts/FeatureFlagContext";
2424
import { ReactComponent as CreditsSvg } from "../images/credits.svg";
2525
import { ReactComponent as Spinner } from "../icons/Spinner.svg";
26+
import Arrow from "../components/Arrow";
2627

2728
function TeamUsage() {
2829
const { teams } = useContext(TeamsContext);
@@ -39,7 +40,7 @@ function TeamUsage() {
3940
const [startDateOfBillMonth, setStartDateOfBillMonth] = useState(timestampStartOfCurrentMonth);
4041
const [endDateOfBillMonth, setEndDateOfBillMonth] = useState(Date.now());
4142
const [isLoading, setIsLoading] = useState<boolean>(true);
42-
const [startedTimeOrder] = useState<SortOrder>(SortOrder.Descending);
43+
const [isStartedTimeDescending, setIsStartedTimeDescending] = useState<boolean>(true);
4344

4445
useEffect(() => {
4546
if (!team) {
@@ -49,7 +50,7 @@ function TeamUsage() {
4950
const attributionId = AttributionId.render({ kind: "team", teamId: team.id });
5051
const request: BillableSessionRequest = {
5152
attributionId,
52-
startedTimeOrder,
53+
startedTimeOrder: isStartedTimeDescending ? SortOrder.Descending : SortOrder.Ascending,
5354
from: startDateOfBillMonth,
5455
to: endDateOfBillMonth,
5556
};
@@ -64,7 +65,7 @@ function TeamUsage() {
6465
setIsLoading(false);
6566
}
6667
})();
67-
}, [team, startDateOfBillMonth, endDateOfBillMonth, startedTimeOrder]);
68+
}, [team, startDateOfBillMonth, endDateOfBillMonth, isStartedTimeDescending]);
6869

6970
if (!showUsageBasedPricingUI) {
7071
return <Redirect to="/" />;
@@ -200,7 +201,12 @@ function TeamUsage() {
200201
<CreditsSvg className="my-auto mr-1" />
201202
<span>Credits</span>
202203
</ItemField>
203-
<ItemField className="my-auto" />
204+
<ItemField className="my-auto cursor-pointer">
205+
<span onClick={() => setIsStartedTimeDescending(!isStartedTimeDescending)}>
206+
Started
207+
<Arrow direction={isStartedTimeDescending ? "down" : "up"} />
208+
</span>
209+
</ItemField>
204210
</Item>
205211
{currentPaginatedResults &&
206212
currentPaginatedResults.map((usage) => (

0 commit comments

Comments
 (0)