-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release-calendar] Calendar view date #821
base: main
Are you sure you want to change the base?
Changes from 2 commits
b007fda
38a9a13
f1fe7a5
2bae8f3
c2e168a
8a72893
cde5772
b151aa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> { | |
this.apiService = new ApiService(); | ||
} | ||
|
||
calendarReference = React.createRef<FullCalendar>(); | ||
|
||
async componentDidMount(): Promise<void> { | ||
const releases = await this.apiService.getReleases(); | ||
this.setState({allEvents: getAllReleasesEvents(releases)}); | ||
|
@@ -68,12 +70,19 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> { | |
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 => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why you use an anonymous function here and not a regular function syntax? ( Anonymous functions are more useful when you use them as, say, an argument to another function (e.g., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No there wasn't any reason. I just wasn't aware one was the "regular", and I've gotten used to the anonymous way since I use functions as arguments more often. I'll switch this one to the regular function syntax! |
||
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<CalendarProps, CalendarState> { | |
center: 'title', | ||
right: 'dayGridMonth,timeGridWeek,listWeek', | ||
}} | ||
ref={this.calendarReference} | ||
plugins={[dayGridPlugin, timeGridPlugin]} | ||
eventSources={displayEvents} | ||
contentHeight={CALENDAR_CONTENT_HEIGHT} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, does Full Calendar have a "go to Today" button option? Going back to the current date when you remove filters might be unexpected, so I'm not sure we should do this. But having a "go to Today" button would help!