Contribute Mail to Quick Access
This commit is contained in:
@@ -26,6 +26,8 @@ from govoplan_core.core.modules import (
|
|||||||
ModuleManifest,
|
ModuleManifest,
|
||||||
NavItem,
|
NavItem,
|
||||||
PermissionDefinition,
|
PermissionDefinition,
|
||||||
|
ProductAreaContribution,
|
||||||
|
QuickAccessTool,
|
||||||
RoleTemplate,
|
RoleTemplate,
|
||||||
)
|
)
|
||||||
from govoplan_core.core.provider_governance import (
|
from govoplan_core.core.provider_governance import (
|
||||||
@@ -376,6 +378,33 @@ manifest = ModuleManifest(
|
|||||||
ViewSurface(id="mail.admin.group-servers", module_id="mail", kind="section", label="Group mail servers", order=20),
|
ViewSurface(id="mail.admin.group-servers", module_id="mail", kind="section", label="Group mail servers", order=20),
|
||||||
ViewSurface(id="mail.admin.user-servers", module_id="mail", kind="section", label="User mail servers", order=20),
|
ViewSurface(id="mail.admin.user-servers", module_id="mail", kind="section", label="User mail servers", order=20),
|
||||||
ViewSurface(id="mail.settings.profiles", module_id="mail", kind="section", label="Personal mail profiles", order=10),
|
ViewSurface(id="mail.settings.profiles", module_id="mail", kind="section", label="Personal mail profiles", order=10),
|
||||||
|
ViewSurface(id="mail.quick_access.messages", module_id="mail", kind="quick_access", label="Mail Quick Access", order=80),
|
||||||
|
),
|
||||||
|
product_areas=(
|
||||||
|
ProductAreaContribution(
|
||||||
|
id="communication",
|
||||||
|
module_id="mail",
|
||||||
|
label="i18n:govoplan-core.product_area.communication",
|
||||||
|
icon="mail",
|
||||||
|
description="i18n:govoplan-core.product_area.communication_description",
|
||||||
|
surface_ids=("mail.nav.mail", "mail.route.mail"),
|
||||||
|
order=40,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
quick_access_tools=(
|
||||||
|
QuickAccessTool(
|
||||||
|
id="mail.messages",
|
||||||
|
module_id="mail",
|
||||||
|
category_id="messages",
|
||||||
|
label="i18n:govoplan-mail.mail.92379cbb",
|
||||||
|
description="i18n:govoplan-mail.quick_access_description",
|
||||||
|
surface_id="mail.quick_access.messages",
|
||||||
|
icon="mail",
|
||||||
|
full_page_path="/mail",
|
||||||
|
required_any=("mail:mailbox:read",),
|
||||||
|
order=10,
|
||||||
|
modes=("browse", "compose"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
migration_spec=MigrationSpec(
|
migration_spec=MigrationSpec(
|
||||||
@@ -418,6 +447,33 @@ manifest = ModuleManifest(
|
|||||||
).SqlMailBounceProcessingProvider(),
|
).SqlMailBounceProcessingProvider(),
|
||||||
},
|
},
|
||||||
documentation=(
|
documentation=(
|
||||||
|
DocumentationTopic(
|
||||||
|
id="mail.quick-access-and-product-area",
|
||||||
|
title="Mail in Communication and Messages",
|
||||||
|
summary="Use Mail in the Communication product area and the shared Messages Quick Access drawer.",
|
||||||
|
body=(
|
||||||
|
"Mail contributes its full mailbox to Communication. When Quick Access is enabled, its compact provider surface "
|
||||||
|
"appears inside the shared Messages drawer alongside independent Postbox and future chat contributions. "
|
||||||
|
"The shared drawer does not merge channel state, credentials, custody, delivery semantics, or authorization."
|
||||||
|
),
|
||||||
|
layer="configured",
|
||||||
|
documentation_types=("user", "admin"),
|
||||||
|
audience=("mail_user", "mail_admin", "administrator"),
|
||||||
|
related_modules=("quick_access", "views", "postbox"),
|
||||||
|
translations={
|
||||||
|
"de": {
|
||||||
|
"title": "Mail in Kommunikation und Nachrichten",
|
||||||
|
"summary": "Mail im Produktbereich Kommunikation und in der gemeinsamen Schnellzugriffseinblendung Nachrichten verwenden.",
|
||||||
|
"body": (
|
||||||
|
"Mail ordnet das vollständige Postfach Kommunikation zu. Ist der Schnellzugriff aktiviert, erscheint die kompakte "
|
||||||
|
"Mail-Oberfläche gemeinsam mit unabhängigen Beiträgen aus Postbox und künftig Chat unter Nachrichten. "
|
||||||
|
"Die gemeinsame Darstellung führt weder Kanalzustand noch Zugangsdaten, Verwahrung oder Berechtigungen zusammen."
|
||||||
|
),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
metadata={"kind": "reference", "help_contexts": ["mail.quick_access.messages"]},
|
||||||
|
order=37,
|
||||||
|
),
|
||||||
DocumentationTopic(
|
DocumentationTopic(
|
||||||
id="mail.search.mailbox-messages",
|
id="mail.search.mailbox-messages",
|
||||||
title="Search authorized mailbox messages",
|
title="Search authorized mailbox messages",
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { useCallback } from "react";
|
||||||
|
import { Mail } from "lucide-react";
|
||||||
|
import { Link } from "react-router";
|
||||||
|
import {
|
||||||
|
DashboardWidgetList,
|
||||||
|
DismissibleAlert,
|
||||||
|
LoadingFrame,
|
||||||
|
useDashboardWidgetData,
|
||||||
|
type ApiSettings
|
||||||
|
} from "@govoplan/core-webui";
|
||||||
|
import {
|
||||||
|
bootstrapMailbox,
|
||||||
|
listMailServerProfiles,
|
||||||
|
type MailMailboxMessageSummary
|
||||||
|
} from "../../api/mail";
|
||||||
|
|
||||||
|
|
||||||
|
type MailQuickAccessData = {
|
||||||
|
profileName?: string;
|
||||||
|
messages: MailMailboxMessageSummary[];
|
||||||
|
available: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function MailQuickAccess({ settings }: { settings: ApiSettings }) {
|
||||||
|
const load = useCallback(async (): Promise<MailQuickAccessData> => {
|
||||||
|
const profiles = await listMailServerProfiles(settings);
|
||||||
|
const profile = profiles.find((item) => item.is_active && item.imap);
|
||||||
|
if (!profile) return { messages: [], available: false };
|
||||||
|
const response = await bootstrapMailbox(settings, profile.id, "INBOX", 7, 0, false);
|
||||||
|
return {
|
||||||
|
profileName: profile.name,
|
||||||
|
messages: response.messages.messages ?? [],
|
||||||
|
available: true
|
||||||
|
};
|
||||||
|
}, [settings]);
|
||||||
|
const { data, loading, error } = useDashboardWidgetData(load, 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LoadingFrame loading={loading} label="i18n:govoplan-mail.loading_messages.4294022c">
|
||||||
|
{error ? <DismissibleAlert tone="warning" resetKey={error}>{error}</DismissibleAlert> : null}
|
||||||
|
<DashboardWidgetList
|
||||||
|
emptyText={data?.available ? "i18n:govoplan-mail.no_messages_in_this_folder.5c7fa25d" : "i18n:govoplan-mail.select_an_imap_profile.5445648c"}
|
||||||
|
items={(data?.messages ?? []).map((message) => ({
|
||||||
|
id: `${message.folder}:${message.uid}`,
|
||||||
|
title: message.subject || "i18n:govoplan-mail.no_subject.49b20da0",
|
||||||
|
detail: message.from_header || data?.profileName,
|
||||||
|
meta: formatMessageDate(message.date),
|
||||||
|
leading: <Mail size={17} aria-hidden="true" />,
|
||||||
|
to: "/mail"
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
<div className="dashboard-contribution-footer">
|
||||||
|
<Link className="btn btn-secondary" to="/mail">i18n:govoplan-mail.mail.92379cbb</Link>
|
||||||
|
</div>
|
||||||
|
</LoadingFrame>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function formatMessageDate(value?: string | null): string | undefined {
|
||||||
|
if (!value) return undefined;
|
||||||
|
const parsed = new Date(value);
|
||||||
|
if (Number.isNaN(parsed.getTime())) return value;
|
||||||
|
return new Intl.DateTimeFormat(undefined, {
|
||||||
|
day: "2-digit",
|
||||||
|
month: "short",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit"
|
||||||
|
}).format(parsed);
|
||||||
|
}
|
||||||
@@ -95,6 +95,7 @@ export const generatedTranslations: PlatformTranslations = {
|
|||||||
"i18n:govoplan-mail.mail_profile_policy.f2ac4b92": "Mail profile policy",
|
"i18n:govoplan-mail.mail_profile_policy.f2ac4b92": "Mail profile policy",
|
||||||
"i18n:govoplan-mail.mail_server_profiles.b1726682": "Mail server profiles",
|
"i18n:govoplan-mail.mail_server_profiles.b1726682": "Mail server profiles",
|
||||||
"i18n:govoplan-mail.mail.92379cbb": "Mail",
|
"i18n:govoplan-mail.mail.92379cbb": "Mail",
|
||||||
|
"i18n:govoplan-mail.quick_access_description": "Recent mailbox messages and mail actions.",
|
||||||
"i18n:govoplan-mail.mailbox_folders_could_not_be_loaded.c3e3880e": "Mailbox folders could not be loaded.",
|
"i18n:govoplan-mail.mailbox_folders_could_not_be_loaded.c3e3880e": "Mailbox folders could not be loaded.",
|
||||||
"i18n:govoplan-mail.mailbox_folders.c92f6de4": "Mailbox folders",
|
"i18n:govoplan-mail.mailbox_folders.c92f6de4": "Mailbox folders",
|
||||||
"i18n:govoplan-mail.mailbox_message_pagination.965407bf": "Mailbox message pagination",
|
"i18n:govoplan-mail.mailbox_message_pagination.965407bf": "Mailbox message pagination",
|
||||||
@@ -292,6 +293,7 @@ export const generatedTranslations: PlatformTranslations = {
|
|||||||
"i18n:govoplan-mail.mail_profile_policy.f2ac4b92": "Mail profile policy",
|
"i18n:govoplan-mail.mail_profile_policy.f2ac4b92": "Mail profile policy",
|
||||||
"i18n:govoplan-mail.mail_server_profiles.b1726682": "Mail server profiles",
|
"i18n:govoplan-mail.mail_server_profiles.b1726682": "Mail server profiles",
|
||||||
"i18n:govoplan-mail.mail.92379cbb": "Mail",
|
"i18n:govoplan-mail.mail.92379cbb": "Mail",
|
||||||
|
"i18n:govoplan-mail.quick_access_description": "Aktuelle Posteingangsnachrichten und Mail-Aktionen.",
|
||||||
"i18n:govoplan-mail.mailbox_folders_could_not_be_loaded.c3e3880e": "Mailbox folders could not be loaded.",
|
"i18n:govoplan-mail.mailbox_folders_could_not_be_loaded.c3e3880e": "Mailbox folders could not be loaded.",
|
||||||
"i18n:govoplan-mail.mailbox_folders.c92f6de4": "Mailbox folders",
|
"i18n:govoplan-mail.mailbox_folders.c92f6de4": "Mailbox folders",
|
||||||
"i18n:govoplan-mail.mailbox_message_pagination.965407bf": "Mailbox message pagination",
|
"i18n:govoplan-mail.mailbox_message_pagination.965407bf": "Mailbox message pagination",
|
||||||
|
|||||||
+14
-3
@@ -1,9 +1,10 @@
|
|||||||
import { createElement, lazy } from "react";
|
import { createElement, lazy } from "react";
|
||||||
import type { MailDevMailboxUiCapability, MailProfilesUiCapability, PlatformWebModule } from "@govoplan/core-webui";
|
import type { MailDevMailboxUiCapability, MailProfilesUiCapability, PlatformWebModule, QuickAccessToolsUiCapability } from "@govoplan/core-webui";
|
||||||
import { MailProfilePolicyEditor, MailProfileScopeManager } from "./features/mail/MailProfileManagement";
|
import { MailProfilePolicyEditor, MailProfileScopeManager } from "./features/mail/MailProfileManagement";
|
||||||
import { validateMailPolicy } from "./features/mail/mailPolicyValidation";
|
import { validateMailPolicy } from "./features/mail/mailPolicyValidation";
|
||||||
import { mailCredentialReferenceSelectors } from "./features/mail/mailReferenceProviders";
|
import { mailCredentialReferenceSelectors } from "./features/mail/mailReferenceProviders";
|
||||||
import { generatedTranslations } from "./i18n/generatedTranslations";
|
import { generatedTranslations } from "./i18n/generatedTranslations";
|
||||||
|
import MailQuickAccess from "./features/mail/MailQuickAccess";
|
||||||
import "./styles/mail-profiles.css";
|
import "./styles/mail-profiles.css";
|
||||||
|
|
||||||
const MailboxPage = lazy(() => import("./features/mail/MailboxPage"));
|
const MailboxPage = lazy(() => import("./features/mail/MailboxPage"));
|
||||||
@@ -14,6 +15,14 @@ const translations = {
|
|||||||
en: generatedTranslations.en,
|
en: generatedTranslations.en,
|
||||||
de: generatedTranslations.de
|
de: generatedTranslations.de
|
||||||
};
|
};
|
||||||
|
const mailQuickAccessTools: QuickAccessToolsUiCapability = {
|
||||||
|
tools: [
|
||||||
|
{
|
||||||
|
id: "mail.messages",
|
||||||
|
render: ({ settings }) => createElement(MailQuickAccess, { settings })
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
export const mailModule: PlatformWebModule = {
|
export const mailModule: PlatformWebModule = {
|
||||||
id: "mail",
|
id: "mail",
|
||||||
@@ -27,7 +36,8 @@ export const mailModule: PlatformWebModule = {
|
|||||||
{ id: "mail.admin.tenant-servers", moduleId: "mail", kind: "section", label: "Tenant mail servers", order: 60 },
|
{ id: "mail.admin.tenant-servers", moduleId: "mail", kind: "section", label: "Tenant mail servers", order: 60 },
|
||||||
{ id: "mail.admin.group-servers", moduleId: "mail", kind: "section", label: "Group mail servers", order: 20 },
|
{ id: "mail.admin.group-servers", moduleId: "mail", kind: "section", label: "Group mail servers", order: 20 },
|
||||||
{ id: "mail.admin.user-servers", moduleId: "mail", kind: "section", label: "User mail servers", order: 20 },
|
{ id: "mail.admin.user-servers", moduleId: "mail", kind: "section", label: "User mail servers", order: 20 },
|
||||||
{ id: "mail.settings.profiles", moduleId: "mail", kind: "section", label: "Personal mail profiles", order: 10 }
|
{ id: "mail.settings.profiles", moduleId: "mail", kind: "section", label: "Personal mail profiles", order: 10 },
|
||||||
|
{ id: "mail.quick_access.messages", moduleId: "mail", kind: "quick_access", label: "Mail Quick Access", order: 80 }
|
||||||
],
|
],
|
||||||
navItems: [{ to: "/mail", label: "i18n:govoplan-mail.mail.92379cbb", iconName: "mail", anyOf: mailboxRead, order: 50 }],
|
navItems: [{ to: "/mail", label: "i18n:govoplan-mail.mail.92379cbb", iconName: "mail", anyOf: mailboxRead, order: 50 }],
|
||||||
routes: [
|
routes: [
|
||||||
@@ -36,7 +46,8 @@ export const mailModule: PlatformWebModule = {
|
|||||||
|
|
||||||
uiCapabilities: {
|
uiCapabilities: {
|
||||||
"mail.profiles": { MailProfileScopeManager, MailProfilePolicyEditor, validateMailPolicy } satisfies MailProfilesUiCapability,
|
"mail.profiles": { MailProfileScopeManager, MailProfilePolicyEditor, validateMailPolicy } satisfies MailProfilesUiCapability,
|
||||||
"core.credentialReferenceSelectors": mailCredentialReferenceSelectors
|
"core.credentialReferenceSelectors": mailCredentialReferenceSelectors,
|
||||||
|
"quickAccess.tools": mailQuickAccessTools
|
||||||
},
|
},
|
||||||
runtimeUiCapabilities: {
|
runtimeUiCapabilities: {
|
||||||
"mail.devMailbox": { enabled: true, label: "i18n:govoplan-mail.development_mock_mailbox.1a379865" } satisfies MailDevMailboxUiCapability
|
"mail.devMailbox": { enabled: true, label: "i18n:govoplan-mail.development_mock_mailbox.1a379865" } satisfies MailDevMailboxUiCapability
|
||||||
|
|||||||
Reference in New Issue
Block a user