182 lines
4.4 KiB
TypeScript
182 lines
4.4 KiB
TypeScript
import { createElement, lazy } from "react";
|
|
import {
|
|
hasScope,
|
|
type AdminSectionsUiCapability,
|
|
type DashboardWidgetsUiCapability,
|
|
type PlatformWebModule,
|
|
type QuickAccessToolsUiCapability
|
|
} from "@govoplan/core-webui";
|
|
import { generatedTranslations } from "./i18n/generatedTranslations";
|
|
import PostboxInboxWidget from "./features/postbox/PostboxInboxWidget";
|
|
import PostboxQuickAccess from "./features/postbox/PostboxQuickAccess";
|
|
import "./styles/postbox.css";
|
|
|
|
|
|
const PostboxPage = lazy(() => import("./features/postbox/PostboxPage"));
|
|
const PostboxAdminPanel = lazy(
|
|
() => import("./features/postbox/PostboxAdminPanel")
|
|
);
|
|
|
|
const translations = {
|
|
en: generatedTranslations.en,
|
|
de: generatedTranslations.de
|
|
};
|
|
|
|
const readScope = ["postbox:postbox:read"];
|
|
const postboxDashboardWidgets: DashboardWidgetsUiCapability = {
|
|
widgets: [
|
|
{
|
|
id: "postbox.inbox",
|
|
surfaceId: "postbox.widget.inbox",
|
|
title: "i18n:govoplan-postbox.postbox_inbox",
|
|
description: "i18n:govoplan-postbox.postbox_inbox_description",
|
|
moduleId: "postbox",
|
|
category: "i18n:govoplan-postbox.communication",
|
|
order: 55,
|
|
defaultVisible: false,
|
|
defaultSize: "medium",
|
|
supportedSizes: ["medium", "wide"],
|
|
anyOf: readScope,
|
|
refreshIntervalMs: 30_000,
|
|
defaultConfiguration: {
|
|
maxItems: 5
|
|
},
|
|
configurationFields: [
|
|
{
|
|
id: "maxItems",
|
|
label: "i18n:govoplan-postbox.maximum_messages",
|
|
kind: "number",
|
|
min: 1,
|
|
max: 12,
|
|
step: 1,
|
|
required: true
|
|
}
|
|
],
|
|
render: ({ settings, refreshKey, configuration }) =>
|
|
createElement(PostboxInboxWidget, {
|
|
settings,
|
|
refreshKey,
|
|
configuration
|
|
})
|
|
}
|
|
]
|
|
};
|
|
const postboxQuickAccessTools: QuickAccessToolsUiCapability = {
|
|
tools: [
|
|
{
|
|
id: "postbox.messages",
|
|
render: (context) => createElement(PostboxQuickAccess, context)
|
|
}
|
|
]
|
|
};
|
|
|
|
const postboxAdminSections: AdminSectionsUiCapability = {
|
|
sections: [
|
|
{
|
|
id: "postbox",
|
|
moduleId: "postbox",
|
|
kind: "management",
|
|
label: "i18n:govoplan-postbox.postboxes",
|
|
group: "TENANT",
|
|
order: 45,
|
|
surfaceId: "postbox.admin.templates",
|
|
anyOf: [
|
|
"postbox:binding:admin",
|
|
"postbox:template:admin"
|
|
],
|
|
render: ({ settings, auth }) =>
|
|
createElement(PostboxAdminPanel, {
|
|
settings,
|
|
canManageBindings: hasScope(auth, "postbox:binding:admin"),
|
|
canManageTemplates: hasScope(auth, "postbox:template:admin")
|
|
})
|
|
}
|
|
]
|
|
};
|
|
|
|
export const postboxModule: PlatformWebModule = {
|
|
id: "postbox",
|
|
label: "i18n:govoplan-postbox.postbox",
|
|
version: "0.1.18",
|
|
dependencies: ["identity", "organizations", "idm"],
|
|
optionalDependencies: [
|
|
"access",
|
|
"audit",
|
|
"campaigns",
|
|
"encryption",
|
|
"files",
|
|
"mail",
|
|
"notifications",
|
|
"policy",
|
|
"portal",
|
|
"search",
|
|
"tasks",
|
|
"views",
|
|
"workflow_engine"
|
|
],
|
|
translations,
|
|
navItems: [
|
|
{
|
|
to: "/postbox",
|
|
label: "i18n:govoplan-postbox.postbox",
|
|
iconName: "inbox",
|
|
anyOf: readScope,
|
|
order: 58
|
|
}
|
|
],
|
|
routes: [
|
|
{
|
|
path: "/postbox",
|
|
anyOf: readScope,
|
|
order: 58,
|
|
surfaceId: "postbox.inbox.messages",
|
|
render: ({ settings, auth }) =>
|
|
createElement(PostboxPage, { settings, auth })
|
|
}
|
|
],
|
|
viewSurfaces: [
|
|
{
|
|
id: "postbox.inbox.directory",
|
|
moduleId: "postbox",
|
|
kind: "section",
|
|
label: "i18n:govoplan-postbox.postbox_directory",
|
|
order: 10
|
|
},
|
|
{
|
|
id: "postbox.inbox.messages",
|
|
moduleId: "postbox",
|
|
kind: "section",
|
|
label: "i18n:govoplan-postbox.postbox_messages",
|
|
order: 20
|
|
},
|
|
{
|
|
id: "postbox.widget.inbox",
|
|
moduleId: "postbox",
|
|
kind: "section",
|
|
label: "i18n:govoplan-postbox.postbox_inbox_widget",
|
|
order: 25
|
|
},
|
|
{
|
|
id: "postbox.admin.templates",
|
|
moduleId: "postbox",
|
|
kind: "section",
|
|
label: "i18n:govoplan-postbox.postbox_templates_bindings",
|
|
order: 30
|
|
},
|
|
{
|
|
id: "postbox.quick_access.messages",
|
|
moduleId: "postbox",
|
|
kind: "quick_access",
|
|
label: "Postbox Quick Access",
|
|
order: 35
|
|
}
|
|
],
|
|
uiCapabilities: {
|
|
"admin.sections": postboxAdminSections,
|
|
"dashboard.widgets": postboxDashboardWidgets,
|
|
"quickAccess.tools": postboxQuickAccessTools
|
|
}
|
|
};
|
|
|
|
export default postboxModule;
|