@terreno/admin-frontend 0.20.2 → 0.21.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/.ai/guidelines/core.md +10 -0
- package/dist/AdminBreadcrumbs.d.ts +13 -0
- package/dist/AdminBreadcrumbs.js +22 -0
- package/dist/AdminBreadcrumbs.js.map +1 -0
- package/dist/AdminFieldRenderer.js +3 -3
- package/dist/AdminFieldRenderer.js.map +1 -1
- package/dist/AdminFieldRendererCore.d.ts +2 -0
- package/dist/AdminFieldRendererCore.js +28 -18
- package/dist/AdminFieldRendererCore.js.map +1 -1
- package/dist/AdminHome.d.ts +22 -0
- package/dist/AdminHome.js +189 -0
- package/dist/AdminHome.js.map +1 -0
- package/dist/AdminModelForm.d.ts +24 -1
- package/dist/AdminModelForm.js +185 -14
- package/dist/AdminModelForm.js.map +1 -1
- package/dist/AdminModelList.d.ts +4 -0
- package/dist/AdminModelList.js +19 -4
- package/dist/AdminModelList.js.map +1 -1
- package/dist/AdminModelTable.d.ts +2 -27
- package/dist/AdminModelTable.js +316 -60
- package/dist/AdminModelTable.js.map +1 -1
- package/dist/AdminNestedArrayField.d.ts +1 -0
- package/dist/AdminNestedArrayField.js +26 -6
- package/dist/AdminNestedArrayField.js.map +1 -1
- package/dist/AdminObjectPicker.d.ts +1 -0
- package/dist/AdminObjectPicker.js +6 -2
- package/dist/AdminObjectPicker.js.map +1 -1
- package/dist/AdminPrimitiveArrayField.d.ts +1 -0
- package/dist/AdminPrimitiveArrayField.js +9 -8
- package/dist/AdminPrimitiveArrayField.js.map +1 -1
- package/dist/AdminRefField.js +2 -2
- package/dist/AdminRefField.js.map +1 -1
- package/dist/AdminScriptList.js +114 -7
- package/dist/AdminScriptList.js.map +1 -1
- package/dist/AdminScriptRunModal.d.ts +5 -0
- package/dist/AdminScriptRunModal.js +136 -30
- package/dist/AdminScriptRunModal.js.map +1 -1
- package/dist/AdminShell.d.ts +39 -0
- package/dist/AdminShell.js +80 -0
- package/dist/AdminShell.js.map +1 -0
- package/dist/AdminShellLayout.d.ts +23 -0
- package/dist/AdminShellLayout.js +32 -0
- package/dist/AdminShellLayout.js.map +1 -0
- package/dist/AdminVersionConfig.d.ts +5 -0
- package/dist/AdminVersionConfig.js +15 -5
- package/dist/AdminVersionConfig.js.map +1 -1
- package/dist/ConfigurationScreen.js +3 -3
- package/dist/ConfigurationScreen.js.map +1 -1
- package/dist/ConsentFormEditor.js +2 -2
- package/dist/ConsentFormEditor.js.map +1 -1
- package/dist/ConsentFormList.js +1 -1
- package/dist/ConsentFormList.js.map +1 -1
- package/dist/ConsentResponseViewer.js +3 -3
- package/dist/ConsentResponseViewer.js.map +1 -1
- package/dist/DocumentStorageBrowser.js +1 -1
- package/dist/DocumentStorageBrowser.js.map +1 -1
- package/dist/adminModelListQueryParams.d.ts +14 -0
- package/dist/adminModelListQueryParams.js +51 -0
- package/dist/adminModelListQueryParams.js.map +1 -0
- package/dist/adminShellNav.d.ts +10 -0
- package/dist/adminShellNav.js +29 -0
- package/dist/adminShellNav.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/scriptRunUtils.d.ts +36 -0
- package/dist/scriptRunUtils.js +121 -0
- package/dist/scriptRunUtils.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js.map +1 -1
- package/dist/useAdminApi.d.ts +1 -0
- package/dist/useAdminApi.js +11 -0
- package/dist/useAdminApi.js.map +1 -1
- package/dist/useAdminBackgroundTask.d.ts +12 -0
- package/dist/useAdminBackgroundTask.js +26 -0
- package/dist/useAdminBackgroundTask.js.map +1 -0
- package/dist/useAdminScripts.d.ts +19 -1
- package/dist/useAdminScripts.js +33 -4
- package/dist/useAdminScripts.js.map +1 -1
- package/package.json +4 -3
- package/src/AdminBreadcrumbs.test.tsx +27 -0
- package/src/AdminBreadcrumbs.tsx +63 -0
- package/src/AdminFieldRenderer.tsx +3 -0
- package/src/AdminFieldRendererCore.tsx +59 -1
- package/src/AdminHome.test.tsx +208 -0
- package/src/AdminHome.tsx +474 -0
- package/src/AdminModelForm.test.tsx +81 -1
- package/src/AdminModelForm.tsx +282 -34
- package/src/AdminModelList.test.tsx +1 -1
- package/src/AdminModelList.tsx +72 -39
- package/src/AdminModelTable.test.tsx +11 -0
- package/src/AdminModelTable.tsx +530 -92
- package/src/AdminNestedArrayField.tsx +59 -9
- package/src/AdminObjectPicker.tsx +19 -1
- package/src/AdminPrimitiveArrayField.tsx +30 -15
- package/src/AdminRefField.tsx +2 -0
- package/src/AdminScriptList.tsx +307 -30
- package/src/AdminScriptRunModal.tsx +410 -95
- package/src/AdminShell.tsx +296 -0
- package/src/AdminShellLayout.tsx +34 -0
- package/src/AdminVersionConfig.tsx +120 -76
- package/src/ConfigurationScreen.tsx +4 -2
- package/src/ConsentFormEditor.tsx +3 -1
- package/src/ConsentFormList.tsx +1 -1
- package/src/ConsentResponseViewer.tsx +3 -3
- package/src/DocumentStorageBrowser.tsx +1 -1
- package/src/adminModelListQueryParams.ts +61 -0
- package/src/adminShellNav.test.ts +29 -0
- package/src/adminShellNav.ts +33 -0
- package/src/index.tsx +6 -1
- package/src/isolated/AdminScriptRunModal.isolated.tsx +152 -1
- package/src/scriptRunUtils.test.ts +146 -0
- package/src/scriptRunUtils.ts +149 -0
- package/src/types.ts +69 -0
- package/src/useAdminApi.ts +11 -0
- package/src/useAdminBackgroundTask.ts +40 -0
- package/src/useAdminScripts.ts +56 -5
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import {Box, Heading, Spinner, Text, useTheme} from "@terreno/ui";
|
|
2
|
+
import type {Href} from "expo-router";
|
|
3
|
+
import {router} from "expo-router";
|
|
4
|
+
import React, {useCallback} from "react";
|
|
5
|
+
import {type AdminBreadcrumbSegment, AdminBreadcrumbs} from "./AdminBreadcrumbs";
|
|
6
|
+
import {groupAdminModelsByGroup} from "./adminShellNav";
|
|
7
|
+
import type {AdminApi, AdminCustomScreen, AdminModelConfig} from "./types";
|
|
8
|
+
import {resolveAdminBases} from "./types";
|
|
9
|
+
import {useAdminConfig} from "./useAdminConfig";
|
|
10
|
+
|
|
11
|
+
/** Sidebar chrome: matches Flourish admin v2 prototype (`adminv2` HTML shell). */
|
|
12
|
+
export type AdminShellSidebarVariant = "clinical" | "colorful";
|
|
13
|
+
|
|
14
|
+
export interface AdminShellProps {
|
|
15
|
+
/** @deprecated Use `apiBase`/`routeBase`. */
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
api: AdminApi;
|
|
18
|
+
apiBase?: string;
|
|
19
|
+
/** Breadcrumb segments for the top bar */
|
|
20
|
+
breadcrumbs?: AdminBreadcrumbSegment[];
|
|
21
|
+
/** Path to configuration screen (e.g. "/configuration") */
|
|
22
|
+
configurationPath?: string;
|
|
23
|
+
/** Path to version / build metadata screen. Default matches admin-spa's `/version-config` route. */
|
|
24
|
+
versionConfigPath?: string;
|
|
25
|
+
/** Main column content */
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
/** Optional footer (e.g. signed-in user) */
|
|
28
|
+
footer?: React.ReactNode;
|
|
29
|
+
/** Optional right side of the top bar (e.g. primary action for the current screen). */
|
|
30
|
+
headerActions?: React.ReactNode;
|
|
31
|
+
routeBase?: string;
|
|
32
|
+
/** Extra custom screens merged with backend config for nav cards */
|
|
33
|
+
customScreens?: AdminCustomScreen[];
|
|
34
|
+
/** Sidebar look: `colorful` (teal rail) vs `clinical` (light bordered rail). */
|
|
35
|
+
sidebarVariant?: AdminShellSidebarVariant;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const NavButton: React.FC<{
|
|
39
|
+
label: string;
|
|
40
|
+
onPress: () => void;
|
|
41
|
+
sidebarVariant: AdminShellSidebarVariant;
|
|
42
|
+
testID?: string;
|
|
43
|
+
}> = ({label, onPress, sidebarVariant, testID}) => (
|
|
44
|
+
<Box
|
|
45
|
+
accessibilityHint={`Open ${label}`}
|
|
46
|
+
accessibilityLabel={label}
|
|
47
|
+
onClick={onPress}
|
|
48
|
+
padding={1}
|
|
49
|
+
testID={testID}
|
|
50
|
+
>
|
|
51
|
+
<Text color={sidebarVariant === "colorful" ? "inverted" : "link"} size="sm">
|
|
52
|
+
{label}
|
|
53
|
+
</Text>
|
|
54
|
+
</Box>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Admin UI v2 shell: grouped sidebar navigation, optional breadcrumbs, and main area.
|
|
59
|
+
*
|
|
60
|
+
* Intended for standalone admin SPA or embedded admin: pair with list/table/form screens
|
|
61
|
+
* as `children`. Fetches `/admin/config` once for the sidebar (Tools, grouped Models, Screens).
|
|
62
|
+
*
|
|
63
|
+
* For Expo Router admin roots, prefer {@link AdminShellLayout}: it wraps `children` in a flex
|
|
64
|
+
* main column so a nested `<Stack />` fills the area beside the sidebar without repeating layout
|
|
65
|
+
* boilerplate in each app.
|
|
66
|
+
*/
|
|
67
|
+
export const AdminShell: React.FC<AdminShellProps> = ({
|
|
68
|
+
api,
|
|
69
|
+
apiBase,
|
|
70
|
+
baseUrl,
|
|
71
|
+
breadcrumbs,
|
|
72
|
+
children,
|
|
73
|
+
configurationPath,
|
|
74
|
+
customScreens: propCustomScreens,
|
|
75
|
+
footer,
|
|
76
|
+
headerActions,
|
|
77
|
+
routeBase,
|
|
78
|
+
sidebarVariant = "colorful",
|
|
79
|
+
versionConfigPath = "/version-config",
|
|
80
|
+
}) => {
|
|
81
|
+
const {theme} = useTheme();
|
|
82
|
+
const {apiBase: resolvedApiBase, routeBase: resolvedRouteBase} = resolveAdminBases({
|
|
83
|
+
apiBase,
|
|
84
|
+
baseUrl,
|
|
85
|
+
routeBase,
|
|
86
|
+
});
|
|
87
|
+
const {config, error, isLoading} = useAdminConfig(api, resolvedApiBase);
|
|
88
|
+
|
|
89
|
+
const navigate = useCallback(
|
|
90
|
+
(path: string) => {
|
|
91
|
+
const prefix = resolvedRouteBase.endsWith("/")
|
|
92
|
+
? resolvedRouteBase.slice(0, -1)
|
|
93
|
+
: resolvedRouteBase;
|
|
94
|
+
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
95
|
+
const href = `${prefix}${normalized}` as Href;
|
|
96
|
+
router.push(href);
|
|
97
|
+
},
|
|
98
|
+
[resolvedRouteBase]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if (isLoading) {
|
|
102
|
+
return (
|
|
103
|
+
<Box
|
|
104
|
+
alignItems="center"
|
|
105
|
+
flex="grow"
|
|
106
|
+
justifyContent="center"
|
|
107
|
+
padding={6}
|
|
108
|
+
testID="admin-shell-loading"
|
|
109
|
+
>
|
|
110
|
+
<Spinner />
|
|
111
|
+
</Box>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (error || !config) {
|
|
116
|
+
return (
|
|
117
|
+
<Box padding={4} testID="admin-shell-error">
|
|
118
|
+
<Text color="error">Failed to load admin configuration.</Text>
|
|
119
|
+
</Box>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const backendScreens = config.customScreens ?? [];
|
|
124
|
+
const allCustomScreens = [...backendScreens, ...(propCustomScreens ?? [])];
|
|
125
|
+
const scripts = config.scripts ?? [];
|
|
126
|
+
const grouped = groupAdminModelsByGroup(config.models as AdminModelConfig[]);
|
|
127
|
+
|
|
128
|
+
const sidebarIsColorful = sidebarVariant === "colorful";
|
|
129
|
+
const sectionLabelColor = sidebarIsColorful ? "inverted" : "secondaryDark";
|
|
130
|
+
|
|
131
|
+
const showTopBar = Boolean(headerActions) || Boolean(breadcrumbs && breadcrumbs.length > 0);
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<Box direction="row" flex="grow" minHeight="100%" testID="admin-shell">
|
|
135
|
+
<Box
|
|
136
|
+
border={sidebarIsColorful ? undefined : "default"}
|
|
137
|
+
color={sidebarIsColorful ? "secondaryDark" : "base"}
|
|
138
|
+
direction="column"
|
|
139
|
+
gap={3}
|
|
140
|
+
padding={3}
|
|
141
|
+
testID="admin-shell-sidebar"
|
|
142
|
+
width={280}
|
|
143
|
+
>
|
|
144
|
+
<Heading {...(sidebarIsColorful ? {color: "inverted"} : {})} size="sm">
|
|
145
|
+
Admin
|
|
146
|
+
</Heading>
|
|
147
|
+
<Box direction="column" flex="grow" gap={3} minHeight={0}>
|
|
148
|
+
<NavButton
|
|
149
|
+
label="Home"
|
|
150
|
+
onPress={() => {
|
|
151
|
+
navigate("/");
|
|
152
|
+
}}
|
|
153
|
+
sidebarVariant={sidebarVariant}
|
|
154
|
+
testID="admin-shell-nav-home"
|
|
155
|
+
/>
|
|
156
|
+
<Box direction="column" gap={1}>
|
|
157
|
+
<Text bold color={sectionLabelColor} size="sm">
|
|
158
|
+
Tools
|
|
159
|
+
</Text>
|
|
160
|
+
{scripts.length > 0 ? (
|
|
161
|
+
<NavButton
|
|
162
|
+
label="Scripts"
|
|
163
|
+
onPress={() => {
|
|
164
|
+
navigate("/__scripts");
|
|
165
|
+
}}
|
|
166
|
+
sidebarVariant={sidebarVariant}
|
|
167
|
+
testID="admin-shell-nav-scripts"
|
|
168
|
+
/>
|
|
169
|
+
) : null}
|
|
170
|
+
<NavButton
|
|
171
|
+
label="Version"
|
|
172
|
+
onPress={() => {
|
|
173
|
+
navigate(versionConfigPath);
|
|
174
|
+
}}
|
|
175
|
+
sidebarVariant={sidebarVariant}
|
|
176
|
+
testID="admin-shell-nav-version"
|
|
177
|
+
/>
|
|
178
|
+
</Box>
|
|
179
|
+
<Box direction="column" gap={1}>
|
|
180
|
+
<Text bold color={sectionLabelColor} size="sm">
|
|
181
|
+
Models
|
|
182
|
+
</Text>
|
|
183
|
+
{grouped.map(({group, models}) => (
|
|
184
|
+
<Box direction="column" gap={1} key={group}>
|
|
185
|
+
<Text bold color={sectionLabelColor} size="sm">
|
|
186
|
+
{group}
|
|
187
|
+
</Text>
|
|
188
|
+
{models.map((model) => (
|
|
189
|
+
<NavButton
|
|
190
|
+
key={model.name}
|
|
191
|
+
label={model.displayName}
|
|
192
|
+
onPress={() => {
|
|
193
|
+
navigate(`/${model.name}`);
|
|
194
|
+
}}
|
|
195
|
+
sidebarVariant={sidebarVariant}
|
|
196
|
+
testID={`admin-shell-nav-model-${model.name}`}
|
|
197
|
+
/>
|
|
198
|
+
))}
|
|
199
|
+
</Box>
|
|
200
|
+
))}
|
|
201
|
+
</Box>
|
|
202
|
+
{allCustomScreens.length > 0 ? (
|
|
203
|
+
<Box direction="column" gap={1}>
|
|
204
|
+
<Text bold color={sectionLabelColor} size="sm">
|
|
205
|
+
Screens
|
|
206
|
+
</Text>
|
|
207
|
+
{allCustomScreens.map((screen) => (
|
|
208
|
+
<NavButton
|
|
209
|
+
key={screen.name}
|
|
210
|
+
label={screen.displayName}
|
|
211
|
+
onPress={() => {
|
|
212
|
+
navigate(`/${screen.name}`);
|
|
213
|
+
}}
|
|
214
|
+
sidebarVariant={sidebarVariant}
|
|
215
|
+
testID={`admin-shell-nav-screen-${screen.name}`}
|
|
216
|
+
/>
|
|
217
|
+
))}
|
|
218
|
+
</Box>
|
|
219
|
+
) : null}
|
|
220
|
+
{configurationPath ? (
|
|
221
|
+
<NavButton
|
|
222
|
+
label="Configuration"
|
|
223
|
+
onPress={() => {
|
|
224
|
+
router.push(configurationPath as Href);
|
|
225
|
+
}}
|
|
226
|
+
sidebarVariant={sidebarVariant}
|
|
227
|
+
testID="admin-shell-nav-configuration"
|
|
228
|
+
/>
|
|
229
|
+
) : null}
|
|
230
|
+
</Box>
|
|
231
|
+
{footer ? <Box marginTop={4}>{footer}</Box> : null}
|
|
232
|
+
</Box>
|
|
233
|
+
<Box
|
|
234
|
+
dangerouslySetInlineStyle={{
|
|
235
|
+
__style: {backgroundColor: theme.primitives.neutral050},
|
|
236
|
+
}}
|
|
237
|
+
direction="column"
|
|
238
|
+
flex="grow"
|
|
239
|
+
minWidth={0}
|
|
240
|
+
>
|
|
241
|
+
{showTopBar ? (
|
|
242
|
+
<Box
|
|
243
|
+
alignItems="center"
|
|
244
|
+
borderBottom="default"
|
|
245
|
+
color="base"
|
|
246
|
+
dangerouslySetInlineStyle={{
|
|
247
|
+
__style: {
|
|
248
|
+
paddingBottom: 12,
|
|
249
|
+
paddingLeft: 28,
|
|
250
|
+
paddingRight: 28,
|
|
251
|
+
paddingTop: 12,
|
|
252
|
+
},
|
|
253
|
+
}}
|
|
254
|
+
direction="row"
|
|
255
|
+
justifyContent="between"
|
|
256
|
+
minWidth={0}
|
|
257
|
+
testID="admin-shell-top-bar"
|
|
258
|
+
>
|
|
259
|
+
<Box flex="grow" minWidth={0}>
|
|
260
|
+
{breadcrumbs && breadcrumbs.length > 0 ? (
|
|
261
|
+
<AdminBreadcrumbs segments={breadcrumbs} />
|
|
262
|
+
) : (
|
|
263
|
+
<Box />
|
|
264
|
+
)}
|
|
265
|
+
</Box>
|
|
266
|
+
{headerActions ? (
|
|
267
|
+
<Box flex="shrink" marginLeft={3}>
|
|
268
|
+
{headerActions}
|
|
269
|
+
</Box>
|
|
270
|
+
) : null}
|
|
271
|
+
</Box>
|
|
272
|
+
) : null}
|
|
273
|
+
<Box alignItems="stretch" flex="grow" minHeight={0} testID="admin-shell-main" width="100%">
|
|
274
|
+
<Box
|
|
275
|
+
alignSelf="center"
|
|
276
|
+
dangerouslySetInlineStyle={{
|
|
277
|
+
__style: {
|
|
278
|
+
boxSizing: "border-box",
|
|
279
|
+
maxWidth: 1280,
|
|
280
|
+
padding: "24px 28px 80px",
|
|
281
|
+
width: "100%",
|
|
282
|
+
},
|
|
283
|
+
}}
|
|
284
|
+
flex="grow"
|
|
285
|
+
minHeight={0}
|
|
286
|
+
width="100%"
|
|
287
|
+
>
|
|
288
|
+
<Box flex="grow" minHeight={0}>
|
|
289
|
+
{children}
|
|
290
|
+
</Box>
|
|
291
|
+
</Box>
|
|
292
|
+
</Box>
|
|
293
|
+
</Box>
|
|
294
|
+
</Box>
|
|
295
|
+
);
|
|
296
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {Box} from "@terreno/ui";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {AdminShell, type AdminShellProps} from "./AdminShell";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Props for {@link AdminShellLayout}: same as {@link AdminShellProps} except `children` is the
|
|
7
|
+
* main column body (typically an Expo Router `<Stack />`, a single screen, or a fragment).
|
|
8
|
+
*/
|
|
9
|
+
export type AdminShellLayoutProps = Omit<AdminShellProps, "children"> & {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default admin chrome for Expo Router (and similar) apps: {@link AdminShell} plus a flex main
|
|
15
|
+
* column so nested navigators fill the area beside the sidebar without each app re-wrapping
|
|
16
|
+
* `children` in a grow `Box`.
|
|
17
|
+
*
|
|
18
|
+
* Use in `app/admin/_layout.tsx` (or your admin root) as:
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <AdminShellLayout api={api} apiBase="/admin" routeBase="/admin" configurationPath="...">
|
|
22
|
+
* <Stack>...</Stack>
|
|
23
|
+
* </AdminShellLayout>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const AdminShellLayout: React.FC<AdminShellLayoutProps> = ({children, ...shellProps}) => {
|
|
27
|
+
return (
|
|
28
|
+
<AdminShell {...shellProps}>
|
|
29
|
+
<Box flex="grow" minHeight={0} minWidth={0}>
|
|
30
|
+
{children}
|
|
31
|
+
</Box>
|
|
32
|
+
</AdminShell>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -23,6 +23,11 @@ interface AdminVersionConfigProps {
|
|
|
23
23
|
apiBase?: string;
|
|
24
24
|
/** Base path used for in-app navigation. Falls back to `baseUrl`. */
|
|
25
25
|
routeBase?: string;
|
|
26
|
+
/**
|
|
27
|
+
* When true, renders a compact bordered panel without a surrounding {@link Page} or Back
|
|
28
|
+
* button — for embedding on the admin home dashboard.
|
|
29
|
+
*/
|
|
30
|
+
embedded?: boolean;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
const VERSION_CONFIG_ENDPOINT = "adminVersionConfig";
|
|
@@ -32,6 +37,7 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({
|
|
|
32
37
|
baseUrl,
|
|
33
38
|
apiBase,
|
|
34
39
|
routeBase,
|
|
40
|
+
embedded,
|
|
35
41
|
}) => {
|
|
36
42
|
const {apiBase: resolvedApiBase} = resolveAdminBases({apiBase, baseUrl, routeBase});
|
|
37
43
|
const [formState, setFormState] = useState<VersionConfigData>({});
|
|
@@ -133,8 +139,15 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({
|
|
|
133
139
|
}, []);
|
|
134
140
|
|
|
135
141
|
if (isFetching) {
|
|
142
|
+
if (embedded) {
|
|
143
|
+
return (
|
|
144
|
+
<Box padding={4} testID="admin-version-config-widget-loading">
|
|
145
|
+
<Spinner />
|
|
146
|
+
</Box>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
136
149
|
return (
|
|
137
|
-
<Page maxWidth="100%" title="Version Config">
|
|
150
|
+
<Page color="transparent" maxWidth="100%" padding={0} title="Version Config">
|
|
138
151
|
<Box alignItems="center" justifyContent="center" padding={6}>
|
|
139
152
|
<Spinner />
|
|
140
153
|
</Box>
|
|
@@ -143,8 +156,17 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({
|
|
|
143
156
|
}
|
|
144
157
|
|
|
145
158
|
if (fetchError) {
|
|
159
|
+
if (embedded) {
|
|
160
|
+
return (
|
|
161
|
+
<Box padding={3} testID="admin-version-config-widget-error">
|
|
162
|
+
<Text color="error" size="sm">
|
|
163
|
+
Version config unavailable.
|
|
164
|
+
</Text>
|
|
165
|
+
</Box>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
146
168
|
return (
|
|
147
|
-
<Page maxWidth="100%" title="Version Config">
|
|
169
|
+
<Page color="transparent" maxWidth="100%" padding={0} title="Version Config">
|
|
148
170
|
<Box alignItems="center" gap={4} justifyContent="center" padding={6}>
|
|
149
171
|
<Text color="error">Failed to load version config. Please try again later.</Text>
|
|
150
172
|
<Button onClick={handleBack} text="Back" variant="outline" />
|
|
@@ -153,94 +175,116 @@ export const AdminVersionConfig: React.FC<AdminVersionConfigProps> = ({
|
|
|
153
175
|
);
|
|
154
176
|
}
|
|
155
177
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
178
|
+
const formInner = (
|
|
179
|
+
<>
|
|
180
|
+
{!embedded ? (
|
|
159
181
|
<Text color="secondaryDark" size="sm">
|
|
160
182
|
Configure version thresholds for upgrade warnings and blocks. Use build numbers (e.g. from
|
|
161
183
|
git rev-list --count HEAD). Set to 0 to disable.
|
|
162
184
|
</Text>
|
|
185
|
+
) : (
|
|
186
|
+
<Text bold size="sm">
|
|
187
|
+
Client version thresholds
|
|
188
|
+
</Text>
|
|
189
|
+
)}
|
|
163
190
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
191
|
+
<Box gap={2}>
|
|
192
|
+
<Text bold size="md">
|
|
193
|
+
Web
|
|
194
|
+
</Text>
|
|
195
|
+
<NumberField
|
|
196
|
+
onChange={(v) => handleFieldChange("webWarningVersion", parseInt(v, 10) || 0)}
|
|
197
|
+
title="Warning version (build number)"
|
|
198
|
+
type="number"
|
|
199
|
+
value={String(formState.webWarningVersion ?? 0)}
|
|
200
|
+
/>
|
|
201
|
+
<NumberField
|
|
202
|
+
onChange={(v) => handleFieldChange("webRequiredVersion", parseInt(v, 10) || 0)}
|
|
203
|
+
title="Required version (build number)"
|
|
204
|
+
type="number"
|
|
205
|
+
value={String(formState.webRequiredVersion ?? 0)}
|
|
206
|
+
/>
|
|
207
|
+
</Box>
|
|
181
208
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
209
|
+
<Box gap={2}>
|
|
210
|
+
<Text bold size="md">
|
|
211
|
+
Mobile
|
|
212
|
+
</Text>
|
|
213
|
+
<NumberField
|
|
214
|
+
onChange={(v) => handleFieldChange("mobileWarningVersion", parseInt(v, 10) || 0)}
|
|
215
|
+
title="Warning version (build number)"
|
|
216
|
+
type="number"
|
|
217
|
+
value={String(formState.mobileWarningVersion ?? 0)}
|
|
218
|
+
/>
|
|
219
|
+
<NumberField
|
|
220
|
+
onChange={(v) => handleFieldChange("mobileRequiredVersion", parseInt(v, 10) || 0)}
|
|
221
|
+
title="Required version (build number)"
|
|
222
|
+
type="number"
|
|
223
|
+
value={String(formState.mobileRequiredVersion ?? 0)}
|
|
224
|
+
/>
|
|
225
|
+
</Box>
|
|
199
226
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
227
|
+
<Box gap={2}>
|
|
228
|
+
<Text bold size="md">
|
|
229
|
+
Messages
|
|
230
|
+
</Text>
|
|
231
|
+
<TextField
|
|
232
|
+
onChange={(v) => handleFieldChange("warningMessage", v)}
|
|
233
|
+
title="Warning message"
|
|
234
|
+
value={formState.warningMessage ?? ""}
|
|
235
|
+
/>
|
|
236
|
+
<TextField
|
|
237
|
+
onChange={(v) => handleFieldChange("requiredMessage", v)}
|
|
238
|
+
title="Required (blocking) message"
|
|
239
|
+
value={formState.requiredMessage ?? ""}
|
|
240
|
+
/>
|
|
241
|
+
</Box>
|
|
215
242
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
243
|
+
<Box gap={2}>
|
|
244
|
+
<TextField
|
|
245
|
+
onChange={(v) => handleFieldChange("updateUrl", v)}
|
|
246
|
+
title="Update URL (optional, for mobile app store link)"
|
|
247
|
+
value={formState.updateUrl ?? ""}
|
|
248
|
+
/>
|
|
249
|
+
</Box>
|
|
223
250
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
251
|
+
<Box gap={2}>
|
|
252
|
+
<Text bold size="md">
|
|
253
|
+
Polling
|
|
254
|
+
</Text>
|
|
255
|
+
<NumberField
|
|
256
|
+
onChange={(v) => handleFieldChange("pollingIntervalMinutes", parseInt(v, 10) || 1440)}
|
|
257
|
+
title="Update check interval (minutes)"
|
|
258
|
+
type="number"
|
|
259
|
+
value={String(formState.pollingIntervalMinutes ?? 1440)}
|
|
260
|
+
/>
|
|
261
|
+
{!embedded ? (
|
|
234
262
|
<Text color="secondaryDark" size="sm">
|
|
235
263
|
How often clients check for updates in the background. Default: 1440 (24 hours).
|
|
236
264
|
Minimum: 1.
|
|
237
265
|
</Text>
|
|
238
|
-
|
|
266
|
+
) : null}
|
|
267
|
+
</Box>
|
|
239
268
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
269
|
+
<Box direction="row" gap={2}>
|
|
270
|
+
{!embedded ? <Button onClick={handleBack} text="Back" variant="outline" /> : null}
|
|
271
|
+
<Button loading={isSaving} onClick={handleSave} text="Save" variant="primary" />
|
|
272
|
+
</Box>
|
|
273
|
+
</>
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
if (embedded) {
|
|
277
|
+
return (
|
|
278
|
+
<Box border="default" gap={3} padding={3} rounding="md" testID="admin-version-config-widget">
|
|
279
|
+
{formInner}
|
|
280
|
+
</Box>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<Page color="transparent" maxWidth="100%" padding={0} scroll title="Version Config">
|
|
286
|
+
<Box gap={4} padding={4}>
|
|
287
|
+
{formInner}
|
|
244
288
|
</Box>
|
|
245
289
|
</Page>
|
|
246
290
|
);
|
|
@@ -278,7 +278,7 @@ export const ConfigurationScreen: React.FC<ConfigurationScreenProps> = ({
|
|
|
278
278
|
const isInitialLoading = (isMetaLoading && !configMeta) || (isValuesLoading && !configValues);
|
|
279
279
|
if (isInitialLoading) {
|
|
280
280
|
return (
|
|
281
|
-
<Page maxWidth="100%" title={title}>
|
|
281
|
+
<Page color="transparent" maxWidth="100%" padding={0} title={title}>
|
|
282
282
|
<Box alignItems="center" justifyContent="center" padding={6}>
|
|
283
283
|
<Spinner />
|
|
284
284
|
</Box>
|
|
@@ -288,7 +288,7 @@ export const ConfigurationScreen: React.FC<ConfigurationScreenProps> = ({
|
|
|
288
288
|
|
|
289
289
|
if (!configMeta) {
|
|
290
290
|
return (
|
|
291
|
-
<Page maxWidth="100%" title={title}>
|
|
291
|
+
<Page color="transparent" maxWidth="100%" padding={0} title={title}>
|
|
292
292
|
<Box padding={4}>
|
|
293
293
|
<Text color="secondaryDark">No configuration metadata available.</Text>
|
|
294
294
|
</Box>
|
|
@@ -298,6 +298,7 @@ export const ConfigurationScreen: React.FC<ConfigurationScreenProps> = ({
|
|
|
298
298
|
|
|
299
299
|
return (
|
|
300
300
|
<Page
|
|
301
|
+
color="transparent"
|
|
301
302
|
footer={
|
|
302
303
|
<Box direction="row" justifyContent="end" padding={2}>
|
|
303
304
|
<Button
|
|
@@ -311,6 +312,7 @@ export const ConfigurationScreen: React.FC<ConfigurationScreenProps> = ({
|
|
|
311
312
|
</Box>
|
|
312
313
|
}
|
|
313
314
|
maxWidth={800}
|
|
315
|
+
padding={0}
|
|
314
316
|
scroll
|
|
315
317
|
title={title}
|
|
316
318
|
>
|
|
@@ -420,7 +420,7 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
|
|
|
420
420
|
|
|
421
421
|
if (isEditMode && isFormLoading) {
|
|
422
422
|
return (
|
|
423
|
-
<Page maxWidth="100%">
|
|
423
|
+
<Page color="transparent" maxWidth="100%" padding={0}>
|
|
424
424
|
<Box alignItems="center" justifyContent="center" padding={6}>
|
|
425
425
|
<Spinner />
|
|
426
426
|
</Box>
|
|
@@ -435,6 +435,7 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
|
|
|
435
435
|
|
|
436
436
|
return (
|
|
437
437
|
<Page
|
|
438
|
+
color="transparent"
|
|
438
439
|
footer={
|
|
439
440
|
<Box direction="row" gap={2} justifyContent="between" padding={2}>
|
|
440
441
|
<Box>
|
|
@@ -457,6 +458,7 @@ export const ConsentFormEditor: React.FC<ConsentFormEditorProps> = ({
|
|
|
457
458
|
</Box>
|
|
458
459
|
}
|
|
459
460
|
maxWidth="100%"
|
|
461
|
+
padding={0}
|
|
460
462
|
scroll
|
|
461
463
|
>
|
|
462
464
|
<Box gap={4} padding={4}>
|
package/src/ConsentFormList.tsx
CHANGED
|
@@ -143,7 +143,7 @@ export const ConsentFormList: React.FC<ConsentFormListProps> = ({
|
|
|
143
143
|
const totalPages = listData ? Math.ceil(listData.total / DEFAULT_LIMIT) : 1;
|
|
144
144
|
|
|
145
145
|
return (
|
|
146
|
-
<Page maxWidth="100%">
|
|
146
|
+
<Page color="transparent" maxWidth="100%" padding={0}>
|
|
147
147
|
<Box alignItems="center" direction="row" justifyContent="between" padding={3}>
|
|
148
148
|
<Text size="lg">Consent Forms</Text>
|
|
149
149
|
{onCreateNew && (
|
|
@@ -62,7 +62,7 @@ export const ConsentResponseViewer: React.FC<ConsentResponseViewerProps> = ({
|
|
|
62
62
|
|
|
63
63
|
if (isLoading) {
|
|
64
64
|
return (
|
|
65
|
-
<Page maxWidth="100%">
|
|
65
|
+
<Page color="transparent" maxWidth="100%" padding={0}>
|
|
66
66
|
<Box alignItems="center" justifyContent="center" padding={6}>
|
|
67
67
|
<Spinner />
|
|
68
68
|
</Box>
|
|
@@ -72,7 +72,7 @@ export const ConsentResponseViewer: React.FC<ConsentResponseViewerProps> = ({
|
|
|
72
72
|
|
|
73
73
|
if (!response) {
|
|
74
74
|
return (
|
|
75
|
-
<Page maxWidth="100%">
|
|
75
|
+
<Page color="transparent" maxWidth="100%" padding={0}>
|
|
76
76
|
<Box alignItems="center" padding={6}>
|
|
77
77
|
<Text color="secondaryDark">Response not found.</Text>
|
|
78
78
|
</Box>
|
|
@@ -108,7 +108,7 @@ export const ConsentResponseViewer: React.FC<ConsentResponseViewerProps> = ({
|
|
|
108
108
|
response.formVersionSnapshot;
|
|
109
109
|
|
|
110
110
|
return (
|
|
111
|
-
<Page maxWidth="100%" scroll>
|
|
111
|
+
<Page color="transparent" maxWidth="100%" padding={0} scroll>
|
|
112
112
|
<Box gap={4} padding={4}>
|
|
113
113
|
<Box alignItems="center" direction="row" justifyContent="between">
|
|
114
114
|
<Heading size="lg">Consent Response</Heading>
|
|
@@ -600,7 +600,7 @@ export const DocumentStorageBrowser: React.FC<DocumentStorageBrowserProps> = ({
|
|
|
600
600
|
};
|
|
601
601
|
|
|
602
602
|
return (
|
|
603
|
-
<Page maxWidth="100%" title={title}>
|
|
603
|
+
<Page color="transparent" maxWidth="100%" padding={0} title={title}>
|
|
604
604
|
{headerRow}
|
|
605
605
|
{renderContent()}
|
|
606
606
|
|