@@ -6,6 +6,7 @@ import 'vis-timeline/styles/vis-timeline-graph2d.css';
6
6
import { statusColorMapping } from '../../consts' ;
7
7
import { DAGStatus } from '../../models' ;
8
8
import { WorkflowListItem } from '../../models/api' ;
9
+ import { useConfig } from '../../contexts/ConfigContext' ;
9
10
10
11
type Props = { data : DAGStatus [ ] | WorkflowListItem [ ] } ;
11
12
@@ -21,15 +22,11 @@ type TimelineItem = {
21
22
function DashboardTimechart ( { data : input } : Props ) {
22
23
const timelineRef = useRef < HTMLDivElement > ( null ) ;
23
24
const timelineInstance = useRef < Timeline | null > ( null ) ;
25
+ const config = useConfig ( ) ;
24
26
25
27
useEffect ( ( ) => {
26
28
if ( ! timelineRef . current ) return ;
27
29
28
- let timezone = getConfig ( ) . tz ;
29
- if ( ! timezone ) {
30
- timezone = moment . tz . guess ( ) ;
31
- }
32
-
33
30
const items : TimelineItem [ ] = [ ] ;
34
31
const now = moment ( ) ;
35
32
const startOfDay = moment ( ) . startOf ( 'day' ) ;
@@ -47,8 +44,8 @@ function DashboardTimechart({ data: input }: Props) {
47
44
items . push ( {
48
45
id : status . Name + `_${ status . RequestId } ` ,
49
46
content : status . Name ,
50
- start : startMoment . tz ( timezone ) . toDate ( ) ,
51
- end : end . tz ( timezone ) . toDate ( ) ,
47
+ start : startMoment . tz ( config . tz ) . toDate ( ) ,
48
+ end : end . tz ( config . tz ) . toDate ( ) ,
52
49
group : 'main' ,
53
50
className : `status-${ status . Status } ` ,
54
51
} ) ;
@@ -59,7 +56,7 @@ function DashboardTimechart({ data: input }: Props) {
59
56
60
57
if ( ! timelineInstance . current ) {
61
58
timelineInstance . current = new Timeline ( timelineRef . current , dataset , {
62
- moment : ( date : MomentInput ) => moment ( date ) . tz ( timezone ) ,
59
+ moment : ( date : MomentInput ) => moment ( date ) . tz ( config . tz ) ,
63
60
start : startOfDay . toDate ( ) ,
64
61
end : now . endOf ( 'day' ) . toDate ( ) ,
65
62
orientation : 'top' ,
@@ -76,7 +73,7 @@ function DashboardTimechart({ data: input }: Props) {
76
73
hour : 'HH:mm' ,
77
74
} ,
78
75
majorLabels : {
79
- hour : 'HH:mm ' ,
76
+ hour : 'ddd D MMMM ' ,
80
77
day : 'ddd D MMMM' ,
81
78
} ,
82
79
} ,
0 commit comments