@malloy-publisher/sdk 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.
- package/README.md +33 -9
- package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
- package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
- package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
- package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
- 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 +52 -52
- package/dist/builder/index.es.js +3961 -3960
- 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 +24 -7
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
- package/dist/components/DocumentStorage/index.d.ts +1 -0
- 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 +17431 -20676
- 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 +24 -5
- 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 +202 -171
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
- 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 +442 -94
- 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/DocumentStorage/BrowserDocumentStorage.ts +7 -6
- package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
- package/src/components/DocumentStorage/index.ts +1 -0
- 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 +184 -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/RenderedResult-CPi6uQWq.cjs.js +0 -115
- 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,35 @@ 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 the host keeps for this package and the package does not have:
|
|
68
|
+
// the builder's drafts, listed so they are found rather than stumbled on.
|
|
69
|
+
// Each carries the workspace's own description, because where a document is
|
|
70
|
+
// kept is the backend's to say and only one host's answer is "this browser".
|
|
71
|
+
const storage = useOptionalDocumentStorage()?.documentStorage;
|
|
72
|
+
const [drafts, setDrafts] = useState<
|
|
73
|
+
{ locator: DocumentLocator; where: string }[]
|
|
74
|
+
>([]);
|
|
75
|
+
const draftPrefix = `${environmentName}/${packageName}/dashboards/`;
|
|
76
|
+
const refreshDrafts = useCallback(async () => {
|
|
77
|
+
if (!storage) return;
|
|
78
|
+
const workspaces = await storage.listWorkspaces(true);
|
|
79
|
+
const found: { locator: DocumentLocator; where: string }[] = [];
|
|
80
|
+
for (const workspace of workspaces)
|
|
81
|
+
for (const locator of await storage.listDocuments(
|
|
82
|
+
workspace,
|
|
83
|
+
"dashboard",
|
|
84
|
+
))
|
|
85
|
+
if (locator.path.startsWith(draftPrefix))
|
|
86
|
+
found.push({ locator, where: workspace.description });
|
|
87
|
+
setDrafts(found);
|
|
88
|
+
}, [storage, draftPrefix]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
void refreshDrafts();
|
|
91
|
+
}, [refreshDrafts]);
|
|
92
|
+
const draftSlug = (locator: DocumentLocator) =>
|
|
93
|
+
locator.path.slice(draftPrefix.length).replace(/\.malloy$/, "");
|
|
61
94
|
|
|
62
95
|
const pkgQuery = useQueryWithApiError({
|
|
63
96
|
queryKey: ["package", environmentName, packageName, versionId],
|
|
@@ -243,25 +276,10 @@ export default function Package({
|
|
|
243
276
|
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
244
277
|
>
|
|
245
278
|
<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>
|
|
279
|
+
<BackLink
|
|
280
|
+
label={environmentName}
|
|
281
|
+
onClick={(event) => onClick(`/${environmentName}/`, event)}
|
|
282
|
+
/>
|
|
265
283
|
<Typography
|
|
266
284
|
variant="h4"
|
|
267
285
|
component="h1"
|
|
@@ -282,6 +300,31 @@ export default function Package({
|
|
|
282
300
|
|
|
283
301
|
{isLoading && <Loading text="Loading package..." />}
|
|
284
302
|
|
|
303
|
+
<NewDashboardDialog
|
|
304
|
+
open={creating}
|
|
305
|
+
environmentName={environmentName}
|
|
306
|
+
packageName={packageName}
|
|
307
|
+
models={models
|
|
308
|
+
.map((model) => model.path)
|
|
309
|
+
.filter(
|
|
310
|
+
(path): path is string =>
|
|
311
|
+
typeof path === "string" &&
|
|
312
|
+
path.endsWith(".malloy") &&
|
|
313
|
+
!path.startsWith("dashboards/"),
|
|
314
|
+
)}
|
|
315
|
+
existing={dashboards
|
|
316
|
+
.map((dashboard) => dashboard.name)
|
|
317
|
+
.filter((name): name is string => typeof name === "string")}
|
|
318
|
+
onClose={() => setCreating(false)}
|
|
319
|
+
onCreated={(slug) => {
|
|
320
|
+
setCreating(false);
|
|
321
|
+
void queryClient.invalidateQueries({ queryKey: ["dashboards"] });
|
|
322
|
+
onClick(
|
|
323
|
+
`/${environmentName}/${packageName}/dashboards/${encodeURIComponent(slug)}/edit`,
|
|
324
|
+
);
|
|
325
|
+
}}
|
|
326
|
+
/>
|
|
327
|
+
|
|
285
328
|
{!isLoading && (
|
|
286
329
|
<>
|
|
287
330
|
{/* First: the at-a-glance artifact a visitor most likely wants,
|
|
@@ -296,15 +339,6 @@ export default function Package({
|
|
|
296
339
|
has no dashboards" is the wrong thing to conclude from a
|
|
297
340
|
transport error. The 404 above stays swallowed: that one is
|
|
298
341
|
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
342
|
{dashboardsQuery.isError && (
|
|
309
343
|
<Box sx={{ mb: 4 }}>
|
|
310
344
|
<Alert severity="warning">
|
|
@@ -313,8 +347,22 @@ export default function Package({
|
|
|
313
347
|
</Alert>
|
|
314
348
|
</Box>
|
|
315
349
|
)}
|
|
316
|
-
{dashboards.length > 0 && (
|
|
317
|
-
<PackageSection
|
|
350
|
+
{(dashboards.length > 0 || mutable) && (
|
|
351
|
+
<PackageSection
|
|
352
|
+
title="Dashboards"
|
|
353
|
+
count={dashboards.length}
|
|
354
|
+
action={
|
|
355
|
+
mutable ? (
|
|
356
|
+
<AddButton
|
|
357
|
+
label="Dashboard"
|
|
358
|
+
onClick={() => setCreating(true)}
|
|
359
|
+
/>
|
|
360
|
+
) : undefined
|
|
361
|
+
}
|
|
362
|
+
>
|
|
363
|
+
{dashboards.length === 0 && (
|
|
364
|
+
<EmptyRow label="No dashboards yet" />
|
|
365
|
+
)}
|
|
318
366
|
{dashboards.map((dashboard) => {
|
|
319
367
|
// A title equal to the slug is what the server falls
|
|
320
368
|
// back to when the file names itself neither way, so
|
|
@@ -346,32 +394,71 @@ export default function Package({
|
|
|
346
394
|
})}
|
|
347
395
|
</PackageSection>
|
|
348
396
|
)}
|
|
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 (
|
|
397
|
+
{drafts.length > 0 && (
|
|
398
|
+
<PackageSection title="Drafts" count={drafts.length}>
|
|
399
|
+
{drafts.map(({ locator, where }) => (
|
|
359
400
|
<PackageItemRow
|
|
360
|
-
key={
|
|
361
|
-
type="
|
|
362
|
-
label={
|
|
363
|
-
rightLabel={
|
|
401
|
+
key={locator.path}
|
|
402
|
+
type="dashboard"
|
|
403
|
+
label={draftSlug(locator)}
|
|
404
|
+
rightLabel={where}
|
|
364
405
|
onClick={(event) =>
|
|
365
406
|
onClick(
|
|
366
|
-
`/${environmentName}/${packageName}/${
|
|
407
|
+
`/${environmentName}/${packageName}/dashboards/${encodeURIComponent(draftSlug(locator))}/edit`,
|
|
367
408
|
event,
|
|
368
409
|
)
|
|
369
410
|
}
|
|
411
|
+
trailingAction={
|
|
412
|
+
<Tooltip title="Delete this draft">
|
|
413
|
+
<IconButton
|
|
414
|
+
size="small"
|
|
415
|
+
aria-label={`Delete draft ${draftSlug(locator)}`}
|
|
416
|
+
onClick={(event) => {
|
|
417
|
+
event.stopPropagation();
|
|
418
|
+
void storage
|
|
419
|
+
?.deleteDocument(locator)
|
|
420
|
+
.then(refreshDrafts);
|
|
421
|
+
}}
|
|
422
|
+
>
|
|
423
|
+
<DeleteOutlineIcon fontSize="small" />
|
|
424
|
+
</IconButton>
|
|
425
|
+
</Tooltip>
|
|
426
|
+
}
|
|
370
427
|
/>
|
|
371
|
-
)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
428
|
+
))}
|
|
429
|
+
</PackageSection>
|
|
430
|
+
)}
|
|
431
|
+
|
|
432
|
+
{/* Hidden when empty, like Dashboards and Data Apps. A package
|
|
433
|
+
that holds no notebooks is not a package missing them, and a
|
|
434
|
+
heading over the words "No notebooks" is a row of furniture
|
|
435
|
+
saying nothing. */}
|
|
436
|
+
{notebooks.length > 0 && (
|
|
437
|
+
<PackageSection title="Notebooks" count={notebooks.length}>
|
|
438
|
+
{notebooks.map((notebook) => {
|
|
439
|
+
// Named the way dashboards and data apps are: a notebook
|
|
440
|
+
// that titles itself is listed by that title, with the
|
|
441
|
+
// filename kept as the secondary label so the path a
|
|
442
|
+
// reader needs to find the file is never lost.
|
|
443
|
+
const hasTitle =
|
|
444
|
+
!!notebook.title && notebook.title !== notebook.path;
|
|
445
|
+
return (
|
|
446
|
+
<PackageItemRow
|
|
447
|
+
key={notebook.path}
|
|
448
|
+
type="report"
|
|
449
|
+
label={hasTitle ? notebook.title! : notebook.path}
|
|
450
|
+
rightLabel={hasTitle ? notebook.path : undefined}
|
|
451
|
+
onClick={(event) =>
|
|
452
|
+
onClick(
|
|
453
|
+
`/${environmentName}/${packageName}/${notebook.path}`,
|
|
454
|
+
event,
|
|
455
|
+
)
|
|
456
|
+
}
|
|
457
|
+
/>
|
|
458
|
+
);
|
|
459
|
+
})}
|
|
460
|
+
</PackageSection>
|
|
461
|
+
)}
|
|
375
462
|
|
|
376
463
|
{dataApps.length > 0 && (
|
|
377
464
|
<PackageSection title="Data Apps" count={dataApps.length}>
|
|
@@ -475,18 +562,7 @@ export default function Package({
|
|
|
475
562
|
{databases.length === 0 && <EmptyRow label="No data files" />}
|
|
476
563
|
</PackageSection>
|
|
477
564
|
|
|
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>
|
|
565
|
+
<Materializations resourceUri={resourceUri} />
|
|
490
566
|
|
|
491
567
|
{hasReadme && (
|
|
492
568
|
<Box sx={{ mt: 6 }}>
|
|
@@ -499,98 +575,42 @@ export default function Package({
|
|
|
499
575
|
</>
|
|
500
576
|
)}
|
|
501
577
|
|
|
502
|
-
<
|
|
578
|
+
<AppDialog
|
|
503
579
|
open={schemaDatabase !== null}
|
|
504
580
|
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 }}
|
|
581
|
+
title={schemaDatabase?.path ?? "Columns"}
|
|
582
|
+
showClose
|
|
566
583
|
>
|
|
567
|
-
|
|
568
|
-
variant="
|
|
569
|
-
|
|
570
|
-
>
|
|
571
|
-
{title}
|
|
572
|
-
</Typography>
|
|
573
|
-
{count !== undefined && (
|
|
574
|
-
<Typography variant="caption" color="text.secondary">
|
|
575
|
-
({count})
|
|
584
|
+
{schemaDatabase?.error && (
|
|
585
|
+
<Typography variant="body2" color="error">
|
|
586
|
+
{schemaDatabase.error}
|
|
576
587
|
</Typography>
|
|
577
588
|
)}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
589
|
+
{schemaDatabase?.info?.columns && (
|
|
590
|
+
<Table size="small">
|
|
591
|
+
<TableHead>
|
|
592
|
+
<TableRow>
|
|
593
|
+
<TableCell>Column</TableCell>
|
|
594
|
+
<TableCell>Type</TableCell>
|
|
595
|
+
</TableRow>
|
|
596
|
+
</TableHead>
|
|
597
|
+
<TableBody>
|
|
598
|
+
{schemaDatabase.info.columns.map((column) => (
|
|
599
|
+
<TableRow key={column.name}>
|
|
600
|
+
<TableCell component="th" scope="row">
|
|
601
|
+
{column.name}
|
|
602
|
+
</TableCell>
|
|
603
|
+
<TableCell>{column.type}</TableCell>
|
|
604
|
+
</TableRow>
|
|
605
|
+
))}
|
|
606
|
+
</TableBody>
|
|
607
|
+
</Table>
|
|
608
|
+
)}
|
|
609
|
+
</AppDialog>
|
|
610
|
+
</Container>
|
|
581
611
|
);
|
|
582
612
|
}
|
|
583
613
|
|
|
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
614
|
function PackageItemRow({
|
|
595
615
|
type,
|
|
596
616
|
label,
|
|
@@ -607,90 +627,16 @@ function PackageItemRow({
|
|
|
607
627
|
* `event.stopPropagation()` so the row click doesn't also fire. */
|
|
608
628
|
trailingAction?: React.ReactNode;
|
|
609
629
|
}) {
|
|
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
630
|
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>
|
|
631
|
+
<ItemRow
|
|
632
|
+
icon={<ContentTypeIcon type={type} />}
|
|
633
|
+
tint={CONTENT_TINT[type]}
|
|
634
|
+
label={label}
|
|
635
|
+
mono
|
|
636
|
+
{...(rightLabel === undefined ? {} : { rightLabel })}
|
|
637
|
+
{...(onClick === undefined ? {} : { onClick })}
|
|
638
|
+
{...(trailingAction === undefined ? {} : { trailingAction })}
|
|
639
|
+
/>
|
|
694
640
|
);
|
|
695
641
|
}
|
|
696
642
|
|
|
@@ -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
|
+
}
|