import { createElement, lazy } from "react"; import type { CalendarPickerUiCapability, DashboardWidgetsUiCapability, PlatformWebModule, QuickAccessToolsUiCapability, SettingsSectionsUiCapability } from "@govoplan/core-webui"; import "./styles/calendar.css"; import { generatedTranslations } from "./i18n/generatedTranslations"; import CalendarPicker from "./features/calendar/CalendarPicker"; import UpcomingEventsWidget from "./features/calendar/UpcomingEventsWidget"; import CalendarQuickAccess from "./features/calendar/CalendarQuickAccess"; const CalendarPage = lazy(() => import("./features/calendar/CalendarPage")); const CalendarSettingsPanel = lazy( () => import("./features/calendar/CalendarSettingsPanel") ); const eventRead = ["calendar:event:read"]; const translations = { en: generatedTranslations.en, de: generatedTranslations.de }; const calendarPicker: CalendarPickerUiCapability = { CalendarPicker }; const calendarSettingsSections: SettingsSectionsUiCapability = { sections: [ { id: "calendar", surfaceId: "calendar.settings.preferences", label: "Calendar", group: "ui", order: 45, anyOf: eventRead, render: ({ settings, auth }) => createElement(CalendarSettingsPanel, { settings, auth }) } ] }; const calendarDashboardWidgets: DashboardWidgetsUiCapability = { widgets: [ { id: "calendar.upcoming", surfaceId: "calendar.widget.upcoming", title: "Upcoming events", description: "The next events across visible calendars.", moduleId: "calendar", category: "Planning", order: 40, defaultVisible: false, defaultSize: "medium", supportedSizes: ["medium", "wide"], anyOf: eventRead, refreshIntervalMs: 60_000, defaultConfiguration: { maxItems: 5, daysAhead: 14, showLocation: true }, configurationFields: [ { id: "maxItems", label: "Maximum events", kind: "number", min: 1, max: 12, step: 1, required: true }, { id: "daysAhead", label: "Days ahead", kind: "number", min: 1, max: 90, step: 1, required: true }, { id: "showLocation", label: "Show locations", kind: "boolean" } ], render: ({ settings, refreshKey, configuration }) => createElement(UpcomingEventsWidget, { settings, refreshKey, configuration }) } ] }; const calendarQuickAccessTools: QuickAccessToolsUiCapability = { tools: [ { id: "calendar.agenda", render: (context) => createElement(CalendarQuickAccess, context) } ] }; export const calendarModule: PlatformWebModule = { id: "calendar", label: "i18n:govoplan-calendar.calendar.adab5090", version: "1.0.0", dependencies: ["access"], optionalDependencies: ["mail", "tasks", "scheduling", "appointments", "workflow", "notifications", "dms", "connectors"], translations, viewSurfaces: [ { id: "calendar.navigation", moduleId: "calendar", kind: "navigation", label: "i18n:govoplan-calendar.surface.navigation", order: 10 }, { id: "calendar.page", moduleId: "calendar", kind: "route", label: "i18n:govoplan-calendar.surface.page", order: 20 }, { id: "calendar.page.sidebar", moduleId: "calendar", kind: "section", label: "i18n:govoplan-calendar.surface.sidebar", parentId: "calendar.page", order: 10 }, { id: "calendar.page.agenda", moduleId: "calendar", kind: "section", label: "i18n:govoplan-calendar.surface.agenda", parentId: "calendar.page.sidebar", order: 20 }, { id: "calendar.page.workspace", moduleId: "calendar", kind: "section", label: "i18n:govoplan-calendar.surface.workspace", parentId: "calendar.page", order: 30 }, { id: "calendar.event-editor", moduleId: "calendar", kind: "action", label: "i18n:govoplan-calendar.surface.event_editor", parentId: "calendar.page", order: 40 }, { id: "calendar.collection-editor", moduleId: "calendar", kind: "action", label: "i18n:govoplan-calendar.surface.collection_editor", parentId: "calendar.page.sidebar", order: 50 }, { id: "calendar.sync-status", moduleId: "calendar", kind: "section", label: "i18n:govoplan-calendar.surface.sync_status", parentId: "calendar.collection-editor", order: 60 }, { id: "calendar.outbox", moduleId: "calendar", kind: "action", label: "i18n:govoplan-calendar.surface.outbox", parentId: "calendar.sync-status", order: 70 }, { id: "calendar.migration", moduleId: "calendar", kind: "action", label: "i18n:govoplan-calendar.surface.migration", parentId: "calendar.sync-status", order: 80 }, { id: "calendar.widget.upcoming", moduleId: "calendar", kind: "section", label: "Upcoming events widget", order: 40 }, { id: "calendar.settings.preferences", moduleId: "calendar", kind: "section", label: "Calendar preferences", order: 45 }, { id: "calendar.quick_access.agenda", moduleId: "calendar", kind: "quick_access", label: "Calendar Quick Access", order: 50 } ], navItems: [{ to: "/calendar", label: "i18n:govoplan-calendar.calendar.adab5090", iconName: "calendar", anyOf: eventRead, order: 55, surfaceId: "calendar.navigation" }], routes: [ { path: "/calendar", anyOf: eventRead, order: 55, surfaceId: "calendar.page", render: ({ settings, auth }) => createElement(CalendarPage, { settings, auth }) }], uiCapabilities: { "calendar.picker": calendarPicker, "dashboard.widgets": calendarDashboardWidgets, "settings.sections": calendarSettingsSections, "quickAccess.tools": calendarQuickAccessTools } }; export default calendarModule;