@shellui/core 0.3.1 → 0.4.1

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.
Files changed (59) hide show
  1. package/package.json +2 -2
  2. package/src/app.tsx +11 -1
  3. package/src/components/ui/dialog.tsx +26 -6
  4. package/src/components/ui/sonner.tsx +9 -5
  5. package/src/features/admin/AdminView.tsx +1 -20
  6. package/src/features/auth/AuthProvider.tsx +68 -13
  7. package/src/features/auth/backends/shellui.ts +8 -1
  8. package/src/features/auth/components/AccessPendingView.tsx +112 -0
  9. package/src/features/auth/components/LoginView.tsx +17 -0
  10. package/src/features/auth/components/OAuthCallbackView.tsx +211 -48
  11. package/src/features/auth/hooks/useAuth.tsx +8 -1
  12. package/src/features/auth/utils/authRequestError.spec.ts +52 -0
  13. package/src/features/auth/utils/authRequestError.ts +45 -0
  14. package/src/features/auth/utils/index.ts +7 -0
  15. package/src/features/auth/utils/isTokenAutoRefreshDisabled.spec.ts +71 -0
  16. package/src/features/auth/utils/isTokenAutoRefreshDisabled.ts +18 -0
  17. package/src/features/config/types.ts +46 -0
  18. package/src/features/layouts/AppLayout.tsx +3 -3
  19. package/src/features/layouts/OverlayShell.tsx +10 -6
  20. package/src/features/modal/ModalContext.spec.ts +77 -0
  21. package/src/features/modal/ModalContext.tsx +12 -50
  22. package/src/features/modal/validateAndNormalizeUrl.ts +96 -0
  23. package/src/features/settings/SettingsIcons.tsx +35 -0
  24. package/src/features/settings/SettingsProvider.tsx +69 -4
  25. package/src/features/settings/SettingsRoutes.tsx +14 -6
  26. package/src/features/settings/SettingsView.tsx +11 -5
  27. package/src/features/settings/components/Advanced.tsx +117 -44
  28. package/src/features/settings/components/Develop.tsx +38 -0
  29. package/src/features/settings/components/Storage.tsx +138 -0
  30. package/src/features/settings/components/develop/StoragePickerTestButtons.tsx +148 -0
  31. package/src/features/settings/components/develop/UploadToastTestButton.tsx +29 -0
  32. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +54 -0
  33. package/src/features/settings/utils/buildSettingsForPropagation.ts +34 -0
  34. package/src/features/settings/utils/toSettingsUser.spec.ts +4 -0
  35. package/src/features/settings/utils/toSettingsUser.ts +2 -0
  36. package/src/features/storage/StorageBridge.tsx +50 -0
  37. package/src/features/storage/StoragePickerContext.tsx +214 -0
  38. package/src/features/storage/api.spec.ts +303 -0
  39. package/src/features/storage/api.ts +414 -0
  40. package/src/features/storage/handleRequest.spec.ts +88 -0
  41. package/src/features/storage/handleRequest.ts +53 -0
  42. package/src/features/storage/quota.spec.ts +151 -0
  43. package/src/features/storage/quota.ts +104 -0
  44. package/src/features/storage/uploads/UploadToastCard.tsx +442 -0
  45. package/src/features/storage/uploads/UploadToaster.tsx +41 -0
  46. package/src/features/storage/uploads/handleTrackedUpload.spec.ts +170 -0
  47. package/src/features/storage/uploads/handleTrackedUpload.ts +97 -0
  48. package/src/features/storage/uploads/types.ts +24 -0
  49. package/src/features/storage/uploads/uploadQueue.spec.ts +118 -0
  50. package/src/features/storage/uploads/uploadQueue.ts +349 -0
  51. package/src/features/storage/uploads/useUploadQueue.ts +30 -0
  52. package/src/i18n/translations/en/common.json +33 -0
  53. package/src/i18n/translations/en/settings.json +47 -4
  54. package/src/i18n/translations/fr/common.json +33 -0
  55. package/src/i18n/translations/fr/settings.json +47 -4
  56. package/src/index.css +2 -1
  57. package/src/index.ts +2 -0
  58. package/src/lib/z-index.ts +9 -3
  59. package/src/service-worker/register.ts +4 -12
