Files
webmail/lib/archive-gate.ts
T
Jacob ZeitzandClaude Opus 5.5 99b0bced3b feat: admin policy gate to turn off archiving #1257
A new feature gate, archiveActionEnabled (default on), lets the admin turn the
Archive action off for installations that archive mail elsewhere, such as a
mail gateway. With it off, Bulwark offers no Archive anywhere: the viewer's
button and its overflow entry, the context menu for one or several messages,
Mountain View's selection bar, the hover and swipe actions, the E shortcut and
its help row, archiving after an export, and the archive mode setting (also in
the settings search). With it off nothing creates an Archive folder:
ensureArchiveMailbox returns null. Existing Archive folders stay ordinary
folders, moving mail into them by hand still works, and the plugin API is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 20:48:28 +02:00

22 lines
1.0 KiB
TypeScript

import { usePolicyStore } from '@/stores/policy-store';
// The admin policy's `archiveActionEnabled` gate (#1257). Installations that
// archive mail elsewhere (a mail gateway) turn the Archive action off: no
// button, menu entry, hover or swipe action, shortcut or archive-after-export,
// and no Archive folder created. Existing Archive folders stay ordinary folders.
/** Whether the Archive action is offered, for components. */
export function useArchiveActionEnabled(): boolean {
return usePolicyStore((s) => s.isFeatureEnabled('archiveActionEnabled'));
}
/** Whether the Archive action is offered, outside React (handlers, stores). */
export function isArchiveActionEnabled(): boolean {
return usePolicyStore.getState().isFeatureEnabled('archiveActionEnabled');
}
/** The actions without `archive` while the gate is off. */
export function withoutArchiveIfOff<T extends string>(actions: readonly T[], archiveActionEnabled: boolean): readonly T[] {
return archiveActionEnabled ? actions : actions.filter((action) => action !== 'archive');
}