@malloy-publisher/sdk 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/README.md +14 -9
- package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorageProvider-CyOJ0hqf.es.js} +7114 -6939
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-BnPzJ9Jf.es.js} +64 -57
- package/dist/{RenderedResult-CPi6uQWq.cjs.js → RenderedResult-Dp22kZsQ.cjs.js} +2 -2
- package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +41 -41
- package/dist/builder/index.es.js +2752 -2831
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/telemetry.d.ts +10 -5
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +8 -2
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +8 -10
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/styles.d.ts +49 -40
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/index.cjs.js +22 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +17425 -20672
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/telemetry.ts +10 -3
- package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +184 -171
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
- package/src/components/DashboardBuilder/DashboardEditor.tsx +135 -61
- package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
- package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
- package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
- package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
- package/src/components/Environment/About.tsx +14 -28
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +10 -0
- package/src/components/styles.ts +49 -85
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
- package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Container,
|
|
8
|
-
Link,
|
|
9
|
-
Snackbar,
|
|
10
|
-
Stack,
|
|
11
|
-
Typography,
|
|
12
|
-
} from "@mui/material";
|
|
4
|
+
import { Snackbar, Stack, Typography } from "@mui/material";
|
|
13
5
|
import { useQueryClient } from "@tanstack/react-query";
|
|
14
6
|
import React, { useState } from "react";
|
|
15
7
|
import {
|
|
@@ -21,26 +13,34 @@ import {
|
|
|
21
13
|
useMutationWithApiError,
|
|
22
14
|
useQueryWithApiError,
|
|
23
15
|
} from "../../hooks/useQueryWithApiError";
|
|
16
|
+
import { reporting } from "../../telemetry/consoleEvents";
|
|
24
17
|
import { parseResourceUri } from "../../utils/formatting";
|
|
25
18
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
26
19
|
import { Loading } from "../Loading";
|
|
20
|
+
import { PackageSection } from "../PackageSection";
|
|
27
21
|
import { useServer } from "../ServerProvider";
|
|
22
|
+
import { describeCron, formatNextRun } from "./cron";
|
|
28
23
|
import CreateMaterializationDialog from "./CreateMaterializationDialog";
|
|
29
24
|
import MaterializationDetailDialog from "./MaterializationDetailDialog";
|
|
30
25
|
import MaterializationRunsList from "./MaterializationRunsList";
|
|
31
|
-
import
|
|
26
|
+
import ScopeButton from "./ScopeButton";
|
|
27
|
+
import SetScheduleDialog from "./SetScheduleDialog";
|
|
32
28
|
import { isActiveStatus } from "./utils";
|
|
33
29
|
|
|
34
30
|
const MATERIALIZATION_POLL_MS = 3000;
|
|
35
31
|
|
|
36
32
|
interface MaterializationsProps {
|
|
37
33
|
resourceUri: string;
|
|
38
|
-
onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
|
|
39
34
|
}
|
|
40
35
|
|
|
36
|
+
/**
|
|
37
|
+
* The package's materializations, as a section of its page: what has been
|
|
38
|
+
* built, and the three controls that change it — scope, schedule, and a new
|
|
39
|
+
* build. The runs are the package's own history, so they sit beside its
|
|
40
|
+
* dashboards and models rather than one click away on a page of their own.
|
|
41
|
+
*/
|
|
41
42
|
export default function Materializations({
|
|
42
43
|
resourceUri,
|
|
43
|
-
onClickPackageFile,
|
|
44
44
|
}: MaterializationsProps) {
|
|
45
45
|
const { apiClients, mutable } = useServer();
|
|
46
46
|
const queryClient = useQueryClient();
|
|
@@ -48,12 +48,6 @@ export default function Materializations({
|
|
|
48
48
|
const [notificationMessage, setNotificationMessage] = useState("");
|
|
49
49
|
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
50
50
|
|
|
51
|
-
const onClick =
|
|
52
|
-
onClickPackageFile ??
|
|
53
|
-
((to: string) => {
|
|
54
|
-
window.location.href = to;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
51
|
if (!packageName) {
|
|
58
52
|
throw new Error(
|
|
59
53
|
"Materializations requires a package in the resource URI",
|
|
@@ -94,14 +88,18 @@ export default function Materializations({
|
|
|
94
88
|
// Auto-run: the publisher compiles, builds every persist source, and loads
|
|
95
89
|
// the resulting manifest in a single pass.
|
|
96
90
|
const createMaterialization = useMutationWithApiError({
|
|
97
|
-
mutationFn: (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
91
|
+
mutationFn: reporting(
|
|
92
|
+
"materialization",
|
|
93
|
+
"create",
|
|
94
|
+
(opts: { forceRefresh: boolean }) =>
|
|
95
|
+
apiClients.materializations.createMaterialization(
|
|
96
|
+
environmentName,
|
|
97
|
+
packageName,
|
|
98
|
+
{
|
|
99
|
+
forceRefresh: opts.forceRefresh,
|
|
100
|
+
},
|
|
101
|
+
),
|
|
102
|
+
),
|
|
105
103
|
onSuccess() {
|
|
106
104
|
setNotificationMessage("Materialization requested");
|
|
107
105
|
invalidateList();
|
|
@@ -113,13 +111,17 @@ export default function Materializations({
|
|
|
113
111
|
});
|
|
114
112
|
|
|
115
113
|
const stopMaterialization = useMutationWithApiError({
|
|
116
|
-
mutationFn: (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
mutationFn: reporting(
|
|
115
|
+
"materialization",
|
|
116
|
+
"update",
|
|
117
|
+
(materialization: Materialization) =>
|
|
118
|
+
apiClients.materializations.materializationAction(
|
|
119
|
+
environmentName,
|
|
120
|
+
packageName,
|
|
121
|
+
materialization.id as string,
|
|
122
|
+
MaterializationActionActionEnum.Stop,
|
|
123
|
+
),
|
|
124
|
+
),
|
|
123
125
|
onSuccess() {
|
|
124
126
|
setNotificationMessage("Materialization stopped");
|
|
125
127
|
invalidateList();
|
|
@@ -130,19 +132,23 @@ export default function Materializations({
|
|
|
130
132
|
});
|
|
131
133
|
|
|
132
134
|
const deleteMaterialization = useMutationWithApiError({
|
|
133
|
-
mutationFn: (
|
|
134
|
-
materialization,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
dropTables: boolean;
|
|
139
|
-
}) =>
|
|
140
|
-
apiClients.materializations.deleteMaterialization(
|
|
141
|
-
environmentName,
|
|
142
|
-
packageName,
|
|
143
|
-
materialization.id as string,
|
|
135
|
+
mutationFn: reporting(
|
|
136
|
+
"materialization",
|
|
137
|
+
"delete",
|
|
138
|
+
({
|
|
139
|
+
materialization,
|
|
144
140
|
dropTables,
|
|
145
|
-
|
|
141
|
+
}: {
|
|
142
|
+
materialization: Materialization;
|
|
143
|
+
dropTables: boolean;
|
|
144
|
+
}) =>
|
|
145
|
+
apiClients.materializations.deleteMaterialization(
|
|
146
|
+
environmentName,
|
|
147
|
+
packageName,
|
|
148
|
+
materialization.id as string,
|
|
149
|
+
dropTables,
|
|
150
|
+
),
|
|
151
|
+
),
|
|
146
152
|
onSuccess() {
|
|
147
153
|
setNotificationMessage("Materialization deleted");
|
|
148
154
|
invalidateList();
|
|
@@ -161,7 +167,7 @@ export default function Materializations({
|
|
|
161
167
|
// strands scope: version with no way back. The running scheduler re-arms from
|
|
162
168
|
// the new cron on its next tick — no reload needed.
|
|
163
169
|
const updateSchedule = useMutationWithApiError({
|
|
164
|
-
mutationFn: (schedule: string | null) =>
|
|
170
|
+
mutationFn: reporting("schedule", "update", (schedule: string | null) =>
|
|
165
171
|
apiClients.packages.updatePackage(environmentName, packageName, {
|
|
166
172
|
name: packageName,
|
|
167
173
|
// updatePackage overwrites description from the body — carry the
|
|
@@ -170,6 +176,7 @@ export default function Materializations({
|
|
|
170
176
|
...(schedule ? { scope: PackageScopeEnum.Version } : {}),
|
|
171
177
|
materialization: { schedule },
|
|
172
178
|
}),
|
|
179
|
+
),
|
|
173
180
|
onSuccess(_data, schedule) {
|
|
174
181
|
setNotificationMessage(
|
|
175
182
|
schedule ? "Schedule updated" : "Schedule cleared",
|
|
@@ -189,12 +196,13 @@ export default function Materializations({
|
|
|
189
196
|
// still set (publish-gate Rule 2), so the UI only offers this when no
|
|
190
197
|
// schedule is active.
|
|
191
198
|
const updateScope = useMutationWithApiError({
|
|
192
|
-
mutationFn: (scope: PackageScopeEnum) =>
|
|
199
|
+
mutationFn: reporting("scope", "update", (scope: PackageScopeEnum) =>
|
|
193
200
|
apiClients.packages.updatePackage(environmentName, packageName, {
|
|
194
201
|
name: packageName,
|
|
195
202
|
description: currentPackage?.description,
|
|
196
203
|
scope,
|
|
197
204
|
}),
|
|
205
|
+
),
|
|
198
206
|
onSuccess() {
|
|
199
207
|
setNotificationMessage("Scope updated");
|
|
200
208
|
queryClient.invalidateQueries({
|
|
@@ -215,99 +223,88 @@ export default function Materializations({
|
|
|
215
223
|
stopMaterialization.isPending ||
|
|
216
224
|
deleteMaterialization.isPending;
|
|
217
225
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
onClick(`/${environmentName}/${packageName}`, event)
|
|
227
|
-
}
|
|
228
|
-
underline="none"
|
|
229
|
-
sx={{
|
|
230
|
-
display: "inline-flex",
|
|
231
|
-
alignItems: "center",
|
|
232
|
-
gap: 0.5,
|
|
233
|
-
cursor: "pointer",
|
|
234
|
-
color: "text.secondary",
|
|
235
|
-
fontSize: "0.875rem",
|
|
236
|
-
mb: 2,
|
|
237
|
-
"&:hover": { color: "primary.main" },
|
|
238
|
-
}}
|
|
239
|
-
>
|
|
240
|
-
<ArrowBackIcon sx={{ fontSize: 18 }} />
|
|
241
|
-
Back to {packageName}
|
|
242
|
-
</Link>
|
|
243
|
-
<Stack
|
|
244
|
-
direction="row"
|
|
245
|
-
alignItems="flex-start"
|
|
246
|
-
justifyContent="space-between"
|
|
247
|
-
>
|
|
248
|
-
<Box>
|
|
249
|
-
<Typography
|
|
250
|
-
variant="h4"
|
|
251
|
-
component="h1"
|
|
252
|
-
sx={{
|
|
253
|
-
fontWeight: 600,
|
|
254
|
-
letterSpacing: "-0.025em",
|
|
255
|
-
mb: 0.5,
|
|
256
|
-
}}
|
|
257
|
-
>
|
|
258
|
-
Materializations
|
|
259
|
-
</Typography>
|
|
260
|
-
<Typography variant="body2" color="text.secondary">
|
|
261
|
-
Materialize the persist sources in {packageName} into
|
|
262
|
-
tables and serve queries from them
|
|
263
|
-
</Typography>
|
|
264
|
-
</Box>
|
|
265
|
-
{mutable && (
|
|
266
|
-
<CreateMaterializationDialog
|
|
267
|
-
onSubmit={(opts) =>
|
|
268
|
-
createMaterialization.mutateAsync(opts)
|
|
269
|
-
}
|
|
270
|
-
isSubmitting={createMaterialization.isPending}
|
|
271
|
-
disabled={hasActive}
|
|
272
|
-
disabledReason="A materialization is already pending or running for this package."
|
|
273
|
-
/>
|
|
274
|
-
)}
|
|
275
|
-
</Stack>
|
|
276
|
-
</Box>
|
|
226
|
+
const schedule = currentPackage?.materialization?.schedule ?? null;
|
|
227
|
+
const scope =
|
|
228
|
+
currentPackage?.scope === PackageScopeEnum.Version
|
|
229
|
+
? "version"
|
|
230
|
+
: "package";
|
|
231
|
+
const orchestrated = Boolean(currentPackage?.manifestLocation);
|
|
232
|
+
const hasFreshness = Boolean(currentPackage?.materialization?.freshness);
|
|
233
|
+
const cron = schedule ? describeCron(schedule) : null;
|
|
277
234
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
onScopeChange={(scope) =>
|
|
295
|
-
updateScope.mutateAsync(
|
|
296
|
-
scope === "version"
|
|
297
|
-
? PackageScopeEnum.Version
|
|
298
|
-
: PackageScopeEnum.Package,
|
|
299
|
-
)
|
|
300
|
-
}
|
|
301
|
-
/>
|
|
302
|
-
)}
|
|
235
|
+
// What the settings currently say, in one line. The controls that change
|
|
236
|
+
// them are buttons on the heading row, so the page no longer needs a card to
|
|
237
|
+
// hold them — but a reader still has to see what is in force without opening
|
|
238
|
+
// anything.
|
|
239
|
+
const summary = orchestrated
|
|
240
|
+
? "Control-plane managed: refresh is driven by the control plane, not the built-in scheduler."
|
|
241
|
+
: [
|
|
242
|
+
cron
|
|
243
|
+
? cron.valid
|
|
244
|
+
? `${cron.description} (${schedule}), next run ${formatNextRun(cron.nextRun)}`
|
|
245
|
+
: `Unrecognized cron expression (${schedule})`
|
|
246
|
+
: hasFreshness
|
|
247
|
+
? "Refreshed by a freshness policy; a cron schedule does not apply"
|
|
248
|
+
: "On demand only, no schedule set",
|
|
249
|
+
`scope: ${scope}`,
|
|
250
|
+
].join(" · ");
|
|
303
251
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
252
|
+
return (
|
|
253
|
+
<>
|
|
254
|
+
<PackageSection
|
|
255
|
+
title="Materializations"
|
|
256
|
+
count={listQuery.isSuccess ? materializations.length : undefined}
|
|
257
|
+
action={
|
|
258
|
+
mutable && (
|
|
259
|
+
<Stack direction="row" spacing={1} alignItems="center">
|
|
260
|
+
{!orchestrated && (
|
|
261
|
+
<ScopeButton
|
|
262
|
+
scope={scope}
|
|
263
|
+
// A schedule requires version scope, so the server
|
|
264
|
+
// refuses `package` while one is set; clearing the
|
|
265
|
+
// schedule is the way back.
|
|
266
|
+
disabled={Boolean(schedule)}
|
|
267
|
+
disabledReason="A schedule requires version scope. Clear the schedule to change it."
|
|
268
|
+
isSubmitting={updateScope.isPending}
|
|
269
|
+
onChange={(next) =>
|
|
270
|
+
updateScope.mutateAsync(
|
|
271
|
+
next === "version"
|
|
272
|
+
? PackageScopeEnum.Version
|
|
273
|
+
: PackageScopeEnum.Package,
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
/>
|
|
277
|
+
)}
|
|
278
|
+
{!orchestrated && (
|
|
279
|
+
<SetScheduleDialog
|
|
280
|
+
currentSchedule={schedule}
|
|
281
|
+
isSubmitting={updateSchedule.isPending}
|
|
282
|
+
disabled={hasFreshness}
|
|
283
|
+
disabledReason="This package declares a freshness policy; a schedule and freshness are mutually exclusive."
|
|
284
|
+
onSubmit={(next) => updateSchedule.mutateAsync(next)}
|
|
285
|
+
/>
|
|
286
|
+
)}
|
|
287
|
+
<CreateMaterializationDialog
|
|
288
|
+
onSubmit={(opts) =>
|
|
289
|
+
createMaterialization.mutateAsync(opts)
|
|
290
|
+
}
|
|
291
|
+
isSubmitting={createMaterialization.isPending}
|
|
292
|
+
disabled={hasActive}
|
|
293
|
+
disabledReason="A materialization is already pending or running for this package."
|
|
294
|
+
/>
|
|
295
|
+
</Stack>
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
>
|
|
299
|
+
{packageQuery.isSuccess && (
|
|
300
|
+
<Typography
|
|
301
|
+
variant="body2"
|
|
302
|
+
color="text.secondary"
|
|
303
|
+
sx={{ mb: 1.5 }}
|
|
304
|
+
>
|
|
305
|
+
{summary}
|
|
306
|
+
</Typography>
|
|
307
|
+
)}
|
|
311
308
|
{listQuery.isError && (
|
|
312
309
|
<ApiErrorDisplay
|
|
313
310
|
error={listQuery.error}
|
|
@@ -336,7 +333,7 @@ export default function Materializations({
|
|
|
336
333
|
}
|
|
337
334
|
/>
|
|
338
335
|
)}
|
|
339
|
-
</
|
|
336
|
+
</PackageSection>
|
|
340
337
|
|
|
341
338
|
<MaterializationDetailDialog
|
|
342
339
|
materialization={selected}
|
|
@@ -350,6 +347,6 @@ export default function Materializations({
|
|
|
350
347
|
onClose={() => setNotificationMessage("")}
|
|
351
348
|
message={notificationMessage}
|
|
352
349
|
/>
|
|
353
|
-
|
|
350
|
+
</>
|
|
354
351
|
);
|
|
355
352
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
5
|
+
import LayersOutlinedIcon from "@mui/icons-material/LayersOutlined";
|
|
6
|
+
import { ListItemIcon, ListItemText, Menu, MenuItem } from "@mui/material";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { SecondaryButton } from "../buttons";
|
|
9
|
+
|
|
10
|
+
export type Scope = "package" | "version";
|
|
11
|
+
|
|
12
|
+
const WHAT_IT_MEANS: Record<Scope, string> = {
|
|
13
|
+
package: "Materialized artifacts are shared across versions",
|
|
14
|
+
version: "Materialized artifacts are per published version",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The package's persist scope, as one button.
|
|
19
|
+
*
|
|
20
|
+
* It is a menu rather than a pair of toggles because the two values are a
|
|
21
|
+
* choice, not a filter, and because the choice is usually made once and then
|
|
22
|
+
* left alone — the section's heading row is not the place for a permanent
|
|
23
|
+
* two-button control. What each value means is in the menu, where it is read at
|
|
24
|
+
* the moment of choosing rather than sitting on the page forever.
|
|
25
|
+
*/
|
|
26
|
+
export default function ScopeButton({
|
|
27
|
+
scope,
|
|
28
|
+
disabled,
|
|
29
|
+
disabledReason,
|
|
30
|
+
isSubmitting,
|
|
31
|
+
onChange,
|
|
32
|
+
}: {
|
|
33
|
+
scope: Scope;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** Why the control is disabled, shown on hover. */
|
|
36
|
+
disabledReason?: string;
|
|
37
|
+
isSubmitting?: boolean;
|
|
38
|
+
onChange: (scope: Scope) => Promise<unknown>;
|
|
39
|
+
}) {
|
|
40
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
41
|
+
|
|
42
|
+
const choose = async (next: Scope) => {
|
|
43
|
+
setAnchor(null);
|
|
44
|
+
if (next !== scope) await onChange(next).catch(() => undefined);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<SecondaryButton
|
|
50
|
+
label="Scope"
|
|
51
|
+
icon={<LayersOutlinedIcon />}
|
|
52
|
+
onClick={(event) => setAnchor(event.currentTarget)}
|
|
53
|
+
disabled={disabled || isSubmitting}
|
|
54
|
+
{...(disabledReason ? { disabledReason } : {})}
|
|
55
|
+
ariaHasPopup="menu"
|
|
56
|
+
// The value is in the name, so the current scope is legible without
|
|
57
|
+
// opening the menu and a test can assert it.
|
|
58
|
+
ariaLabel={`Scope: ${scope}`}
|
|
59
|
+
/>
|
|
60
|
+
<Menu
|
|
61
|
+
anchorEl={anchor}
|
|
62
|
+
open={Boolean(anchor)}
|
|
63
|
+
onClose={() => setAnchor(null)}
|
|
64
|
+
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
|
|
65
|
+
transformOrigin={{ vertical: "top", horizontal: "right" }}
|
|
66
|
+
>
|
|
67
|
+
{(["package", "version"] as const).map((value) => (
|
|
68
|
+
<MenuItem
|
|
69
|
+
key={value}
|
|
70
|
+
selected={value === scope}
|
|
71
|
+
onClick={() => void choose(value)}
|
|
72
|
+
>
|
|
73
|
+
<ListItemIcon sx={{ minWidth: 32 }}>
|
|
74
|
+
{value === scope && <CheckIcon fontSize="small" />}
|
|
75
|
+
</ListItemIcon>
|
|
76
|
+
<ListItemText
|
|
77
|
+
primary={value}
|
|
78
|
+
secondary={WHAT_IT_MEANS[value]}
|
|
79
|
+
/>
|
|
80
|
+
</MenuItem>
|
|
81
|
+
))}
|
|
82
|
+
</Menu>
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -5,10 +5,13 @@ import { Typography } from "@mui/material";
|
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* A sub-heading INSIDE a materialization view — the detail dialog and the
|
|
9
|
+
* manifest view — where `PackageSection` does not apply: those are sections of
|
|
10
|
+
* a dialog, not of a page. Small and uppercase to sit a level under the
|
|
11
|
+
* dialog's own title.
|
|
12
|
+
*
|
|
13
|
+
* Renders as an `<h6>`, so it is a real heading to anything navigating by
|
|
14
|
+
* them; the caption styling is purely visual.
|
|
12
15
|
*/
|
|
13
16
|
export default function SectionLabel({ children }: { children: ReactNode }) {
|
|
14
17
|
return (
|
|
@@ -2,21 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import ScheduleIcon from "@mui/icons-material/Schedule";
|
|
5
|
-
import {
|
|
6
|
-
Alert,
|
|
7
|
-
Box,
|
|
8
|
-
Button,
|
|
9
|
-
Dialog,
|
|
10
|
-
DialogActions,
|
|
11
|
-
DialogContent,
|
|
12
|
-
DialogContentText,
|
|
13
|
-
DialogTitle,
|
|
14
|
-
TextField,
|
|
15
|
-
Tooltip,
|
|
16
|
-
Typography,
|
|
17
|
-
} from "@mui/material";
|
|
5
|
+
import { Alert, Button, TextField } from "@mui/material";
|
|
18
6
|
import { useState } from "react";
|
|
19
7
|
import { MONO_FONT_FAMILY } from "../styles";
|
|
8
|
+
import { AppDialog } from "../AppDialog";
|
|
9
|
+
import { SecondaryButton } from "../buttons";
|
|
20
10
|
import { describeCron, formatNextRun } from "./cron";
|
|
21
11
|
|
|
22
12
|
type SetScheduleDialogProps = {
|
|
@@ -59,104 +49,73 @@ export default function SetScheduleDialog({
|
|
|
59
49
|
}
|
|
60
50
|
};
|
|
61
51
|
|
|
62
|
-
const button = (
|
|
63
|
-
<span>
|
|
64
|
-
<Button
|
|
65
|
-
variant="outlined"
|
|
66
|
-
size="small"
|
|
67
|
-
startIcon={<ScheduleIcon />}
|
|
68
|
-
onClick={handleOpen}
|
|
69
|
-
disabled={disabled}
|
|
70
|
-
aria-label={currentSchedule ? "Edit schedule" : "Set schedule"}
|
|
71
|
-
>
|
|
72
|
-
{currentSchedule ? "Edit schedule" : "Set schedule"}
|
|
73
|
-
</Button>
|
|
74
|
-
</span>
|
|
75
|
-
);
|
|
76
|
-
|
|
77
52
|
return (
|
|
78
53
|
<>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
54
|
+
<SecondaryButton
|
|
55
|
+
label="Schedule"
|
|
56
|
+
icon={<ScheduleIcon />}
|
|
57
|
+
onClick={handleOpen}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
{...(disabledReason ? { disabledReason } : {})}
|
|
60
|
+
ariaHasPopup="dialog"
|
|
61
|
+
// The label is the noun, like every other control on this row; the
|
|
62
|
+
// accessible name keeps the verb, and says which verb it is.
|
|
63
|
+
ariaLabel={currentSchedule ? "Edit schedule" : "Set schedule"}
|
|
64
|
+
/>
|
|
84
65
|
|
|
85
|
-
<
|
|
66
|
+
<AppDialog
|
|
86
67
|
open={open}
|
|
87
68
|
onClose={handleClose}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
<DialogTitle id="set-schedule-title">
|
|
93
|
-
{currentSchedule ? "Edit schedule" : "Set schedule"}
|
|
94
|
-
</DialogTitle>
|
|
95
|
-
<DialogContent>
|
|
96
|
-
<DialogContentText sx={{ mb: 2 }}>
|
|
97
|
-
The publisher rebuilds the materializations in this package on
|
|
98
|
-
this cadence. Enter a 5-field UNIX cron, evaluated in UTC. In
|
|
99
|
-
a hosted deployment, the change takes effect on your next
|
|
100
|
-
publish.
|
|
101
|
-
</DialogContentText>
|
|
102
|
-
<TextField
|
|
103
|
-
autoFocus
|
|
104
|
-
fullWidth
|
|
105
|
-
label="Cron expression"
|
|
106
|
-
value={expr}
|
|
107
|
-
onChange={(event) => setExpr(event.target.value)}
|
|
108
|
-
error={expr.trim() !== "" && !info.valid}
|
|
109
|
-
slotProps={{
|
|
110
|
-
htmlInput: { style: { fontFamily: MONO_FONT_FAMILY } },
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
<Box sx={{ mt: 1.5, minHeight: 48 }}>
|
|
114
|
-
{info.valid ? (
|
|
115
|
-
<>
|
|
116
|
-
<Typography variant="body2">
|
|
117
|
-
{info.description}
|
|
118
|
-
</Typography>
|
|
119
|
-
<Typography variant="body2" color="text.secondary">
|
|
120
|
-
Next run: {formatNextRun(info.nextRun)}
|
|
121
|
-
</Typography>
|
|
122
|
-
</>
|
|
123
|
-
) : (
|
|
124
|
-
<Typography variant="body2" color="error">
|
|
125
|
-
{info.error}
|
|
126
|
-
</Typography>
|
|
127
|
-
)}
|
|
128
|
-
</Box>
|
|
129
|
-
<Alert severity="info" sx={{ mt: 2 }}>
|
|
130
|
-
A schedule runs only on version-scoped packages, so saving one
|
|
131
|
-
sets <code>scope: version</code> for this package.
|
|
132
|
-
</Alert>
|
|
133
|
-
</DialogContent>
|
|
134
|
-
<DialogActions sx={{ justifyContent: "space-between", px: 3 }}>
|
|
135
|
-
<Box>
|
|
69
|
+
title={currentSchedule ? "Edit schedule" : "Set schedule"}
|
|
70
|
+
description="The publisher rebuilds this package's materializations on this cadence: a 5-field UNIX cron, in UTC. In a hosted deployment the change takes effect on your next publish."
|
|
71
|
+
actions={
|
|
72
|
+
<>
|
|
136
73
|
{currentSchedule && (
|
|
137
74
|
<Button
|
|
138
75
|
color="error"
|
|
139
76
|
loading={isSubmitting}
|
|
140
77
|
onClick={() => submit(null)}
|
|
78
|
+
// The destructive option sits away from the pair that
|
|
79
|
+
// confirms and cancels.
|
|
80
|
+
sx={{ mr: "auto" }}
|
|
141
81
|
>
|
|
142
82
|
Clear schedule
|
|
143
83
|
</Button>
|
|
144
84
|
)}
|
|
145
|
-
</Box>
|
|
146
|
-
<Box>
|
|
147
85
|
<Button onClick={handleClose}>Cancel</Button>
|
|
148
86
|
<Button
|
|
149
87
|
variant="contained"
|
|
150
88
|
loading={isSubmitting}
|
|
151
89
|
disabled={!info.valid}
|
|
152
90
|
onClick={() => submit(expr.trim())}
|
|
153
|
-
sx={{ ml: 1 }}
|
|
154
91
|
>
|
|
155
|
-
Save
|
|
92
|
+
Save schedule
|
|
156
93
|
</Button>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
94
|
+
</>
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
<TextField
|
|
98
|
+
autoFocus
|
|
99
|
+
fullWidth
|
|
100
|
+
size="small"
|
|
101
|
+
label="Cron expression"
|
|
102
|
+
value={expr}
|
|
103
|
+
onChange={(event) => setExpr(event.target.value)}
|
|
104
|
+
error={expr.trim() !== "" && !info.valid}
|
|
105
|
+
helperText={
|
|
106
|
+
info.valid
|
|
107
|
+
? `${info.description} · next run ${formatNextRun(info.nextRun)}`
|
|
108
|
+
: info.error
|
|
109
|
+
}
|
|
110
|
+
slotProps={{
|
|
111
|
+
htmlInput: { style: { fontFamily: MONO_FONT_FAMILY } },
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
<Alert severity="info">
|
|
115
|
+
A schedule runs only on version-scoped packages, so saving one
|
|
116
|
+
sets <code>scope: version</code> for this package.
|
|
117
|
+
</Alert>
|
|
118
|
+
</AppDialog>
|
|
160
119
|
</>
|
|
161
120
|
);
|
|
162
121
|
}
|