@@ -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 className="flex items-center justify-between">
88
- <div className="space-y-0.5">
89
- <label
90
- htmlFor="developer-features"
91
- className="text-sm font-medium leading-none"
92
- style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
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
- {t('advanced.developerFeatures.label')}
95
- </label>
96
- <p className="text-sm text-muted-foreground">
97
- {t('advanced.developerFeatures.description')}
98
- </p>
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="border-t pt-6 mt-6">
108
- <div className="space-y-4">
109
- <div className="space-y-0.5">
110
- <h3
111
- className="text-sm font-semibold leading-none text-destructive"
112
- style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
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
- {t('advanced.dangerZone.title')}
115
- </h3>
116
- <p className="text-sm text-muted-foreground">{t('advanced.dangerZone.description')}</p>
117
- </div>
118
-
119
- <div className="space-y-2">
120
- <div className="space-y-0.5">
121
- <label
122
- className="text-sm font-medium leading-none"
123
- style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
124
- >
125
- {t('advanced.dangerZone.reset.title')}
126
- </label>
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.reset.warning')}
178
+ {t('advanced.dangerZone.description')}
129
179
  </p>
130
180
  </div>
131
- <Button
132
- variant="destructive"
133
- onClick={handleResetClick}
134
- className="w-full sm:w-auto"
135
- >
136
- {t('advanced.dangerZone.reset.button')}
137
- </Button>
138
- </div>
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">
@@ -0,0 +1,138 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Button } from '../../../components/ui/button';
4
+ import { useAuth } from '../../auth/hooks/useAuth';
5
+ import { useConfig } from '../../config/useConfig';
6
+ import {
7
+ fetchStorageQuota,
8
+ formatBytes,
9
+ getStorageBaseUrl,
10
+ getUsagePercent,
11
+ type StorageQuotaBucket,
12
+ type StorageQuotaSnapshot,
13
+ } from '../../storage/quota';
14
+
15
+ const QuotaMeter = ({
16
+ label,
17
+ description,
18
+ bucket,
19
+ }: {
20
+ label: string;
21
+ description?: string;
22
+ bucket: StorageQuotaBucket;
23
+ }) => {
24
+ const { t, i18n } = useTranslation('settings');
25
+ const locale = i18n.language || 'en';
26
+ const percent = getUsagePercent(bucket.usedBytes, bucket.maxBytes);
27
+ const used = formatBytes(bucket.usedBytes, locale);
28
+ const max = bucket.maxBytes !== null ? formatBytes(bucket.maxBytes, locale) : null;
29
+ const barTone = percent !== null && percent >= 100 ? 'bg-destructive' : 'bg-primary';
30
+
31
+ return (
32
+ <div className="space-y-2">
33
+ <div className="space-y-0.5">
34
+ <h3
35
+ className="text-sm font-medium leading-none"
36
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
37
+ >
38
+ {label}
39
+ </h3>
40
+ {description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
41
+ </div>
42
+ <p className="text-sm tabular-nums">
43
+ {max ? t('storage.usedOfMax', { used, max }) : t('storage.usedOnly', { used })}
44
+ </p>
45
+ {percent !== null ? (
46
+ <div
47
+ className="h-2 w-full overflow-hidden rounded-full bg-muted"
48
+ role="progressbar"
49
+ aria-valuemin={0}
50
+ aria-valuemax={100}
51
+ aria-valuenow={Math.round(percent)}
52
+ aria-label={label}
53
+ >
54
+ <div
55
+ className={`h-full rounded-full transition-[width] ${barTone}`}
56
+ style={{ width: `${percent}%` }}
57
+ />
58
+ </div>
59
+ ) : null}
60
+ </div>
61
+ );
62
+ };
63
+
64
+ export const Storage = () => {
65
+ const { t } = useTranslation('settings');
66
+ const { config } = useConfig();
67
+ const { session, isAuthenticated } = useAuth();
68
+ const storageBaseUrl = getStorageBaseUrl(config);
69
+ const accessToken = session?.accessToken ?? null;
70
+
71
+ const [snapshot, setSnapshot] = useState<StorageQuotaSnapshot | null>(null);
72
+ const [loading, setLoading] = useState(false);
73
+ const [error, setError] = useState(false);
74
+
75
+ const load = useCallback(async () => {
76
+ if (!storageBaseUrl || !accessToken) {
77
+ setSnapshot(null);
78
+ setLoading(false);
79
+ setError(false);
80
+ return;
81
+ }
82
+ setLoading(true);
83
+ setError(false);
84
+ try {
85
+ setSnapshot(await fetchStorageQuota(storageBaseUrl, accessToken));
86
+ } catch {
87
+ setSnapshot(null);
88
+ setError(true);
89
+ } finally {
90
+ setLoading(false);
91
+ }
92
+ }, [accessToken, storageBaseUrl]);
93
+
94
+ useEffect(() => {
95
+ void load();
96
+ }, [load]);
97
+
98
+ if (!isAuthenticated || !accessToken) {
99
+ return <p className="text-sm text-muted-foreground">{t('storage.signInRequired')}</p>;
100
+ }
101
+
102
+ return (
103
+ <div className="space-y-6">
104
+ <p className="text-sm text-muted-foreground">{t('storage.description')}</p>
105
+
106
+ {loading && !snapshot ? (
107
+ <p className="text-sm text-muted-foreground">{t('storage.loading')}</p>
108
+ ) : null}
109
+
110
+ {error ? (
111
+ <div className="space-y-3">
112
+ <p className="text-sm text-destructive">{t('storage.error')}</p>
113
+ <Button
114
+ variant="outline"
115
+ size="sm"
116
+ onClick={() => void load()}
117
+ >
118
+ {t('storage.retry')}
119
+ </Button>
120
+ </div>
121
+ ) : null}
122
+
123
+ {snapshot ? (
124
+ <div className="space-y-6">
125
+ <QuotaMeter
126
+ label={t('storage.yourUsage')}
127
+ description={snapshot.user.maxBytes === null ? t('storage.noPersonalLimit') : undefined}
128
+ bucket={snapshot.user}
129
+ />
130
+ <QuotaMeter
131
+ label={t('storage.organization')}
132
+ bucket={snapshot.company}
133
+ />
134
+ </div>
135
+ ) : null}
136
+ </div>
137
+ );
138
+ };
@@ -0,0 +1,148 @@
1
+ import { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { shellui, type StorageSelectedItem } from '@shellui/sdk';
4
+ import { Button } from '../../../../components/ui/button';
5
+
6
+ const FolderIcon = () => (
7
+ <svg
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ width="16"
10
+ height="16"
11
+ viewBox="0 0 24 24"
12
+ fill="none"
13
+ stroke="currentColor"
14
+ strokeWidth="2"
15
+ strokeLinecap="round"
16
+ strokeLinejoin="round"
17
+ aria-hidden
18
+ >
19
+ <path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" />
20
+ </svg>
21
+ );
22
+
23
+ const FileIcon = () => (
24
+ <svg
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ width="16"
27
+ height="16"
28
+ viewBox="0 0 24 24"
29
+ fill="none"
30
+ stroke="currentColor"
31
+ strokeWidth="2"
32
+ strokeLinecap="round"
33
+ strokeLinejoin="round"
34
+ aria-hidden
35
+ >
36
+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z" />
37
+ <path d="M14 2v6h6" />
38
+ </svg>
39
+ );
40
+
41
+ const CloseIcon = () => (
42
+ <svg
43
+ xmlns="http://www.w3.org/2000/svg"
44
+ width="16"
45
+ height="16"
46
+ viewBox="0 0 24 24"
47
+ fill="none"
48
+ stroke="currentColor"
49
+ strokeWidth="2"
50
+ strokeLinecap="round"
51
+ strokeLinejoin="round"
52
+ aria-hidden
53
+ >
54
+ <path d="M18 6 6 18" />
55
+ <path d="m6 6 12 12" />
56
+ </svg>
57
+ );
58
+
59
+ export const StoragePickerTestButtons = () => {
60
+ const { t } = useTranslation('settings');
61
+ const [items, setItems] = useState<StorageSelectedItem[]>([]);
62
+
63
+ const runPicker = async (fn: () => Promise<{ items: StorageSelectedItem[] } | null>) => {
64
+ try {
65
+ const result = await fn();
66
+ if (result) setItems(result.items);
67
+ } catch (err) {
68
+ shellui.toast({
69
+ title: t('develop.testing.storagePicker.errorTitle'),
70
+ description: err instanceof Error ? err.message : t('develop.testing.storagePicker.error'),
71
+ type: 'error',
72
+ });
73
+ }
74
+ };
75
+
76
+ return (
77
+ <div>
78
+ <h4
79
+ className="text-sm font-medium mb-2"
80
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
81
+ >
82
+ {t('develop.testing.storagePicker.title')}
83
+ </h4>
84
+ <div className="flex flex-wrap gap-2">
85
+ <Button
86
+ variant="outline"
87
+ onClick={() => void runPicker(() => shellui.selectFolders())}
88
+ >
89
+ {t('develop.testing.storagePicker.buttons.folders')}
90
+ </Button>
91
+ <Button
92
+ variant="outline"
93
+ onClick={() => void runPicker(() => shellui.selectFolders({ multiple: true }))}
94
+ >
95
+ {t('develop.testing.storagePicker.buttons.foldersMultiple')}
96
+ </Button>
97
+ <Button
98
+ variant="outline"
99
+ onClick={() => void runPicker(() => shellui.selectFiles({ multiple: true }))}
100
+ >
101
+ {t('develop.testing.storagePicker.buttons.files')}
102
+ </Button>
103
+ <Button
104
+ variant="outline"
105
+ onClick={() =>
106
+ void runPicker(() => shellui.selectFiles({ multiple: true, folders: true }))
107
+ }
108
+ >
109
+ {t('develop.testing.storagePicker.buttons.filesAndFolders')}
110
+ </Button>
111
+ </div>
112
+ {items.length > 0 ? (
113
+ <ul className="mt-3 divide-y divide-border rounded-md border border-border">
114
+ {items.map((item) => (
115
+ <li
116
+ key={`${item.bucket}:${item.type}:${item.id}`}
117
+ className="flex items-center gap-2 px-3 py-2 text-sm"
118
+ >
119
+ <span className="shrink-0 text-muted-foreground">
120
+ {item.type === 'folder' ? <FolderIcon /> : <FileIcon />}
121
+ </span>
122
+ <span className="min-w-0 flex-1 truncate">{item.name}</span>
123
+ <button
124
+ type="button"
125
+ className="inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"
126
+ onClick={() =>
127
+ setItems((current) =>
128
+ current.filter(
129
+ (entry) =>
130
+ !(
131
+ entry.id === item.id &&
132
+ entry.bucket === item.bucket &&
133
+ entry.type === item.type
134
+ ),
135
+ ),
136
+ )
137
+ }
138
+ aria-label={t('develop.testing.storagePicker.remove', { name: item.name })}
139
+ >
140
+ <CloseIcon />
141
+ </button>
142
+ </li>
143
+ ))}
144
+ </ul>
145
+ ) : null}
146
+ </div>
147
+ );
148
+ };
@@ -0,0 +1,29 @@
1
+ import { useTranslation } from 'react-i18next';
2
+ import { Button } from '../../../../components/ui/button';
3
+ import { requestUploadToastDemo } from '../../../storage/uploads/uploadQueue';
4
+
5
+ export const UploadToastTestButton = () => {
6
+ const { t } = useTranslation('settings');
7
+
8
+ return (
9
+ <div>
10
+ <h4
11
+ className="text-sm font-medium mb-2"
12
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
13
+ >
14
+ {t('develop.testing.uploadProgress.title')}
15
+ </h4>
16
+ <div className="flex flex-wrap gap-2">
17
+ <Button
18
+ onClick={() => requestUploadToastDemo()}
19
+ variant="outline"
20
+ >
21
+ {t('develop.testing.uploadProgress.buttons.simulate')}
22
+ </Button>
23
+ </div>
24
+ <p className="text-xs text-muted-foreground mt-2">
25
+ {t('develop.testing.uploadProgress.description')}
26
+ </p>
27
+ </div>
28
+ );
29
+ };
@@ -164,4 +164,58 @@ describe('buildSettingsForPropagation', () => {
164
164
  const result = buildSettingsForPropagation(baseSettings, config, 'en');
165
165
  expect(result.authBackendBaseUrl).toBeNull();
166
166
  });
167
+
168
+ it('injects localized administration navigation from config', () => {
169
+ const config = {
170
+ storage: { url: 'http://localhost:8001/', filesUrl: 'http://localhost:5175/' },
171
+ administration: {
172
+ title: { en: 'Applications', fr: 'Applications FR' },
173
+ navigation: [
174
+ {
175
+ label: { en: 'Billing', fr: 'Facturation' },
176
+ path: 'billing',
177
+ url: 'https://app.example.com/billing',
178
+ icon: '/icons/billing.svg',
179
+ },
180
+ {
181
+ label: { en: 'Django admin', fr: 'Admin Django' },
182
+ path: 'django-admin',
183
+ url: '/admin/',
184
+ requiresStaff: true,
185
+ openIn: 'external',
186
+ },
187
+ ],
188
+ },
189
+ } as ShellUIConfig;
190
+
191
+ const result = buildSettingsForPropagation(baseSettings, config, 'fr');
192
+ expect(result.administration).toEqual({
193
+ title: 'Applications FR',
194
+ navigation: [
195
+ {
196
+ path: 'billing',
197
+ url: 'https://app.example.com/billing',
198
+ label: 'Facturation',
199
+ icon: '/icons/billing.svg',
200
+ },
201
+ {
202
+ path: 'django-admin',
203
+ url: '/admin/',
204
+ label: 'Admin Django',
205
+ requiresStaff: true,
206
+ openIn: 'external',
207
+ },
208
+ ],
209
+ });
210
+ expect(result.storage).toEqual({
211
+ url: 'http://localhost:8001',
212
+ filesUrl: 'http://localhost:5175/',
213
+ });
214
+ });
215
+
216
+ it('sets administration and storage to null when not configured', () => {
217
+ const result = buildSettingsForPropagation(baseSettings, undefined, 'en');
218
+ expect(result.administration).toBeNull();
219
+ expect(result.storage).toBeNull();
220
+ });
167
221
  });
