@shellui/core 0.3.1 → 0.4.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/package.json +2 -2
- package/src/app.tsx +11 -1
- package/src/components/ui/dialog.tsx +26 -6
- package/src/components/ui/sonner.tsx +9 -5
- package/src/features/admin/AdminView.tsx +1 -20
- package/src/features/auth/AuthProvider.tsx +68 -13
- package/src/features/auth/backends/shellui.ts +8 -1
- package/src/features/auth/components/AccessPendingView.tsx +112 -0
- package/src/features/auth/components/LoginView.tsx +17 -0
- package/src/features/auth/components/OAuthCallbackView.tsx +211 -48
- package/src/features/auth/hooks/useAuth.tsx +8 -1
- package/src/features/auth/utils/authRequestError.spec.ts +52 -0
- package/src/features/auth/utils/authRequestError.ts +45 -0
- package/src/features/auth/utils/index.ts +7 -0
- package/src/features/auth/utils/isTokenAutoRefreshDisabled.spec.ts +71 -0
- package/src/features/auth/utils/isTokenAutoRefreshDisabled.ts +18 -0
- package/src/features/config/types.ts +46 -0
- package/src/features/layouts/AppLayout.tsx +3 -3
- package/src/features/layouts/OverlayShell.tsx +10 -6
- package/src/features/settings/SettingsIcons.tsx +35 -0
- package/src/features/settings/SettingsProvider.tsx +69 -4
- package/src/features/settings/SettingsRoutes.tsx +14 -6
- package/src/features/settings/SettingsView.tsx +11 -5
- package/src/features/settings/components/Advanced.tsx +117 -44
- package/src/features/settings/components/Develop.tsx +38 -0
- package/src/features/settings/components/Storage.tsx +138 -0
- package/src/features/settings/components/develop/StoragePickerTestButtons.tsx +148 -0
- package/src/features/settings/components/develop/UploadToastTestButton.tsx +29 -0
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +54 -0
- package/src/features/settings/utils/buildSettingsForPropagation.ts +34 -0
- package/src/features/settings/utils/toSettingsUser.spec.ts +4 -0
- package/src/features/settings/utils/toSettingsUser.ts +2 -0
- package/src/features/storage/StorageBridge.tsx +50 -0
- package/src/features/storage/StoragePickerContext.tsx +214 -0
- package/src/features/storage/api.spec.ts +303 -0
- package/src/features/storage/api.ts +414 -0
- package/src/features/storage/handleRequest.spec.ts +88 -0
- package/src/features/storage/handleRequest.ts +53 -0
- package/src/features/storage/quota.spec.ts +151 -0
- package/src/features/storage/quota.ts +104 -0
- package/src/features/storage/uploads/UploadToastCard.tsx +442 -0
- package/src/features/storage/uploads/UploadToaster.tsx +41 -0
- package/src/features/storage/uploads/handleTrackedUpload.spec.ts +170 -0
- package/src/features/storage/uploads/handleTrackedUpload.ts +97 -0
- package/src/features/storage/uploads/types.ts +24 -0
- package/src/features/storage/uploads/uploadQueue.spec.ts +118 -0
- package/src/features/storage/uploads/uploadQueue.ts +349 -0
- package/src/features/storage/uploads/useUploadQueue.ts +30 -0
- package/src/i18n/translations/en/common.json +33 -0
- package/src/i18n/translations/en/settings.json +47 -4
- package/src/i18n/translations/fr/common.json +33 -0
- package/src/i18n/translations/fr/settings.json +47 -4
- package/src/index.css +2 -1
- package/src/index.ts +2 -0
- package/src/lib/z-index.ts +9 -3
- package/src/service-worker/register.ts +4 -12
|
@@ -5,20 +5,20 @@ import { shellui } from '@shellui/sdk';
|
|
|
5
5
|
import type { NavigationItem } from '../config/types';
|
|
6
6
|
import { Dialog, DialogContent, DialogTitle, DialogDescription } from '../../components/ui/dialog';
|
|
7
7
|
import { Drawer, DrawerContent } from '../../components/ui/drawer';
|
|
8
|
-
import { Toaster } from '../../components/ui/sonner';
|
|
9
8
|
import { ContentView } from '../../components/ContentView';
|
|
10
9
|
import { useModal } from '../modal/ModalContext';
|
|
11
10
|
import { useDrawer } from '../drawer/DrawerContext';
|
|
11
|
+
import { useStoragePicker } from '../storage/StoragePickerContext';
|
|
12
12
|
import { useNavigationItems } from '../../routes/hooks/useNavigationItems';
|
|
13
13
|
import { useConfig } from '../config/useConfig';
|
|
14
|
-
import {
|
|
14
|
+
import { resolveLocalizedString } from './utils';
|
|
15
15
|
import { resolveSdkNavigatePath } from './resolveSdkNavigatePath';
|
|
16
16
|
|
|
17
17
|
interface OverlayShellProps {
|
|
18
18
|
children: ReactNode;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/** Renders modal
|
|
21
|
+
/** Renders modal and drawer overlays and handles SHELLUI_OPEN_MODAL / SHELLUI_NAVIGATE. */
|
|
22
22
|
export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
23
23
|
const location = useLocation();
|
|
24
24
|
const navigate = useNavigate();
|
|
@@ -32,6 +32,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
32
32
|
size: drawerSize,
|
|
33
33
|
closeDrawer,
|
|
34
34
|
} = useDrawer();
|
|
35
|
+
const { isOpen: isPickerOpen, closePicker } = useStoragePicker();
|
|
35
36
|
const { t, i18n } = useTranslation('common');
|
|
36
37
|
const currentLanguage = i18n.language || 'en';
|
|
37
38
|
|
|
@@ -42,9 +43,10 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
42
43
|
if (locationKeyRef.current !== currentKey) {
|
|
43
44
|
closeModal();
|
|
44
45
|
closeDrawer();
|
|
46
|
+
closePicker();
|
|
45
47
|
locationKeyRef.current = currentKey;
|
|
46
48
|
}
|
|
47
|
-
}, [location.pathname, location.search, location.hash, closeModal, closeDrawer]);
|
|
49
|
+
}, [location.pathname, location.search, location.hash, closeModal, closeDrawer, closePicker]);
|
|
48
50
|
|
|
49
51
|
useEffect(() => {
|
|
50
52
|
const cleanup = shellui.addMessageListener('SHELLUI_OPEN_MODAL', () => {
|
|
@@ -81,7 +83,10 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
81
83
|
{children}
|
|
82
84
|
<Dialog
|
|
83
85
|
open={isOpen}
|
|
84
|
-
onOpenChange={(open) =>
|
|
86
|
+
onOpenChange={(open) => {
|
|
87
|
+
if (!open && isPickerOpen) return;
|
|
88
|
+
if (!open) closeModal();
|
|
89
|
+
}}
|
|
85
90
|
>
|
|
86
91
|
<DialogContent className="max-w-4xl w-full h-[80vh] max-h-[680px] flex flex-col p-0 overflow-hidden">
|
|
87
92
|
{modalUrl ? (
|
|
@@ -164,7 +169,6 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
164
169
|
)}
|
|
165
170
|
</DrawerContent>
|
|
166
171
|
</Drawer>
|
|
167
|
-
<Toaster />
|
|
168
172
|
</>
|
|
169
173
|
);
|
|
170
174
|
};
|
|
@@ -291,6 +291,23 @@ export const ChevronLeftIcon = () => (
|
|
|
291
291
|
</svg>
|
|
292
292
|
);
|
|
293
293
|
|
|
294
|
+
export const ChevronDownIcon = ({ className }: { className?: string }) => (
|
|
295
|
+
<svg
|
|
296
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
297
|
+
width="16"
|
|
298
|
+
height="16"
|
|
299
|
+
viewBox="0 0 24 24"
|
|
300
|
+
fill="none"
|
|
301
|
+
stroke="currentColor"
|
|
302
|
+
strokeWidth="2"
|
|
303
|
+
strokeLinecap="round"
|
|
304
|
+
strokeLinejoin="round"
|
|
305
|
+
className={className}
|
|
306
|
+
>
|
|
307
|
+
<polyline points="6 9 12 15 18 9" />
|
|
308
|
+
</svg>
|
|
309
|
+
);
|
|
310
|
+
|
|
294
311
|
export const ShieldIcon = () => (
|
|
295
312
|
<svg
|
|
296
313
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -307,6 +324,24 @@ export const ShieldIcon = () => (
|
|
|
307
324
|
</svg>
|
|
308
325
|
);
|
|
309
326
|
|
|
327
|
+
export const AlertTriangleIcon = () => (
|
|
328
|
+
<svg
|
|
329
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
330
|
+
width="16"
|
|
331
|
+
height="16"
|
|
332
|
+
viewBox="0 0 24 24"
|
|
333
|
+
fill="none"
|
|
334
|
+
stroke="currentColor"
|
|
335
|
+
strokeWidth="2"
|
|
336
|
+
strokeLinecap="round"
|
|
337
|
+
strokeLinejoin="round"
|
|
338
|
+
>
|
|
339
|
+
<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" />
|
|
340
|
+
<path d="M12 9v4" />
|
|
341
|
+
<path d="M12 17h.01" />
|
|
342
|
+
</svg>
|
|
343
|
+
);
|
|
344
|
+
|
|
310
345
|
export const HardDriveIcon = () => (
|
|
311
346
|
<svg
|
|
312
347
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -90,6 +90,7 @@ const defaultAppearance: Appearance = {
|
|
|
90
90
|
const defaultSettings: Settings = {
|
|
91
91
|
developerFeatures: {
|
|
92
92
|
enabled: false,
|
|
93
|
+
disableTokenAutoRefresh: false,
|
|
93
94
|
},
|
|
94
95
|
errorReporting: {
|
|
95
96
|
enabled: true,
|
|
@@ -153,6 +154,13 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
153
154
|
...parsed.logging?.namespaces,
|
|
154
155
|
},
|
|
155
156
|
},
|
|
157
|
+
developerFeatures: {
|
|
158
|
+
enabled:
|
|
159
|
+
parsed.developerFeatures?.enabled ?? defaultSettings.developerFeatures.enabled,
|
|
160
|
+
disableTokenAutoRefresh:
|
|
161
|
+
parsed.developerFeatures?.disableTokenAutoRefresh ??
|
|
162
|
+
defaultSettings.developerFeatures.disableTokenAutoRefresh,
|
|
163
|
+
},
|
|
156
164
|
appearance: {
|
|
157
165
|
...defaultAppearance,
|
|
158
166
|
...parsed.appearance,
|
|
@@ -211,6 +219,22 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
211
219
|
if (isAdminFrame(frameSrc, config)) {
|
|
212
220
|
return true;
|
|
213
221
|
}
|
|
222
|
+
// Trust admin-panel iframe apps (navigation + storage files explorer / viewer modals).
|
|
223
|
+
const adminNavItems = config?.administration?.navigation ?? [];
|
|
224
|
+
if (
|
|
225
|
+
adminNavItems.some(
|
|
226
|
+
(item) =>
|
|
227
|
+
item.openIn !== 'external' &&
|
|
228
|
+
Boolean(item.url?.trim()) &&
|
|
229
|
+
isFrameForNavigationItem(frameSrc, item.url),
|
|
230
|
+
)
|
|
231
|
+
) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
const filesUrl = config?.storage?.filesUrl?.trim();
|
|
235
|
+
if (filesUrl && isFrameForNavigationItem(frameSrc, filesUrl)) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
214
238
|
return navigationItems.some(
|
|
215
239
|
(item) => item.safeForAuthToken !== false && isFrameForNavigationItem(frameSrc, item.url),
|
|
216
240
|
);
|
|
@@ -218,17 +242,21 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
218
242
|
[config, navigationItems],
|
|
219
243
|
);
|
|
220
244
|
|
|
245
|
+
const accessTokenRef = useRef<string | null>(session?.accessToken ?? null);
|
|
246
|
+
accessTokenRef.current = session?.accessToken ?? null;
|
|
247
|
+
|
|
221
248
|
const propagateSettingsToIframes = useCallback(
|
|
222
249
|
(baseSettings: Settings) => {
|
|
223
250
|
const iframes = shellui.frameRegistry.getAllIframes();
|
|
224
251
|
if (iframes.length === 0) return;
|
|
225
252
|
const lang = baseSettings.language?.code || 'en';
|
|
253
|
+
const accessToken = accessTokenRef.current;
|
|
226
254
|
for (const [uuid, iframe] of iframes) {
|
|
227
255
|
const frameSrc = iframe?.src ?? '';
|
|
228
256
|
const includeAuthAccessToken = isTrustedFrameForAuthToken(frameSrc);
|
|
229
257
|
const settingsToPropagate = buildSettingsForPropagation(baseSettings, config, lang, {
|
|
230
258
|
includeAuthAccessToken,
|
|
231
|
-
accessToken
|
|
259
|
+
accessToken,
|
|
232
260
|
});
|
|
233
261
|
shellui.sendMessage({
|
|
234
262
|
type: 'SHELLUI_SETTINGS',
|
|
@@ -237,7 +265,24 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
237
265
|
});
|
|
238
266
|
}
|
|
239
267
|
},
|
|
240
|
-
[config, isTrustedFrameForAuthToken
|
|
268
|
+
[config, isTrustedFrameForAuthToken],
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const pushSettingsToFrame = useCallback(
|
|
272
|
+
(iframeUuid: string, frameSrc: string, baseSettings: Settings) => {
|
|
273
|
+
const lang = baseSettings.language?.code || 'en';
|
|
274
|
+
const includeAuthAccessToken = isTrustedFrameForAuthToken(frameSrc);
|
|
275
|
+
const settingsToPropagate = buildSettingsForPropagation(baseSettings, config, lang, {
|
|
276
|
+
includeAuthAccessToken,
|
|
277
|
+
accessToken: accessTokenRef.current,
|
|
278
|
+
});
|
|
279
|
+
shellui.sendMessage({
|
|
280
|
+
type: 'SHELLUI_SETTINGS',
|
|
281
|
+
payload: { settings: settingsToPropagate },
|
|
282
|
+
to: [iframeUuid],
|
|
283
|
+
});
|
|
284
|
+
},
|
|
285
|
+
[config, isTrustedFrameForAuthToken],
|
|
241
286
|
);
|
|
242
287
|
|
|
243
288
|
// When the shell rotates the JWT, `authUser` often does not change, so the user-sync effect
|
|
@@ -431,7 +476,7 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
431
476
|
: false;
|
|
432
477
|
const settingsToPropagate = buildSettingsForPropagation(currentSettings, config, lang, {
|
|
433
478
|
includeAuthAccessToken,
|
|
434
|
-
accessToken:
|
|
479
|
+
accessToken: accessTokenRef.current,
|
|
435
480
|
});
|
|
436
481
|
|
|
437
482
|
// Route through the full parent -> child -> ... -> requester path so deep descendants
|
|
@@ -469,12 +514,32 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|
|
469
514
|
},
|
|
470
515
|
);
|
|
471
516
|
|
|
517
|
+
// After an iframe finishes SDK init, re-push current settings (incl. rotated JWT).
|
|
518
|
+
// Covers races where the frame registered after a refresh broadcast, or remounted.
|
|
519
|
+
const cleanupInitialized = shellui.addMessageListener(
|
|
520
|
+
'SHELLUI_INITIALIZED',
|
|
521
|
+
(_message: ShellUIMessage, event: MessageEvent) => {
|
|
522
|
+
if (typeof window === 'undefined' || window.parent !== window) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const source = event.source;
|
|
526
|
+
if (!source) return;
|
|
527
|
+
const match = shellui.frameRegistry
|
|
528
|
+
.getAllIframes()
|
|
529
|
+
.find(([, iframe]) => iframe?.contentWindow === source);
|
|
530
|
+
if (!match) return;
|
|
531
|
+
const [iframeUuid, iframe] = match;
|
|
532
|
+
pushSettingsToFrame(iframeUuid, iframe?.src ?? '', settingsRef.current ?? defaultSettings);
|
|
533
|
+
},
|
|
534
|
+
);
|
|
535
|
+
|
|
472
536
|
return () => {
|
|
473
537
|
cleanup();
|
|
474
538
|
cleanupSettings();
|
|
475
539
|
cleanupSettingsRequested();
|
|
540
|
+
cleanupInitialized();
|
|
476
541
|
};
|
|
477
|
-
}, [config, isTrustedFrameForAuthToken, propagateSettingsToIframes,
|
|
542
|
+
}, [config, isTrustedFrameForAuthToken, propagateSettingsToIframes, pushSettingsToFrame]);
|
|
478
543
|
|
|
479
544
|
useEffect(() => {
|
|
480
545
|
if (
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
FileTextIcon,
|
|
8
8
|
PackageIcon,
|
|
9
9
|
RefreshDoubleIcon,
|
|
10
|
+
HardDriveIcon,
|
|
10
11
|
} from './SettingsIcons';
|
|
11
12
|
import { Appearance } from './components/Appearance';
|
|
12
13
|
import { LanguageAndRegion } from './components/LanguageAndRegion';
|
|
@@ -16,6 +17,7 @@ import { Develop } from './components/Develop';
|
|
|
16
17
|
import { DataPrivacy } from './components/DataPrivacy';
|
|
17
18
|
import { ServiceWorker } from './components/ServiceWorker';
|
|
18
19
|
import { LegalDocumentsPanel } from './components/LegalDocumentsPanel';
|
|
20
|
+
import { Storage } from './components/Storage';
|
|
19
21
|
import { isTauri } from '../../service-worker/register';
|
|
20
22
|
|
|
21
23
|
export const createSettingsRoutes = (t: (key: string) => string) => [
|
|
@@ -31,6 +33,18 @@ export const createSettingsRoutes = (t: (key: string) => string) => [
|
|
|
31
33
|
path: 'language-and-region',
|
|
32
34
|
element: <LanguageAndRegion />,
|
|
33
35
|
},
|
|
36
|
+
{
|
|
37
|
+
name: t('routes.dataPrivacy'),
|
|
38
|
+
icon: ShieldIcon,
|
|
39
|
+
path: 'data-privacy',
|
|
40
|
+
element: <DataPrivacy />,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: t('routes.storage'),
|
|
44
|
+
icon: HardDriveIcon,
|
|
45
|
+
path: 'storage',
|
|
46
|
+
element: <Storage />,
|
|
47
|
+
},
|
|
34
48
|
{
|
|
35
49
|
name: t('routes.updateApp'),
|
|
36
50
|
icon: RefreshDoubleIcon,
|
|
@@ -43,12 +57,6 @@ export const createSettingsRoutes = (t: (key: string) => string) => [
|
|
|
43
57
|
path: 'advanced',
|
|
44
58
|
element: <Advanced />,
|
|
45
59
|
},
|
|
46
|
-
{
|
|
47
|
-
name: t('routes.dataPrivacy'),
|
|
48
|
-
icon: ShieldIcon,
|
|
49
|
-
path: 'data-privacy',
|
|
50
|
-
element: <DataPrivacy />,
|
|
51
|
-
},
|
|
52
60
|
{
|
|
53
61
|
name: t('routes.legalDocuments'),
|
|
54
62
|
icon: FileTextIcon,
|
|
@@ -32,13 +32,14 @@ import type { NavigationItem } from '../config/types';
|
|
|
32
32
|
import { cn } from '../../lib/utils';
|
|
33
33
|
import { useAuth } from '../auth/hooks/useAuth';
|
|
34
34
|
import { getLegalDocuments } from '../legal/legalDocuments';
|
|
35
|
+
import { isStorageSettingsEnabled } from '../storage/quota';
|
|
35
36
|
|
|
36
37
|
export const SettingsView = () => {
|
|
37
38
|
const location = useLocation();
|
|
38
39
|
const navigate = useNavigate();
|
|
39
40
|
const { settings } = useSettings();
|
|
40
41
|
const { config } = useConfig();
|
|
41
|
-
const { user, session, logout } = useAuth();
|
|
42
|
+
const { user, session, logout, isAuthenticated } = useAuth();
|
|
42
43
|
const { t, i18n } = useTranslation('settings');
|
|
43
44
|
// Re-check isTauri after mount and after a short delay so we catch late-injected __TAURI__ in dev
|
|
44
45
|
const [isTauriEnv, setIsTauriEnv] = useState(() => isTauri());
|
|
@@ -78,11 +79,15 @@ export const SettingsView = () => {
|
|
|
78
79
|
}, [settings.developerFeatures.enabled, routesWithoutTauriSw]);
|
|
79
80
|
|
|
80
81
|
const settingsNavRoutes = useMemo(() => {
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
let routes = filteredRoutes;
|
|
83
|
+
if (getLegalDocuments(config).length === 0) {
|
|
84
|
+
routes = routes.filter((route) => route.path !== 'legal-documents');
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
if (!isStorageSettingsEnabled(config) || !isAuthenticated) {
|
|
87
|
+
routes = routes.filter((route) => route.path !== 'storage');
|
|
88
|
+
}
|
|
89
|
+
return routes;
|
|
90
|
+
}, [filteredRoutes, config, isAuthenticated]);
|
|
86
91
|
|
|
87
92
|
// Application settings from navigation items with settings URL
|
|
88
93
|
const applicationRoutes = useMemo(() => {
|
|
@@ -150,6 +155,7 @@ export const SettingsView = () => {
|
|
|
150
155
|
['appearance', 'language-and-region', 'data-privacy'].includes(route.path),
|
|
151
156
|
),
|
|
152
157
|
...userRoute,
|
|
158
|
+
...settingsNavRoutes.filter((route) => route.path === 'storage'),
|
|
153
159
|
],
|
|
154
160
|
},
|
|
155
161
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
1
2
|
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import { Switch } from '../../../components/ui/switch';
|
|
3
4
|
import { useConfig } from '../../config/useConfig';
|
|
@@ -6,6 +7,8 @@ import { useSettings } from '../hooks/useSettings';
|
|
|
6
7
|
import { Button } from '../../../components/ui/button';
|
|
7
8
|
import { shellui } from '@shellui/sdk';
|
|
8
9
|
import { useCookieConsent } from '../../cookieConsent/useCookieConsent';
|
|
10
|
+
import { AlertTriangleIcon, ChevronDownIcon, CodeIcon } from '../SettingsIcons';
|
|
11
|
+
import { cn } from '../../../lib/utils';
|
|
9
12
|
|
|
10
13
|
export const Advanced = () => {
|
|
11
14
|
const { t } = useTranslation('settings');
|
|
@@ -13,6 +16,7 @@ export const Advanced = () => {
|
|
|
13
16
|
const { settings, updateSetting, resetAllData } = useSettings();
|
|
14
17
|
const errorReportingConfigured = Boolean(config?.sentry?.dsn);
|
|
15
18
|
const { isAccepted: sentryConsentAccepted } = useCookieConsent('sentry.io');
|
|
19
|
+
const [dangerZoneOpen, setDangerZoneOpen] = useState(false);
|
|
16
20
|
|
|
17
21
|
const handleErrorReportingChange = (checked: boolean) => {
|
|
18
22
|
// Don't allow enabling if cookie consent hasn't been approved
|
|
@@ -84,58 +88,127 @@ export const Advanced = () => {
|
|
|
84
88
|
)}
|
|
85
89
|
</div>
|
|
86
90
|
|
|
87
|
-
<div
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
<div
|
|
92
|
+
className={cn(
|
|
93
|
+
'rounded-lg border p-4 transition-colors',
|
|
94
|
+
settings.developerFeatures.enabled
|
|
95
|
+
? 'border-primary/40 bg-primary/5'
|
|
96
|
+
: 'border-border bg-muted/30',
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
<div className="flex items-start gap-3">
|
|
100
|
+
<div
|
|
101
|
+
className={cn(
|
|
102
|
+
'flex h-10 w-10 shrink-0 items-center justify-center rounded-md',
|
|
103
|
+
settings.developerFeatures.enabled
|
|
104
|
+
? 'bg-primary/15 text-primary'
|
|
105
|
+
: 'bg-muted text-muted-foreground',
|
|
106
|
+
)}
|
|
107
|
+
aria-hidden
|
|
93
108
|
>
|
|
94
|
-
|
|
95
|
-
</
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
<CodeIcon />
|
|
110
|
+
</div>
|
|
111
|
+
<div className="min-w-0 flex-1 space-y-3">
|
|
112
|
+
<div className="flex items-start justify-between gap-3">
|
|
113
|
+
<div className="space-y-1">
|
|
114
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
115
|
+
<label
|
|
116
|
+
htmlFor="developer-features"
|
|
117
|
+
className="text-sm font-medium leading-none"
|
|
118
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
119
|
+
>
|
|
120
|
+
{t('advanced.developerFeatures.label')}
|
|
121
|
+
</label>
|
|
122
|
+
{settings.developerFeatures.enabled && (
|
|
123
|
+
<span className="rounded-full bg-primary/15 px-2 py-0.5 text-[11px] font-medium text-primary">
|
|
124
|
+
{t('advanced.developerFeatures.badge')}
|
|
125
|
+
</span>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
<p className="text-sm text-muted-foreground">
|
|
129
|
+
{t('advanced.developerFeatures.description')}
|
|
130
|
+
</p>
|
|
131
|
+
</div>
|
|
132
|
+
<Switch
|
|
133
|
+
id="developer-features"
|
|
134
|
+
checked={settings.developerFeatures.enabled}
|
|
135
|
+
onCheckedChange={(checked) =>
|
|
136
|
+
updateSetting('developerFeatures', { enabled: checked })
|
|
137
|
+
}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
<div className="rounded-md border border-border/60 bg-background/60 px-3 py-2">
|
|
141
|
+
<p className="text-xs text-muted-foreground">
|
|
142
|
+
{settings.developerFeatures.enabled
|
|
143
|
+
? t('advanced.developerFeatures.hintEnabled')
|
|
144
|
+
: t('advanced.developerFeatures.hintDisabled')}
|
|
145
|
+
</p>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
99
148
|
</div>
|
|
100
|
-
<Switch
|
|
101
|
-
id="developer-features"
|
|
102
|
-
checked={settings.developerFeatures.enabled}
|
|
103
|
-
onCheckedChange={(checked) => updateSetting('developerFeatures', { enabled: checked })}
|
|
104
|
-
/>
|
|
105
149
|
</div>
|
|
106
150
|
|
|
107
|
-
<div className="
|
|
108
|
-
<div className="
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
151
|
+
<div className="mt-8">
|
|
152
|
+
<div className="rounded-lg border border-destructive/30 bg-destructive/5">
|
|
153
|
+
<button
|
|
154
|
+
type="button"
|
|
155
|
+
className="flex w-full cursor-pointer items-start gap-3 p-4 text-left"
|
|
156
|
+
aria-expanded={dangerZoneOpen}
|
|
157
|
+
onClick={() => setDangerZoneOpen((open) => !open)}
|
|
158
|
+
>
|
|
159
|
+
<div
|
|
160
|
+
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-destructive/15 text-destructive"
|
|
161
|
+
aria-hidden
|
|
113
162
|
>
|
|
114
|
-
|
|
115
|
-
</
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
163
|
+
<AlertTriangleIcon />
|
|
164
|
+
</div>
|
|
165
|
+
<div className="min-w-0 flex-1 space-y-1">
|
|
166
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
167
|
+
<h3
|
|
168
|
+
className="text-sm font-semibold leading-none text-destructive"
|
|
169
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
170
|
+
>
|
|
171
|
+
{t('advanced.dangerZone.title')}
|
|
172
|
+
</h3>
|
|
173
|
+
<span className="rounded-full bg-destructive/15 px-2 py-0.5 text-[11px] font-medium text-destructive">
|
|
174
|
+
{t('advanced.dangerZone.badge')}
|
|
175
|
+
</span>
|
|
176
|
+
</div>
|
|
127
177
|
<p className="text-sm text-muted-foreground">
|
|
128
|
-
{t('advanced.dangerZone.
|
|
178
|
+
{t('advanced.dangerZone.description')}
|
|
129
179
|
</p>
|
|
130
180
|
</div>
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
181
|
+
<ChevronDownIcon
|
|
182
|
+
className={cn(
|
|
183
|
+
'mt-1 shrink-0 text-destructive transition-transform',
|
|
184
|
+
dangerZoneOpen && 'rotate-180',
|
|
185
|
+
)}
|
|
186
|
+
/>
|
|
187
|
+
</button>
|
|
188
|
+
|
|
189
|
+
{dangerZoneOpen && (
|
|
190
|
+
<div className="space-y-3 border-t border-destructive/20 px-4 pb-4 pt-3">
|
|
191
|
+
<div className="space-y-1">
|
|
192
|
+
<label
|
|
193
|
+
className="text-sm font-medium leading-none"
|
|
194
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
195
|
+
>
|
|
196
|
+
{t('advanced.dangerZone.reset.title')}
|
|
197
|
+
</label>
|
|
198
|
+
<p className="text-sm text-muted-foreground">
|
|
199
|
+
{t('advanced.dangerZone.reset.warning')}
|
|
200
|
+
</p>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<Button
|
|
204
|
+
variant="destructive"
|
|
205
|
+
onClick={handleResetClick}
|
|
206
|
+
className="w-full sm:w-auto"
|
|
207
|
+
>
|
|
208
|
+
{t('advanced.dangerZone.reset.button')}
|
|
209
|
+
</Button>
|
|
210
|
+
</div>
|
|
211
|
+
)}
|
|
139
212
|
</div>
|
|
140
213
|
</div>
|
|
141
214
|
</div>
|
|
@@ -11,9 +11,11 @@ import { Switch } from '../../../components/ui/switch';
|
|
|
11
11
|
import { Select } from '../../../components/ui/select';
|
|
12
12
|
import { Button } from '../../../components/ui/button';
|
|
13
13
|
import { ToastTestButtons } from './develop/ToastTestButtons';
|
|
14
|
+
import { UploadToastTestButton } from './develop/UploadToastTestButton';
|
|
14
15
|
import { DialogTestButtons } from './develop/DialogTestButtons';
|
|
15
16
|
import { ModalTestButtons } from './develop/ModalTestButtons';
|
|
16
17
|
import { DrawerTestButtons } from './develop/DrawerTestButtons';
|
|
18
|
+
import { StoragePickerTestButtons } from './develop/StoragePickerTestButtons';
|
|
17
19
|
import { captureException } from '../../sentry/initSentry';
|
|
18
20
|
import { useCookieConsent } from '../../cookieConsent/useCookieConsent';
|
|
19
21
|
import type { LayoutType } from '../../config/types';
|
|
@@ -163,6 +165,40 @@ export const Develop = () => {
|
|
|
163
165
|
</div>
|
|
164
166
|
</div>
|
|
165
167
|
|
|
168
|
+
<div>
|
|
169
|
+
<h3
|
|
170
|
+
className="text-lg font-semibold mb-2"
|
|
171
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
172
|
+
>
|
|
173
|
+
{t('develop.auth.title')}
|
|
174
|
+
</h3>
|
|
175
|
+
<div className="space-y-4">
|
|
176
|
+
<div className="flex items-center justify-between">
|
|
177
|
+
<div className="space-y-0.5">
|
|
178
|
+
<label
|
|
179
|
+
htmlFor="disable-token-auto-refresh"
|
|
180
|
+
className="text-sm font-medium leading-none"
|
|
181
|
+
style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
|
|
182
|
+
>
|
|
183
|
+
{t('develop.auth.disableTokenAutoRefresh.label')}
|
|
184
|
+
</label>
|
|
185
|
+
<p className="text-sm text-muted-foreground">
|
|
186
|
+
{t('develop.auth.disableTokenAutoRefresh.description')}
|
|
187
|
+
</p>
|
|
188
|
+
</div>
|
|
189
|
+
<Switch
|
|
190
|
+
id="disable-token-auto-refresh"
|
|
191
|
+
checked={settings.developerFeatures?.disableTokenAutoRefresh || false}
|
|
192
|
+
onCheckedChange={(checked) =>
|
|
193
|
+
updateSetting('developerFeatures', {
|
|
194
|
+
disableTokenAutoRefresh: checked,
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
166
202
|
<div>
|
|
167
203
|
<h3
|
|
168
204
|
className="text-lg font-semibold mb-2"
|
|
@@ -172,9 +208,11 @@ export const Develop = () => {
|
|
|
172
208
|
</h3>
|
|
173
209
|
<div className="space-y-4">
|
|
174
210
|
<ToastTestButtons />
|
|
211
|
+
<UploadToastTestButton />
|
|
175
212
|
<DialogTestButtons />
|
|
176
213
|
<ModalTestButtons />
|
|
177
214
|
<DrawerTestButtons />
|
|
215
|
+
<StoragePickerTestButtons />
|
|
178
216
|
{errorReportingConfigured && (
|
|
179
217
|
<div className="flex items-center justify-between">
|
|
180
218
|
<div className="space-y-0.5">
|