Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions release-calendar/src/client/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
Expand All @@ -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());
Copy link
Contributor

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!

}
}
}

gotoDate = (date: Date): void => {
Copy link
Member

Choose a reason for hiding this comment

The 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? (gotoDate(date: Date): void {)

Anonymous functions are more useful when you use them as, say, an argument to another function (e.g., arr.sort((firstEl, secondEl) => { ... }))

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions release-calendar/src/client/components/ChannelTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down