@@ -41,11 +41,45 @@ export const buildSettingsForPropagation = (
41
41
  path: item.path,
42
42
  url: item.url,
43
43
  label: resolveLabel(item.label, lang),
44
+ ...(item.icon ? { icon: item.icon } : {}),
44
45
  }),
45
46
  );
46
47
  result = { ...result, navigation: { items } };
47
48
  }
48
49
 
50
+ if (config?.administration) {
51
+ result = {
52
+ ...result,
53
+ administration: {
54
+ title: resolveLabel(config.administration.title, lang),
55
+ navigation: (config.administration.navigation ?? []).map((item) => ({
56
+ path: item.path,
57
+ url: item.url,
58
+ label: resolveLabel(item.label, lang),
59
+ ...(item.icon ? { icon: item.icon } : {}),
60
+ ...(item.requiresStaff ? { requiresStaff: true } : {}),
61
+ ...(item.openIn === 'external' ? { openIn: 'external' as const } : {}),
62
+ })),
63
+ },
64
+ };
65
+ } else {
66
+ result = { ...result, administration: null };
67
+ }
68
+
69
+ const storageUrl = config?.storage?.url?.trim().replace(/\/+$/, '') || null;
70
+ if (storageUrl) {
71
+ const filesUrl = config.storage?.filesUrl?.trim() || null;
72
+ result = {
73
+ ...result,
74
+ storage: {
75
+ url: storageUrl,
76
+ ...(filesUrl ? { filesUrl } : {}),
77
+ },
78
+ };
79
+ } else {
80
+ result = { ...result, storage: null };
81
+ }
82
+
49
83
  const authBackendBaseUrl =
50
84
  config?.backend?.type === 'shellui' && config.backend.url?.trim()
51
85
  ? config.backend.url.trim().replace(/\/+$/, '')