From b007fda78407d9ad026eb2a0d3f80f30068c0dd1 Mon Sep 17 00:00:00 2001 From: Anna Watson Date: Thu, 30 Apr 2020 22:22:58 -0700 Subject: [PATCH 1/3] calendar view date --- release-calendar/src/client/components/Calendar.tsx | 10 ++++++++++ .../src/client/components/ChannelTable.tsx | 1 + 2 files changed, 11 insertions(+) diff --git a/release-calendar/src/client/components/Calendar.tsx b/release-calendar/src/client/components/Calendar.tsx index 3a9be7371..1763035d3 100644 --- a/release-calendar/src/client/components/Calendar.tsx +++ b/release-calendar/src/client/components/Calendar.tsx @@ -56,6 +56,8 @@ export class Calendar extends React.Component { this.apiService = new ApiService(); } + calendarReference = React.createRef(); + async componentDidMount(): Promise { const releases = await this.apiService.getReleases(); this.setState({allEvents: getAllReleasesEvents(releases)}); @@ -68,12 +70,19 @@ export class Calendar extends React.Component { this.props.singleRelease, ); this.setState({singleEvents: getSingleReleaseEvents(release)}); + this.gotoDate(release[0].start); } else { this.setState({singleEvents: []}); + this.gotoDate(new Date()); } } } + gotoDate = (date: Date): void => { + const calendarApi = this.calendarReference.current.getApi(); + calendarApi.gotoDate(date); + }; + tooltip = (arg: { isMirror: boolean; isStart: boolean; @@ -114,6 +123,7 @@ export class Calendar extends React.Component { center: 'title', right: 'dayGridMonth,timeGridWeek,listWeek', }} + ref={this.calendarReference} plugins={[dayGridPlugin, timeGridPlugin]} eventSources={displayEvents} contentHeight={CALENDAR_CONTENT_HEIGHT} diff --git a/release-calendar/src/client/components/ChannelTable.tsx b/release-calendar/src/client/components/ChannelTable.tsx index ed046825a..37fbd4259 100644 --- a/release-calendar/src/client/components/ChannelTable.tsx +++ b/release-calendar/src/client/components/ChannelTable.tsx @@ -43,6 +43,7 @@ export class ChannelTable extends React.Component< }; this.apiService = new ApiService(); this.handleChannelClick = this.handleChannelClick.bind(this); + this.handleReleaseClick = this.handleReleaseClick.bind(this); } async componentDidMount(): Promise { From 2bae8f39098d758359a44b20c1eb772700baf7a1 Mon Sep 17 00:00:00 2001 From: Anna Watson Date: Fri, 1 May 2020 13:45:29 -0700 Subject: [PATCH 2/3] add today button --- release-calendar/src/client/components/Calendar.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/release-calendar/src/client/components/Calendar.tsx b/release-calendar/src/client/components/Calendar.tsx index 1763035d3..9e06fe6ca 100644 --- a/release-calendar/src/client/components/Calendar.tsx +++ b/release-calendar/src/client/components/Calendar.tsx @@ -73,7 +73,6 @@ export class Calendar extends React.Component { this.gotoDate(release[0].start); } else { this.setState({singleEvents: []}); - this.gotoDate(new Date()); } } } @@ -119,7 +118,7 @@ export class Calendar extends React.Component { Date: Mon, 4 May 2020 11:30:07 -0700 Subject: [PATCH 3/3] switch to regular function syntax --- release-calendar/src/client/components/Calendar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-calendar/src/client/components/Calendar.tsx b/release-calendar/src/client/components/Calendar.tsx index 9e06fe6ca..89b92ae66 100644 --- a/release-calendar/src/client/components/Calendar.tsx +++ b/release-calendar/src/client/components/Calendar.tsx @@ -77,10 +77,10 @@ export class Calendar extends React.Component { } } - gotoDate = (date: Date): void => { + gotoDate(date: Date): void { const calendarApi = this.calendarReference.current.getApi(); calendarApi.gotoDate(date); - }; + } tooltip = (arg: { isMirror: boolean;