@micha.bigler/ui-core-micha 4.30.0 → 4.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +26 -0
- package/dist/billing/CancellationDialog.js +68 -0
- package/dist/billing/ContractSummary.js +22 -0
- package/dist/billing/DeclarationConfirm.js +27 -0
- package/dist/billing/DeclarationForm.js +134 -0
- package/dist/billing/PlanPicker.js +1 -1
- package/dist/billing/SubscriptionSection.js +35 -1
- package/dist/billing/WithdrawalDialog.js +4 -1
- package/dist/billing/WithdrawalSection.js +7 -4
- package/dist/billing/api.js +6 -0
- package/dist/billing/wire.js +6 -0
- package/dist/components/ProfileComponent.js +11 -10
- package/dist/components/ProfileStepContent.js +29 -17
- package/dist/i18n/authTranslations.js +7 -0
- package/dist/i18n/billingTranslations.js +74 -0
- package/dist/i18n/privacyTranslations.js +37 -0
- package/dist/i18n/uiCoreTranslations.js +2 -1
- package/dist/index.js +14 -0
- package/dist/onboarding/OnboardingProvider.js +5 -2
- package/dist/onboarding/steps/CookieConsentStep.js +1 -0
- package/dist/privacy/PrivacyBanner.js +60 -0
- package/dist/privacy/PrivacyFooterLinks.js +69 -0
- package/dist/privacy/PrivacyNoticeLink.js +60 -0
- package/dist/privacy/PrivacyProvider.js +470 -0
- package/dist/privacy/PrivacySettings.js +89 -0
- package/dist/privacy/PrivacySettingsLink.js +25 -0
- package/dist/privacy/privacyApi.js +27 -0
- package/dist/privacy/serviceRegistry.js +222 -0
- package/dist/theme/kitSxRegistry.js +8 -0
- package/dist/utils/profileDraft.js +13 -8
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { Link } from '@mui/material';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { usePrivacy } from './PrivacyProvider';
|
|
17
|
+
import { localeForManifest } from './PrivacyProvider';
|
|
18
|
+
export function safePrivacyDocumentUrl(value) {
|
|
19
|
+
if (typeof value !== 'string' || !value || /[\u0000-\u001f\\]/.test(value))
|
|
20
|
+
return null;
|
|
21
|
+
const trimmed = value.trim();
|
|
22
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = new URL(trimmed);
|
|
25
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
|
|
26
|
+
return null;
|
|
27
|
+
return parsed.href;
|
|
28
|
+
}
|
|
29
|
+
catch (_a) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (trimmed.startsWith('/') && !trimmed.startsWith('//'))
|
|
34
|
+
return trimmed;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function documentReference(manifest, locale, documentId) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const documents = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.notice) === null || _a === void 0 ? void 0 : _a.documents) || {};
|
|
40
|
+
const id = documentId && documents[documentId]
|
|
41
|
+
? documentId
|
|
42
|
+
: Object.keys(documents)[0];
|
|
43
|
+
const localized = id ? (_b = documents[id]) === null || _b === void 0 ? void 0 : _b[locale] : null;
|
|
44
|
+
if (typeof localized === 'string')
|
|
45
|
+
return localized;
|
|
46
|
+
return (localized === null || localized === void 0 ? void 0 : localized.url) || (localized === null || localized === void 0 ? void 0 : localized.href) || (localized === null || localized === void 0 ? void 0 : localized.path) || (localized === null || localized === void 0 ? void 0 : localized.reference) || null;
|
|
47
|
+
}
|
|
48
|
+
export function PrivacyNoticeLink(_a) {
|
|
49
|
+
var { documentId, children } = _a, props = __rest(_a, ["documentId", "children"]);
|
|
50
|
+
const privacy = usePrivacy();
|
|
51
|
+
const { t, i18n } = useTranslation();
|
|
52
|
+
if (!privacy || privacy.status !== 'ready' || !privacy.manifest)
|
|
53
|
+
return null;
|
|
54
|
+
const locale = localeForManifest(privacy.manifest, i18n.language);
|
|
55
|
+
const href = safePrivacyDocumentUrl(documentReference(privacy.manifest, locale, documentId));
|
|
56
|
+
if (!href)
|
|
57
|
+
return null;
|
|
58
|
+
return (_jsx(Link, Object.assign({}, props, { href: href, target: "_blank", rel: "noopener noreferrer", children: children || t('Privacy.NOTICE_LINK') })));
|
|
59
|
+
}
|
|
60
|
+
export default PrivacyNoticeLink;
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { createPrivacyApi, defaultPrivacyApi } from './privacyApi';
|
|
5
|
+
import { setPrivacyState } from './serviceRegistry';
|
|
6
|
+
import { PrivacySettingsDialog } from './PrivacySettings';
|
|
7
|
+
const PrivacyContext = createContext(null);
|
|
8
|
+
const OPTIONAL_STATES = new Set(['granted', 'refused']);
|
|
9
|
+
function errorCode(error) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const data = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
12
|
+
return (data === null || data === void 0 ? void 0 : data.code) || ((_b = data === null || data === void 0 ? void 0 : data.detail) === null || _b === void 0 ? void 0 : _b.code) || (typeof (data === null || data === void 0 ? void 0 : data.detail) === 'string' ? data.detail : null);
|
|
13
|
+
}
|
|
14
|
+
function isNotConfigured(error) {
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 404 && errorCode(error) === 'not_configured';
|
|
17
|
+
}
|
|
18
|
+
function makeUnsetChoices(manifest, source = {}) {
|
|
19
|
+
var _a;
|
|
20
|
+
const choices = {};
|
|
21
|
+
((manifest === null || manifest === void 0 ? void 0 : manifest.purposes) || []).filter((purpose) => !purpose.required).forEach((purpose) => {
|
|
22
|
+
choices[purpose.id] = {
|
|
23
|
+
state: 'unset',
|
|
24
|
+
revision: purpose.revision,
|
|
25
|
+
expires_at: null,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
receipt_state: source.receipt_state || 'unset',
|
|
30
|
+
seq: Number.isFinite(source.seq) ? source.seq : 0,
|
|
31
|
+
config_version: source.config_version || (manifest === null || manifest === void 0 ? void 0 : manifest.config_version),
|
|
32
|
+
notice_version: source.notice_version || ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.notice) === null || _a === void 0 ? void 0 : _a.version),
|
|
33
|
+
choices,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function normalizePrivacyChoices(manifest, source, now = Date.now()) {
|
|
37
|
+
var _a;
|
|
38
|
+
const normalized = makeUnsetChoices(manifest, source);
|
|
39
|
+
if (!manifest || !source || source.receipt_state !== 'present')
|
|
40
|
+
return normalized;
|
|
41
|
+
if (source.config_version !== manifest.config_version
|
|
42
|
+
|| source.notice_version !== ((_a = manifest.notice) === null || _a === void 0 ? void 0 : _a.version)
|
|
43
|
+
|| !Number.isInteger(source.seq) || source.seq < 0)
|
|
44
|
+
return normalized;
|
|
45
|
+
(manifest.purposes || []).filter((purpose) => !purpose.required).forEach((purpose) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const choice = (_a = source.choices) === null || _a === void 0 ? void 0 : _a[purpose.id];
|
|
48
|
+
const expiryText = choice === null || choice === void 0 ? void 0 : choice.expires_at;
|
|
49
|
+
const expiry = typeof expiryText === 'string'
|
|
50
|
+
&& /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/.test(expiryText)
|
|
51
|
+
? Date.parse(expiryText)
|
|
52
|
+
: NaN;
|
|
53
|
+
if (!purpose.id || purpose.revision === undefined || purpose.revision === null
|
|
54
|
+
|| !choice || !OPTIONAL_STATES.has(choice.state) || choice.revision !== purpose.revision
|
|
55
|
+
|| !Number.isFinite(expiry) || expiry <= now)
|
|
56
|
+
return;
|
|
57
|
+
normalized.choices[purpose.id] = {
|
|
58
|
+
state: choice.state,
|
|
59
|
+
revision: purpose.revision,
|
|
60
|
+
expires_at: choice.expires_at,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
return normalized;
|
|
64
|
+
}
|
|
65
|
+
function forceUnset(manifest, source) {
|
|
66
|
+
const unset = makeUnsetChoices(manifest, source);
|
|
67
|
+
return Object.assign(Object.assign({}, unset), { receipt_state: (source === null || source === void 0 ? void 0 : source.receipt_state) || 'unset' });
|
|
68
|
+
}
|
|
69
|
+
function localeForManifest(manifest, language = '') {
|
|
70
|
+
const locales = Array.isArray(manifest === null || manifest === void 0 ? void 0 : manifest.locales) ? manifest.locales : [];
|
|
71
|
+
if (!locales.length)
|
|
72
|
+
return '';
|
|
73
|
+
const normalized = String(language || '').replace('_', '-').toLowerCase();
|
|
74
|
+
const exact = locales.find((locale) => String(locale).toLowerCase() === normalized);
|
|
75
|
+
if (exact)
|
|
76
|
+
return exact;
|
|
77
|
+
const base = normalized.split('-')[0];
|
|
78
|
+
return locales.find((locale) => String(locale).toLowerCase() === base)
|
|
79
|
+
|| locales.find((locale) => String(locale).toLowerCase().split('-')[0] === base)
|
|
80
|
+
|| locales[0];
|
|
81
|
+
}
|
|
82
|
+
function requestId() {
|
|
83
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function')
|
|
84
|
+
return crypto.randomUUID();
|
|
85
|
+
const bytes = new Uint8Array(16);
|
|
86
|
+
if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function')
|
|
87
|
+
crypto.getRandomValues(bytes);
|
|
88
|
+
else
|
|
89
|
+
for (let i = 0; i < bytes.length; i += 1)
|
|
90
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
91
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
92
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
93
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
94
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
95
|
+
}
|
|
96
|
+
function toServerChoices(manifest, selections) {
|
|
97
|
+
const result = {};
|
|
98
|
+
((manifest === null || manifest === void 0 ? void 0 : manifest.purposes) || []).filter((purpose) => !purpose.required).forEach((purpose) => {
|
|
99
|
+
const selection = selections === null || selections === void 0 ? void 0 : selections[purpose.id];
|
|
100
|
+
const state = typeof selection === 'boolean' ? (selection ? 'granted' : 'refused') : selection;
|
|
101
|
+
if (OPTIONAL_STATES.has(state))
|
|
102
|
+
result[purpose.id] = state;
|
|
103
|
+
});
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
function effectiveChoices(serverChoices, pendingChoices) {
|
|
107
|
+
if (!serverChoices)
|
|
108
|
+
return null;
|
|
109
|
+
if (!pendingChoices)
|
|
110
|
+
return serverChoices;
|
|
111
|
+
const choices = Object.assign({}, serverChoices.choices);
|
|
112
|
+
Object.entries(pendingChoices).forEach(([purposeId, state]) => {
|
|
113
|
+
if (state === 'refused' && choices[purposeId])
|
|
114
|
+
choices[purposeId] = Object.assign(Object.assign({}, choices[purposeId]), { state: 'refused' });
|
|
115
|
+
});
|
|
116
|
+
return Object.assign(Object.assign({}, serverChoices), { choices });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Loads the host's privacy manifest and server receipt before any app adapter
|
|
120
|
+
* can observe a grant. This provider stores no choice in browser storage.
|
|
121
|
+
*/
|
|
122
|
+
export function PrivacyProvider({ children, api: apiOverride, apiBase = '/api/privacy/', csrfUrl = '/api/csrf/', }) {
|
|
123
|
+
const { i18n } = useTranslation();
|
|
124
|
+
const resolvedApi = useMemo(() => apiOverride || (apiBase === '/api/privacy/' && csrfUrl === '/api/csrf/'
|
|
125
|
+
? defaultPrivacyApi
|
|
126
|
+
: createPrivacyApi({}, { apiBase, csrfUrl })), [apiOverride, apiBase, csrfUrl]);
|
|
127
|
+
const [status, setStatus] = useState('loading');
|
|
128
|
+
const [manifest, setManifest] = useState(null);
|
|
129
|
+
const [serverChoices, setServerChoices] = useState(null);
|
|
130
|
+
const [pendingChoices, setPendingChoices] = useState(null);
|
|
131
|
+
const [pendingFailed, setPendingFailed] = useState(false);
|
|
132
|
+
const [saveState, setSaveState] = useState('idle');
|
|
133
|
+
const [error, setError] = useState(null);
|
|
134
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
135
|
+
const [bannerDismissed, setBannerDismissed] = useState(false);
|
|
136
|
+
const manifestRef = useRef(null);
|
|
137
|
+
const choicesRef = useRef(null);
|
|
138
|
+
const locallyDisabledRef = useRef(new Set());
|
|
139
|
+
const forceDecisionRef = useRef(false);
|
|
140
|
+
const pendingRef = useRef(null);
|
|
141
|
+
const mountedRef = useRef(false);
|
|
142
|
+
const loadSequenceRef = useRef(0);
|
|
143
|
+
const localWriteRef = useRef(Promise.resolve());
|
|
144
|
+
const channelRef = useRef(null);
|
|
145
|
+
const setRegistry = useCallback((nextManifest, nextChoices) => {
|
|
146
|
+
const source = forceDecisionRef.current && nextManifest
|
|
147
|
+
? forceUnset(nextManifest, nextChoices || {})
|
|
148
|
+
: nextChoices;
|
|
149
|
+
setPrivacyState(nextManifest, source, locallyDisabledRef.current);
|
|
150
|
+
}, []);
|
|
151
|
+
const applyManifestAndChoices = useCallback((nextManifest, source, { forceUnsetChoices = false } = {}) => {
|
|
152
|
+
const nextChoices = forceUnsetChoices
|
|
153
|
+
? forceUnset(nextManifest, source)
|
|
154
|
+
: normalizePrivacyChoices(nextManifest, source);
|
|
155
|
+
manifestRef.current = nextManifest;
|
|
156
|
+
choicesRef.current = nextChoices;
|
|
157
|
+
if (mountedRef.current) {
|
|
158
|
+
setManifest(nextManifest);
|
|
159
|
+
setServerChoices(nextChoices);
|
|
160
|
+
setStatus('ready');
|
|
161
|
+
}
|
|
162
|
+
setRegistry(nextManifest, nextChoices);
|
|
163
|
+
return nextChoices;
|
|
164
|
+
}, [setRegistry]);
|
|
165
|
+
const load = useCallback(async ({ forceUnsetChoices = false } = {}) => {
|
|
166
|
+
const sequence = ++loadSequenceRef.current;
|
|
167
|
+
if (mountedRef.current) {
|
|
168
|
+
setStatus((previous) => (previous === 'ready' ? previous : 'loading'));
|
|
169
|
+
setError(null);
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const nextManifest = await resolvedApi.getManifest();
|
|
173
|
+
const source = await resolvedApi.getChoices();
|
|
174
|
+
if (sequence !== loadSequenceRef.current)
|
|
175
|
+
return null;
|
|
176
|
+
const mustForceDecision = forceUnsetChoices || forceDecisionRef.current;
|
|
177
|
+
forceDecisionRef.current = mustForceDecision;
|
|
178
|
+
const nextChoices = applyManifestAndChoices(nextManifest, source, { forceUnsetChoices: mustForceDecision });
|
|
179
|
+
if (mountedRef.current)
|
|
180
|
+
setError(null);
|
|
181
|
+
return { manifest: nextManifest, choices: nextChoices };
|
|
182
|
+
}
|
|
183
|
+
catch (loadError) {
|
|
184
|
+
if (sequence !== loadSequenceRef.current)
|
|
185
|
+
return null;
|
|
186
|
+
if (isNotConfigured(loadError)) {
|
|
187
|
+
manifestRef.current = null;
|
|
188
|
+
choicesRef.current = null;
|
|
189
|
+
if (mountedRef.current) {
|
|
190
|
+
setManifest(null);
|
|
191
|
+
setServerChoices(null);
|
|
192
|
+
setStatus('unconfigured');
|
|
193
|
+
setError(null);
|
|
194
|
+
}
|
|
195
|
+
setRegistry(null, null);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
manifestRef.current = null;
|
|
199
|
+
choicesRef.current = null;
|
|
200
|
+
if (mountedRef.current) {
|
|
201
|
+
setManifest(null);
|
|
202
|
+
setServerChoices(null);
|
|
203
|
+
setStatus('error');
|
|
204
|
+
setError(loadError);
|
|
205
|
+
}
|
|
206
|
+
setRegistry(null, null);
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}, [applyManifestAndChoices, resolvedApi, setRegistry]);
|
|
210
|
+
const channelKey = useMemo(() => {
|
|
211
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : 'server';
|
|
212
|
+
return `privacy-state:${origin}:${apiBase}`;
|
|
213
|
+
}, [apiBase]);
|
|
214
|
+
const broadcastChanged = useCallback(() => {
|
|
215
|
+
const channel = channelRef.current;
|
|
216
|
+
if (channel) {
|
|
217
|
+
try {
|
|
218
|
+
channel.postMessage({ type: 'state-changed' });
|
|
219
|
+
}
|
|
220
|
+
catch (_a) { /* A later GET still recovers state. */ }
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (typeof window === 'undefined')
|
|
224
|
+
return;
|
|
225
|
+
const key = `${channelKey}:signal`;
|
|
226
|
+
try {
|
|
227
|
+
window.localStorage.setItem(key, requestId());
|
|
228
|
+
window.localStorage.removeItem(key);
|
|
229
|
+
}
|
|
230
|
+
catch (_b) {
|
|
231
|
+
// Synchronisation is best effort when storage is unavailable.
|
|
232
|
+
}
|
|
233
|
+
}, [channelKey]);
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
mountedRef.current = true;
|
|
236
|
+
load();
|
|
237
|
+
let channel = null;
|
|
238
|
+
if (typeof BroadcastChannel !== 'undefined') {
|
|
239
|
+
try {
|
|
240
|
+
channel = new BroadcastChannel(channelKey);
|
|
241
|
+
channel.onmessage = (event) => {
|
|
242
|
+
var _a;
|
|
243
|
+
if (((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.type) === 'state-changed')
|
|
244
|
+
load();
|
|
245
|
+
};
|
|
246
|
+
channelRef.current = channel;
|
|
247
|
+
}
|
|
248
|
+
catch (_a) {
|
|
249
|
+
channel = null;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const handleStorage = (event) => {
|
|
253
|
+
if (!channel && event.key === `${channelKey}:signal`)
|
|
254
|
+
load();
|
|
255
|
+
};
|
|
256
|
+
if (typeof window !== 'undefined')
|
|
257
|
+
window.addEventListener('storage', handleStorage);
|
|
258
|
+
return () => {
|
|
259
|
+
mountedRef.current = false;
|
|
260
|
+
loadSequenceRef.current += 1;
|
|
261
|
+
if (typeof window !== 'undefined')
|
|
262
|
+
window.removeEventListener('storage', handleStorage);
|
|
263
|
+
try {
|
|
264
|
+
channel === null || channel === void 0 ? void 0 : channel.close();
|
|
265
|
+
}
|
|
266
|
+
catch (_a) { /* no-op */ }
|
|
267
|
+
channelRef.current = null;
|
|
268
|
+
setPrivacyState(null, null);
|
|
269
|
+
};
|
|
270
|
+
}, [channelKey, load]);
|
|
271
|
+
const save = useCallback(async (selections, channel = 'other') => {
|
|
272
|
+
var _a, _b, _c;
|
|
273
|
+
const activeManifest = manifestRef.current;
|
|
274
|
+
if (!activeManifest || !Array.isArray(activeManifest.purposes))
|
|
275
|
+
return false;
|
|
276
|
+
const decisions = toServerChoices(activeManifest, selections);
|
|
277
|
+
if (!Object.keys(decisions).length)
|
|
278
|
+
return false;
|
|
279
|
+
// The state the person decided on. A grant is never re-based onto a newer server state (another tab may
|
|
280
|
+
// have refused in between); a refusal is the safe direction and may be.
|
|
281
|
+
const basisSeq = Number.isInteger((_a = choicesRef.current) === null || _a === void 0 ? void 0 : _a.seq) ? choicesRef.current.seq : 0;
|
|
282
|
+
const hasGrantDecision = Object.values(decisions).includes('granted');
|
|
283
|
+
Object.entries(decisions).forEach(([purposeId, state]) => {
|
|
284
|
+
if (state === 'refused')
|
|
285
|
+
locallyDisabledRef.current.add(purposeId);
|
|
286
|
+
});
|
|
287
|
+
pendingRef.current = decisions;
|
|
288
|
+
// A refresh that started before this write may still be in flight with an older (possibly granted) state:
|
|
289
|
+
// invalidate it so it cannot be applied after the user's later decision.
|
|
290
|
+
loadSequenceRef.current += 1;
|
|
291
|
+
if (mountedRef.current) {
|
|
292
|
+
setPendingChoices(decisions);
|
|
293
|
+
setPendingFailed(false);
|
|
294
|
+
setSaveState('saving');
|
|
295
|
+
setError(null);
|
|
296
|
+
setBannerDismissed(false);
|
|
297
|
+
}
|
|
298
|
+
// Withdrawals stop services synchronously, before CSRF priming or network work.
|
|
299
|
+
setRegistry(activeManifest, choicesRef.current);
|
|
300
|
+
const execute = async () => {
|
|
301
|
+
const freshSource = await resolvedApi.getChoices();
|
|
302
|
+
if (!Number.isInteger(freshSource === null || freshSource === void 0 ? void 0 : freshSource.seq) || freshSource.seq < 0)
|
|
303
|
+
throw new Error('privacy_state_invalid');
|
|
304
|
+
const latestManifest = manifestRef.current;
|
|
305
|
+
if (!latestManifest)
|
|
306
|
+
throw new Error('privacy_manifest_unavailable');
|
|
307
|
+
const freshChoices = normalizePrivacyChoices(latestManifest, freshSource);
|
|
308
|
+
if (hasGrantDecision && freshChoices.seq !== basisSeq) {
|
|
309
|
+
const staleError = new Error('stale');
|
|
310
|
+
staleError.response = { data: { code: 'stale', state: freshSource } };
|
|
311
|
+
throw staleError;
|
|
312
|
+
}
|
|
313
|
+
choicesRef.current = freshChoices;
|
|
314
|
+
if (mountedRef.current)
|
|
315
|
+
setServerChoices(freshChoices);
|
|
316
|
+
setRegistry(latestManifest, freshChoices);
|
|
317
|
+
await resolvedApi.primeCsrf();
|
|
318
|
+
const body = {
|
|
319
|
+
request_id: requestId(),
|
|
320
|
+
expected_seq: freshChoices.seq,
|
|
321
|
+
notice_version: latestManifest.notice.version,
|
|
322
|
+
config_version: latestManifest.config_version,
|
|
323
|
+
locale: localeForManifest(latestManifest, i18n.language),
|
|
324
|
+
channel,
|
|
325
|
+
choices: decisions,
|
|
326
|
+
};
|
|
327
|
+
const returned = await resolvedApi.saveChoices(body);
|
|
328
|
+
const confirmedSource = await resolvedApi.getChoices();
|
|
329
|
+
const saved = normalizePrivacyChoices(latestManifest, confirmedSource);
|
|
330
|
+
const confirmedAll = Object.entries(decisions).every(([purposeId, choice]) => { var _a, _b; return (saved.receipt_state === 'present' && ((_b = (_a = saved.choices) === null || _a === void 0 ? void 0 : _a[purposeId]) === null || _b === void 0 ? void 0 : _b.state) === choice); });
|
|
331
|
+
if (!confirmedAll)
|
|
332
|
+
throw new Error('privacy_choice_not_persisted');
|
|
333
|
+
// The POST response confirms the server handled the request; the follow-up
|
|
334
|
+
// read also proves the host receipt is usable in this browser context.
|
|
335
|
+
if (!returned || returned.receipt_state !== 'present')
|
|
336
|
+
throw new Error('privacy_receipt_missing');
|
|
337
|
+
Object.entries(decisions).forEach(([purposeId, choice]) => {
|
|
338
|
+
if (choice === 'refused' || choice === 'granted')
|
|
339
|
+
locallyDisabledRef.current.delete(purposeId);
|
|
340
|
+
});
|
|
341
|
+
pendingRef.current = null;
|
|
342
|
+
forceDecisionRef.current = false;
|
|
343
|
+
choicesRef.current = saved;
|
|
344
|
+
loadSequenceRef.current += 1; // any refresh begun during the write read pre-write state
|
|
345
|
+
if (mountedRef.current) {
|
|
346
|
+
setServerChoices(saved);
|
|
347
|
+
setPendingChoices(null);
|
|
348
|
+
setPendingFailed(false);
|
|
349
|
+
setSaveState('saved');
|
|
350
|
+
setError(null);
|
|
351
|
+
}
|
|
352
|
+
setRegistry(latestManifest, saved);
|
|
353
|
+
broadcastChanged();
|
|
354
|
+
return true;
|
|
355
|
+
};
|
|
356
|
+
const runLocalSerial = () => {
|
|
357
|
+
const task = localWriteRef.current.then(async () => {
|
|
358
|
+
const locks = typeof navigator !== 'undefined' ? navigator.locks : null;
|
|
359
|
+
const lockName = `${channelKey}:write`;
|
|
360
|
+
if (locks === null || locks === void 0 ? void 0 : locks.request)
|
|
361
|
+
return locks.request(lockName, { mode: 'exclusive' }, execute);
|
|
362
|
+
return execute();
|
|
363
|
+
});
|
|
364
|
+
localWriteRef.current = task.catch(() => { });
|
|
365
|
+
return task;
|
|
366
|
+
};
|
|
367
|
+
try {
|
|
368
|
+
await runLocalSerial();
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
catch (saveError) {
|
|
372
|
+
const code = errorCode(saveError);
|
|
373
|
+
if (code === 'stale' && ((_c = (_b = saveError === null || saveError === void 0 ? void 0 : saveError.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state)) {
|
|
374
|
+
const fresh = normalizePrivacyChoices(manifestRef.current, saveError.response.data.state);
|
|
375
|
+
choicesRef.current = fresh;
|
|
376
|
+
if (mountedRef.current)
|
|
377
|
+
setServerChoices(fresh);
|
|
378
|
+
setRegistry(manifestRef.current, fresh);
|
|
379
|
+
}
|
|
380
|
+
else if (code === 'stale_notice' || code === 'stale_config') {
|
|
381
|
+
// Changed notice/configuration requires a fresh manifest and a new human decision.
|
|
382
|
+
forceDecisionRef.current = true;
|
|
383
|
+
setRegistry(manifestRef.current, choicesRef.current);
|
|
384
|
+
pendingRef.current = null;
|
|
385
|
+
if (mountedRef.current)
|
|
386
|
+
setPendingChoices(null);
|
|
387
|
+
await load({ forceUnsetChoices: true });
|
|
388
|
+
}
|
|
389
|
+
if (mountedRef.current) {
|
|
390
|
+
setPendingFailed(true);
|
|
391
|
+
setSaveState('error');
|
|
392
|
+
setError(saveError);
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
}, [broadcastChanged, channelKey, i18n.language, load, resolvedApi, setRegistry]);
|
|
397
|
+
// A grant that expires while the page stays open must stop optional processing at its expiry:
|
|
398
|
+
// schedule one re-read at the earliest `expires_at`; the server answers "unset" and the registry follows
|
|
399
|
+
// (a failed re-read also fails closed, because load errors clear the registry).
|
|
400
|
+
useEffect(() => {
|
|
401
|
+
const expiries = Object.values((serverChoices === null || serverChoices === void 0 ? void 0 : serverChoices.choices) || {})
|
|
402
|
+
.filter((choice) => (choice === null || choice === void 0 ? void 0 : choice.state) === 'granted' && choice.expires_at)
|
|
403
|
+
.map((choice) => Date.parse(choice.expires_at))
|
|
404
|
+
.filter(Number.isFinite);
|
|
405
|
+
if (!expiries.length)
|
|
406
|
+
return undefined;
|
|
407
|
+
const delay = Math.min(Math.max(Math.min(...expiries) - Date.now(), 0) + 250, 2 ** 31 - 1);
|
|
408
|
+
const timer = setTimeout(() => { load(); }, delay);
|
|
409
|
+
return () => clearTimeout(timer);
|
|
410
|
+
}, [serverChoices, load]);
|
|
411
|
+
const retry = useCallback(() => {
|
|
412
|
+
if (pendingRef.current && manifestRef.current)
|
|
413
|
+
return save(pendingRef.current, 'settings');
|
|
414
|
+
return load();
|
|
415
|
+
}, [load, save]);
|
|
416
|
+
const optionalPurposes = useMemo(() => { var _a; return ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.purposes) === null || _a === void 0 ? void 0 : _a.filter((purpose) => !purpose.required)) || []; }, [manifest]);
|
|
417
|
+
const choices = useMemo(() => effectiveChoices(serverChoices, pendingChoices), [serverChoices, pendingChoices]);
|
|
418
|
+
const needsDecision = status === 'ready' && optionalPurposes.some((purpose) => { var _a, _b; return ((_b = (_a = choices === null || choices === void 0 ? void 0 : choices.choices) === null || _a === void 0 ? void 0 : _a[purpose.id]) === null || _b === void 0 ? void 0 : _b.state) === 'unset'; });
|
|
419
|
+
const hasPendingDecision = Boolean(pendingRef.current) && (saveState === 'saving' || pendingFailed);
|
|
420
|
+
const bannerVisible = status === 'ready' && optionalPurposes.length > 0
|
|
421
|
+
&& (needsDecision || hasPendingDecision) && !bannerDismissed;
|
|
422
|
+
const hasGrant = useCallback((purposeId, serviceId) => {
|
|
423
|
+
var _a, _b, _c, _d, _e, _f;
|
|
424
|
+
if (status !== 'ready')
|
|
425
|
+
return false;
|
|
426
|
+
if (locallyDisabledRef.current.has(purposeId))
|
|
427
|
+
return false;
|
|
428
|
+
const purpose = (_b = (_a = manifestRef.current) === null || _a === void 0 ? void 0 : _a.purposes) === null || _b === void 0 ? void 0 : _b.find((item) => item.id === purposeId);
|
|
429
|
+
if (!purpose || purpose.required || ((_e = (_d = (_c = choicesRef.current) === null || _c === void 0 ? void 0 : _c.choices) === null || _d === void 0 ? void 0 : _d[purposeId]) === null || _e === void 0 ? void 0 : _e.state) !== 'granted')
|
|
430
|
+
return false;
|
|
431
|
+
return serviceId === undefined || ((_f = purpose.services) === null || _f === void 0 ? void 0 : _f.some((service) => service.id === serviceId)) === true;
|
|
432
|
+
}, [status]);
|
|
433
|
+
const acceptAll = useCallback((channel = 'banner') => {
|
|
434
|
+
const selections = Object.fromEntries(optionalPurposes.map((purpose) => [purpose.id, 'granted']));
|
|
435
|
+
return save(selections, channel);
|
|
436
|
+
}, [optionalPurposes, save]);
|
|
437
|
+
const necessaryOnly = useCallback((channel = 'banner') => {
|
|
438
|
+
const selections = Object.fromEntries(optionalPurposes.map((purpose) => [purpose.id, 'refused']));
|
|
439
|
+
return save(selections, channel);
|
|
440
|
+
}, [optionalPurposes, save]);
|
|
441
|
+
const openSettings = useCallback(() => setSettingsOpen(true), []);
|
|
442
|
+
const closeSettings = useCallback(() => setSettingsOpen(false), []);
|
|
443
|
+
const dismissBanner = useCallback(() => setBannerDismissed(true), []);
|
|
444
|
+
const value = useMemo(() => ({
|
|
445
|
+
status,
|
|
446
|
+
manifest,
|
|
447
|
+
choices,
|
|
448
|
+
needsDecision,
|
|
449
|
+
bannerVisible,
|
|
450
|
+
saveState,
|
|
451
|
+
error,
|
|
452
|
+
hasGrant,
|
|
453
|
+
save,
|
|
454
|
+
acceptAll,
|
|
455
|
+
necessaryOnly,
|
|
456
|
+
retry,
|
|
457
|
+
settingsOpen,
|
|
458
|
+
openSettings,
|
|
459
|
+
closeSettings,
|
|
460
|
+
dismissBanner,
|
|
461
|
+
}), [
|
|
462
|
+
status, manifest, choices, needsDecision, bannerVisible, saveState, error, hasGrant,
|
|
463
|
+
save, acceptAll, necessaryOnly, retry, settingsOpen, openSettings, closeSettings, dismissBanner,
|
|
464
|
+
]);
|
|
465
|
+
return (_jsxs(PrivacyContext.Provider, { value: value, children: [children, _jsx(PrivacySettingsDialog, {})] }));
|
|
466
|
+
}
|
|
467
|
+
export function usePrivacy() {
|
|
468
|
+
return useContext(PrivacyContext);
|
|
469
|
+
}
|
|
470
|
+
export { localeForManifest };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { Accordion, AccordionDetails, AccordionSummary, Alert, Box, Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Stack, Typography, } from '@mui/material';
|
|
4
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { usePrivacy } from './PrivacyProvider';
|
|
7
|
+
import { PrivacyNoticeLink } from './PrivacyNoticeLink';
|
|
8
|
+
function localized(value, language) {
|
|
9
|
+
if (!value || typeof value !== 'object')
|
|
10
|
+
return '';
|
|
11
|
+
const normalized = String(language || '').replace('_', '-').toLowerCase();
|
|
12
|
+
const exact = Object.keys(value).find((key) => key.toLowerCase() === normalized);
|
|
13
|
+
if (exact)
|
|
14
|
+
return value[exact];
|
|
15
|
+
const base = normalized.split('-')[0];
|
|
16
|
+
const match = Object.keys(value).find((key) => key.toLowerCase() === base)
|
|
17
|
+
|| Object.keys(value).find((key) => key.toLowerCase().split('-')[0] === base);
|
|
18
|
+
return value[match || Object.keys(value)[0]] || '';
|
|
19
|
+
}
|
|
20
|
+
function storageText(storage) {
|
|
21
|
+
if (!storage || typeof storage !== 'object')
|
|
22
|
+
return '';
|
|
23
|
+
return [storage.kind, storage.name, storage.scope, storage.lifetime].filter(Boolean).join(' · ');
|
|
24
|
+
}
|
|
25
|
+
function ServiceDetails({ purpose, locale, t }) {
|
|
26
|
+
const services = purpose.services || [];
|
|
27
|
+
const justification = typeof purpose.justification === 'string'
|
|
28
|
+
? purpose.justification
|
|
29
|
+
: localized(purpose.justification, locale);
|
|
30
|
+
return (_jsxs(Stack, { spacing: 1, children: [justification && _jsx(Typography, { variant: "body2", children: justification }), services.map((service) => { var _a, _b, _c, _d; return (_jsxs(Box, { children: [service.provider && (_jsx(Typography, { variant: "body2", children: t('Privacy.PROVIDER_STORAGE_DETAIL', { provider: service.provider }) })), ((_a = service.browser_storage) === null || _a === void 0 ? void 0 : _a.length) > 0 && (_jsx(Box, { component: "ul", sx: { my: 0.5, pl: 3 }, children: service.browser_storage.map((storage, index) => (_jsx("li", { children: _jsx(Typography, { variant: "body2", children: storageText(storage) }) }, `${service.id}-storage-${index}`))) })), service.server_retention && (_jsx(Typography, { variant: "body2", children: t('Privacy.SERVER_RETENTION', { retention: service.server_retention }) })), ((_b = service.data_categories) === null || _b === void 0 ? void 0 : _b.length) > 0 && (_jsx(Typography, { variant: "body2", children: t('Privacy.DATA_CATEGORIES', { values: service.data_categories.join(', ') }) })), ((_c = service.recipients) === null || _c === void 0 ? void 0 : _c.length) > 0 && (_jsx(Typography, { variant: "body2", children: t('Privacy.RECIPIENTS', { values: service.recipients.join(', ') }) })), ((_d = service.transfers) === null || _d === void 0 ? void 0 : _d.length) > 0 && (_jsx(Typography, { variant: "body2", children: t('Privacy.TRANSFERS', { values: service.transfers.join(', ') }) }))] }, service.id)); })] }));
|
|
31
|
+
}
|
|
32
|
+
function NecessaryStorage({ storage, t }) {
|
|
33
|
+
if (!Array.isArray(storage) || storage.length === 0)
|
|
34
|
+
return null;
|
|
35
|
+
return (_jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", children: t('Privacy.NECESSARY_STORAGE') }), _jsx(Box, { component: "ul", sx: { my: 0.5, pl: 3 }, children: storage.map((item, index) => (_jsx("li", { children: _jsx(Typography, { variant: "body2", children: storageText(item) }) }, `necessary-storage-${index}`))) })] }));
|
|
36
|
+
}
|
|
37
|
+
export function PrivacySettingsPanel({ onClose }) {
|
|
38
|
+
var _a;
|
|
39
|
+
const privacy = usePrivacy();
|
|
40
|
+
const { t, i18n } = useTranslation();
|
|
41
|
+
const [draft, setDraft] = useState({});
|
|
42
|
+
const [saving, setSaving] = useState(false);
|
|
43
|
+
const manifest = privacy === null || privacy === void 0 ? void 0 : privacy.manifest;
|
|
44
|
+
const purposes = useMemo(() => { var _a; return ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.purposes) === null || _a === void 0 ? void 0 : _a.filter((purpose) => !purpose.required)) || []; }, [manifest]);
|
|
45
|
+
const required = useMemo(() => { var _a; return ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.purposes) === null || _a === void 0 ? void 0 : _a.filter((purpose) => purpose.required)) || []; }, [manifest]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if ((privacy === null || privacy === void 0 ? void 0 : privacy.status) !== 'ready')
|
|
48
|
+
return;
|
|
49
|
+
const nextDraft = {};
|
|
50
|
+
purposes.forEach((purpose) => {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
nextDraft[purpose.id] = ((_c = (_b = (_a = privacy.choices) === null || _a === void 0 ? void 0 : _a.choices) === null || _b === void 0 ? void 0 : _b[purpose.id]) === null || _c === void 0 ? void 0 : _c.state) === 'granted';
|
|
53
|
+
});
|
|
54
|
+
setDraft(nextDraft);
|
|
55
|
+
}, [privacy === null || privacy === void 0 ? void 0 : privacy.status, privacy === null || privacy === void 0 ? void 0 : privacy.choices, purposes]);
|
|
56
|
+
if (!privacy || privacy.status === 'unconfigured')
|
|
57
|
+
return null;
|
|
58
|
+
if (privacy.status === 'loading') {
|
|
59
|
+
return _jsx(Typography, { role: "status", children: t('Privacy.LOADING') });
|
|
60
|
+
}
|
|
61
|
+
if (privacy.status === 'error' || !manifest) {
|
|
62
|
+
return (_jsxs(Stack, { spacing: 1.5, children: [_jsx(Alert, { severity: "error", role: "alert", children: t('Privacy.UNAVAILABLE') }), _jsx(Button, { type: "button", variant: "outlined", onClick: privacy.retry, children: t('Privacy.RETRY') })] }));
|
|
63
|
+
}
|
|
64
|
+
const locale = i18n.language;
|
|
65
|
+
const hasOtherGrant = purposes.some((purpose) => { var _a, _b, _c; return ((_c = (_b = (_a = privacy.choices) === null || _a === void 0 ? void 0 : _a.choices) === null || _b === void 0 ? void 0 : _b[purpose.id]) === null || _c === void 0 ? void 0 : _c.state) === 'granted'; });
|
|
66
|
+
const onlyNecessaryActive = purposes.length > 0 && purposes.every((purpose) => { var _a, _b, _c; return ((_c = (_b = (_a = privacy.choices) === null || _a === void 0 ? void 0 : _a.choices) === null || _b === void 0 ? void 0 : _b[purpose.id]) === null || _c === void 0 ? void 0 : _c.state) === 'refused'; });
|
|
67
|
+
const setPurpose = (purposeId, checked) => setDraft((previous) => (Object.assign(Object.assign({}, previous), { [purposeId]: checked })));
|
|
68
|
+
const save = async () => {
|
|
69
|
+
setSaving(true);
|
|
70
|
+
try {
|
|
71
|
+
await privacy.save(Object.fromEntries(purposes.map((purpose) => [
|
|
72
|
+
purpose.id,
|
|
73
|
+
draft[purpose.id] ? 'granted' : 'refused',
|
|
74
|
+
])), 'settings');
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
setSaving(false);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return (_jsxs(Stack, { spacing: 2, children: [_jsx(Typography, { variant: "body2", children: t('Privacy.CHANGE_ANYTIME') }), ((_a = manifest.controller) === null || _a === void 0 ? void 0 : _a.name) && (_jsxs(Typography, { variant: "body2", children: [_jsxs("strong", { children: [t('Privacy.CONTROLLER'), ":"] }), " ", manifest.controller.name, manifest.controller.contact ? ` · ${manifest.controller.contact}` : ''] })), purposes.length === 0 && _jsx(Typography, { children: t('Privacy.NO_OPTIONAL') }), required.length > 0 && (_jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle1", children: t('Privacy.ALWAYS_ACTIVE') }), _jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Privacy.REQUIRED_INFORMATION') }), _jsx(Stack, { spacing: 1, sx: { mt: 1 }, children: required.map((purpose) => (_jsxs(Accordion, { disableGutters: true, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ExpandMoreIcon, {}), children: _jsx(Typography, { fontWeight: 600, children: localized(purpose.label, locale) }) }), _jsxs(AccordionDetails, { children: [localized(purpose.summary, locale) && _jsx(Typography, { variant: "body2", sx: { mb: 1 }, children: localized(purpose.summary, locale) }), _jsx(ServiceDetails, { purpose: purpose, locale: locale, t: t })] })] }, purpose.id))) })] })), purposes.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Stack, { spacing: 1, children: purposes.map((purpose) => (_jsxs(Box, { sx: { borderBottom: 1, borderColor: 'divider', pb: 1 }, children: [_jsx(FormControlLabel, { control: (_jsx(Checkbox, { checked: Boolean(draft[purpose.id]), onChange: (event) => setPurpose(purpose.id, event.target.checked), disabled: saving || privacy.saveState === 'saving' })), label: localized(purpose.label, locale) }), localized(purpose.summary, locale) && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { ml: 4 }, children: localized(purpose.summary, locale) })), _jsxs(Accordion, { disableGutters: true, elevation: 0, sx: { mt: 0.5 }, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ExpandMoreIcon, {}), children: _jsx(Typography, { variant: "body2", children: t('Privacy.DETAILS') }) }), _jsx(AccordionDetails, { children: _jsx(ServiceDetails, { purpose: purpose, locale: locale, t: t }) })] })] }, purpose.id))) }), privacy.saveState === 'error' && (_jsx(Alert, { severity: "error", role: "alert", children: t(hasOtherGrant ? 'Privacy.SAVE_ERROR_WITH_GRANTS' : 'Privacy.SAVE_ERROR') })), privacy.saveState === 'saved' && (_jsx(Alert, { severity: "success", role: "status", children: onlyNecessaryActive ? t('Privacy.NECESSARY_ONLY_ACTIVE') : t('Privacy.SAVED') })), _jsxs(Stack, { direction: "row", spacing: 1, flexWrap: "wrap", children: [_jsx(Button, { type: "button", variant: "contained", disabled: saving || privacy.saveState === 'saving', onClick: save, children: saving || privacy.saveState === 'saving' ? t('Privacy.SAVING') : t('Privacy.SAVE') }), privacy.saveState === 'error' && (_jsx(Button, { type: "button", variant: "outlined", disabled: saving, onClick: privacy.retry, children: t('Privacy.RETRY') }))] })] })), _jsx(NecessaryStorage, { storage: manifest.necessary_storage, t: t }), _jsxs(Box, { children: [_jsxs(Typography, { variant: "body2", component: "span", children: [t('Privacy.NOTICE_EXPLANATION'), " "] }), _jsx(PrivacyNoticeLink, {})] }), onClose && _jsx(Button, { type: "button", onClick: onClose, children: t('Privacy.CLOSE') })] }));
|
|
81
|
+
}
|
|
82
|
+
export function PrivacySettingsDialog() {
|
|
83
|
+
const privacy = usePrivacy();
|
|
84
|
+
const { t } = useTranslation();
|
|
85
|
+
if (!privacy || privacy.status === 'unconfigured' || !privacy.settingsOpen)
|
|
86
|
+
return null;
|
|
87
|
+
return (_jsxs(Dialog, { open: true, onClose: privacy.closeSettings, "aria-labelledby": "privacy-settings-title", fullWidth: true, maxWidth: "sm", children: [_jsx(DialogTitle, { id: "privacy-settings-title", children: t('Privacy.SETTINGS_TITLE') }), _jsx(DialogContent, { dividers: true, children: _jsx(PrivacySettingsPanel, {}) }), _jsx(DialogActions, { children: _jsx(Button, { type: "button", onClick: privacy.closeSettings, children: t('Privacy.CLOSE') }) })] }));
|
|
88
|
+
}
|
|
89
|
+
export default PrivacySettingsDialog;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { Link } from '@mui/material';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { usePrivacy } from './PrivacyProvider';
|
|
17
|
+
export function PrivacySettingsLink(_a) {
|
|
18
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
19
|
+
const privacy = usePrivacy();
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
if (!privacy || privacy.status === 'unconfigured')
|
|
22
|
+
return null;
|
|
23
|
+
return (_jsx(Link, Object.assign({ component: "button", type: "button", onClick: privacy.openSettings }, props, { children: children || t('Privacy.SETTINGS') })));
|
|
24
|
+
}
|
|
25
|
+
export default PrivacySettingsLink;
|