FIX: ensures UpcomingEventsCalendar can be used alone (#755)

This is a recent regression due to bdf8869a01

I wanted to write a test, but this is non trivial given this is a standalone component. We also have other internal repos testing this behavior (how I discovered the regression). Will try to have  a test for this one later.
This commit is contained in:
Joffrey JAFFEUX 2025-06-25 17:38:43 +02:00 committed by GitHub
parent d06761b6fe
commit 0162ed5797
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 3 deletions

View File

@ -22,6 +22,10 @@ export default class UpcomingEventsCalendar extends Component {
_calendar = null; _calendar = null;
get displayFilters() {
return this.currentUser && this.args.controller;
}
@action @action
teardown() { teardown() {
this._calendar?.destroy?.(); this._calendar?.destroy?.();
@ -43,7 +47,7 @@ export default class UpcomingEventsCalendar extends Component {
await this._loadCalendar(); await this._loadCalendar();
const view = const view =
this.args.controller.view || (isMobileView ? "listNextYear" : "month"); this.args.controller?.view || (isMobileView ? "listNextYear" : "month");
const fullCalendar = new window.FullCalendar.Calendar(calendarNode, { const fullCalendar = new window.FullCalendar.Calendar(calendarNode, {
...fullCalendarDefaultOptions(), ...fullCalendarDefaultOptions(),
@ -110,7 +114,9 @@ export default class UpcomingEventsCalendar extends Component {
const tagsColorsMap = JSON.parse(siteSettings.map_events_to_color); const tagsColorsMap = JSON.parse(siteSettings.map_events_to_color);
const resolvedEvents = await this.args.controller.model; const resolvedEvents = this.args.events
? await this.args.events
: await this.args.controller.model;
const originalEventAndRecurrents = addRecurrentEvents(resolvedEvents); const originalEventAndRecurrents = addRecurrentEvents(resolvedEvents);
(originalEventAndRecurrents || []).forEach((event) => { (originalEventAndRecurrents || []).forEach((event) => {
@ -175,7 +181,7 @@ export default class UpcomingEventsCalendar extends Component {
} }
<template> <template>
{{#if this.currentUser}} {{#if this.displayFilters}}
<ul class="events-filter nav nav-pills"> <ul class="events-filter nav nav-pills">
<li> <li>
<LinkTo <LinkTo