111 lines
4.7 KiB
TypeScript
111 lines
4.7 KiB
TypeScript
import { createElement, lazy } from "react";
|
|
import type {
|
|
DashboardWidgetsUiCapability,
|
|
PlatformWebModule,
|
|
SettingsSectionsUiCapability
|
|
} from "@govoplan/core-webui";
|
|
import NotificationSummaryWidget from "./features/notifications/NotificationSummaryWidget";
|
|
import { generatedTranslations } from "./i18n/generatedTranslations";
|
|
import "./styles/notifications.css";
|
|
|
|
const NotificationCenterPage = lazy(() => import("./features/notifications/NotificationCenterPage"));
|
|
const NotificationSettingsPanel = lazy(() => import("./features/notifications/NotificationSettingsPanel"));
|
|
|
|
const notificationRead = ["notifications:notification:read"];
|
|
|
|
const notificationDashboardWidgets: DashboardWidgetsUiCapability = {
|
|
widgets: [
|
|
{
|
|
id: "notifications.summary",
|
|
surfaceId: "notifications.widget.summary",
|
|
title: "i18n:govoplan-notifications.surface.center",
|
|
description: "i18n:govoplan-notifications.widget_description",
|
|
moduleId: "notifications",
|
|
category: "i18n:govoplan-notifications.communication",
|
|
order: 60,
|
|
defaultSize: "medium",
|
|
supportedSizes: ["medium", "wide"],
|
|
anyOf: notificationRead,
|
|
refreshIntervalMs: 30_000,
|
|
defaultConfiguration: {
|
|
showDeliveryState: true
|
|
},
|
|
configurationFields: [
|
|
{
|
|
id: "showDeliveryState",
|
|
label: "i18n:govoplan-notifications.show_delivery_state",
|
|
description: "i18n:govoplan-notifications.show_delivery_state_help",
|
|
kind: "boolean"
|
|
}
|
|
],
|
|
render: ({ settings, effectiveView, refreshKey, configuration }) =>
|
|
createElement(NotificationSummaryWidget, {
|
|
settings,
|
|
refreshKey,
|
|
configuration,
|
|
showCenterLink: (
|
|
!effectiveView?.activeViewId
|
|
|| effectiveView.visibleSurfaceIds.includes(
|
|
"notifications.route.notifications"
|
|
)
|
|
)
|
|
})
|
|
}
|
|
]
|
|
};
|
|
|
|
const notificationSettingsSections: SettingsSectionsUiCapability = {
|
|
sections: [
|
|
{
|
|
id: "notifications",
|
|
surfaceId: "notifications.settings.preferences",
|
|
label: "i18n:govoplan-notifications.surface.center",
|
|
group: "ui",
|
|
order: 40,
|
|
anyOf: notificationRead,
|
|
render: ({ settings, auth }) => createElement(NotificationSettingsPanel, { settings, auth })
|
|
}
|
|
]
|
|
};
|
|
|
|
export const notificationsModule: PlatformWebModule = {
|
|
id: "notifications",
|
|
label: "i18n:govoplan-notifications.surface.center",
|
|
version: "1.0.0",
|
|
dependencies: [],
|
|
optionalDependencies: ["mail", "tasks", "portal", "workflow", "calendar", "scheduling"],
|
|
translations: generatedTranslations,
|
|
viewSurfaces: [
|
|
{ id: "notifications.page.inbox", moduleId: "notifications", kind: "section", label: "i18n:govoplan-notifications.surface.inbox", parentId: "notifications.route.notifications", order: 20 },
|
|
{ id: "notifications.page.detail", moduleId: "notifications", kind: "section", label: "i18n:govoplan-notifications.surface.detail", parentId: "notifications.route.notifications", order: 30 },
|
|
{ id: "notifications.page.delivery", moduleId: "notifications", kind: "section", label: "i18n:govoplan-notifications.surface.delivery", parentId: "notifications.page.detail", order: 40 },
|
|
{ id: "notifications.action.mark-read", moduleId: "notifications", kind: "action", label: "i18n:govoplan-notifications.surface.mark_read", parentId: "notifications.page.detail", order: 50 },
|
|
{ id: "notifications.action.acknowledge", moduleId: "notifications", kind: "action", label: "i18n:govoplan-notifications.surface.acknowledge", parentId: "notifications.page.detail", order: 60 },
|
|
{ id: "notifications.action.cancel", moduleId: "notifications", kind: "action", label: "i18n:govoplan-notifications.surface.cancel", parentId: "notifications.page.delivery", order: 70 },
|
|
{ id: "notifications.action.dispatch", moduleId: "notifications", kind: "action", label: "i18n:govoplan-notifications.surface.dispatch", parentId: "notifications.page.delivery", order: 80 },
|
|
{
|
|
id: "notifications.widget.summary",
|
|
moduleId: "notifications",
|
|
kind: "section",
|
|
label: "i18n:govoplan-notifications.surface.widget_summary",
|
|
order: 90
|
|
},
|
|
{
|
|
id: "notifications.settings.preferences",
|
|
moduleId: "notifications",
|
|
kind: "section",
|
|
label: "i18n:govoplan-notifications.surface.preferences",
|
|
order: 100
|
|
}
|
|
],
|
|
routes: [
|
|
{ path: "/notifications", anyOf: notificationRead, order: 59, surfaceId: "notifications.route.notifications", render: ({ settings, auth }) => createElement(NotificationCenterPage, { settings, auth }) }
|
|
],
|
|
uiCapabilities: {
|
|
"settings.sections": notificationSettingsSections,
|
|
"dashboard.widgets": notificationDashboardWidgets
|
|
}
|
|
};
|
|
|
|
export default notificationsModule;
|