@@ -8,7 +8,12 @@ import { useContext, useEffect, useState } from "react";
8
8
import { Redirect , useLocation } from "react-router" ;
9
9
import { getCurrentTeam , TeamsContext } from "./teams-context" ;
10
10
import { getGitpodService , gitpodHostUrl } from "../service/service" ;
11
- import { BillableSession , BillableWorkspaceType , SortOrder } from "@gitpod/gitpod-protocol/lib/usage" ;
11
+ import {
12
+ BillableSession ,
13
+ BillableSessionRequest ,
14
+ BillableWorkspaceType ,
15
+ SortOrder ,
16
+ } from "@gitpod/gitpod-protocol/lib/usage" ;
12
17
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution" ;
13
18
import { Item , ItemField , ItemsList } from "../components/ItemsList" ;
14
19
import moment from "moment" ;
@@ -18,6 +23,7 @@ import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
18
23
import { FeatureFlagContext } from "../contexts/FeatureFlagContext" ;
19
24
import { ReactComponent as CreditsSvg } from "../images/credits.svg" ;
20
25
import { ReactComponent as Spinner } from "../icons/Spinner.svg" ;
26
+ import Arrow from "../components/Arrow" ;
21
27
22
28
function TeamUsage ( ) {
23
29
const { teams } = useContext ( TeamsContext ) ;
@@ -34,19 +40,19 @@ function TeamUsage() {
34
40
const [ startDateOfBillMonth , setStartDateOfBillMonth ] = useState ( timestampStartOfCurrentMonth ) ;
35
41
const [ endDateOfBillMonth , setEndDateOfBillMonth ] = useState ( Date . now ( ) ) ;
36
42
const [ isLoading , setIsLoading ] = useState < boolean > ( true ) ;
37
- const [ startedTimeOrder ] = useState < SortOrder > ( SortOrder . Descending ) ;
43
+ const [ isStartedTimeDescending , setIsStartedTimeDescending ] = useState < boolean > ( true ) ;
38
44
39
45
useEffect ( ( ) => {
40
46
if ( ! team ) {
41
47
return ;
42
48
}
43
49
( async ( ) => {
44
50
const attributionId = AttributionId . render ( { kind : "team" , teamId : team . id } ) ;
45
- const request = {
51
+ const request : BillableSessionRequest = {
46
52
attributionId,
47
- startedTimeOrder,
48
- startDateOfBillMonth,
49
- endDateOfBillMonth,
53
+ startedTimeOrder : isStartedTimeDescending ? SortOrder . Descending : SortOrder . Ascending ,
54
+ from : startDateOfBillMonth ,
55
+ to : endDateOfBillMonth ,
50
56
} ;
51
57
try {
52
58
const billedUsageResult = await getGitpodService ( ) . server . listBilledUsage ( request ) ;
@@ -59,7 +65,7 @@ function TeamUsage() {
59
65
setIsLoading ( false ) ;
60
66
}
61
67
} ) ( ) ;
62
- } , [ team , startDateOfBillMonth , endDateOfBillMonth , startedTimeOrder ] ) ;
68
+ } , [ team , startDateOfBillMonth , endDateOfBillMonth , isStartedTimeDescending ] ) ;
63
69
64
70
if ( ! showUsageBasedPricingUI ) {
65
71
return < Redirect to = "/" /> ;
@@ -195,7 +201,12 @@ function TeamUsage() {
195
201
< CreditsSvg className = "my-auto mr-1" />
196
202
< span > Credits</ span >
197
203
</ ItemField >
198
- < 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 >
199
210
</ Item >
200
211
{ currentPaginatedResults &&
201
212
currentPaginatedResults . map ( ( usage ) => (
0 commit comments