From 19e558d4fceb5d48318594444c0542bb2eeb25b8 Mon Sep 17 00:00:00 2001 From: Joshua Strobl Date: Wed, 23 Aug 2023 18:44:42 +0300 Subject: [PATCH] Add BrowserOnly rendering for release table. Fix permission for ics file not having currect setuid --- .../schedule/ThirdPartyReleaseTable.tsx | 225 +++++++++--------- src/scripts/genCalendar.ts | 2 +- 2 files changed, 116 insertions(+), 111 deletions(-) diff --git a/src/components/schedule/ThirdPartyReleaseTable.tsx b/src/components/schedule/ThirdPartyReleaseTable.tsx index 1e3c408..a3ffcdd 100644 --- a/src/components/schedule/ThirdPartyReleaseTable.tsx +++ b/src/components/schedule/ThirdPartyReleaseTable.tsx @@ -18,6 +18,7 @@ import { UnifiedReleaseSchedules } from "@site/src/data/schedules/unified"; import { CalendarEventCategory, CalendarEventStrictType, CalendarEventType } from "@site/src/types"; import React, { useMemo, useState } from "react"; +import BrowserOnly from "@docusaurus/BrowserOnly"; import Link from "@docusaurus/Link"; import Translate, { translate } from "@docusaurus/Translate"; import { A, pipe } from "@mobily/ts-belt"; @@ -119,117 +120,121 @@ const ThirdPartyReleaseTable = () => { }); return ( - - - setShowFilters(!showFilters)} selected={showFilters} value={showFilters}> - - - - - {showFilters && ( - <> - setShowPastEvents(!showPastEvents)} />} - label={translate({ id: "showPastEvents", message: "Show past events" })} - /> - - defaultValues={Object.values(CalendarEventCategory)} - id="release-table-filter-category" - label={translate({ id: "projects", message: "Projects" })} - onChange={(v) => setSelectedCategories(v)} - options={Object.values(CalendarEventCategory)} - /> - - defaultValues={Object.values(CalendarEventType)} - id="release-table-filter-types" - label={translate({ id: "event", message: "Event" })} - onChange={(v) => setSelectedTypes(v)} - options={Object.values(CalendarEventType)} - /> - - )} - - - - - Event - - - Project - - - Start - - - End - - - Duration - - - - - {filteredEvents.map((e, i) => { - const startDate = DateTime.fromISO(e.dates[0]); - const endDate = DateTime.fromISO(e.dates[1]).plus({ days: e.dates[0] === e.dates[0] ? 1 : 0 }); - const diff = Interval.fromDateTimes(startDate, endDate); - const duration = diff.toDuration("days").toHuman({ unitDisplay: "narrow" }); + + {() => ( + + + setShowFilters(!showFilters)} selected={showFilters} value={showFilters}> + + + + + {showFilters && ( + <> + setShowPastEvents(!showPastEvents)} />} + label={translate({ id: "showPastEvents", message: "Show past events" })} + /> + + defaultValues={Object.values(CalendarEventCategory)} + id="release-table-filter-category" + label={translate({ id: "projects", message: "Projects" })} + onChange={(v) => setSelectedCategories(v)} + options={Object.values(CalendarEventCategory)} + /> + + defaultValues={Object.values(CalendarEventType)} + id="release-table-filter-types" + label={translate({ id: "event", message: "Event" })} + onChange={(v) => setSelectedTypes(v)} + options={Object.values(CalendarEventType)} + /> + + )} + + + + + Event + + + Project + + + Start + + + End + + + Duration + + + + + {filteredEvents.map((e, i) => { + const startDate = DateTime.fromISO(e.dates[0]); + const endDate = DateTime.fromISO(e.dates[1]).plus({ days: e.dates[0] === e.dates[0] ? 1 : 0 }); + const diff = Interval.fromDateTimes(startDate, endDate); + const duration = diff.toDuration("days").toHuman({ unitDisplay: "narrow" }); - return ( - <> - {showPastEvents && firstUpcomingEvent?.name === e.name && ( - - - - Current or upcoming - - - - )} - - - - - - - - {"{type} for {rel}"} - - - - - - - - - {e.dates[0]} - {e.dates[1]} - {duration} - - - ); - })} - - - + return ( + <> + {showPastEvents && firstUpcomingEvent?.name === e.name && ( + + + + Current or upcoming + + + + )} + + + + + + + + {"{type} for {rel}"} + + + + + + + + + {e.dates[0]} + {e.dates[1]} + {duration} + + + ); + })} + + + + )} + ); }; diff --git a/src/scripts/genCalendar.ts b/src/scripts/genCalendar.ts index 0ddf8dc..90fb72c 100644 --- a/src/scripts/genCalendar.ts +++ b/src/scripts/genCalendar.ts @@ -32,5 +32,5 @@ const { error, value } = createEvents(scheduleToEvents); const folderPath = join(process.cwd(), "static", "calendars"); mkdirSync(folderPath, { recursive: true }); const fsPath = join(folderPath, "third-party-schedules.ics"); -if (!error) writeFileSync(fsPath, value, { mode: 755 }); +if (!error) writeFileSync(fsPath, value); if (error) console.error(error);