mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-02 00:06:23 +00:00
feat: hide or lock the external content option as the organisation sets it
This commit is contained in:
@@ -13,6 +13,7 @@ import { useHasContacts } from '../../lib/capabilities';
|
|||||||
import { isTrustedSendersSyncOn } from '../../lib/trusted-senders';
|
import { isTrustedSendersSyncOn } from '../../lib/trusted-senders';
|
||||||
import { removeTrustedSenderWithUndo } from '../../lib/settings-undo';
|
import { removeTrustedSenderWithUndo } from '../../lib/settings-undo';
|
||||||
import { useLocaleStore } from '../../stores/locale-store';
|
import { useLocaleStore } from '../../stores/locale-store';
|
||||||
|
import { usePolicyFeature, useSettingHidden, useSettingLocked } from '../../stores/policy-store';
|
||||||
import { MODAL_ORIENTATIONS } from '../../lib/modal-orientations';
|
import { MODAL_ORIENTATIONS } from '../../lib/modal-orientations';
|
||||||
import { useSheetBottomInset } from '../../lib/sheet-bottom-inset';
|
import { useSheetBottomInset } from '../../lib/sheet-bottom-inset';
|
||||||
import { ToastHost } from '../ToastHost';
|
import { ToastHost } from '../ToastHost';
|
||||||
@@ -31,6 +32,12 @@ export function ContentSendersSettings() {
|
|||||||
const t = useLocaleStore((s) => s.t);
|
const t = useLocaleStore((s) => s.t);
|
||||||
const externalContentPolicy = useSettingsStore((s) => s.externalContentPolicy);
|
const externalContentPolicy = useSettingsStore((s) => s.externalContentPolicy);
|
||||||
const setExternalContentPolicy = useSettingsStore((s) => s.setExternalContentPolicy);
|
const setExternalContentPolicy = useSettingsStore((s) => s.setExternalContentPolicy);
|
||||||
|
// The organisation can take the option away or pin it (webmail
|
||||||
|
// reading-settings.tsx).
|
||||||
|
const externalContentAllowed = usePolicyFeature('externalContentEnabled');
|
||||||
|
const externalContentHidden = useSettingHidden('externalContentPolicy');
|
||||||
|
const externalContentLocked = useSettingLocked('externalContentPolicy');
|
||||||
|
const showExternalContent = externalContentAllowed && !externalContentHidden;
|
||||||
const emailAlwaysLightMode = useSettingsStore((s) => s.emailAlwaysLightMode);
|
const emailAlwaysLightMode = useSettingsStore((s) => s.emailAlwaysLightMode);
|
||||||
const setEmailAlwaysLightMode = useSettingsStore((s) => s.setEmailAlwaysLightMode);
|
const setEmailAlwaysLightMode = useSettingsStore((s) => s.setEmailAlwaysLightMode);
|
||||||
const trustedSenders = useSettingsStore((s) => s.trustedSenders);
|
const trustedSenders = useSettingsStore((s) => s.trustedSenders);
|
||||||
@@ -134,20 +141,23 @@ export function ContentSendersSettings() {
|
|||||||
title={t('settings.tabs.content_senders', 'Content & Senders')}
|
title={t('settings.tabs.content_senders', 'Content & Senders')}
|
||||||
description={t('settings.email_behavior.content_senders_description_mobile', 'Control how external resources and tracking pixels are handled.')}
|
description={t('settings.email_behavior.content_senders_description_mobile', 'Control how external resources and tracking pixels are handled.')}
|
||||||
>
|
>
|
||||||
<SettingItem
|
{showExternalContent && (
|
||||||
label={t('settings.email_behavior.external_content.label', 'External Content')}
|
<SettingItem
|
||||||
description={t('settings.email_behavior.external_content.description', 'How to handle images and external content')}
|
label={t('settings.email_behavior.external_content.label', 'External Content')}
|
||||||
>
|
description={t('settings.email_behavior.external_content.description', 'How to handle images and external content')}
|
||||||
<RadioGroup
|
locked={externalContentLocked}
|
||||||
value={externalContentPolicy}
|
>
|
||||||
onChange={(v) => setExternalContentPolicy(v as ExternalContentPolicy)}
|
<RadioGroup
|
||||||
options={[
|
value={externalContentPolicy}
|
||||||
{ value: 'ask', label: t('settings.email_behavior.external_content.ask_mobile', 'Ask') },
|
onChange={(v) => setExternalContentPolicy(v as ExternalContentPolicy)}
|
||||||
{ value: 'block', label: t('settings.email_behavior.external_content.block_mobile', 'Block') },
|
options={[
|
||||||
{ value: 'allow', label: t('settings.email_behavior.external_content.allow_mobile', 'Allow') },
|
{ value: 'ask', label: t('settings.email_behavior.external_content.ask_mobile', 'Ask') },
|
||||||
]}
|
{ value: 'block', label: t('settings.email_behavior.external_content.block_mobile', 'Block') },
|
||||||
/>
|
{ value: 'allow', label: t('settings.email_behavior.external_content.allow_mobile', 'Allow') },
|
||||||
</SettingItem>
|
]}
|
||||||
|
/>
|
||||||
|
</SettingItem>
|
||||||
|
)}
|
||||||
|
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('settings.email_behavior.always_light_mode.label', 'Always Show Emails in Light Mode')}
|
label={t('settings.email_behavior.always_light_mode.label', 'Always Show Emails in Light Mode')}
|
||||||
|
|||||||
@@ -34,4 +34,13 @@ describe('organisation policy on the settings pages', () => {
|
|||||||
expect(page).toMatch(/\{tasksAllowed && \(\s*<SettingItem\s+label=\{t\('calendar\.settings\.enable_tasks'[\s\S]*?locked=\{tasksLocked\}/);
|
expect(page).toMatch(/\{tasksAllowed && \(\s*<SettingItem\s+label=\{t\('calendar\.settings\.enable_tasks'[\s\S]*?locked=\{tasksLocked\}/);
|
||||||
expect(page).toContain('{tasksAllowed && tasksEnabled && (');
|
expect(page).toContain('{tasksAllowed && tasksEnabled && (');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('hides the external content option when the organisation turns it off or hides it', () => {
|
||||||
|
const page = settings('ContentSendersSettings');
|
||||||
|
expect(page).toContain("const externalContentAllowed = usePolicyFeature('externalContentEnabled');");
|
||||||
|
expect(page).toContain("const externalContentHidden = useSettingHidden('externalContentPolicy');");
|
||||||
|
expect(page).toContain('const showExternalContent = externalContentAllowed && !externalContentHidden;');
|
||||||
|
expect(page).toMatch(/\{showExternalContent && \(\s*<SettingItem\s+label=\{t\('settings\.email_behavior\.external_content\.label'[\s\S]*?locked=\{externalContentLocked\}/);
|
||||||
|
expect(page).toContain("const externalContentLocked = useSettingLocked('externalContentPolicy');");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user