@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,19 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import CloseIcon from "@mui/icons-material/Close";
|
|
4
|
+
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
6
5
|
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
|
|
7
6
|
import {
|
|
8
7
|
Alert,
|
|
9
8
|
Box,
|
|
10
9
|
Container,
|
|
11
|
-
Dialog,
|
|
12
|
-
DialogContent,
|
|
13
|
-
DialogTitle,
|
|
14
10
|
IconButton,
|
|
15
|
-
Link,
|
|
16
|
-
Stack,
|
|
17
11
|
Table,
|
|
18
12
|
TableBody,
|
|
19
13
|
TableCell,
|
|
@@ -22,20 +16,29 @@ import {
|
|
|
22
16
|
Tooltip,
|
|
23
17
|
Typography,
|
|
24
18
|
} from "@mui/material";
|
|
25
|
-
import
|
|
19
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
20
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
26
21
|
import { Database } from "../../client";
|
|
27
22
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
28
23
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
29
24
|
import { Loading } from "../Loading";
|
|
25
|
+
import type { DocumentLocator } from "../DocumentStorage/DocumentStorage";
|
|
26
|
+
import { useOptionalDocumentStorage } from "../DocumentStorage/DocumentStorageProvider";
|
|
30
27
|
import { Notebook } from "../Notebook";
|
|
31
28
|
import { useServer } from "../ServerProvider";
|
|
29
|
+
import { NewDashboardDialog } from "./NewDashboardDialog";
|
|
32
30
|
import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
|
|
33
31
|
import { serverBaseUrl } from "../../utils/dataAppEmbed";
|
|
34
|
-
import { MONO_FONT_FAMILY } from "../styles";
|
|
35
32
|
import ContentTypeIcon, {
|
|
36
33
|
CONTENT_TINT,
|
|
37
34
|
type ContentType,
|
|
38
35
|
} from "./ContentTypeIcon";
|
|
36
|
+
import { AddButton } from "../buttons";
|
|
37
|
+
import { AppDialog } from "../AppDialog";
|
|
38
|
+
import { BackLink } from "../BackLink";
|
|
39
|
+
import { ItemRow } from "../ItemRow";
|
|
40
|
+
import { Materializations } from "../Materializations";
|
|
41
|
+
import { PackageSection } from "../PackageSection";
|
|
39
42
|
|
|
40
43
|
const README_NOTEBOOK = "README.malloynb";
|
|
41
44
|
|
|
@@ -48,7 +51,8 @@ export default function Package({
|
|
|
48
51
|
onClickPackageFile,
|
|
49
52
|
resourceUri,
|
|
50
53
|
}: PackageProps) {
|
|
51
|
-
const { apiClients, server } = useServer();
|
|
54
|
+
const { apiClients, server, mutable } = useServer();
|
|
55
|
+
const queryClient = useQueryClient();
|
|
52
56
|
const onClick =
|
|
53
57
|
onClickPackageFile ??
|
|
54
58
|
((to: string) => {
|
|
@@ -58,6 +62,30 @@ export default function Package({
|
|
|
58
62
|
parseResourceUri(resourceUri);
|
|
59
63
|
|
|
60
64
|
const [schemaDatabase, setSchemaDatabase] = useState<Database | null>(null);
|
|
65
|
+
const [creating, setCreating] = useState(false);
|
|
66
|
+
|
|
67
|
+
// Dashboards saved in this browser and not (yet) in the package: the
|
|
68
|
+
// builder's drafts, listed so they are found rather than stumbled on.
|
|
69
|
+
const storage = useOptionalDocumentStorage()?.documentStorage;
|
|
70
|
+
const [drafts, setDrafts] = useState<DocumentLocator[]>([]);
|
|
71
|
+
const draftPrefix = `${environmentName}/${packageName}/dashboards/`;
|
|
72
|
+
const refreshDrafts = useCallback(async () => {
|
|
73
|
+
if (!storage) return;
|
|
74
|
+
const workspaces = await storage.listWorkspaces(true);
|
|
75
|
+
const found: DocumentLocator[] = [];
|
|
76
|
+
for (const workspace of workspaces)
|
|
77
|
+
for (const locator of await storage.listDocuments(
|
|
78
|
+
workspace,
|
|
79
|
+
"dashboard",
|
|
80
|
+
))
|
|
81
|
+
if (locator.path.startsWith(draftPrefix)) found.push(locator);
|
|
82
|
+
setDrafts(found);
|
|
83
|
+
}, [storage, draftPrefix]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
void refreshDrafts();
|
|
86
|
+
}, [refreshDrafts]);
|
|
87
|
+
const draftSlug = (locator: DocumentLocator) =>
|
|
88
|
+
locator.path.slice(draftPrefix.length).replace(/\.malloy$/, "");
|
|
61
89
|
|
|
62
90
|
const pkgQuery = useQueryWithApiError({
|
|
63
91
|
queryKey: ["package", environmentName, packageName, versionId],
|
|
@@ -243,25 +271,10 @@ export default function Package({
|
|
|
243
271
|
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
244
272
|
>
|
|
245
273
|
<Box sx={{ mb: 4 }}>
|
|
246
|
-
<
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
underline="none"
|
|
251
|
-
sx={{
|
|
252
|
-
display: "inline-flex",
|
|
253
|
-
alignItems: "center",
|
|
254
|
-
gap: 0.5,
|
|
255
|
-
cursor: "pointer",
|
|
256
|
-
color: "text.secondary",
|
|
257
|
-
fontSize: "0.875rem",
|
|
258
|
-
mb: 2,
|
|
259
|
-
"&:hover": { color: "primary.main" },
|
|
260
|
-
}}
|
|
261
|
-
>
|
|
262
|
-
<ArrowBackIcon sx={{ fontSize: 18 }} />
|
|
263
|
-
Back to {environmentName}
|
|
264
|
-
</Link>
|
|
274
|
+
<BackLink
|
|
275
|
+
label={environmentName}
|
|
276
|
+
onClick={(event) => onClick(`/${environmentName}/`, event)}
|
|
277
|
+
/>
|
|
265
278
|
<Typography
|
|
266
279
|
variant="h4"
|
|
267
280
|
component="h1"
|
|
@@ -282,6 +295,31 @@ export default function Package({
|
|
|
282
295
|
|
|
283
296
|
{isLoading && <Loading text="Loading package..." />}
|
|
284
297
|
|
|
298
|
+
<NewDashboardDialog
|
|
299
|
+
open={creating}
|
|
300
|
+
environmentName={environmentName}
|
|
301
|
+
packageName={packageName}
|
|
302
|
+
models={models
|
|
303
|
+
.map((model) => model.path)
|
|
304
|
+
.filter(
|
|
305
|
+
(path): path is string =>
|
|
306
|
+
typeof path === "string" &&
|
|
307
|
+
path.endsWith(".malloy") &&
|
|
308
|
+
!path.startsWith("dashboards/"),
|
|
309
|
+
)}
|
|
310
|
+
existing={dashboards
|
|
311
|
+
.map((dashboard) => dashboard.name)
|
|
312
|
+
.filter((name): name is string => typeof name === "string")}
|
|
313
|
+
onClose={() => setCreating(false)}
|
|
314
|
+
onCreated={(slug) => {
|
|
315
|
+
setCreating(false);
|
|
316
|
+
void queryClient.invalidateQueries({ queryKey: ["dashboards"] });
|
|
317
|
+
onClick(
|
|
318
|
+
`/${environmentName}/${packageName}/dashboards/${encodeURIComponent(slug)}/edit`,
|
|
319
|
+
);
|
|
320
|
+
}}
|
|
321
|
+
/>
|
|
322
|
+
|
|
285
323
|
{!isLoading && (
|
|
286
324
|
<>
|
|
287
325
|
{/* First: the at-a-glance artifact a visitor most likely wants,
|
|
@@ -296,15 +334,6 @@ export default function Package({
|
|
|
296
334
|
has no dashboards" is the wrong thing to conclude from a
|
|
297
335
|
transport error. The 404 above stays swallowed: that one is
|
|
298
336
|
an older Publisher with no route, which genuinely has none. */}
|
|
299
|
-
{/* A listing that FAILED renders identically to a package with
|
|
300
|
-
no dashboards: `dashboards` falls back to `[]` and the
|
|
301
|
-
section hides itself. Only `pkgQuery` reaches the error page,
|
|
302
|
-
so nothing else here would say a word. Now that the listing
|
|
303
|
-
carries a `versionId`, a host that resolves it on some routes
|
|
304
|
-
and refuses it on others has a new way in, and "this package
|
|
305
|
-
has no dashboards" is the wrong thing to conclude from a
|
|
306
|
-
transport error. The 404 above stays swallowed: that one is
|
|
307
|
-
an older Publisher with no route, which genuinely has none. */}
|
|
308
337
|
{dashboardsQuery.isError && (
|
|
309
338
|
<Box sx={{ mb: 4 }}>
|
|
310
339
|
<Alert severity="warning">
|
|
@@ -313,8 +342,22 @@ export default function Package({
|
|
|
313
342
|
</Alert>
|
|
314
343
|
</Box>
|
|
315
344
|
)}
|
|
316
|
-
{dashboards.length > 0 && (
|
|
317
|
-
<PackageSection
|
|
345
|
+
{(dashboards.length > 0 || mutable) && (
|
|
346
|
+
<PackageSection
|
|
347
|
+
title="Dashboards"
|
|
348
|
+
count={dashboards.length}
|
|
349
|
+
action={
|
|
350
|
+
mutable ? (
|
|
351
|
+
<AddButton
|
|
352
|
+
label="Dashboard"
|
|
353
|
+
onClick={() => setCreating(true)}
|
|
354
|
+
/>
|
|
355
|
+
) : undefined
|
|
356
|
+
}
|
|
357
|
+
>
|
|
358
|
+
{dashboards.length === 0 && (
|
|
359
|
+
<EmptyRow label="No dashboards yet" />
|
|
360
|
+
)}
|
|
318
361
|
{dashboards.map((dashboard) => {
|
|
319
362
|
// A title equal to the slug is what the server falls
|
|
320
363
|
// back to when the file names itself neither way, so
|
|
@@ -346,32 +389,71 @@ export default function Package({
|
|
|
346
389
|
})}
|
|
347
390
|
</PackageSection>
|
|
348
391
|
)}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
// Named the way dashboards and data apps are: a notebook
|
|
353
|
-
// that titles itself is listed by that title, with the
|
|
354
|
-
// filename kept as the secondary label so the path a
|
|
355
|
-
// reader needs to find the file is never lost.
|
|
356
|
-
const hasTitle =
|
|
357
|
-
!!notebook.title && notebook.title !== notebook.path;
|
|
358
|
-
return (
|
|
392
|
+
{drafts.length > 0 && (
|
|
393
|
+
<PackageSection title="Drafts" count={drafts.length}>
|
|
394
|
+
{drafts.map((locator) => (
|
|
359
395
|
<PackageItemRow
|
|
360
|
-
key={
|
|
361
|
-
type="
|
|
362
|
-
label={
|
|
363
|
-
rightLabel=
|
|
396
|
+
key={locator.path}
|
|
397
|
+
type="dashboard"
|
|
398
|
+
label={draftSlug(locator)}
|
|
399
|
+
rightLabel="saved in this browser"
|
|
364
400
|
onClick={(event) =>
|
|
365
401
|
onClick(
|
|
366
|
-
`/${environmentName}/${packageName}/${
|
|
402
|
+
`/${environmentName}/${packageName}/dashboards/${encodeURIComponent(draftSlug(locator))}/edit`,
|
|
367
403
|
event,
|
|
368
404
|
)
|
|
369
405
|
}
|
|
406
|
+
trailingAction={
|
|
407
|
+
<Tooltip title="Delete this draft">
|
|
408
|
+
<IconButton
|
|
409
|
+
size="small"
|
|
410
|
+
aria-label={`Delete draft ${draftSlug(locator)}`}
|
|
411
|
+
onClick={(event) => {
|
|
412
|
+
event.stopPropagation();
|
|
413
|
+
void storage
|
|
414
|
+
?.deleteDocument(locator)
|
|
415
|
+
.then(refreshDrafts);
|
|
416
|
+
}}
|
|
417
|
+
>
|
|
418
|
+
<DeleteOutlineIcon fontSize="small" />
|
|
419
|
+
</IconButton>
|
|
420
|
+
</Tooltip>
|
|
421
|
+
}
|
|
370
422
|
/>
|
|
371
|
-
)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
423
|
+
))}
|
|
424
|
+
</PackageSection>
|
|
425
|
+
)}
|
|
426
|
+
|
|
427
|
+
{/* Hidden when empty, like Dashboards and Data Apps. A package
|
|
428
|
+
that holds no notebooks is not a package missing them, and a
|
|
429
|
+
heading over the words "No notebooks" is a row of furniture
|
|
430
|
+
saying nothing. */}
|
|
431
|
+
{notebooks.length > 0 && (
|
|
432
|
+
<PackageSection title="Notebooks" count={notebooks.length}>
|
|
433
|
+
{notebooks.map((notebook) => {
|
|
434
|
+
// Named the way dashboards and data apps are: a notebook
|
|
435
|
+
// that titles itself is listed by that title, with the
|
|
436
|
+
// filename kept as the secondary label so the path a
|
|
437
|
+
// reader needs to find the file is never lost.
|
|
438
|
+
const hasTitle =
|
|
439
|
+
!!notebook.title && notebook.title !== notebook.path;
|
|
440
|
+
return (
|
|
441
|
+
<PackageItemRow
|
|
442
|
+
key={notebook.path}
|
|
443
|
+
type="report"
|
|
444
|
+
label={hasTitle ? notebook.title! : notebook.path}
|
|
445
|
+
rightLabel={hasTitle ? notebook.path : undefined}
|
|
446
|
+
onClick={(event) =>
|
|
447
|
+
onClick(
|
|
448
|
+
`/${environmentName}/${packageName}/${notebook.path}`,
|
|
449
|
+
event,
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
/>
|
|
453
|
+
);
|
|
454
|
+
})}
|
|
455
|
+
</PackageSection>
|
|
456
|
+
)}
|
|
375
457
|
|
|
376
458
|
{dataApps.length > 0 && (
|
|
377
459
|
<PackageSection title="Data Apps" count={dataApps.length}>
|
|
@@ -475,18 +557,7 @@ export default function Package({
|
|
|
475
557
|
{databases.length === 0 && <EmptyRow label="No data files" />}
|
|
476
558
|
</PackageSection>
|
|
477
559
|
|
|
478
|
-
<
|
|
479
|
-
<PackageItemRow
|
|
480
|
-
type="materialization"
|
|
481
|
-
label="Materializations"
|
|
482
|
-
onClick={(event) =>
|
|
483
|
-
onClick(
|
|
484
|
-
`/${environmentName}/${packageName}/materializations`,
|
|
485
|
-
event,
|
|
486
|
-
)
|
|
487
|
-
}
|
|
488
|
-
/>
|
|
489
|
-
</PackageSection>
|
|
560
|
+
<Materializations resourceUri={resourceUri} />
|
|
490
561
|
|
|
491
562
|
{hasReadme && (
|
|
492
563
|
<Box sx={{ mt: 6 }}>
|
|
@@ -499,98 +570,42 @@ export default function Package({
|
|
|
499
570
|
</>
|
|
500
571
|
)}
|
|
501
572
|
|
|
502
|
-
<
|
|
573
|
+
<AppDialog
|
|
503
574
|
open={schemaDatabase !== null}
|
|
504
575
|
onClose={() => setSchemaDatabase(null)}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
>
|
|
508
|
-
<DialogTitle sx={{ pr: 6 }}>
|
|
509
|
-
{schemaDatabase?.path}
|
|
510
|
-
<IconButton
|
|
511
|
-
aria-label="close"
|
|
512
|
-
onClick={() => setSchemaDatabase(null)}
|
|
513
|
-
sx={{ position: "absolute", right: 8, top: 8 }}
|
|
514
|
-
>
|
|
515
|
-
<CloseIcon fontSize="small" />
|
|
516
|
-
</IconButton>
|
|
517
|
-
</DialogTitle>
|
|
518
|
-
<DialogContent>
|
|
519
|
-
{schemaDatabase?.error && (
|
|
520
|
-
<Typography variant="body2" color="error">
|
|
521
|
-
{schemaDatabase.error}
|
|
522
|
-
</Typography>
|
|
523
|
-
)}
|
|
524
|
-
{schemaDatabase?.info?.columns && (
|
|
525
|
-
<Table size="small">
|
|
526
|
-
<TableHead>
|
|
527
|
-
<TableRow>
|
|
528
|
-
<TableCell>Column</TableCell>
|
|
529
|
-
<TableCell>Type</TableCell>
|
|
530
|
-
</TableRow>
|
|
531
|
-
</TableHead>
|
|
532
|
-
<TableBody>
|
|
533
|
-
{schemaDatabase.info.columns.map((column) => (
|
|
534
|
-
<TableRow key={column.name}>
|
|
535
|
-
<TableCell component="th" scope="row">
|
|
536
|
-
{column.name}
|
|
537
|
-
</TableCell>
|
|
538
|
-
<TableCell>{column.type}</TableCell>
|
|
539
|
-
</TableRow>
|
|
540
|
-
))}
|
|
541
|
-
</TableBody>
|
|
542
|
-
</Table>
|
|
543
|
-
)}
|
|
544
|
-
</DialogContent>
|
|
545
|
-
</Dialog>
|
|
546
|
-
</Container>
|
|
547
|
-
);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
function PackageSection({
|
|
551
|
-
title,
|
|
552
|
-
count,
|
|
553
|
-
children,
|
|
554
|
-
}: {
|
|
555
|
-
title: string;
|
|
556
|
-
count?: number;
|
|
557
|
-
children: React.ReactNode;
|
|
558
|
-
}) {
|
|
559
|
-
return (
|
|
560
|
-
<Box sx={{ mb: 4 }}>
|
|
561
|
-
<Stack
|
|
562
|
-
direction="row"
|
|
563
|
-
alignItems="baseline"
|
|
564
|
-
spacing={1}
|
|
565
|
-
sx={{ mb: 1 }}
|
|
576
|
+
title={schemaDatabase?.path ?? "Columns"}
|
|
577
|
+
showClose
|
|
566
578
|
>
|
|
567
|
-
|
|
568
|
-
variant="
|
|
569
|
-
|
|
570
|
-
>
|
|
571
|
-
{title}
|
|
572
|
-
</Typography>
|
|
573
|
-
{count !== undefined && (
|
|
574
|
-
<Typography variant="caption" color="text.secondary">
|
|
575
|
-
({count})
|
|
579
|
+
{schemaDatabase?.error && (
|
|
580
|
+
<Typography variant="body2" color="error">
|
|
581
|
+
{schemaDatabase.error}
|
|
576
582
|
</Typography>
|
|
577
583
|
)}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
584
|
+
{schemaDatabase?.info?.columns && (
|
|
585
|
+
<Table size="small">
|
|
586
|
+
<TableHead>
|
|
587
|
+
<TableRow>
|
|
588
|
+
<TableCell>Column</TableCell>
|
|
589
|
+
<TableCell>Type</TableCell>
|
|
590
|
+
</TableRow>
|
|
591
|
+
</TableHead>
|
|
592
|
+
<TableBody>
|
|
593
|
+
{schemaDatabase.info.columns.map((column) => (
|
|
594
|
+
<TableRow key={column.name}>
|
|
595
|
+
<TableCell component="th" scope="row">
|
|
596
|
+
{column.name}
|
|
597
|
+
</TableCell>
|
|
598
|
+
<TableCell>{column.type}</TableCell>
|
|
599
|
+
</TableRow>
|
|
600
|
+
))}
|
|
601
|
+
</TableBody>
|
|
602
|
+
</Table>
|
|
603
|
+
)}
|
|
604
|
+
</AppDialog>
|
|
605
|
+
</Container>
|
|
581
606
|
);
|
|
582
607
|
}
|
|
583
608
|
|
|
584
|
-
/**
|
|
585
|
-
* A row names its content type once. The glyph and the color behind it are two
|
|
586
|
-
* halves of one signal, so the row derives both rather than letting a caller
|
|
587
|
-
* pair a dashboard's icon with a model's color.
|
|
588
|
-
*
|
|
589
|
-
* That is not hypothetical tidying: with the two passed separately, four of the
|
|
590
|
-
* six rows on this page had been handed the same teal, so color told a reader
|
|
591
|
-
* nothing about four of the kinds it was there to distinguish. A rule each call
|
|
592
|
-
* site has to remember is a rule some call sites will forget.
|
|
593
|
-
*/
|
|
594
609
|
function PackageItemRow({
|
|
595
610
|
type,
|
|
596
611
|
label,
|
|
@@ -607,90 +622,16 @@ function PackageItemRow({
|
|
|
607
622
|
* `event.stopPropagation()` so the row click doesn't also fire. */
|
|
608
623
|
trailingAction?: React.ReactNode;
|
|
609
624
|
}) {
|
|
610
|
-
const interactive = !!onClick;
|
|
611
|
-
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
612
|
-
if (!onClick) return;
|
|
613
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
614
|
-
event.preventDefault();
|
|
615
|
-
onClick(event as unknown as React.MouseEvent);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
625
|
return (
|
|
619
|
-
<
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
py: 1,
|
|
629
|
-
px: 1,
|
|
630
|
-
mx: -1,
|
|
631
|
-
cursor: interactive ? "pointer" : "default",
|
|
632
|
-
borderRadius: 1.5,
|
|
633
|
-
transition: "background-color 0.1s",
|
|
634
|
-
"&:hover": interactive
|
|
635
|
-
? {
|
|
636
|
-
backgroundColor:
|
|
637
|
-
theme.palette.mode === "dark"
|
|
638
|
-
? "rgba(255, 255, 255, 0.08)"
|
|
639
|
-
: "grey.100",
|
|
640
|
-
}
|
|
641
|
-
: undefined,
|
|
642
|
-
"&:focus-visible": interactive
|
|
643
|
-
? {
|
|
644
|
-
outline: "2px solid",
|
|
645
|
-
outlineColor: "primary.main",
|
|
646
|
-
outlineOffset: 2,
|
|
647
|
-
}
|
|
648
|
-
: undefined,
|
|
649
|
-
})}
|
|
650
|
-
>
|
|
651
|
-
<Box
|
|
652
|
-
sx={{
|
|
653
|
-
width: 32,
|
|
654
|
-
height: 32,
|
|
655
|
-
borderRadius: 1,
|
|
656
|
-
bgcolor: CONTENT_TINT[type],
|
|
657
|
-
color: "#FFFFFF",
|
|
658
|
-
display: "flex",
|
|
659
|
-
alignItems: "center",
|
|
660
|
-
justifyContent: "center",
|
|
661
|
-
flexShrink: 0,
|
|
662
|
-
}}
|
|
663
|
-
>
|
|
664
|
-
<ContentTypeIcon type={type} />
|
|
665
|
-
</Box>
|
|
666
|
-
<Typography
|
|
667
|
-
variant="body2"
|
|
668
|
-
sx={{
|
|
669
|
-
fontFamily: MONO_FONT_FAMILY,
|
|
670
|
-
flex: 1,
|
|
671
|
-
minWidth: 0,
|
|
672
|
-
overflow: "hidden",
|
|
673
|
-
textOverflow: "ellipsis",
|
|
674
|
-
whiteSpace: "nowrap",
|
|
675
|
-
}}
|
|
676
|
-
>
|
|
677
|
-
{label}
|
|
678
|
-
</Typography>
|
|
679
|
-
{rightLabel && (
|
|
680
|
-
<Typography
|
|
681
|
-
variant="caption"
|
|
682
|
-
color="text.secondary"
|
|
683
|
-
sx={{ flexShrink: 0 }}
|
|
684
|
-
>
|
|
685
|
-
{rightLabel}
|
|
686
|
-
</Typography>
|
|
687
|
-
)}
|
|
688
|
-
{trailingAction && (
|
|
689
|
-
<Box sx={{ flexShrink: 0, display: "flex", alignItems: "center" }}>
|
|
690
|
-
{trailingAction}
|
|
691
|
-
</Box>
|
|
692
|
-
)}
|
|
693
|
-
</Box>
|
|
626
|
+
<ItemRow
|
|
627
|
+
icon={<ContentTypeIcon type={type} />}
|
|
628
|
+
tint={CONTENT_TINT[type]}
|
|
629
|
+
label={label}
|
|
630
|
+
mono
|
|
631
|
+
{...(rightLabel === undefined ? {} : { rightLabel })}
|
|
632
|
+
{...(onClick === undefined ? {} : { onClick })}
|
|
633
|
+
{...(trailingAction === undefined ? {} : { trailingAction })}
|
|
634
|
+
/>
|
|
694
635
|
);
|
|
695
636
|
}
|
|
696
637
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Box, Stack, Typography } from "@mui/material";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One titled section of a page: a heading, how many things are in it, what they
|
|
10
|
+
* are, and the control that adds one.
|
|
11
|
+
*
|
|
12
|
+
* Every section on every page is this component, so moving between a package
|
|
13
|
+
* and the environment above it does not restate the same heading at a different
|
|
14
|
+
* size, indent or gap.
|
|
15
|
+
*
|
|
16
|
+
* The section is a landmark named by its own heading, which is what makes
|
|
17
|
+
* "Dashboards" addressable — to a screen reader moving by region, and to a test
|
|
18
|
+
* that wants the dashboards list rather than every row on the page that happens
|
|
19
|
+
* to share a word with it.
|
|
20
|
+
*/
|
|
21
|
+
export function PackageSection({
|
|
22
|
+
title,
|
|
23
|
+
count,
|
|
24
|
+
description,
|
|
25
|
+
action,
|
|
26
|
+
children,
|
|
27
|
+
}: {
|
|
28
|
+
title: string;
|
|
29
|
+
count?: number;
|
|
30
|
+
/** What the section holds, in a line, under the heading. */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** A control on the heading's row, hard right. */
|
|
33
|
+
action?: React.ReactNode;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
}) {
|
|
36
|
+
const titleId = useId();
|
|
37
|
+
return (
|
|
38
|
+
<Box component="section" aria-labelledby={titleId} sx={{ mb: 4 }}>
|
|
39
|
+
<Stack
|
|
40
|
+
direction="row"
|
|
41
|
+
alignItems="center"
|
|
42
|
+
justifyContent="space-between"
|
|
43
|
+
// Tall enough for the section's add button whether or not it has
|
|
44
|
+
// one, so a section with nothing to add does not sit tighter than
|
|
45
|
+
// its neighbours. The action is pushed right by the layout rather
|
|
46
|
+
// than by a margin on itself: `Stack`'s own spacing rule outranks
|
|
47
|
+
// an `ml: auto` on a child, which is how the button ended up
|
|
48
|
+
// beside the heading instead of at the edge.
|
|
49
|
+
sx={{ mb: description ? 0 : 1, minHeight: 40 }}
|
|
50
|
+
>
|
|
51
|
+
<Stack direction="row" alignItems="baseline" spacing={1}>
|
|
52
|
+
<Typography
|
|
53
|
+
id={titleId}
|
|
54
|
+
variant="h6"
|
|
55
|
+
sx={{
|
|
56
|
+
fontWeight: 600,
|
|
57
|
+
letterSpacing: "-0.025em",
|
|
58
|
+
// The heading's box is centred against the buttons, but
|
|
59
|
+
// its ink is not: at the theme's 1.6 line height the
|
|
60
|
+
// leading sits mostly under a word with no descenders, so
|
|
61
|
+
// the title reads as riding high. Trim the box to the
|
|
62
|
+
// glyphs and the two line up by eye as well as by
|
|
63
|
+
// measurement.
|
|
64
|
+
lineHeight: 1.2,
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
{title}
|
|
68
|
+
</Typography>
|
|
69
|
+
{count !== undefined && (
|
|
70
|
+
<Typography variant="caption" color="text.secondary">
|
|
71
|
+
({count})
|
|
72
|
+
</Typography>
|
|
73
|
+
)}
|
|
74
|
+
</Stack>
|
|
75
|
+
{action}
|
|
76
|
+
</Stack>
|
|
77
|
+
{description && (
|
|
78
|
+
<Typography variant="body2" color="text.secondary" sx={{ mb: 1.5 }}>
|
|
79
|
+
{description}
|
|
80
|
+
</Typography>
|
|
81
|
+
)}
|
|
82
|
+
<Box>{children}</Box>
|
|
83
|
+
</Box>
|
|
84
|
+
);
|
|
85
|
+
}
|